-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathprepare_xcode_project.py
49 lines (36 loc) · 1.81 KB
/
prepare_xcode_project.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import os
import sys
from script_config import ScriptConfig
import copy_c_files
import build_individual_libldk
def run(config: ScriptConfig):
print('Preparing Xcode project…')
project_directory = os.getenv('PROJECT_DIR')
bindings_binary_directory = os.getenv('LDK_C_BINDINGS_BINARY_DIRECTORY')
forced_rebuild_override_directory = os.getenv('LDK_C_BINDINGS_BINARY_FORCED_REBUILD_OUTPUT_DIRECTORY')
print('PROJECT_DIR:', project_directory)
print('LDK_C_BINDINGS_BINARY_DIRECTORY:', bindings_binary_directory)
print('LDK_C_BINDINGS_BINARY_FORCED_REBUILD_OUTPUT_DIRECTORY:', forced_rebuild_override_directory)
# step 1: copy C files, *.h and *.c
copy_c_files.run(config)
if bindings_binary_directory and forced_rebuild_override_directory:
print('LDK_C_BINDINGS_BINARY_DIRECTORY and LDK_C_BINDINGS_BINARY_FORCED_REBUILD_OUTPUT_DIRECTORY may not both be set at the same time!', file=sys.stderr)
sys.exit(1)
if not bindings_binary_directory and not forced_rebuild_override_directory:
print('One of LDK_C_BINDINGS_BINARY_DIRECTORY and LDK_C_BINDINGS_BINARY_FORCED_REBUILD_OUTPUT_DIRECTORY must be set!', file=sys.stderr)
sys.exit(1)
if not forced_rebuild_override_directory:
print('LDK_C_BINDINGS_BINARY_FORCED_REBUILD_OUTPUT_DIRECTORY not set: binary rebuild not necessary.')
return
# if and only if and if only LDK_C_BINDINGS_BINARY_FORCED_REBUILD_OUTPUT_DIRECTORY is set, we build the individual libldk
config.LIPO_BINARY_OUTPUT_DIRECTORY = forced_rebuild_override_directory
# TODO: detect if there's already a libldk.a in that directory and then not do the build
build_individual_libldk.run(config)
if __name__ == '__main__':
script_config = ScriptConfig.parse(
allow_ldk_argument=False,
parse_configuration=True,
parse_lipo_output_directory=True,
parse_as_xcode_invocation=True
)
run(script_config)