Skip to content

Commit 29615ae

Browse files
committed
scripts: check minimum required macOS vesion is set
We use a compile flag (-mmacosx-version-min) to set the minimum required version of macOS needed to run our binaries. This adds a sanity check that the version is being set as expected.
1 parent 8732f7b commit 29615ae

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

contrib/devtools/symbol-check.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,12 @@ def check_MACHO_libraries(filename) -> bool:
212212
ok = False
213213
return ok
214214

215+
def check_MACHO_min_os(filename) -> bool:
216+
binary = lief.parse(filename)
217+
if binary.build_version.minos == [10,14,0]:
218+
return True
219+
return False
220+
215221
def check_PE_libraries(filename) -> bool:
216222
ok: bool = True
217223
binary = lief.parse(filename)
@@ -228,7 +234,8 @@ def check_PE_libraries(filename) -> bool:
228234
('LIBRARY_DEPENDENCIES', check_ELF_libraries)
229235
],
230236
'MACHO': [
231-
('DYNAMIC_LIBRARIES', check_MACHO_libraries)
237+
('DYNAMIC_LIBRARIES', check_MACHO_libraries),
238+
('MIN_OS', check_MACHO_min_os),
232239
],
233240
'PE' : [
234241
('DYNAMIC_LIBRARIES', check_PE_libraries)

contrib/devtools/test-symbol-check.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def test_MACHO(self):
9898

9999
self.assertEqual(call_symbol_check(cc, source, executable, ['-lexpat']),
100100
(1, 'libexpat.1.dylib is not in ALLOWED_LIBRARIES!\n' +
101-
executable + ': failed DYNAMIC_LIBRARIES'))
101+
executable + ': failed DYNAMIC_LIBRARIES MIN_OS'))
102102

103103
source = 'test2.c'
104104
executable = 'test2'
@@ -114,6 +114,19 @@ def test_MACHO(self):
114114
''')
115115

116116
self.assertEqual(call_symbol_check(cc, source, executable, ['-framework', 'CoreGraphics']),
117+
(1, executable + ': failed MIN_OS'))
118+
119+
source = 'test3.c'
120+
executable = 'test3'
121+
with open(source, 'w', encoding="utf8") as f:
122+
f.write('''
123+
int main()
124+
{
125+
return 0;
126+
}
127+
''')
128+
129+
self.assertEqual(call_symbol_check(cc, source, executable, ['-mmacosx-version-min=10.14']),
117130
(0, ''))
118131

119132
def test_PE(self):

0 commit comments

Comments
 (0)