Skip to content

Commit 7fe060f

Browse files
committed
Test on Apple Silicon ARM64
1 parent a50d836 commit 7fe060f

File tree

2 files changed

+37
-6
lines changed

2 files changed

+37
-6
lines changed

.github/scripts/ci_build_cairo.py

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,38 @@ def main():
144144
]
145145
)
146146

147-
env_vars = {
148-
# add the venv bin directory to PATH so that meson can find ninja
149-
"PATH": f"{os.path.join(tmpdir, VENV_NAME, 'bin')}{os.pathsep}{os.environ['PATH']}",
150-
}
147+
# Inherit the current environment so PKG_CONFIG_PATH, CFLAGS, LDFLAGS, etc. are preserved.
148+
env_vars = os.environ.copy()
149+
# Prepend the venv bin directory so meson/ninja from the venv are used.
150+
env_vars["PATH"] = f"{os.path.join(tmpdir, VENV_NAME, 'bin')}{os.pathsep}{env_vars.get('PATH','')}"
151+
152+
# Ensure Homebrew-provided pkgconfig and include/lib paths are present on macOS ARM.
153+
if sys.platform == "darwin":
154+
try:
155+
# Try to get specific prefix for lzo (safer for opt path), fall back to generic brew prefix.
156+
brew_prefix = subprocess.check_output(["brew", "--prefix", "lzo"], text=True).strip()
157+
except subprocess.CalledProcessError:
158+
try:
159+
brew_prefix = subprocess.check_output(["brew", "--prefix"], text=True).strip()
160+
except Exception:
161+
brew_prefix = None
162+
163+
if brew_prefix:
164+
# pkg-config files can live in lib/pkgconfig or opt/<pkg>/lib/pkgconfig
165+
pkgconfig_paths = [f"{brew_prefix}/lib/pkgconfig", f"{brew_prefix}/opt/lzo/lib/pkgconfig"]
166+
# merge with any existing PKG_CONFIG_PATH
167+
existing_pc = env_vars.get("PKG_CONFIG_PATH", "")
168+
merged_pc = ":".join([p for p in pkgconfig_paths if p]) + (f":{existing_pc}" if existing_pc else "")
169+
env_vars["PKG_CONFIG_PATH"] = merged_pc
170+
171+
# Ensure compiler & linker flags include brew include/lib
172+
existing_cflags = env_vars.get("CFLAGS", "")
173+
existing_ldflags = env_vars.get("LDFLAGS", "")
174+
env_vars["CFLAGS"] = f"-I{brew_prefix}/include {existing_cflags}".strip()
175+
env_vars["LDFLAGS"] = f"-L{brew_prefix}/lib {existing_ldflags}".strip()
176+
177+
# Debugging: log environment keys relevant to detection
178+
# logger.info(f"env vars for meson: {env_vars}")
151179

152180
with gha_group("Building and Installing Cairo"):
153181
logger.info("Running meson setup")

.github/workflows/ci.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ jobs:
2222
strategy:
2323
fail-fast: false
2424
matrix:
25-
os: [ubuntu-22.04, macos-15-intel, windows-latest]
25+
os: [ubuntu-22.04, macos-latest, windows-latest]
2626
python: ["3.10", "3.11", "3.12", "3.13"]
27+
include:
28+
- os: macos-15-intel
29+
python: "3.13"
2730

2831
steps:
2932
- name: Checkout the repository
@@ -74,7 +77,7 @@ jobs:
7477
if: runner.os == 'Linux' || runner.os == 'macOS'
7578
with:
7679
path: ${{ github.workspace }}/third_party
77-
key: ${{ runner.os }}-dependencies-cairo-${{ hashFiles('.github/scripts/ci_build_cairo.py') }}
80+
key: ${{ runner.os }}-${{ runner.arch }}-dependencies-cairo-${{ hashFiles('.github/scripts/ci_build_cairo.py') }}
7881

7982
- name: Build and install Cairo (Linux and macOS)
8083
if: (runner.os == 'Linux' || runner.os == 'macOS') && steps.cache-cairo.outputs.cache-hit != 'true'

0 commit comments

Comments
 (0)