Skip to content

Commit b981924

Browse files
committed
[lldb] Move triple construction out of getArchCFlags in DarwinBuilder (NFC)
Move the construction of the triple out of getArchCFlags in the DarwinBuilder.
1 parent dd04fa1 commit b981924

File tree

1 file changed

+35
-33
lines changed
  • lldb/packages/Python/lldbsuite/test/builders

1 file changed

+35
-33
lines changed

lldb/packages/Python/lldbsuite/test/builders/darwin.py

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,35 @@ def get_os_env_from_platform(platform):
2323
def get_os_from_sdk(sdk):
2424
return sdk[:sdk.find('.')], ""
2525

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
2755

2856

2957
class BuilderDarwin(Builder):
@@ -37,50 +65,24 @@ def getExtraMakeArgs(self):
3765
if configuration.dsymutil:
3866
args['DSYMUTIL'] = configuration.dsymutil
3967

40-
operating_system, _ = self.getOsAndEnv()
68+
operating_system, _ = get_os_and_env()
4169
if operating_system and operating_system != "macosx":
4270
builder_dir = os.path.dirname(os.path.abspath(__file__))
4371
test_dir = os.path.dirname(builder_dir)
4472
entitlements = os.path.join(test_dir, 'make', 'entitlements.plist')
45-
args['CODESIGN'] = 'codesign --entitlements {}'.format(entitlements)
73+
args['CODESIGN'] = 'codesign --entitlements {}'.format(
74+
entitlements)
4675

4776
# Return extra args as a formatted string.
4877
return ' '.join(
4978
{'{}="{}"'.format(key, value)
5079
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
5780

5881
def getArchCFlags(self, architecture):
5982
"""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:
8486
return ""
8587

8688
# Construct the triple from its components.

0 commit comments

Comments
 (0)