BuildBase.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  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 (sendEvent)
  195. {
  196. String colorMsg = ToString("<color #D4FB79>%s</color>\n", message.CString());
  197. VariantMap buildOutput;
  198. buildOutput[BuildOutput::P_TEXT] = colorMsg;
  199. SendEvent(E_BUILDOUTPUT, buildOutput);
  200. }
  201. }
  202. void BuildBase::BuildWarn(const String& warning, bool sendEvent)
  203. {
  204. buildWarnings_.Push(warning);
  205. if (sendEvent)
  206. {
  207. String colorMsg = ToString("<color #FFFF00>%s</color>\n", warning.CString());
  208. VariantMap buildOutput;
  209. buildOutput[BuildOutput::P_TEXT] = colorMsg;
  210. SendEvent(E_BUILDOUTPUT, buildOutput);
  211. }
  212. }
  213. void BuildBase::BuildError(const String& error, bool sendEvent)
  214. {
  215. buildErrors_.Push(error);
  216. if (sendEvent)
  217. {
  218. String colorMsg = ToString("<color #FF0000>%s</color>\n", error.CString());
  219. VariantMap buildOutput;
  220. buildOutput[BuildOutput::P_TEXT] = colorMsg;
  221. SendEvent(E_BUILDOUTPUT, buildOutput);
  222. }
  223. }
  224. void BuildBase::FailBuild(const String& message)
  225. {
  226. if (buildFailed_)
  227. {
  228. ATOMIC_LOGERRORF("BuildBase::FailBuild - Attempt to fail already failed build: %s", message.CString());
  229. return;
  230. }
  231. buildFailed_ = true;
  232. BuildError(message);
  233. BuildSystem* buildSystem = GetSubsystem<BuildSystem>();
  234. buildSystem->BuildComplete(platformID_, buildPath_, false, message);
  235. }
  236. void BuildBase::HandleSubprocessOutputEvent(StringHash eventType, VariantMap& eventData)
  237. {
  238. // E_SUBPROCESSOUTPUT
  239. const String& text = eventData[SubprocessOutput::P_TEXT].GetString();
  240. // convert to a build output event and forward to subscribers
  241. VariantMap buildOutputData;
  242. buildOutputData[BuildOutput::P_TEXT] = text;
  243. SendEvent(E_BUILDOUTPUT, buildOutputData);
  244. }
  245. void BuildBase::GetDefaultResourcePaths(Vector<String>& paths)
  246. {
  247. paths.Clear();
  248. ToolEnvironment* tenv = GetSubsystem<ToolEnvironment>();
  249. paths.Push(AddTrailingSlash(tenv->GetCoreDataDir()));
  250. paths.Push(AddTrailingSlash(tenv->GetPlayerDataDir()));
  251. }
  252. String BuildBase::GetSettingsDirectory()
  253. {
  254. return project_->GetProjectPath() + "/Settings";
  255. }
  256. void BuildBase::BuildDefaultResourceEntries()
  257. {
  258. String buildLogOutput(String::EMPTY);
  259. for (unsigned i = 0; i < resourceDirs_.Size(); i++)
  260. {
  261. String resourceDir = resourceDirs_[i];
  262. fileIncludedResourcesLog_->WriteLine("\nBuildBase::BuildDefaultResourceEntries - Default resources being included from: " + resourceDir);
  263. Vector<String> fileNames;
  264. FileSystem* fileSystem = GetSubsystem<FileSystem>();
  265. fileSystem->ScanDir(fileNames, resourceDir, "*.*", SCAN_FILES, true);
  266. for (unsigned i = 0; i < fileNames.Size(); i++)
  267. {
  268. const String& filename = fileNames[i];
  269. AddToResourcePackager(filename, resourceDir);
  270. if (verbose_)
  271. {
  272. ATOMIC_LOGINFO(ToString("Default Resource Added: %s%s", resourceDir.CString(), filename.CString()));
  273. }
  274. }
  275. }
  276. }
  277. void BuildBase::BuildProjectResourceEntries()
  278. {
  279. String buildLogOutput(String::EMPTY);
  280. if (AssetBuildConfig::IsLoaded())
  281. {
  282. buildLogOutput += "\nBaseBuild::BuildProjectResourceEntries - ./Settings/AssetBuildConfig.json found. ";
  283. if (!assetBuildTag_.Empty())
  284. {
  285. buildLogOutput += "Using build-tag parameter : " + assetBuildTag_;
  286. fileIncludedResourcesLog_->WriteLine(buildLogOutput);
  287. BuildFilteredProjectResourceEntries();
  288. return;
  289. }
  290. buildLogOutput += "No build-tag parameter used.";
  291. }
  292. buildLogOutput += "\nBaseBuild::BuildProjectResourceEntries - No custom asset include configuration being used - ";
  293. buildLogOutput += "AssetBuildConfig.json not loaded, OR no build-tag parameter used.";
  294. fileIncludedResourcesLog_->WriteLine(buildLogOutput);
  295. BuildAllProjectResourceEntries();
  296. }
  297. void BuildBase::BuildAllProjectResourceEntries()
  298. {
  299. for (unsigned i = 0; i < projectResourceDir_.Size(); i++)
  300. {
  301. String projectResourceDir = projectResourceDir_[i];
  302. fileIncludedResourcesLog_->WriteLine("\nBuildBase::BuildAllProjectResourceEntries - Project resources being included from: " + projectResourceDir);
  303. Vector<String> fileNamesInProject;
  304. FileSystem* fileSystem = GetSubsystem<FileSystem>();
  305. fileSystem->ScanDir(fileNamesInProject, projectResourceDir, "*.*", SCAN_FILES, true);
  306. for (unsigned i = 0; i < fileNamesInProject.Size(); i++)
  307. {
  308. AddToResourcePackager(fileNamesInProject[i], projectResourceDir);
  309. if (verbose_)
  310. {
  311. ATOMIC_LOGINFO(ToString("Project Resource Added: %s%s", projectResourceDir.CString(), fileNamesInProject[i].CString()));
  312. }
  313. }
  314. }
  315. }
  316. void BuildBase::BuildFilteredProjectResourceEntries()
  317. {
  318. // Loading up the AssetBuildConfig.json,
  319. // obtaining a list of files to include in the build.
  320. VariantMap resourceTags;
  321. AssetBuildConfig::ApplyConfig(resourceTags);
  322. Vector<String> assetBuildConfigFiles;
  323. VariantMap::ConstIterator itr = resourceTags.Begin();
  324. while (itr != resourceTags.End())
  325. {
  326. if (itr->first_ == assetBuildTag_)
  327. {
  328. assetBuildConfigFiles = itr->second_.GetStringVector();
  329. for (unsigned i = 0; i < assetBuildConfigFiles.Size(); ++i)
  330. {
  331. // remove case sensitivity
  332. assetBuildConfigFiles[i] = assetBuildConfigFiles[i].ToLower();
  333. }
  334. break;
  335. }
  336. itr++;
  337. if (itr == resourceTags.End())
  338. {
  339. ATOMIC_LOGERRORF("BuildBase::BuildFilteredProjectResourceEntries - Asset build-tag \"%s\" not defined in ./Settings/AssetBuildConfig.json", assetBuildTag_.CString());
  340. }
  341. }
  342. // find any folders defined in assetbuildconfig.json, and add the non-".asset" files in them.
  343. FileSystem* fileSystem = GetSubsystem<FileSystem>();
  344. Vector<String> filesInFolderToAdd;
  345. for (unsigned i = 0; i < assetBuildConfigFiles.Size(); ++i)
  346. {
  347. String &filename = assetBuildConfigFiles[i];
  348. if (GetExtension(filename) == String::EMPTY &&
  349. fileSystem->DirExists(project_->GetResourcePath() + filename))
  350. {
  351. // rename 'filename' to 'folder' for context
  352. String folder(filename);
  353. // add a trailing slash if not defined
  354. if (folder.Back() != '/')
  355. folder = AddTrailingSlash(folder);
  356. Vector<String> filesInFolder;
  357. fileSystem->ScanDir(filesInFolder, project_->GetResourcePath() + folder, "*.*", SCAN_FILES, true);
  358. for (unsigned j = 0; j < filesInFolder.Size(); ++j)
  359. {
  360. String path = filesInFolder[j];
  361. // not interested in .asset files for now, will be included later.
  362. if (GetExtension(path) != ".asset")
  363. {
  364. filesInFolderToAdd.Push(folder + path.ToLower());
  365. }
  366. }
  367. }
  368. }
  369. // add the files defined using a folder in AssetBuildConfig.json
  370. for (unsigned i = 0; i < filesInFolderToAdd.Size(); ++i)
  371. {
  372. assetBuildConfigFiles.Push(filesInFolderToAdd[i]);
  373. }
  374. // check if the files in AssetBuildConfig.json exist,
  375. // as well as their corresponding .asset file
  376. Vector<String> filesInResourceFolder;
  377. Vector<String> resourceFilesToInclude;
  378. fileSystem->ScanDir(filesInResourceFolder, project_->GetResourcePath(), "*.*", SCAN_FILES, true);
  379. for (unsigned j = 0; j < filesInResourceFolder.Size(); ++j)
  380. {
  381. // don't want to checks to be case sensitive
  382. filesInResourceFolder[j] = filesInResourceFolder[j].ToLower();
  383. }
  384. for (unsigned i = 0; i < assetBuildConfigFiles.Size(); ++i)
  385. {
  386. // .asset file is of primary importance since we used it to identify the associated cached file.
  387. // without the .asset file the resource is removed from being included in the build.
  388. // don't want checks to be case sensitive
  389. String &filename = assetBuildConfigFiles[i];
  390. if (filesInResourceFolder.Contains(filename) &&
  391. filesInResourceFolder.Contains(filename + ".asset"))
  392. {
  393. resourceFilesToInclude.Push(filename);
  394. resourceFilesToInclude.Push(filename + ".asset");
  395. continue;
  396. }
  397. fileIncludedResourcesLog_->WriteLine("File " + filename + " ignored since it does not have an associated .asset file");
  398. }
  399. // add valid files included from the AssetBuildConfig.json
  400. for (StringVector::ConstIterator it = resourceFilesToInclude.Begin(); it != resourceFilesToInclude.End(); ++it)
  401. {
  402. AddToResourcePackager(*it, project_->GetResourcePath());
  403. }
  404. // Get associated cache GUID from the asset file
  405. Vector<String> filesWithGUIDtoInclude;
  406. for (StringVector::Iterator it = resourceFilesToInclude.Begin(); it != resourceFilesToInclude.End(); ++it)
  407. {
  408. String &filename = *it;
  409. if (GetExtension(*it) == ".asset")
  410. {
  411. SharedPtr<File> file(new File(context_, project_->GetResourcePath() + *it));
  412. SharedPtr<JSONFile> json(new JSONFile(context_));
  413. json->Load(*file);
  414. file->Close();
  415. JSONValue root = json->GetRoot();
  416. int test = root.Get("version").GetInt();
  417. assert(root.Get("version").GetInt() == ASSET_VERSION);
  418. String guid = root.Get("guid").GetString();
  419. filesWithGUIDtoInclude.Push(guid);
  420. }
  421. }
  422. // Obtain files in cache folder,
  423. // Check if the file contains the guid, and add it to the cacheFilesToInclude
  424. Vector<String> filesInCacheFolder;
  425. Vector<String> cacheFilesToInclude;
  426. AssetDatabase* db = GetSubsystem<AssetDatabase>();
  427. String cachePath = db->GetCachePath();
  428. fileSystem->ScanDir(filesInCacheFolder, cachePath, "*.*", SCAN_FILES, false);
  429. for (unsigned i = 0; i < filesWithGUIDtoInclude.Size(); ++i)
  430. {
  431. String &guid = filesWithGUIDtoInclude[i];
  432. for (unsigned j = 0; j < filesInCacheFolder.Size(); ++j)
  433. {
  434. const String &filename = GetFileName(filesInCacheFolder[j]);
  435. String &filenamePath = filesInCacheFolder[j];
  436. if (filename.Contains(guid))
  437. {
  438. cacheFilesToInclude.Push(filesInCacheFolder[j]);
  439. // do not continue...
  440. // there might be multiple files with the same guid having an guid_animaiton extention.
  441. }
  442. }
  443. }
  444. // include a texture file's cached .dds file when building in windows
  445. #ifdef ATOMIC_PLATFORM_DESKTOP
  446. for (StringVector::ConstIterator it = resourceFilesToInclude.Begin(); it != resourceFilesToInclude.End(); ++it)
  447. {
  448. if (!CheckIncludeResourceFile(project_->GetResourcePath(), *it))
  449. {
  450. FileSystem* fileSystem = GetSubsystem<FileSystem>();
  451. String associatedDDSpath = "DDS/" + *it + ".dds";
  452. String compressedPath = cachePath + associatedDDSpath;
  453. if (fileSystem->FileExists(compressedPath))
  454. {
  455. cacheFilesToInclude.Push(associatedDDSpath);
  456. }
  457. }
  458. }
  459. #endif
  460. // Add the cache files to the resource packager
  461. for (StringVector::ConstIterator it = cacheFilesToInclude.Begin(); it != cacheFilesToInclude.End(); ++it)
  462. {
  463. AddToResourcePackager(*it, cachePath);
  464. }
  465. }
  466. void BuildBase::AddToResourcePackager(const String& filename, const String& resourceDir)
  467. {
  468. // Check if the file is already included in the resourceEntries_ list
  469. for (unsigned j = 0; j < resourceEntries_.Size(); j++)
  470. {
  471. const BuildResourceEntry* entry = resourceEntries_[j];
  472. if (entry->packagePath_ == filename)
  473. {
  474. BuildWarn(ToString("Resource Path: %s already exists", filename.CString()));
  475. continue;
  476. }
  477. }
  478. if (!CheckIncludeResourceFile(resourceDir, filename))
  479. {
  480. fileIncludedResourcesLog_->WriteLine(resourceDir + filename + " skipped because of file extention: " + GetExtension(filename));
  481. return;
  482. }
  483. BuildResourceEntry* newEntry = new BuildResourceEntry;
  484. // BEGIN LICENSE MANAGEMENT
  485. if (GetExtension(filename) == ".mdl")
  486. {
  487. containsMDL_ = true;
  488. }
  489. // END LICENSE MANAGEMENT
  490. newEntry->absolutePath_ = resourceDir + filename;
  491. newEntry->resourceDir_ = resourceDir;
  492. newEntry->packagePath_ = filename;
  493. resourceEntries_.Push(newEntry);
  494. assert(resourcePackager_.NotNull());
  495. resourcePackager_->AddResourceEntry(newEntry);
  496. fileIncludedResourcesLog_->WriteLine(newEntry->absolutePath_);
  497. }
  498. void BuildBase::GenerateResourcePackage(const String& resourcePackagePath)
  499. {
  500. resourcePackager_->GeneratePackage(resourcePackagePath);
  501. }
  502. void BuildBase::AddResourceDir(const String& dir)
  503. {
  504. assert(!resourceDirs_.Contains(dir));
  505. resourceDirs_.Push(dir);
  506. }
  507. void BuildBase::AddProjectResourceDir(const String& dir)
  508. {
  509. assert(!projectResourceDir_.Contains(dir));
  510. projectResourceDir_.Push(dir);
  511. }
  512. void BuildBase::ReadAssetBuildConfig()
  513. {
  514. String projectPath = project_->GetProjectPath();
  515. projectPath = RemoveTrailingSlash(projectPath);
  516. String filename = projectPath + "Settings/AssetBuildConfig.json";
  517. FileSystem* fileSystem = GetSubsystem<FileSystem>();
  518. if (!fileSystem->FileExists(filename))
  519. return;
  520. if (AssetBuildConfig::LoadFromFile(context_, filename))
  521. {
  522. VariantMap assetBuildConfig;
  523. AssetBuildConfig::ApplyConfig(assetBuildConfig);
  524. }
  525. }
  526. }