-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add runtime scripts etc. for checking MacOS SDK version etc.
- Loading branch information
1 parent
d1d7e23
commit 8fde5b4
Showing
3 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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})' | ||
|