Skip to content

Commit 6b0da57

Browse files
authored
Rollup merge of #109702 - chenyukang:yukang/fix-109316-configure, r=albertlarsan68
configure --set support list as arguments Fixes #109316 r? `@jyn514`
2 parents 1a6ae3d + 787f3fe commit 6b0da57

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/bootstrap/bootstrap_test.py

+8
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,14 @@ def test_set_top_level(self):
112112
build = self.serialize_and_parse(["--set", "profile=compiler"])
113113
self.assertEqual(build.get_toml("profile"), 'compiler')
114114

115+
def test_set_codegen_backends(self):
116+
build = self.serialize_and_parse(["--set", "rust.codegen-backends=cranelift"])
117+
self.assertNotEqual(build.config_toml.find("codegen-backends = ['cranelift']"), -1)
118+
build = self.serialize_and_parse(["--set", "rust.codegen-backends=cranelift,llvm"])
119+
self.assertNotEqual(build.config_toml.find("codegen-backends = ['cranelift', 'llvm']"), -1)
120+
build = self.serialize_and_parse(["--enable-full-tools"])
121+
self.assertNotEqual(build.config_toml.find("codegen-backends = ['llvm']"), -1)
122+
115123
if __name__ == '__main__':
116124
SUITE = unittest.TestSuite()
117125
TEST_LOADER = unittest.TestLoader()

src/bootstrap/configure.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,7 @@ def v(*args):
153153
"experimental LLVM targets to build")
154154
v("release-channel", "rust.channel", "the name of the release channel to build")
155155
v("release-description", "rust.description", "optional descriptive string for version output")
156-
v("dist-compression-formats", None,
157-
"comma-separated list of compression formats to use")
156+
v("dist-compression-formats", None, "List of compression formats to use")
158157

159158
# Used on systems where "cc" is unavailable
160159
v("default-linker", "rust.default-linker", "the default linker")
@@ -168,8 +167,8 @@ def v(*args):
168167
v("tools", None, "List of extended tools will be installed")
169168
v("codegen-backends", None, "List of codegen backends to build")
170169
v("build", "build.build", "GNUs ./configure syntax LLVM build triple")
171-
v("host", None, "GNUs ./configure syntax LLVM host triples")
172-
v("target", None, "GNUs ./configure syntax LLVM target triples")
170+
v("host", None, "List of GNUs ./configure syntax LLVM host triples")
171+
v("target", None, "List of GNUs ./configure syntax LLVM target triples")
173172

174173
v("set", None, "set arbitrary key/value pairs in TOML configuration")
175174

@@ -182,6 +181,11 @@ def err(msg):
182181
print("configure: error: " + msg)
183182
sys.exit(1)
184183

184+
def is_value_list(key):
185+
for option in options:
186+
if option.name == key and option.desc.startswith('List of'):
187+
return True
188+
return False
185189

186190
if '--help' in sys.argv or '-h' in sys.argv:
187191
print('Usage: ./configure [options]')
@@ -295,6 +299,8 @@ def set(key, value, config):
295299
parts = key.split('.')
296300
for i, part in enumerate(parts):
297301
if i == len(parts) - 1:
302+
if is_value_list(part) and isinstance(value, str):
303+
value = value.split(',')
298304
arr[part] = value
299305
else:
300306
if part not in arr:

0 commit comments

Comments
 (0)