BuildBase.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  1. //
  2. // Copyright (c) 2014-2016 THUNDERBEAST GAMES LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. #include <Poco/File.h>
  23. #include <Atomic/IO/Log.h>
  24. #include <Atomic/IO/FileSystem.h>
  25. #include <Atomic/Resource/JSONFile.h>
  26. #include "../Subprocess/SubprocessSystem.h"
  27. #include "../Project/Project.h"
  28. #include "../ToolEnvironment.h"
  29. #include "../Assets/Asset.h"
  30. #include "../Assets/AssetDatabase.h"
  31. #include "BuildSystem.h"
  32. #include "BuildEvents.h"
  33. #include "BuildBase.h"
  34. #include "ResourcePackager.h"
  35. #include "AssetBuildConfig.h"
  36. namespace ToolCore
  37. {
  38. BuildBase::BuildBase(Context * context, Project* project, PlatformID platform) : Object(context),
  39. platformID_(platform),
  40. project_(project),
  41. containsMDL_(false),
  42. buildFailed_(false),
  43. assetBuildTag_(String::EMPTY),
  44. fileIncludedResourcesLog_(nullptr),
  45. resourcesOnly_(false),
  46. verbose_(false)
  47. {
  48. if (UseResourcePackager())
  49. resourcePackager_ = new ResourcePackager(context, this);
  50. fileIncludedResourcesLog_ = new File(context_, "BuildIncludedResources.log", Atomic::FILE_WRITE);
  51. ReadAssetBuildConfig();
  52. }
  53. BuildBase::~BuildBase()
  54. {
  55. for (unsigned i = 0; i < resourceEntries_.Size(); i++)
  56. {
  57. delete resourceEntries_[i];
  58. }
  59. fileIncludedResourcesLog_->Close();
  60. delete fileIncludedResourcesLog_;
  61. }
  62. #ifdef ATOMIC_PLATFORM_WINDOWS
  63. bool BuildBase::BuildClean(const String& path)
  64. {
  65. if (buildFailed_)
  66. {
  67. ATOMIC_LOGERRORF("BuildBase::BuildClean - Attempt to clean directory of failed build, %s", path.CString());
  68. return false;
  69. }
  70. FileSystem* fileSystem = GetSubsystem<FileSystem>();
  71. if (!fileSystem->DirExists(path))
  72. return true;
  73. // On Windows, do a little dance with the folder to avoid issues
  74. // with deleting folder and immediately recreating it
  75. String pathName, fileName, ext;
  76. SplitPath(path, pathName, fileName, ext);
  77. pathName = AddTrailingSlash(pathName);
  78. unsigned i = 0;
  79. while (true)
  80. {
  81. String newPath = ToString("%s%s_Temp_%u", pathName.CString(), fileName.CString(), i++);
  82. if (!fileSystem->DirExists(newPath))
  83. {
  84. if (!MoveFileExW(GetWideNativePath(path).CString(), GetWideNativePath(newPath).CString(), MOVEFILE_WRITE_THROUGH))
  85. {
  86. FailBuild(ToString("BuildBase::BuildClean: Unable to move directory %s -> ", path.CString(), newPath.CString()));
  87. return false;
  88. }
  89. // Remove the moved directory
  90. return BuildRemoveDirectory(newPath);
  91. }
  92. else
  93. {
  94. ATOMIC_LOGWARNINGF("BuildBase::BuildClean - temp build folder exists, removing: %s", newPath.CString());
  95. fileSystem->RemoveDir(newPath, true);
  96. }
  97. if (i == 255)
  98. {
  99. FailBuild(ToString("BuildBase::BuildClean: Unable to move directory ( i == 255) %s -> ", path.CString(), newPath.CString()));
  100. return false;
  101. }
  102. }
  103. return false;
  104. }
  105. #else
  106. bool BuildBase::BuildClean(const String& path)
  107. {
  108. return BuildRemoveDirectory(path);
  109. }
  110. #endif
  111. bool BuildBase::BuildCreateDirectory(const String& path)
  112. {
  113. if (buildFailed_)
  114. {
  115. ATOMIC_LOGERRORF("BuildBase::BuildCreateDirectory - Attempt to create directory of failed build, %s", path.CString());
  116. return false;
  117. }
  118. FileSystem* fileSystem = GetSubsystem<FileSystem>();
  119. if (fileSystem->DirExists(path))
  120. return true;
  121. bool result = fileSystem->CreateDir(path);
  122. if (!result)
  123. {
  124. FailBuild(ToString("BuildBase::BuildCreateDirectory: Unable to create directory %s", path.CString()));
  125. return false;
  126. }
  127. return true;
  128. }
  129. bool BuildBase::BuildCopyFile(const String& srcFileName, const String& destFileName)
  130. {
  131. if (buildFailed_)
  132. {
  133. ATOMIC_LOGERRORF("BuildBase::BuildCopyFile - Attempt to copy file of failed build, %s", srcFileName.CString());
  134. return false;
  135. }
  136. FileSystem* fileSystem = GetSubsystem<FileSystem>();
  137. bool result = fileSystem->Copy(srcFileName, destFileName);
  138. if (!result)
  139. {
  140. FailBuild(ToString("BuildBase::BuildCopyFile: Unable to copy file %s -> %s", srcFileName.CString(), destFileName.CString()));
  141. return false;
  142. }
  143. return true;
  144. }
  145. bool BuildBase::BuildCopyDir(const String& srcDir, const String& destDir)
  146. {
  147. if (buildFailed_)
  148. {
  149. ATOMIC_LOGERRORF("BuildBase::BuildCopyDir - Attempt to copy directory of failed build, %s", srcDir.CString());
  150. return false;
  151. }
  152. FileSystem* fileSystem = GetSubsystem<FileSystem>();
  153. bool result = fileSystem->CopyDir(srcDir, destDir);
  154. if (!result)
  155. {
  156. FailBuild(ToString("BuildBase::BuildCopyDir: Unable to copy dir %s -> %s", srcDir.CString(), destDir.CString()));
  157. return false;
  158. }
  159. return true;
  160. }
  161. bool BuildBase::CheckIncludeResourceFile(const String & resourceDir, const String & fileName)
  162. {
  163. return (GetExtension(fileName) != ".psd");
  164. }
  165. bool BuildBase::BuildRemoveDirectory(const String& path)
  166. {
  167. if (buildFailed_)
  168. {
  169. ATOMIC_LOGERRORF("BuildBase::BuildRemoveDirectory - Attempt to remove directory of failed build, %s", path.CString());
  170. return false;
  171. }
  172. FileSystem* fileSystem = GetSubsystem<FileSystem>();
  173. if (!fileSystem->DirExists(path))
  174. return true;
  175. #ifdef ATOMIC_PLATFORM_LINUX
  176. bool result = true; // fileSystem->RemoveDir(path, true); crashes on linux
  177. Poco::File dirs(buildPath_.CString());
  178. dirs.remove(true);
  179. if (fileSystem->DirExists(buildPath_))
  180. result = false;
  181. #else
  182. bool result = fileSystem->RemoveDir(path, true);
  183. #endif
  184. if (!result)
  185. {
  186. FailBuild(ToString("BuildBase::BuildRemoveDirectory: Unable to remove directory %s", path.CString()));
  187. return false;
  188. }
  189. return true;
  190. }
  191. void BuildBase::BuildLog(const String& message, bool sendEvent)
  192. {
  193. buildLog_.Push(message);
  194. if (autoLog_)
  195. ATOMIC_LOGINFO(message);
  196. if (sendEvent)
  197. {
  198. String colorMsg = ToString("<color #D4FB79>%s</color>\n", message.CString());
  199. VariantMap buildOutput;
  200. buildOutput[BuildOutput::P_TEXT] = colorMsg;
  201. SendEvent(E_BUILDOUTPUT, buildOutput);
  202. }
  203. }
  204. void BuildBase::BuildWarn(const String& warning, bool sendEvent)
  205. {
  206. buildWarnings_.Push(warning);
  207. if (autoLog_)
  208. ATOMIC_LOGWARNING(warning);
  209. if (sendEvent)
  210. {
  211. String colorMsg = ToString("<color #FFFF00>%s</color>\n", warning.CString());
  212. VariantMap buildOutput;
  213. buildOutput[BuildOutput::P_TEXT] = colorMsg;
  214. SendEvent(E_BUILDOUTPUT, buildOutput);
  215. }
  216. }
  217. void BuildBase::BuildError(const String& error, bool sendEvent)
  218. {
  219. buildErrors_.Push(error);
  220. if (autoLog_)
  221. ATOMIC_LOGERROR(error);
  222. if (sendEvent)
  223. {
  224. String colorMsg = ToString("<color #FF0000>%s</color>\n", error.CString());
  225. VariantMap buildOutput;
  226. buildOutput[BuildOutput::P_TEXT] = colorMsg;
  227. SendEvent(E_BUILDOUTPUT, buildOutput);
  228. }
  229. }
  230. void BuildBase::FailBuild(const String& message)
  231. {
  232. if (buildFailed_)
  233. {
  234. ATOMIC_LOGERRORF("BuildBase::FailBuild - Attempt to fail already failed build: %s", message.CString());
  235. return;
  236. }
  237. buildFailed_ = true;
  238. BuildError(message);
  239. BuildSystem* buildSystem = GetSubsystem<BuildSystem>();
  240. buildSystem->BuildComplete(platformID_, buildPath_, false, message);
  241. }
  242. void BuildBase::HandleSubprocessOutputEvent(StringHash eventType, VariantMap& eventData)
  243. {
  244. // E_SUBPROCESSOUTPUT
  245. const String& text = eventData[SubprocessOutput::P_TEXT].GetString();
  246. // convert to a build output event and forward to subscribers
  247. VariantMap buildOutputData;
  248. buildOutputData[BuildOutput::P_TEXT] = text;
  249. SendEvent(E_BUILDOUTPUT, buildOutputData);
  250. }
  251. void BuildBase::GetDefaultResourcePaths(Vector<String>& paths)
  252. {
  253. paths.Clear();
  254. ToolEnvironment* tenv = GetSubsystem<ToolEnvironment>();
  255. paths.Push(AddTrailingSlash(tenv->GetCoreDataDir()));
  256. paths.Push(AddTrailingSlash(tenv->GetPlayerDataDir()));
  257. }
  258. String BuildBase::GetSettingsDirectory()
  259. {
  260. return project_->GetProjectPath() + "/Settings";
  261. }
  262. void BuildBase::BuildDefaultResourceEntries()
  263. {
  264. String buildLogOutput(String::EMPTY);
  265. for (unsigned i = 0; i < resourceDirs_.Size(); i++)
  266. {
  267. String resourceDir = resourceDirs_[i];
  268. fileIncludedResourcesLog_->WriteLine("\nBuildBase::BuildDefaultResourceEntries - Default resources being included from: " + resourceDir);
  269. Vector<String> fileNames;
  270. FileSystem* fileSystem = GetSubsystem<FileSystem>();
  271. fileSystem->ScanDir(fileNames, resourceDir, "*.*", SCAN_FILES, true);
  272. for (unsigned i = 0; i < fileNames.Size(); i++)
  273. {
  274. const String& filename = fileNames[i];
  275. AddToResourcePackager(filename, resourceDir);
  276. if (verbose_)
  277. {
  278. ATOMIC_LOGINFO(ToString("Default Resource Added: %s%s", resourceDir.CString(), filename.CString()));
  279. }
  280. }
  281. }
  282. }
  283. void BuildBase::BuildProjectResourceEntries()
  284. {
  285. String buildLogOutput(String::EMPTY);
  286. if (AssetBuildConfig::IsLoaded())
  287. {
  288. buildLogOutput += "\nBaseBuild::BuildProjectResourceEntries - ./Settings/AssetBuildConfig.json found. ";
  289. if (!assetBuildTag_.Empty())
  290. {
  291. buildLogOutput += "Using build-tag parameter : " + assetBuildTag_;
  292. fileIncludedResourcesLog_->WriteLine(buildLogOutput);
  293. BuildFilteredProjectResourceEntries();
  294. return;
  295. }
  296. buildLogOutput += "No build-tag parameter used.";
  297. }
  298. buildLogOutput += "\nBaseBuild::BuildProjectResourceEntries - No custom asset include configuration being used - ";
  299. buildLogOutput += "AssetBuildConfig.json not loaded, OR no build-tag parameter used.";
  300. fileIncludedResourcesLog_->WriteLine(buildLogOutput);
  301. BuildAllProjectResourceEntries();
  302. }
  303. void BuildBase::BuildAllProjectResourceEntries()
  304. {
  305. for (unsigned i = 0; i < projectResourceDir_.Size(); i++)
  306. {
  307. String projectResourceDir = projectResourceDir_[i];
  308. fileIncludedResourcesLog_->WriteLine("\nBuildBase::BuildAllProjectResourceEntries - Project resources being included from: " + projectResourceDir);
  309. Vector<String> fileNamesInProject;
  310. FileSystem* fileSystem = GetSubsystem<FileSystem>();
  311. fileSystem->ScanDir(fileNamesInProject, projectResourceDir, "*.*", SCAN_FILES, true);
  312. for (unsigned i = 0; i < fileNamesInProject.Size(); i++)
  313. {
  314. AddToResourcePackager(fileNamesInProject[i], projectResourceDir);
  315. if (verbose_)
  316. {
  317. ATOMIC_LOGINFO(ToString("Project Resource Added: %s%s", projectResourceDir.CString(), fileNamesInProject[i].CString()));
  318. }
  319. }
  320. }
  321. }
  322. void BuildBase::BuildFilteredProjectResourceEntries()
  323. {
  324. // Loading up the AssetBuildConfig.json,
  325. // obtaining a list of files to include in the build.
  326. VariantMap resourceTags;
  327. AssetBuildConfig::ApplyConfig(resourceTags);
  328. Vector<String> assetBuildConfigFiles;
  329. VariantMap::ConstIterator itr = resourceTags.Begin();
  330. while (itr != resourceTags.End())
  331. {
  332. if (itr->first_ == assetBuildTag_)
  333. {
  334. assetBuildConfigFiles = itr->second_.GetStringVector();
  335. for (unsigned i = 0; i < assetBuildConfigFiles.Size(); ++i)
  336. {
  337. // remove case sensitivity
  338. assetBuildConfigFiles[i] = assetBuildConfigFiles[i].ToLower();
  339. }
  340. break;
  341. }
  342. itr++;
  343. if (itr == resourceTags.End())
  344. {
  345. ATOMIC_LOGERRORF("BuildBase::BuildFilteredProjectResourceEntries - Asset build-tag \"%s\" not defined in ./Settings/AssetBuildConfig.json", assetBuildTag_.CString());
  346. }
  347. }
  348. // find any folders defined in assetbuildconfig.json, and add the non-".asset" files in them.
  349. FileSystem* fileSystem = GetSubsystem<FileSystem>();
  350. Vector<String> filesInFolderToAdd;
  351. for (unsigned i = 0; i < assetBuildConfigFiles.Size(); ++i)
  352. {
  353. String &filename = assetBuildConfigFiles[i];
  354. if (GetExtension(filename) == String::EMPTY &&
  355. fileSystem->DirExists(project_->GetResourcePath() + filename))
  356. {
  357. // rename 'filename' to 'folder' for context
  358. String folder(filename);
  359. // add a trailing slash if not defined
  360. if (folder.Back() != '/')
  361. folder = AddTrailingSlash(folder);
  362. Vector<String> filesInFolder;
  363. fileSystem->ScanDir(filesInFolder, project_->GetResourcePath() + folder, "*.*", SCAN_FILES, true);
  364. for (unsigned j = 0; j < filesInFolder.Size(); ++j)
  365. {
  366. String path = filesInFolder[j];
  367. // not interested in .asset files for now, will be included later.
  368. if (GetExtension(path) != ".asset")
  369. {
  370. filesInFolderToAdd.Push(folder + path.ToLower());
  371. }
  372. }
  373. }
  374. }
  375. // add the files defined using a folder in AssetBuildConfig.json
  376. for (unsigned i = 0; i < filesInFolderToAdd.Size(); ++i)
  377. {
  378. assetBuildConfigFiles.Push(filesInFolderToAdd[i]);
  379. }
  380. // check if the files in AssetBuildConfig.json exist,
  381. // as well as their corresponding .asset file
  382. Vector<String> filesInResourceFolder;
  383. Vector<String> resourceFilesToInclude;
  384. fileSystem->ScanDir(filesInResourceFolder, project_->GetResourcePath(), "*.*", SCAN_FILES, true);
  385. for (unsigned j = 0; j < filesInResourceFolder.Size(); ++j)
  386. {
  387. // don't want to checks to be case sensitive
  388. filesInResourceFolder[j] = filesInResourceFolder[j].ToLower();
  389. }
  390. for (unsigned i = 0; i < assetBuildConfigFiles.Size(); ++i)
  391. {
  392. // .asset file is of primary importance since we used it to identify the associated cached file.
  393. // without the .asset file the resource is removed from being included in the build.
  394. // don't want checks to be case sensitive
  395. String &filename = assetBuildConfigFiles[i];
  396. if (filesInResourceFolder.Contains(filename) &&
  397. filesInResourceFolder.Contains(filename + ".asset"))
  398. {
  399. resourceFilesToInclude.Push(filename);
  400. resourceFilesToInclude.Push(filename + ".asset");
  401. continue;
  402. }
  403. fileIncludedResourcesLog_->WriteLine("File " + filename + " ignored since it does not have an associated .asset file");
  404. }
  405. // add valid files included from the AssetBuildConfig.json
  406. for (StringVector::ConstIterator it = resourceFilesToInclude.Begin(); it != resourceFilesToInclude.End(); ++it)
  407. {
  408. AddToResourcePackager(*it, project_->GetResourcePath());
  409. }
  410. // Get associated cache GUID from the asset file
  411. Vector<String> filesWithGUIDtoInclude;
  412. for (StringVector::Iterator it = resourceFilesToInclude.Begin(); it != resourceFilesToInclude.End(); ++it)
  413. {
  414. String &filename = *it;
  415. if (GetExtension(*it) == ".asset")
  416. {
  417. SharedPtr<File> file(new File(context_, project_->GetResourcePath() + *it));
  418. SharedPtr<JSONFile> json(new JSONFile(context_));
  419. json->Load(*file);
  420. file->Close();
  421. JSONValue& root = json->GetRoot();
  422. int test = root.Get("version").GetInt();
  423. assert(root.Get("version").GetInt() == ASSET_VERSION);
  424. String guid = root.Get("guid").GetString();
  425. filesWithGUIDtoInclude.Push(guid);
  426. }
  427. }
  428. // Obtain files in cache folder,
  429. // Check if the file contains the guid, and add it to the cacheFilesToInclude
  430. Vector<String> filesInCacheFolder;
  431. Vector<String> cacheFilesToInclude;
  432. AssetDatabase* db = GetSubsystem<AssetDatabase>();
  433. String cachePath = db->GetCachePath();
  434. fileSystem->ScanDir(filesInCacheFolder, cachePath, "*.*", SCAN_FILES, false);
  435. for (unsigned i = 0; i < filesWithGUIDtoInclude.Size(); ++i)
  436. {
  437. String &guid = filesWithGUIDtoInclude[i];
  438. for (unsigned j = 0; j < filesInCacheFolder.Size(); ++j)
  439. {
  440. const String &filename = GetFileName(filesInCacheFolder[j]);
  441. String &filenamePath = filesInCacheFolder[j];
  442. if (filename.Contains(guid))
  443. {
  444. cacheFilesToInclude.Push(filesInCacheFolder[j]);
  445. // do not continue...
  446. // there might be multiple files with the same guid having an guid_animaiton extention.
  447. }
  448. }
  449. }
  450. // include a texture file's cached .dds file when building in windows
  451. #ifdef ATOMIC_PLATFORM_DESKTOP
  452. for (StringVector::ConstIterator it = resourceFilesToInclude.Begin(); it != resourceFilesToInclude.End(); ++it)
  453. {
  454. if (!CheckIncludeResourceFile(project_->GetResourcePath(), *it))
  455. {
  456. FileSystem* fileSystem = GetSubsystem<FileSystem>();
  457. String associatedDDSpath = "DDS/" + *it + ".dds";
  458. String compressedPath = cachePath + associatedDDSpath;
  459. if (fileSystem->FileExists(compressedPath))
  460. {
  461. cacheFilesToInclude.Push(associatedDDSpath);
  462. }
  463. }
  464. }
  465. #endif
  466. // Add the cache files to the resource packager
  467. for (StringVector::ConstIterator it = cacheFilesToInclude.Begin(); it != cacheFilesToInclude.End(); ++it)
  468. {
  469. AddToResourcePackager(*it, cachePath);
  470. }
  471. }
  472. void BuildBase::AddToResourcePackager(const String& filename, const String& resourceDir)
  473. {
  474. // Check if the file is already included in the resourceEntries_ list
  475. for (unsigned j = 0; j < resourceEntries_.Size(); j++)
  476. {
  477. const BuildResourceEntry* entry = resourceEntries_[j];
  478. if (entry->packagePath_ == filename)
  479. {
  480. BuildWarn(ToString("Resource Path: %s already exists", filename.CString()));
  481. continue;
  482. }
  483. }
  484. if (!CheckIncludeResourceFile(resourceDir, filename))
  485. {
  486. fileIncludedResourcesLog_->WriteLine(resourceDir + filename + " skipped because of file extention: " + GetExtension(filename));
  487. return;
  488. }
  489. BuildResourceEntry* newEntry = new BuildResourceEntry;
  490. // BEGIN LICENSE MANAGEMENT
  491. if (GetExtension(filename) == ".mdl")
  492. {
  493. containsMDL_ = true;
  494. }
  495. // END LICENSE MANAGEMENT
  496. newEntry->absolutePath_ = resourceDir + filename;
  497. newEntry->resourceDir_ = resourceDir;
  498. newEntry->packagePath_ = filename;
  499. resourceEntries_.Push(newEntry);
  500. assert(resourcePackager_.NotNull());
  501. resourcePackager_->AddResourceEntry(newEntry);
  502. fileIncludedResourcesLog_->WriteLine(newEntry->absolutePath_);
  503. }
  504. void BuildBase::GenerateResourcePackage(const String& resourcePackagePath)
  505. {
  506. resourcePackager_->GeneratePackage(resourcePackagePath);
  507. }
  508. void BuildBase::AddResourceDir(const String& dir)
  509. {
  510. assert(!resourceDirs_.Contains(dir));
  511. resourceDirs_.Push(dir);
  512. }
  513. void BuildBase::AddProjectResourceDir(const String& dir)
  514. {
  515. assert(!projectResourceDir_.Contains(dir));
  516. projectResourceDir_.Push(dir);
  517. }
  518. void BuildBase::ReadAssetBuildConfig()
  519. {
  520. String projectPath = project_->GetProjectPath();
  521. projectPath = RemoveTrailingSlash(projectPath);
  522. String filename = projectPath + "Settings/AssetBuildConfig.json";
  523. FileSystem* fileSystem = GetSubsystem<FileSystem>();
  524. if (!fileSystem->FileExists(filename))
  525. return;
  526. if (AssetBuildConfig::LoadFromFile(context_, filename))
  527. {
  528. VariantMap assetBuildConfig;
  529. AssetBuildConfig::ApplyConfig(assetBuildConfig);
  530. }
  531. }
  532. }