mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 15:32:23 -04:00
Make libankihelper a universal library
We were shipping a single arch library in a purelib, leading to breakages when running on a different platform.
This commit is contained in:
parent
c7e9cb2d88
commit
b3a75fe298
1 changed files with 28 additions and 15 deletions
|
@ -11,19 +11,32 @@ out_dylib, *src_files = sys.argv[1:]
|
||||||
out_dir = Path(out_dylib).parent.resolve()
|
out_dir = Path(out_dylib).parent.resolve()
|
||||||
src_dir = Path(src_files[0]).parent.resolve()
|
src_dir = Path(src_files[0]).parent.resolve()
|
||||||
|
|
||||||
if platform.machine() == "arm64" and not os.environ.get("MAC_X86"):
|
# Build for both architectures
|
||||||
target = "arm64-apple-macos11"
|
architectures = ["arm64", "x86_64"]
|
||||||
else:
|
temp_files = []
|
||||||
target = "x86_64-apple-macos10.14"
|
|
||||||
|
|
||||||
args = [
|
for arch in architectures:
|
||||||
"swiftc",
|
target = f"{arch}-apple-macos11"
|
||||||
"-target",
|
temp_out = out_dir / f"temp_{arch}.dylib"
|
||||||
target,
|
temp_files.append(temp_out)
|
||||||
"-emit-library",
|
|
||||||
"-module-name",
|
args = [
|
||||||
"ankihelper",
|
"swiftc",
|
||||||
"-O",
|
"-target",
|
||||||
]
|
target,
|
||||||
args.extend(src_dir / Path(file).name for file in src_files)
|
"-emit-library",
|
||||||
subprocess.run(args, check=True, cwd=out_dir)
|
"-module-name",
|
||||||
|
"ankihelper",
|
||||||
|
"-O",
|
||||||
|
]
|
||||||
|
args.extend(src_dir / Path(file).name for file in src_files)
|
||||||
|
args.extend(["-o", str(temp_out)])
|
||||||
|
subprocess.run(args, check=True, cwd=out_dir)
|
||||||
|
|
||||||
|
# Create universal binary
|
||||||
|
lipo_args = ["lipo", "-create", "-output", out_dylib] + [str(f) for f in temp_files]
|
||||||
|
subprocess.run(lipo_args, check=True)
|
||||||
|
|
||||||
|
# Clean up temporary files
|
||||||
|
for temp_file in temp_files:
|
||||||
|
temp_file.unlink()
|
||||||
|
|
Loading…
Reference in a new issue