@@ -23,7 +23,35 @@ def get_os_env_from_platform(platform):
23
23
def get_os_from_sdk (sdk ):
24
24
return sdk [:sdk .find ('.' )], ""
25
25
26
- from lldbsuite .test import configuration
26
+
27
+ def get_os_and_env ():
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 )
32
+ return None , None
33
+
34
+
35
+ def get_triple ():
36
+ # Construct the vendor component.
37
+ vendor = "apple"
38
+
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
43
+
44
+ # Get the SDK from the os and env.
45
+ sdk = lldbutil .get_xcode_sdk (os , env )
46
+ if not sdk :
47
+ return None , None , None , None
48
+
49
+ # Get the version from the SDK.
50
+ version = lldbutil .get_xcode_sdk_version (sdk )
51
+ if not version :
52
+ return None , None , None , None
53
+
54
+ return vendor , os , version , env
27
55
28
56
29
57
class BuilderDarwin (Builder ):
@@ -37,50 +65,24 @@ def getExtraMakeArgs(self):
37
65
if configuration .dsymutil :
38
66
args ['DSYMUTIL' ] = configuration .dsymutil
39
67
40
- operating_system , _ = self . getOsAndEnv ()
68
+ operating_system , _ = get_os_and_env ()
41
69
if operating_system and operating_system != "macosx" :
42
70
builder_dir = os .path .dirname (os .path .abspath (__file__ ))
43
71
test_dir = os .path .dirname (builder_dir )
44
72
entitlements = os .path .join (test_dir , 'make' , 'entitlements.plist' )
45
- args ['CODESIGN' ] = 'codesign --entitlements {}' .format (entitlements )
73
+ args ['CODESIGN' ] = 'codesign --entitlements {}' .format (
74
+ entitlements )
46
75
47
76
# Return extra args as a formatted string.
48
77
return ' ' .join (
49
78
{'{}="{}"' .format (key , value )
50
79
for key , value in args .items ()})
51
- def getOsAndEnv (self ):
52
- if configuration .lldb_platform_name :
53
- return get_os_env_from_platform (configuration .lldb_platform_name )
54
- elif configuration .apple_sdk :
55
- return get_os_from_sdk (configuration .apple_sdk )
56
- return None , None
57
80
58
81
def getArchCFlags (self , architecture ):
59
82
"""Returns the ARCH_CFLAGS for the make system."""
60
-
61
- # Construct the arch component.
62
- arch = architecture if architecture else configuration .arch
63
- if not arch :
64
- arch = subprocess .check_output (['machine'
65
- ]).rstrip ().decode ('utf-8' )
66
- if not arch :
67
- return ""
68
-
69
- # Construct the vendor component.
70
- vendor = "apple"
71
-
72
- # Construct the os component.
73
- os , env = self .getOsAndEnv ()
74
- if os is None or env is None :
75
- return ""
76
-
77
- # Get the SDK from the os and env.
78
- sdk = lldbutil .get_xcode_sdk (os , env )
79
- if not sdk :
80
- return ""
81
-
82
- version = lldbutil .get_xcode_sdk_version (sdk )
83
- if not version :
83
+ # Get the triple components.
84
+ vendor , os , version , env = get_triple ()
85
+ if not vendor or not os or not version or not env :
84
86
return ""
85
87
86
88
# Construct the triple from its components.
0 commit comments