5 from .builder
import Builder
6 from lldbsuite
.test
import configuration
7 import lldbsuite
.test
.lldbutil
as lldbutil
9 REMOTE_PLATFORM_NAME_RE
= re
.compile(r
"^remote-(.+)$")
10 SIMULATOR_PLATFORM_RE
= re
.compile(r
"^(.+)-simulator$")
13 def get_os_env_from_platform(platform
):
14 match
= REMOTE_PLATFORM_NAME_RE
.match(platform
)
16 return match
.group(1), ""
17 match
= SIMULATOR_PLATFORM_RE
.match(platform
)
19 return match
.group(1), "simulator"
23 def get_os_from_sdk(sdk
):
24 return sdk
[: sdk
.find(".")], ""
28 if configuration
.lldb_platform_name
:
29 return get_os_env_from_platform(configuration
.lldb_platform_name
)
30 if configuration
.apple_sdk
:
31 return get_os_from_sdk(configuration
.apple_sdk
)
36 # Construct the vendor component.
39 # Construct the os component.
40 os
, env
= get_os_and_env()
41 if os
is None or env
is None:
42 return None, None, None, None
44 # Get the SDK from the os and env.
45 sdk
= lldbutil
.get_xcode_sdk(os
, env
)
47 return None, None, None, None
49 # Get the version from the SDK.
50 version
= lldbutil
.get_xcode_sdk_version(sdk
)
52 return None, None, None, None
54 return vendor
, os
, version
, env
57 def get_triple_str(arch
, vendor
, os
, version
, env
):
58 if None in [arch
, vendor
, os
, version
, env
]:
61 component
= [arch
, vendor
, os
+ version
]
63 components
.append(env
)
64 return "-".join(component
)
67 class BuilderDarwin(Builder
):
68 def getTriple(self
, arch
):
69 vendor
, os
, version
, env
= get_triple()
70 return get_triple_str(arch
, vendor
, os
, version
, env
)
72 def getExtraMakeArgs(self
):
74 Helper function to return extra argumentsfor the make system. This
75 method is meant to be overridden by platform specific builders.
79 if configuration
.dsymutil
:
80 args
["DSYMUTIL"] = configuration
.dsymutil
82 if configuration
.apple_sdk
and "internal" in configuration
.apple_sdk
:
83 sdk_root
= lldbutil
.get_xcode_sdk_root(configuration
.apple_sdk
)
85 private_frameworks
= os
.path
.join(
86 sdk_root
, "System", "Library", "PrivateFrameworks"
88 args
["FRAMEWORK_INCLUDES"] = "-F{}".format(private_frameworks
)
90 operating_system
, env
= get_os_and_env()
91 if operating_system
and operating_system
!= "macosx":
92 builder_dir
= os
.path
.dirname(os
.path
.abspath(__file__
))
93 test_dir
= os
.path
.dirname(builder_dir
)
94 if env
== "simulator":
95 entitlements_file
= "entitlements-simulator.plist"
97 entitlements_file
= "entitlements.plist"
98 entitlements
= os
.path
.join(test_dir
, "make", entitlements_file
)
99 args
["CODESIGN"] = "codesign --entitlements {}".format(entitlements
)
101 args
["CODESIGN"] = "codesign"
103 # Return extra args as a formatted string.
104 return ["{}={}".format(key
, value
) for key
, value
in args
.items()]
106 def getArchCFlags(self
, arch
):
107 """Returns the ARCH_CFLAGS for the make system."""
108 # Get the triple components.
109 vendor
, os
, version
, env
= get_triple()
110 triple
= get_triple_str(arch
, vendor
, os
, version
, env
)
114 # Construct min version argument
116 if env
== "simulator":
117 version_min
= "-m{}-simulator-version-min={}".format(os
, version
)
119 version_min
= "-m{}-version-min={}".format(os
, version
)
121 return ["ARCH_CFLAGS=-target {} {}".format(triple
, version_min
)]
123 def _getDebugInfoArgs(self
, debug_info
):
124 if debug_info
== "dsym":
125 return ["MAKE_DSYM=YES"]
126 return super(BuilderDarwin
, self
)._getDebugInfoArgs
(debug_info
)