9 private ref array<string> m_EntFiles;
27 static bool FindAddonByAbsolutePath(
28 string queryAbsolutePath,
29 out
string outAddonGuid,
30 out
string outAddonId,
31 out
string outAddonExactRoot
34 if (!
FilePath.IsAbsolutePath(queryAbsolutePath))
37 queryAbsolutePath =
FilePath.ToInternalFormat(queryAbsolutePath);
38 if (!queryAbsolutePath.EndsWith(
"/"))
39 queryAbsolutePath +=
"/";
41 array<string> addonGuids = {};
44 foreach(
string addonGuid : addonGuids)
47 string addonExactRoot =
string.Format(
"$%1:", addonId);
48 string addonAbsolutePath;
49 if (!Workbench.GetAbsolutePath(addonExactRoot, addonAbsolutePath))
52 if (!addonAbsolutePath.EndsWith(
"/"))
53 addonAbsolutePath +=
"/";
55 if (addonAbsolutePath.Compare(queryAbsolutePath, caseSensitive:
false) == 0)
57 outAddonGuid = addonGuid;
59 outAddonExactRoot = addonExactRoot;
67 private void OnEntFileFound(
ResourceName resName,
string file)
69 m_EntFiles.Insert(resName.GetPath());
72 private bool TryExtractGUID(
ResourceName resName, out
string guid)
74 int guidBeg = resName.IndexOf(
"{");
75 int guidEnd = resName.IndexOf(
"}");
76 if (guidBeg != -1 && guidEnd != -1)
79 guid = resName.Substring(guidBeg, guidEnd - guidBeg);
88 void GenerateCiInfo(ResourceManager rm,
FileHandle outputFile,
string addonExactRoot,
string addonID)
90 Print(addonExactRoot);
94 filter.fileExtensions = {
"ent"};
95 filter.rootPath = addonExactRoot;
100 foreach (
string entFile : m_EntFiles)
103 string entExactPath = addonExactRoot + entFile;
104 MetaFile mf = rm.GetMetaFile(entExactPath);
106 for (
int i = 0, count = configs.Count(); i < count; i++)
110 if (!TryExtractGUID(mf.GetResourceID(), resourceID))
112 PrintFormat(
"Couldn't extract GUID from resource name '%1'", mf.GetResourceID());
116 string configName = config.GetName();
117 array<string> buildTags;
118 config.Get(
"BuildTags", buildTags);
119 if (!buildTags.IsEmpty())
121 WorldBuildMeta wbm =
new WorldBuildMeta();
124 wbm.tags = buildTags;
125 array<ref WorldBuildMeta> resultList;
126 if (!result.Find(configName, resultList))
129 result.Set(configName, resultList);
131 resultList.Insert(wbm);
137 bool separateConfigs =
false;
138 foreach (
string k, array<ref WorldBuildMeta> v : result)
143 json +=
string.Format(
"\"%1\":{", k);
144 bool separateWbm =
false;
145 foreach (WorldBuildMeta wbm : v)
150 json +=
string.Format(
151 "\"%1\": {\"name\":\"%2\",\"path\":\"%3\",\"tags\":[",
156 bool separateTags =
false;
157 foreach (
string tag : wbm.tags)
161 json +=
string.Format(
"\"%1\"", tag);
168 separateConfigs =
true;
172 outputFile.WriteLine(json);
175#ifdef AddonBuildInfoTool_IN_UI
178 ResourceManager rm = Workbench.GetModule(ResourceManager);
179 array<string> addonGUIDs = {};
182 foreach(
string addonGUID : addonGUIDs)
184 string addonID =
GameProject.GetAddonID(addonGUID);
185 string addonExactRoot =
string.Format(
"$%1:", addonID);
187 if (!outputFile.IsOpen())
190 GenerateCiInfo(rm, outputFile, addonExactRoot, addonID);
198 ResourceManager rm = Workbench.GetModule(ResourceManager);
200 if (!rm.GetCmdLine(
"-addonPath", addonPathCli))
202 Print(
"Missing argument 'addonPath', which is required AddonBuildInfoTool plugin.", level:
LogLevel.ERROR);
206 if (!
FilePath.IsAbsolutePath(addonPathCli))
208 PrintFormat(
"Argument 'addonPath' must be an absolute path, but its value is '%1'", addonPathCli, level:
LogLevel.ERROR);
213 string addonGuid, addonId, addonExactRoot;
215 addonPathCli, addonGuid, addonId, addonExactRoot
219 PrintFormat(
"Could not find addon matching path '%1'.", addonPathCli);
224 if (!rm.GetCmdLine(
"-ciInfoDst", ciInfoDstCli))
226 Print(
"Missing argument 'ciInfoDst' for AddonBuildInfoTool plugin.", level:
LogLevel.ERROR);
230 ciInfoDstCli =
FilePath.ToInternalFormat(ciInfoDstCli);
233 if (!outputFile.IsOpen())
240 GenerateCiInfo(rm, outputFile, addonExactRoot, addonId);
proto void PrintFormat(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL, LogLevel level=LogLevel.NORMAL)