示例#1
0
void WiiPlatform::Compile(SoundResource *obj)
{
	bfs::create_directories(obj->GetOutputPath().parent_path());
	/*bfs::path dspadpcm(this->GetName());
	dspadpcm /= "dspadpcm";*/
	bfs::path wiiToolPath(this->GetName());

	std::ostringstream cmd;
	//cmd << dspadpcm.string() << " -e -v " << "\"" << obj->GetInputPath() << "\""; // file_string
	cmd << (wiiToolPath / DSPADPCM).string() << " -e -v " << "\"" << obj->GetInputPath() << "\""; // file_string
	cmd << " " << "\"" << obj->GetOutputPath() << "\"";
	RUN_COMMAND(cmd);

	/*if (e->IsCompressionEnabled())
	{
		bfs::path pathNewExtension = obj->GetOutputPath();
		pathNewExtension.replace_extension(".lzf");
		cmd.str("");
		cmd << (wiiToolPath / LZFTOOL).string() << " \"" << obj->GetOutputPath() << "\" \"" << pathNewExtension << "\""; // file_string

		DebugInfo("CMD: %s\n", cmd.str().c_str());
		cmdRetCode = system(cmd.str().c_str());
		if (cmdRetCode)
		{
			fprintf(stderr, "%s didn't execute properly. Return code: %d.\n", LZFTOOL, cmdRetCode);
			//exit(EXIT_FAILURE);
		}
	}*/
}
示例#2
0
void WiiPlatform::ConvertSound(bfs::path filename, SoundResource *obj)
{
	std::ostringstream cmd;

	cmd << this->GetName() << PLATFORM_PATH_SEPARATOR_STR << "sox ";
	cmd << filename.string().c_str() << " -b 16 ";
	cmd << obj->GetInputPath().string().c_str();

	RUN_COMMAND(cmd);
}
示例#3
0
void SdlPlatform::Compile(Image *obj)
{
	bfs::create_directories(obj->GetOutputPath().parent_path());

	std::ostringstream cmd;
	cmd << PLATFORM_SDL_COPY_COMMAND << " \"" << obj->GetInputPath().string() << "\""; // directory_string
	cmd << " \"" << obj->GetOutputPath().string() << "\""; // directory_string
	cmd << " " << PLATFORM_SDL_COPY_OVERWRITE_PARAM;
	RUN_COMMAND(cmd);

	DebugInfo("IMAGE: %s\n", cmd.str().c_str());
}
示例#4
0
bfs::path SdlPlatform::ProcessFont(Font *obj, IResource *res, u32 totalChars)
{
	bfs::create_directories(res->GetOutputPath().parent_path());
	Image *img = static_cast<Image *>(res);

	/* build basic font */
	std::ostringstream cmd;
	bfs::path toolPath(this->GetName());
	toolPath /= PLATFORM_SDL_FONTGEN_COMMAND;

	cmd << toolPath.string() << " \""; // file_string
	//cmd << res->GetInputPath() << "\"";
	const char *lang = res->GetLanguage();
	cmd << e->GetInputPath(RESOURCE_IMAGE).string() << "/l10n/" << lang << "/" << obj->GetName() << "_ext.tga\" ";

	cmd << " \"l10n/" << lang << "/" << obj->GetName() << "_ext\" " << totalChars << " ";
	//cmd << " \"" << res->GetName() << "\" " << totalChars;
	//cmd << " \"" << name << "\" " << totalChars;
	cmd << obj->GetGlyphWidth() << " " << obj->GetGlyphHeight();
	if (obj->IsUsingAtlas())
	{
		cmd << " \"" << res->GetFilename() << "\" " << img->GetX() << " " << img->GetY();
	}
	RUN_COMMAND(cmd);


	bfs::path fontXML("tmp/font.xml");

	cmd.str("");
	cmd << e->bfsExeName.string() << " -i " << fontXML << " -p " << this->GetName();
	RUN_COMMAND(cmd);

	bfs::path fontSprite;
	//fontSprite = res->GetOutputPath();
	fontSprite = res->GetInputPath();
	fontSprite.replace_extension(".sprite");
	//bfs::remove(fontXML);

	return fontSprite;
}
示例#5
0
void SdlPlatform::Compile(SoundResource *obj)
{
	bfs::create_directories(obj->GetOutputPath().parent_path());

	std::ostringstream cmd;

	cmd << this->GetName() << PLATFORM_PATH_SEPARATOR_STR << "sox \"";
	cmd << obj->GetInputPath().string().c_str() << "\" \"";
	cmd << obj->GetOutputPath().string().c_str() << "\"";

	RUN_COMMAND(cmd);

	obj->AddFilePath(obj->GetOutputPath().string().c_str());
}
示例#6
0
void IphPlatform::Compile(SoundResource *obj)
{
	bfs::create_directories(obj->GetOutputPath().parent_path());

	std::ostringstream cmd;

	cmd << "afconvert -f caff -d LEI16 -c 1 ";
	cmd << obj->GetInputPath().string().c_str() << " ";
	cmd << obj->GetOutputPath().string().c_str();

	RUN_COMMAND(cmd);

	obj->AddFilePath(obj->GetOutputPath().string().c_str());
}
示例#7
0
void IphPlatform::Compile(Mask *obj)
{
	bfs::create_directories(obj->GetOutputPath().parent_path());

	std::ostringstream cmd;

	cmd << this->GetName() << PLATFORM_PATH_SEPARATOR_STR << "maskgen ";
	cmd << obj->GetInputPath().string().c_str();
	cmd << " ";
	cmd << obj->GetOutputPath().string().c_str();
	cmd << " -p " << this->GetName();

	RUN_COMMAND(cmd);

	obj->AddFilePath(obj->GetOutputPath().string().c_str());
}
示例#8
0
void SdlPlatform::Compile(Font *obj)
{
	bfs::create_directories(obj->GetOutputPath().parent_path());
	IResource *res = const_cast<IResource *>(obj->GetResource());
	Image *img = static_cast<Image *>(res);

	std::ostringstream cmd;
	bfs::path toolPath(this->GetName());
	toolPath /= PLATFORM_SDL_FONTGEN_COMMAND;

	cmd << toolPath.string() << " \""; // file_string
	cmd << obj->GetInputPath() << "\"";
	cmd << " \"" << obj->GetName() << "\" " << obj->GetCharacters() << " ";
	cmd << obj->GetGlyphWidth() << " " << obj->GetGlyphHeight();

	if (obj->IsUsingAtlas())
	{
		cmd << " \"" << res->GetFilename() << "\" " << img->GetX() << " " << img->GetY();
	}
	RUN_COMMAND(cmd);

	// current cache dump
	pCache->Dump();

	bfs::path fontXML("tmp/font.xml");

	cmd.str("");
	cmd << e->bfsExeName.string() << " -i " << fontXML << " -p " << this->GetName();
	RUN_COMMAND(cmd);

	// updated cache reload
	pCache->Reset();
	pCache->Load();

	bfs::path fontSprite = obj->GetOutputPath();
	fontSprite.replace_extension(".sprite");
	//bfs::remove(fontXML);

	obj->SetSprite(fontSprite);
	obj->AddFilePath(fontSprite);

	/* build extension tables for languages */
	DictionaryMap dict = e->GetDictionaries();
	DictionaryMapIterator it = dict.begin();
	DictionaryMapIterator end = dict.end();
	for (; it != end; ++it)
	{
		Dictionary *dict = (*it).second;
		u32 size = dict->GetExtensionTableSize();
		if (size)
		{
			//std::ostringstream extname;
			//extname << "l10n/" << dict->pcGetLanguage() << "/" << obj->GetFilename() << "_ext";
			//extname << res->GetName() << "_ext";

			std::string extname(res->GetName());
			extname += "_ext";
			IResource *ext = e->GetResource(extname.c_str(), dict->pcGetLanguage());

			//IResource *ext = e->GetResource(res->GetName(), dict->pcGetLanguage());
			if (ext)
			{
				//std::string x(res->GetFilename());
				std::ostringstream x;
				//x << "l10n/" << dict->pcGetLanguage() << "/" << res->GetName() << "_ext.tga";
				x << res->GetName() << "_ext.tga";
				bfs::path xx(e->GetOutputPath());
				xx /= x.str();
				//pCache->AddFilename(xx.string().c_str());
				obj->SetExtId(pCache->GetFilenameId(xx.string().c_str()));

				std::ostringstream x2;
				//x2 << "l10n/" << dict->pcGetLanguage() << "/" << res->GetName() << "_ext.sprite";
				x2 << res->GetName() << "_ext.sprite";
				xx = e->GetOutputPath();
				xx /= x2.str();
				pCache->AddFilename(xx.string().c_str());
				obj->SetExtId(pCache->GetFilenameId(xx.string().c_str()));


				//bfs::path sprite = this->ProcessFont(obj, ext, size);
				//obj->AddFilePath(sprite);
				this->ProcessFont(obj, ext, size);
				std::ostringstream x3;
				x3 << "l10n/" << dict->pcGetLanguage() << "/" << res->GetName() << "_ext.sprite";
				xx = e->GetOutputPath();
				xx /= x3.str();
				obj->AddFilePath(xx.string().c_str());
			}
			else
			{
				//Error(ERROR_UNKNOWN, TAG "Needed language '%s' resource extension table %s for font %s not found.", dict->pcGetLanguage(), extname.c_str(), obj->GetName());
				//Error(ERROR_UNKNOWN, TAG "Needed language '%s' specific resource for font %s not found.", dict->pcGetLanguage(), obj->GetName());
			}
		}
	}
}
示例#9
0
void
test_cgroup_job_start (void)
{
	char             confdir[PATH_MAX];
	char             logdir[PATH_MAX];
	char             flagfile[PATH_MAX];
	nih_local char  *cmd = NULL;
	pid_t            dbus_pid = 0;
	pid_t            upstart_pid = 0;
	char           **output;
	size_t           lines;
	size_t           len;
	nih_local char  *logfile = NULL;
	nih_local char  *logfile_name = NULL;
	nih_local char  *contents = NULL;

	if (geteuid ()) {
		printf ("INFO: skipping %s tests as not running as root\n", __func__);
		fflush (NULL);
		return;
	}

	TEST_GROUP ("cgroup manager handling");

        TEST_FILENAME (confdir);
        TEST_EQ (mkdir (confdir, 0755), 0);

        TEST_FILENAME (logdir);
        TEST_EQ (mkdir (logdir, 0755), 0);

        TEST_FILENAME (flagfile);

	/* Use the "secret" interface */
	TEST_EQ (setenv ("UPSTART_CONFDIR", confdir, 1), 0);
	TEST_EQ (setenv ("UPSTART_LOGDIR", logdir, 1), 0);

	TEST_DBUS (dbus_pid);

	/*******************************************************************/
	TEST_FEATURE ("Ensure startup job does not start until cgmanager available");

	contents = nih_sprintf (NULL, 
			"start on startup\n"
			"\n"
			"cgroup memory mem-%s\n"
			"\n"
			"exec echo hello\n",
			__func__);
	TEST_NE_P (contents, NULL);

	CREATE_FILE (confdir, "cgroup.conf", contents);

	logfile_name = NIH_MUST (nih_sprintf (NULL, "%s/%s",
				logdir,
				"cgroup.log"));

	start_upstart_common (&upstart_pid, FALSE, FALSE, confdir, logdir, NULL);

	cmd = nih_sprintf (NULL, "%s status %s 2>&1", get_initctl (), "cgroup");
	TEST_NE_P (cmd, NULL);
	RUN_COMMAND (NULL, cmd, &output, &lines);
	TEST_EQ (lines, 1);

	/* job should *NOT* start on startup */
	TEST_EQ_STR (output[0], "cgroup stop/waiting");
	nih_free (output);

	TEST_FALSE (file_exists (logfile_name));

	cmd = nih_sprintf (NULL, "%s notify-cgroup-manager-address %s 2>&1",
			get_initctl (),
			CGMANAGER_DBUS_SOCK);
	TEST_NE_P (cmd, NULL);
	RUN_COMMAND (NULL, cmd, &output, &lines);
	TEST_EQ (lines, 0);

	WAIT_FOR_FILE (logfile_name);

	logfile = nih_file_read (NULL, logfile_name, &len);
	TEST_NE_P (logfile, NULL);

	TEST_EQ_STR (logfile, "hello\r\n");

	DELETE_FILE (confdir, "cgroup.conf");
	assert0 (unlink (logfile_name));

	/*******************************************************************/
	TEST_FEATURE ("Ensure bogus cgroups don't crash init");

	contents = nih_sprintf (NULL, 
			"cgroup name\n"
			"\n"
			"exec echo hello\n");
	TEST_NE_P (contents, NULL);

	CREATE_FILE (confdir, "cgroup-name.conf", contents);

	logfile_name = NIH_MUST (nih_sprintf (NULL, "%s/%s",
				logdir,
				"cgroup-name.log"));

	cmd = nih_sprintf (NULL, "%s status %s 2>&1", get_initctl (), "cgroup-name");
	TEST_NE_P (cmd, NULL);
	RUN_COMMAND (NULL, cmd, &output, &lines);
	TEST_EQ (lines, 1);

	/* job is not running yet */
	TEST_EQ_STR (output[0], "cgroup-name stop/waiting");
	nih_free (output);

	TEST_FALSE (file_exists (logfile_name));

	cmd = nih_sprintf (NULL, "%s start %s 2>&1", get_initctl (), "cgroup-name");
	TEST_NE_P (cmd, NULL);
	RUN_COMMAND (NULL, cmd, &output, &lines);
	TEST_EQ (lines, 1);

        TEST_EQ_STR (output[0], "initctl: Job failed to start");

	DELETE_FILE (confdir, "cgroup-name.conf");
	/*******************************************************************/

	STOP_UPSTART (upstart_pid);
	TEST_DBUS_END (dbus_pid);

        TEST_EQ (rmdir (confdir), 0);
        TEST_EQ (rmdir (logdir), 0);

	/*******************************************************************/

}
示例#10
0
void WiiPlatform::Compile(Font *obj)
{
	bfs::create_directories(obj->GetOutputPath().parent_path());
	IResource *res = const_cast<IResource *>(obj->GetResource());
	Image *img = static_cast<Image *>(res);

	std::ostringstream cmd;
	bfs::path toolPath(this->GetName());
	toolPath /= PLATFORM_WII_FONTGEN_COMMAND;

	cmd << toolPath.string() << " \""; // file_string
	cmd << obj->GetInputPath() << "\"";
	cmd << " \"" << obj->GetName() << "\" " << obj->GetCharacters();

	if (obj->IsUsingAtlas())
	{
		cmd << " \"" << res->GetFilename() << "\" " << img->GetX() << " " << img->GetY();
	}
	RUN_COMMAND(cmd);

	// current cache dump
	pCache->Dump();

	bfs::path fontXML("tmp/font.xml");

	cmd.str("");
	cmd << e->bfsExeName.string() << " -i " << fontXML << " -p " << this->GetName();
	RUN_COMMAND(cmd);

	// updated cache reload
	pCache->Reset();
	pCache->Load();

	bfs::path fontSprite = obj->GetOutputPath();
	fontSprite.replace_extension(".sprite");
	bfs::remove(fontXML);

	obj->SetSprite(fontSprite);
	obj->AddFilePath(fontSprite);

	/*if (e->IsCompressionEnabled())
	{
		// .font
		bfs::path pathNewExtension = obj->GetOutputPath();
		pathNewExtension.replace_extension(".lzf");
		cmd.str("");
		cmd << (wiiToolPath / LZFTOOL).string() << " \"" << obj->GetOutputPath() << "\" \"" << pathNewExtension << "\""; // file_string

		DebugInfo("CMD: %s\n", cmd.str().c_str());
		cmdRetCode = system(cmd.str().c_str());
		if (cmdRetCode)
		{
			fprintf(stderr, "%s didn't execute properly. Return code: %d.\n", LZFTOOL, cmdRetCode);
			//exit(EXIT_FAILURE);
		}

		bfs::remove(obj->GetOutputPath());
		bfs::rename(pathNewExtension, obj->GetOutputPath());

		// .sprite
		pathNewExtension = fontSprite;
		pathNewExtension.replace_extension(".lzf");

		cmd.str("");
		cmd << (wiiToolPath / LZFTOOL).string() << " \"" << fontSprite << "\" \"" << pathNewExtension << "\""; // file_string

		DebugInfo("CMD: %s\n", cmd.str().c_str());
		cmdRetCode = system(cmd.str().c_str());
		if (cmdRetCode)
		{
			fprintf(stderr, "%s didn't execute properly. Return code: %d.\n", LZFTOOL, cmdRetCode);
			//exit(EXIT_FAILURE);
		}

		bfs::remove(fontSprite);
		bfs::rename(pathNewExtension, fontSprite);
	}*/

	/* build extension tables for languages */
	DictionaryMap dict = e->GetDictionaries();
	DictionaryMapIterator it = dict.begin();
	DictionaryMapIterator end = dict.end();
	for (; it != end; ++it)
	{
		Dictionary *dict = (*it).second;
		u32 size = dict->GetExtensionTableSize();
		if (size)
		{
			//std::ostringstream extname;
			//extname << "l10n/" << dict->pcGetLanguage() << "/" << obj->GetFilename() << "_ext";
			//IResource *ext = e->GetResource(extname.str().c_str());

			std::string extname(res->GetName());
			extname += "_ext";
			IResource *ext = e->GetResource(extname.c_str(), dict->pcGetLanguage());

			//IResource *ext = e->GetResource(res->GetName(), dict->pcGetLanguage());
			if (ext)
			{
				std::string x(res->GetFilename());
				x += "_ext.tpl";
				bfs::path xx(e->GetOutputPath());
				xx /= x;
				pCache->AddFilename(xx.string().c_str());
				obj->SetExtId(pCache->GetFilenameId(xx.string().c_str()));

				x = res->GetFilename();
				x += "_ext.sprite";
				xx = e->GetOutputPath();
				xx /= x;
				pCache->AddFilename(xx.string().c_str());
				obj->SetExtId(pCache->GetFilenameId(xx.string().c_str()));


				bfs::path sprite = this->ProcessFont(obj, ext, size);
				obj->AddFilePath(sprite);
			}
			else
			{
				//Error(ERROR_UNKNOWN, TAG "Needed language '%s' resource extension table %s for font %s not found.", dict->pcGetLanguage(), extname.c_str(), obj->GetName());
				Error(ERROR_UNKNOWN, TAG "Needed language '%s' specific resource for font %s not found.", dict->pcGetLanguage(), obj->GetName());
			}
		}
	}
}
示例#11
0
void WiiPlatform::Compile(MusicResource *obj)
{
	bfs::create_directories(obj->GetOutputPath().parent_path());
	/*bfs::path dspadpcm(this->GetName());
	dspadpcm /= "dspadpcm";*/
	bfs::path wiiToolPath(this->GetName());

	bfs::path musicInpPath(e->GetInputPath(RESOURCE_MUSIC));

	// L
	bfs::path musicLOutPath;
	{
		std::string musicL(obj->GetFilename());
		musicL = musicL + "_L";
		bfs::path musicLInpPath = musicInpPath / (musicL + std::string(".aif"));

		if (!bfs::exists(musicLInpPath))
		{
			Log(TAG "File %s not found, falling back to .wav and converting it to platform specific format.", musicLInpPath.string().c_str());
			bfs::path tmp = musicInpPath / (musicL + ".wav");

			if (!bfs::exists(tmp))
			{
				Error(ERROR_FILE_NOT_FOUND, TAG "Music audio file '%s' not found.", tmp.string().c_str());
			}
			else
			{
				std::ostringstream cmd;
				cmd << this->GetName() << PLATFORM_PATH_SEPARATOR_STR << "sox ";
				cmd << tmp.string().c_str() << " -c 1 -r 44100 -b 16 ";
				cmd << musicLInpPath.string().c_str();

				RUN_COMMAND(cmd);
			}
		}

		musicLOutPath = e->GetOutputPath() / (musicL + std::string(".adpcm"));

		std::ostringstream cmd;
		//cmd << dspadpcm.string() << " -e -v "; // file_string
		cmd << (wiiToolPath / DSPADPCM).string() << " -e -v "; // file_string
		cmd << "\"" << musicLInpPath << "\"" << " ";
		cmd << musicLOutPath;

		RUN_COMMAND(cmd);
	}

	// R
	bfs::path musicROutPath;
	{
		std::string musicR(obj->GetFilename());
		musicR = musicR + "_R";

		bfs::path musicRInpPath(e->GetInputPath(RESOURCE_MUSIC));
		musicRInpPath /= (musicR + std::string(".aif"));

		if (!bfs::exists(musicRInpPath))
		{
			Log(TAG "File %s not found, falling back to .wav and converting it to platform specific format.", musicRInpPath.string().c_str());
			bfs::path tmp = musicInpPath / (musicR + ".wav");

			if (!bfs::exists(tmp))
			{
				Error(ERROR_FILE_NOT_FOUND, TAG "Music audio file '%s' not found.", tmp.string().c_str());
			}
			else
			{
				std::ostringstream cmd;
				cmd << this->GetName() << PLATFORM_PATH_SEPARATOR_STR << "sox ";
				cmd << tmp.string().c_str() << " -c 1 -r 44100 -b 16 ";
				cmd << musicRInpPath.string().c_str();

				RUN_COMMAND(cmd);
			}
		}

		musicROutPath = e->GetOutputPath() / (musicR + std::string(".adpcm"));

		std::ostringstream cmd;
		//cmd << dspadpcm.string() << " -e -v "; // file_string
		cmd << (wiiToolPath / DSPADPCM).string() << " -e -v "; // file_string
		cmd << "\"" << musicRInpPath << "\"" << " ";
		cmd << musicROutPath;

		RUN_COMMAND(cmd);
	}

	/*if (e->IsCompressionEnabled())
	{
		bfs::path pathNewExtension = musicLOutPath;
		pathNewExtension.replace_extension(".lzf");
		cmd.str("");
		cmd << (wiiToolPath / LZFTOOL).string() << " \"" << musicLOutPath << "\" \"" << pathNewExtension << "\""; // file_string

		DebugInfo("CMD: %s\n", cmd.str().c_str());
		cmdRetCode = system(cmd.str().c_str());
		if (cmdRetCode)
		{
			fprintf(stderr, "%s didn't execute properly. Return code: %d.\n", LZFTOOL, cmdRetCode);
			//exit(EXIT_FAILURE);
		}

		pathNewExtension = musicROutPath;
		pathNewExtension.replace_extension(".lzf");
		cmd.str("");
		cmd << (wiiToolPath / LZFTOOL).string() << " \"" << musicROutPath << "\" \"" << pathNewExtension << "\""; // file_string

		DebugInfo("CMD: %s\n", cmd.str().c_str());
		cmdRetCode = system(cmd.str().c_str());
		if (cmdRetCode)
		{
			fprintf(stderr, "%s didn't execute properly. Return code: %d.\n", LZFTOOL, cmdRetCode);
			//exit(EXIT_FAILURE);
		}
	}*/

	obj->AddFilePath(musicLOutPath);
	obj->AddFilePath(musicROutPath);
}
示例#12
0
void WiiPlatform::Compile(Sprite *obj)
{
	bfs::create_directories(obj->GetOutputPath().parent_path());

	std::ostringstream files;
	std::ostringstream alphas;
	std::map<const char*, int, LowerThanStringComparator> frames;

	int id = 0;
	int as = obj->GetSize();
	for (int a = 0; a < as; a++)
	{
		Animation *anim = obj->GetAnimation(a);
		int fs = anim->GetSize();
		for (int f = 0; f < fs; f++)
		{
			const Frame *frame = anim->GetFrame(f);

			if (frames.find(frame->GetFilename()) == frames.end())
			{
				frames[frame->GetFilename()] = 1;
				files << "file " << id << " = " << frame->GetFilename() << ".tga\n";

				if (!frame->HasAlpha())
					alphas << "image " << id << " = " << id << ", x, RGBA8\n";
				else
					alphas << "image " << id << " = " << id << ", " << id << ", RGBA8\n";

				id++;
			}
		}
	}

	for (int i = 0; i < id; i++)
	{
		char tex[32];
		snprintf(tex, 32, "texture %d = %d, x\n", id, id);
	}

	std::ostringstream fileTmp;
	fileTmp << "tmp" << PLATFORM_PATH_SEPARATOR_STR << "tmp.tcs";

	FILE *fp = fopen(fileTmp.str().c_str(), "w+");
	fprintf(fp, "path = %s\\\n", e->GetInputPath(RESOURCE_IMAGE).string().c_str());
	fprintf(fp, "%s", files.str().c_str());
	fprintf(fp, "%s", alphas.str().c_str());
	for (int i = 0; i < id; i++)
		fprintf(fp, "texture %d = %d, x\n", i, i);
	fclose(fp);

	// xunxo mode on
	/*std::ostringstream tplOut;
	tplOut << e->GetOutputPath() << PLATFORM_PATH_SEPARATOR_STR << obj->GetName() << PLATFORM_WII_OUTPUT_IMG_EXT;
	pCache->AddFilename(tplOut.str().c_str());*/

	std::ostringstream cmd;
	cmd << this->GetName() << PLATFORM_PATH_SEPARATOR_STR << "texconv tmp" << PLATFORM_PATH_SEPARATOR_STR << "tmp.tcs ";
	cmd << e->GetOutputPath() << PLATFORM_PATH_SEPARATOR_STR << obj->GetName() << PLATFORM_WII_OUTPUT_IMG_EXT;

	BOOL valid = TRUE;
	for (u32 i = 0; i < obj->GetSize(); i++)
	{
		Animation *anim = obj->GetAnimation(i);
		if (!anim)
			continue;

		for (u32 j = 0; j < anim->GetSize(); j++)
		{
			Frame *frame = const_cast<Frame*>(anim->GetFrame(j));
			if (!frame)
				continue;

			// a regular 1024x1024x32 TGA texture has a size of 4MB
			const Image *img = frame->GetImage();
			if (bfs::file_size(img->GetInputPath()) / (1024 * 1024) >= 4)
			{
				valid = FALSE;
				break;
			}
		}

		if (!valid)
			break;
	}

	if (valid)
	{
		std::ostringstream tplOut;
		tplOut << e->GetOutputPath() << PLATFORM_PATH_SEPARATOR_STR << obj->GetName() << PLATFORM_WII_OUTPUT_IMG_EXT;
		pCache->AddFilename(tplOut.str().c_str());

		RUN_COMMAND(cmd);
	}

	// xm off


	if (e->IsCompressionEnabled() && valid)
	{
		bfs::path wiiToolsPath(this->GetName());
		bfs::path pathNewExtension = obj->GetOutputPath();
		pathNewExtension.replace_extension(".lh");

		std::ostringstream foo;
		foo << e->GetOutputPath() << PLATFORM_PATH_SEPARATOR_STR << obj->GetName() << PLATFORM_WII_OUTPUT_IMG_EXT;
		bfs::path inputTPL(foo.str());

		cmd.str("");
		//cmd << (wiiToolsPath / LZFTOOL).string() << " \""; // file_string
		cmd << (wiiToolsPath / COMPRESSTOOL).string() << " \""; // file_string
		cmd << foo.str();
		cmd << "\" -o \"" << pathNewExtension << "\"";

		RUN_COMMAND(cmd);

		bfs::remove(inputTPL);
		bfs::rename(pathNewExtension, inputTPL);
	}
}
示例#13
0
int run_command(const char *s, int x)
{
	return(RUN_COMMAND(s,x));
}