Skip to content

Commit f2834ac

Browse files
authored
build for iOS - KeyError: 'DEPLOYMENT_TARGET_CLANG_FLAG_NAME' (#1296)
1 parent 5aa8c74 commit f2834ac

1 file changed

Lines changed: 37 additions & 12 deletions

File tree

build/scripts/build-step-metadata-generator.py

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,38 @@ def map_and_list(func, iterable):
3535

3636

3737
# process environment variables
38+
effective_platofrm_name = env("EFFECTIVE_PLATFORM_NAME")
39+
docset_platform = "iOS"
40+
default_deployment_target_flag_name = "-mios-simulator-version-min"
41+
default_deployment_target_clang_env_name = "IPHONEOS_DEPLOYMENT_TARGET"
42+
if effective_platofrm_name is "-macosx":
43+
docset_platform = "OSX"
44+
default_deployment_target_flag_name = "-mmacosx-version-min"
45+
default_deployment_target_clang_env_name = "MACOSX_DEPLOYMENT_TARGET"
46+
elif effective_platofrm_name is "-watchos":
47+
docset_platform = "watchOS"
48+
default_deployment_target_flag_name = "-mwatchos-version-min"
49+
default_deployment_target_clang_env_name = "WATCHOS_DEPLOYMENT_TARGET"
50+
elif effective_platofrm_name is "-watchsimulator":
51+
docset_platform = "watchOS"
52+
default_deployment_target_flag_name = "-mwatchos-simulator-version-min"
53+
default_deployment_target_clang_env_name = "WATCHOS_DEPLOYMENT_TARGET"
54+
elif effective_platofrm_name is "-appletvos":
55+
docset_platform = "tvOS"
56+
default_deployment_target_flag_name = "-mappletvos-version-min"
57+
default_deployment_target_clang_env_name = "APPLETVOS_DEPLOYMENT_TARGET"
58+
elif effective_platofrm_name is "-appletvsimulator":
59+
docset_platform = "tvOS"
60+
default_deployment_target_flag_name = "-mappletvsimulator-version-min"
61+
default_deployment_target_clang_env_name = "APPLETVOS_DEPLOYMENT_TARGET"
62+
elif effective_platofrm_name is "-iphoneos":
63+
default_deployment_target_flag_name = "-miphoneos-version-min"
64+
3865
conf_build_dir = env("CONFIGURATION_BUILD_DIR")
3966
sdk_root = env("SDKROOT")
4067
src_root = env("SRCROOT")
41-
deployment_target_flag_name = env("DEPLOYMENT_TARGET_CLANG_FLAG_NAME")
42-
deployment_target = env(env("DEPLOYMENT_TARGET_CLANG_ENV_NAME"))
68+
deployment_target_flag_name = env_or_empty("DEPLOYMENT_TARGET_CLANG_FLAG_NAME") or default_deployment_target_flag_name
69+
deployment_target = env(env_or_empty("DEPLOYMENT_TARGET_CLANG_ENV_NAME") or default_deployment_target_clang_env_name)
4370
std = env("GCC_C_LANGUAGE_STANDARD")
4471
header_search_paths = env_or_empty("HEADER_SEARCH_PATHS")
4572
header_search_paths_parsed = map_and_list((lambda s: "-I" + s), shlex.split(header_search_paths))
@@ -51,15 +78,9 @@ def map_and_list(func, iterable):
5178
preprocessor_defs = env_or_empty("GCC_PREPROCESSOR_DEFINITIONS")
5279
preprocessor_defs_parsed = map_and_list((lambda s: "-D" + s), shlex.split(preprocessor_defs, '\''))
5380
typescript_output_folder = env_or_none("TNS_TYPESCRIPT_DECLARATIONS_PATH")
54-
docset_platform = "iOS"
55-
effective_platofrm_name = env("EFFECTIVE_PLATFORM_NAME")
5681

57-
if effective_platofrm_name is "-macosx":
58-
docset_platform = "OSX"
59-
elif effective_platofrm_name is "-watchos" or effective_platofrm_name is "-watchsimulator":
60-
docset_platform = "watchOS"
61-
elif effective_platofrm_name is "-appletvos" or effective_platofrm_name is "-appletvsimulator":
62-
docset_platform = "tvOS"
82+
83+
6384

6485
docset_path = os.path.join(os.path.expanduser("~"),
6586
"Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.{}.docset"
@@ -109,10 +130,14 @@ def generate_metadata(arch):
109130
# clang arguments
110131
generator_call.extend(["Xclang",
111132
"-isysroot", sdk_root,
112-
"-arch", arch,
113133
"-" + deployment_target_flag_name + "=" + deployment_target,
114134
"-std=" + std])
115135

136+
if env_or_empty("IS_UIKITFORMAC").capitalize() is "YES":
137+
generator_call.extend(["-arch", arch])
138+
else:
139+
generator_call.extend(["-target", "{}-apple-ios13.0-macabi".format(arch)])
140+
116141
generator_call.extend(header_search_paths_parsed) # HEADER_SEARCH_PATHS
117142
generator_call.extend(framework_search_paths_parsed) # FRAMEWORK_SEARCH_PATHS
118143
generator_call.extend(other_cflags_parsed) # OTHER_CFLAGS
@@ -143,4 +168,4 @@ def generate_metadata(arch):
143168

144169
for arch in env("ARCHS").split():
145170
print("Generating metadata for " + arch)
146-
generate_metadata(arch)
171+
generate_metadata(arch)

0 commit comments

Comments
 (0)