Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configure --set support list as arguments #109702

Merged
merged 4 commits into from
Apr 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/bootstrap/bootstrap_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ def test_set_top_level(self):
build = self.serialize_and_parse(["--set", "profile=compiler"])
self.assertEqual(build.get_toml("profile"), 'compiler')

def test_set_codegen_backends(self):
build = self.serialize_and_parse(["--set", "rust.codegen-backends=cranelift"])
self.assertNotEqual(build.config_toml.find("codegen-backends = ['cranelift']"), -1)
build = self.serialize_and_parse(["--set", "rust.codegen-backends=cranelift,llvm"])
self.assertNotEqual(build.config_toml.find("codegen-backends = ['cranelift', 'llvm']"), -1)
Copy link
Member Author

@chenyukang chenyukang Mar 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use config_toml.find here because get_string don't support list right now.
I think we need to rewrite get_toml, regular expression match seems won't work well 😂

build = self.serialize_and_parse(["--enable-full-tools"])
self.assertNotEqual(build.config_toml.find("codegen-backends = ['llvm']"), -1)

if __name__ == '__main__':
SUITE = unittest.TestSuite()
TEST_LOADER = unittest.TestLoader()
Expand Down
14 changes: 10 additions & 4 deletions src/bootstrap/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ def v(*args):
"experimental LLVM targets to build")
v("release-channel", "rust.channel", "the name of the release channel to build")
v("release-description", "rust.description", "optional descriptive string for version output")
v("dist-compression-formats", None,
"comma-separated list of compression formats to use")
v("dist-compression-formats", None, "List of compression formats to use")

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

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

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

def is_value_list(key):
for option in options:
if option.name == key and option.desc.startswith('List of'):
return True
albertlarsan68 marked this conversation as resolved.
Show resolved Hide resolved
return False

if '--help' in sys.argv or '-h' in sys.argv:
print('Usage: ./configure [options]')
Expand Down Expand Up @@ -295,6 +299,8 @@ def set(key, value, config):
parts = key.split('.')
for i, part in enumerate(parts):
if i == len(parts) - 1:
if is_value_list(part) and isinstance(value, str):
value = value.split(',')
arr[part] = value
else:
if part not in arr:
Expand Down