Skip to content

Commit eb0c02e

Browse files
committed
Convert args to config in ./configure main()
1 parent fe594e9 commit eb0c02e

File tree

1 file changed

+37
-36
lines changed

1 file changed

+37
-36
lines changed

configure

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,29 @@ def main():
5454
type=str,
5555
help="override antares_version string")
5656
args = parser.parse_args()
57-
configure("Antares", args)
5857

58+
config = {
59+
"mode": args.mode,
60+
"target_os": args.target_os,
61+
"prefix": args.prefix,
62+
"add_cflags": shlex.split(os.environ.get("CPPFLAGS", "")),
63+
"add_cflags_c": shlex.split(os.environ.get("CFLAGS", "")),
64+
"add_cflags_cc": shlex.split(os.environ.get("CXXFLAGS", "")),
65+
"add_ldflags": shlex.split(os.environ.get("LDFLAGS", "")),
66+
}
67+
if args.antares_version:
68+
config["antares_version"] = args.antares_version
69+
if config["target_os"] == "mac":
70+
config["macosx_version_min"] = "10.7"
71+
72+
import deps
73+
configure("Antares", deps.DISTROS, config)
5974

60-
def configure(project, args):
61-
config = check_deps(project, args)
75+
76+
def configure(project, distros, config):
77+
for k, v in check_deps(project, distros, config).items():
78+
if k not in config:
79+
config[k] = v
6280

6381
script_executable = "python3"
6482
if cfg.host_os() == "win":
@@ -69,18 +87,7 @@ def configure(project, args):
6987
gnf.write('script_executable = "' + script_executable + '"\n')
7088

7189
with cfg.step("configure mode") as msg:
72-
msg(args.mode, color="green")
73-
config["mode"] = args.mode
74-
config["target_os"] = args.target_os
75-
config["prefix"] = args.prefix
76-
config["add_cflags"] = shlex.split(os.environ.get("CPPFLAGS", ""))
77-
config["add_cflags_c"] = shlex.split(os.environ.get("CFLAGS", ""))
78-
config["add_cflags_cc"] = shlex.split(os.environ.get("CXXFLAGS", ""))
79-
config["add_ldflags"] = shlex.split(os.environ.get("LDFLAGS", ""))
80-
if args.antares_version:
81-
config["antares_version"] = args.antares_version
82-
if args.target_os == "mac":
83-
config["macosx_version_min"] = "10.7"
90+
msg(config["mode"], color="green")
8491
cfg.gn(**config)
8592

8693
print("make(1) it so!")
@@ -114,7 +121,7 @@ def check_submodules():
114121
sys.exit(1)
115122

116123

117-
def check_deps(project, args):
124+
def check_deps(project, distros, config):
118125
with cfg.step("checking host os") as msg:
119126
if cfg.host_os() in ["mac", "linux", "win"]:
120127
msg(cfg.host_os(), color="green")
@@ -124,25 +131,23 @@ def check_deps(project, args):
124131
sys.exit(1)
125132

126133
with cfg.step("checking target os") as msg:
127-
if args.target_os is None:
128-
args.target_os = cfg.host_os()
134+
if config["target_os"] is None:
135+
config["target_os"] = cfg.host_os()
129136
checker = {
130137
("mac", "mac"): check_mac,
131138
("linux", "linux"): check_linux_native,
132139
("linux", "win"): check_win_on_linux,
133140
("win", "win"): check_win_native,
134-
}.get((cfg.host_os(), args.target_os))
141+
}.get((cfg.host_os(), config["target_os"]))
135142
if checker is None:
136-
msg(args.target_os, color="red")
143+
msg(config["target_os"], color="red")
137144
sys.exit(1)
138-
msg(args.target_os, color="green")
145+
msg(config["target_os"], color="green")
139146

140-
return checker(project, args)
147+
return checker(project, distros)
141148

142149

143-
def check_mac(project, args):
144-
import deps
145-
150+
def check_mac(project, distros):
146151
with cfg.step("checking Mac OS X version") as msg:
147152
ver = platform.mac_ver()[0]
148153
ver = tuple(int(x) for x in ver.split(".")[:2])
@@ -171,38 +176,34 @@ def check_mac(project, args):
171176
print("Then, try ./configure again")
172177
sys.exit(1)
173178

174-
config = cfg.check_all(distro=deps.DISTROS["mac"], codename="mac")
179+
config = cfg.check_all(distro=distros["mac"], codename="mac")
175180
if config is None:
176181
sys.exit(1)
177182
return config
178183

179184

180-
def check_linux_native(project, args):
181-
import deps
182-
185+
def check_linux_native(project, distros):
183186
with cfg.step("checking Linux distro") as msg:
184187
pretty, distro, codename = cfg.dist_proto()
185-
if distro in deps.DISTROS:
188+
if distro in distros:
186189
msg(pretty, color="green")
187190
else:
188191
msg(pretty + " (untested)", color="yellow")
189192
distro = "debian"
190-
config = cfg.check_all(distro=deps.DISTROS[distro], codename=codename, prefix="sudo")
193+
config = cfg.check_all(distro=distros[distro], codename=codename, prefix="sudo")
191194
if config is None:
192195
sys.exit(1)
193196
return config
194197

195198

196-
def check_win_native(project, args):
197-
import deps
198-
199-
config = cfg.check_all(distro=deps.DISTROS["win"], codename="win")
199+
def check_win_native(project, distros):
200+
config = cfg.check_all(distro=distros["win"], codename="win")
200201
if config is None:
201202
sys.exit(1)
202203
return config
203204

204205

205-
def check_win_on_linux(project, args):
206+
def check_win_on_linux(project):
206207
with cfg.step("checking Linux distro") as msg:
207208
pretty, distro, codename = cfg.dist_proto()
208209
if (distro, codename) == ("debian", "focal"):

0 commit comments

Comments
 (0)