Skip to content

Commit 1492aab

Browse files
author
Cynthia Jiang
committed
test
1 parent c7454be commit 1492aab

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

build_package.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@
6161
flags.DEFINE_boolean("output_upm", False, "Whether output packages as tgz for"
6262
"Unity Package Manager.")
6363

64+
flags.DEFINE_boolean("update_guids", False, "If true, update guids_file first.")
65+
6466
def get_zip_files():
6567
"""Get all zip files from FLAGS.zip_dir.
6668
@@ -165,8 +167,33 @@ def main(argv):
165167
cmd_args.append("--output_unitypackage=False")
166168
else:
167169
cmd_args.append("--enabled_sections=build_dotnet3 build_dotnet4")
168-
169-
return subprocess.call(cmd_args)
170+
171+
# Check if need to gen new guids
172+
p = subprocess.Popen(cmd_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
173+
output, error = p.communicate()
174+
if p.returncode != 0:
175+
error_str = str(error)
176+
split_string = error_str.split("assets:")[-1]
177+
split_string = split_string.rstrip("\\n\'")
178+
print(split_string)
179+
split_string = split_string.split(" ")
180+
split_string = split_string[3:] # exclude first 3 lines
181+
gen_guids_script_path = os.path.join(os.getcwd(), "gen_guids.py")
182+
gen_cmd_args = [
183+
sys.executable,
184+
gen_guids_script_path,
185+
"--guids_file=" + guids_file_path,
186+
"--version=" + last_version,
187+
"--generate_new_guids=True",
188+
]
189+
for file in split_string:
190+
file=file.strip("\"")
191+
print(file)
192+
gen_cmd_args.append(file)
193+
subprocess.call(gen_cmd_args)
194+
195+
# Need to package again if has that error
196+
subprocess.call(cmd_args)
170197

171198
if __name__ == '__main__':
172199
app.run(main)

0 commit comments

Comments
 (0)