|
3 | 3 | import os |
4 | 4 | import shlex |
5 | 5 | import subprocess |
| 6 | +import filecmp |
6 | 7 | import sys |
7 | 8 |
|
8 | 9 | print("Python version: " + sys.version) |
@@ -126,7 +127,7 @@ def save_stream_to_file(filename, stream): |
126 | 127 | def generate_metadata(arch): |
127 | 128 | # metadata generator arguments |
128 | 129 | generator_call = ["./objc-metadata-generator", "-verbose", |
129 | | - "-output-bin", "{}/metadata-{}.bin".format(conf_build_dir, arch), |
| 130 | + "-output-bin", "{}/metadata-{}.bin.tmp".format(conf_build_dir, arch), |
130 | 131 | "-output-umbrella", "{}/umbrella-{}.h".format(conf_build_dir, arch), |
131 | 132 | "-docset-path", docset_path] |
132 | 133 |
|
@@ -192,6 +193,14 @@ def generate_metadata(arch): |
192 | 193 | print(error_stream_content) |
193 | 194 | sys.exit(1) |
194 | 195 |
|
| 196 | + # Generated during linking, but also an input of the link (-sectcreate): |
| 197 | + # replacing unchanged metadata would make Xcode relink on every build. |
| 198 | + output_bin = "{}/metadata-{}.bin".format(conf_build_dir, arch) |
| 199 | + if os.path.exists(output_bin) and filecmp.cmp(output_bin + ".tmp", output_bin, shallow=False): |
| 200 | + os.remove(output_bin + ".tmp") |
| 201 | + else: |
| 202 | + os.replace(output_bin + ".tmp", output_bin) |
| 203 | + |
195 | 204 |
|
196 | 205 | for arch in env("ARCHS").split(): |
197 | 206 | # skip metadata generation for architectures different than the one specified in the command line |
|
0 commit comments