|
61 | 61 | flags.DEFINE_boolean("output_upm", False, "Whether output packages as tgz for"
|
62 | 62 | "Unity Package Manager.")
|
63 | 63 |
|
| 64 | +flags.DEFINE_boolean("update_guids", False, "If true, update guids_file first.") |
| 65 | + |
64 | 66 | def get_zip_files():
|
65 | 67 | """Get all zip files from FLAGS.zip_dir.
|
66 | 68 |
|
@@ -165,8 +167,33 @@ def main(argv):
|
165 | 167 | cmd_args.append("--output_unitypackage=False")
|
166 | 168 | else:
|
167 | 169 | 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) |
170 | 197 |
|
171 | 198 | if __name__ == '__main__':
|
172 | 199 | app.run(main)
|
0 commit comments