Skip to content

Commit

Permalink
Rollup merge of rust-lang#64288 - guanqun:use-get-toml, r=Mark-Simula…
Browse files Browse the repository at this point in the history
…crum

use 'get_toml' instead of regular expression
  • Loading branch information
Centril authored Sep 8, 2019
2 parents 1716678 + 85e09c6 commit 51b110f
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,10 @@ def get_toml(self, key, section=None):
'value2'
>>> rb.get_toml('key', 'c') is None
True
>>> rb.config_toml = 'key1 = true'
>>> rb.get_toml("key1")
'true'
"""

cur_section = None
Expand Down Expand Up @@ -571,6 +575,12 @@ def get_string(line):
>>> RustBuild.get_string(' "devel" ')
'devel'
>>> RustBuild.get_string(" 'devel' ")
'devel'
>>> RustBuild.get_string('devel') is None
True
>>> RustBuild.get_string(' "devel ')
''
"""
start = line.find('"')
if start != -1:
Expand Down Expand Up @@ -822,13 +832,13 @@ def bootstrap(help_triggered):
except (OSError, IOError):
pass

match = re.search(r'\nverbose = (\d+)', build.config_toml)
if match is not None:
build.verbose = max(build.verbose, int(match.group(1)))
config_verbose = build.get_toml('verbose', 'build')
if config_verbose is not None:
build.verbose = max(build.verbose, int(config_verbose))

build.use_vendored_sources = '\nvendor = true' in build.config_toml
build.use_vendored_sources = build.get_toml('vendor', 'build') == 'true'

build.use_locked_deps = '\nlocked-deps = true' in build.config_toml
build.use_locked_deps = build.get_toml('locked-deps', 'build') == 'true'

build.check_vendored_status()

Expand Down

0 comments on commit 51b110f

Please sign in to comment.