61d6b406fbb743e06d3cba39761627a144bdfd2d
2 # Copyright © 2019 Intel Corporation
4 # Permission is hereby granted, free of charge, to any person obtaining a copy
5 # of this software and associated documentation files (the "Software"), to deal
6 # in the Software without restriction, including without limitation the rights
7 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 # copies of the Software, and to permit persons to whom the Software is
9 # furnished to do so, subject to the following conditions:
11 # The above copyright notice and this permission notice shall be included in
12 # all copies or substantial portions of the Software.
14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 """This script reads a meson build directory and gives back the command line it
25 This only works for meson 0.49.0 and newer.
34 def parse_args() -> argparse
.Namespace
:
35 """Parse arguments."""
36 parser
= argparse
.ArgumentParser()
39 help='Path the meson build directory')
40 args
= parser
.parse_args()
44 def load_config(path
: pathlib
.Path
) -> configparser
.ConfigParser
:
45 """Load config file."""
46 conf
= configparser
.ConfigParser()
47 with path
.open() as f
:
52 def build_cmd(conf
: configparser
.ConfigParser
) -> str:
53 """Rebuild the command line."""
55 for k
, v
in conf
['options'].items():
57 args
.append(f
'-D{k}="{v}"')
59 args
.append(f
'-D{k}={v}')
65 path
= pathlib
.Path(args
.build_dir
, 'meson-private', 'cmd_line.txt')
67 print('Cannot find the necessary file to rebuild command line. '
68 'Is your meson version >= 0.49.0?', file=sys
.stderr
)
71 conf
= load_config(path
)
76 if __name__
== '__main__':