Skip to content

Commit

Permalink
Add runtime scripts etc. for checking MacOS SDK version etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamkewley committed Jan 16, 2025
1 parent d1d7e23 commit 8fde5b4
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/continuous-integration-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ jobs:
OSC_CMAKE_CONFIG_EXTRA="-Werror=dev -DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -DCMAKE_OSX_DEPLOYMENT_TARGET=14 -DCMAKE_OSX_ARCHITECTURES=x86_64"
export OSC_BUILD_CONCURRENCY=$(sysctl -n hw.physicalcpu)
./scripts/build_mac.sh
./scripts/macos_check-dependencies.py osc-build/osc/osc
./scripts/macos_check-sdk.py 14.shouldfail osc-build/osc/osc
- uses: actions/upload-artifact@v4
with:
Expand Down
20 changes: 20 additions & 0 deletions scripts/macos_check-dependencies.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env python3

import argparse
import subprocess

whitelisted_library_prefixes = [
'/System/Library',
'/usr/lib/libc++',
'/usr/lib/libobjc',
'/usr/lib/libSystem.B.dylib'
]

parser = argparse.ArgumentParser(description='check that the given binary (usually, osc) only uses whitelisted libraries')
parser.add_argument('binary', help='path to the binary')
args = parser.parse_args()

output = subprocess.check_output(f'otool -L {args.binary}', shell=True).decode('utf-8')
for line in output.splitlines():
if line.startswith('\t'):
assert any([line[1:].startswith(x) for x in whitelisted_library_prefixes]), f'{line} isnt a permitted dependency'
14 changes: 14 additions & 0 deletions scripts/macos_check-sdk.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env python3


import argparse
import subprocess

parser = argparse.ArgumentParser(description='check that the given binary uses the correct MacOS SDK')
parser.add_argument('expected_sdk_version', help='the expected SDK version')
parser.add_argument('binary', help='the binary to check')
args = parser.parse_args()

sdk_version = subprocess.check_output(f'otool -l {args.binary} | grep sdk', shell=True).decode('utf-8').split(' ')[-1].strip()
assert sdk_version == args.expected_sdk_version, f'{sdk_version} is not the expected SDK version ({args.expected_sdk_version})'

0 comments on commit 8fde5b4

Please sign in to comment.