Skip to content

Commit

Permalink
Add ability to build SDK for macOS hosts
Browse files Browse the repository at this point in the history
The Microkit tool can now be built for x64 macOS as well as ARM64
macOS, allowing the use of the Microkit SDK in macOS environments.

Note that unlike the Linux Microkit tool, the macOS one will be
dynamically linked due to macOS not supporting statically linked
binaries.

Signed-off-by: Ivan Velickovic <[email protected]>
  • Loading branch information
Ivan-Velickovic committed Jan 27, 2024
1 parent 1516b7d commit 6eb7b31
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions build_sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from dataclasses import dataclass
from sys import executable
from tarfile import open as tar_open, TarInfo
import platform as host_platform

from typing import Dict, Union, List, Tuple

Expand Down Expand Up @@ -162,12 +163,27 @@ def build_tool(tool_target: Path) -> None:
pyoxidizer = ENV_BIN_DIR / "pyoxidizer"
if not pyoxidizer.exists():
raise Exception("pyoxidizer does not appear to be installed in your Python environment")

host_system = host_platform.system()
if host_system == "Linux":
target_triple = "x86_64-unknown-linux-musl"
elif host_system == "Darwin":
host_arch = host_platform.machine()
if host_arch == "x86_64":
target_triple = "x86_64-apple-darwin"
elif host_arch == "arm64":
target_triple = "aarch64-apple-darwin"
else:
raise Exception(f"Unexpected Darwin architecture: {host_arch}")
else:
raise Exception(f"The platform \"{host_system}\" is not supported")

r = system(
f"{pyoxidizer} build --release --path tool --target-triple x86_64-unknown-linux-musl"
f"{pyoxidizer} build --release --path tool --target-triple {target_triple}"
)
assert r == 0

tool_output = "./tool/build/x86_64-unknown-linux-musl/release/install/microkit"
tool_output = f"./tool/build/{target_triple}/release/install/microkit"

r = system(f"strip {tool_output}")
assert r == 0
Expand Down

0 comments on commit 6eb7b31

Please sign in to comment.