Skip to content

Commit b32e045

Browse files
authored
Move config.buildTarget* into a dict (#235)
1 parent 9871fb0 commit b32e045

File tree

2 files changed

+26
-22
lines changed

2 files changed

+26
-22
lines changed

ue4docker/build.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def build():
106106
)
107107

108108
# Resolve our main set of tags for the generated images; this is used only for Source and downstream
109-
if config.buildTargetSource:
109+
if config.buildTargets["source"]:
110110
mainTags = [
111111
"{}{}-{}".format(config.release, config.suffix, config.prereqsTag),
112112
config.release + config.suffix,
@@ -243,7 +243,7 @@ def build():
243243

244244
# Ensure the Docker daemon is configured correctly
245245
requiredLimit = WindowsUtils.requiredSizeLimit()
246-
if DockerUtils.maxsize() < requiredLimit and config.buildTargetSource:
246+
if DockerUtils.maxsize() < requiredLimit and config.buildTargets["source"]:
247247
logger.error("SETUP REQUIRED:")
248248
logger.error(
249249
"The max image size for Windows containers must be set to at least {}GB.".format(
@@ -308,7 +308,7 @@ def build():
308308
password = ""
309309

310310
elif (
311-
not config.buildTargetSource
311+
not config.buildTargets["source"]
312312
or builder.willBuild("ue4-source", mainTags) == False
313313
):
314314

@@ -357,7 +357,7 @@ def build():
357357
]
358358

359359
# Build the UE4 build prerequisites image
360-
if config.buildTargetPrerequisites:
360+
if config.buildTargets["build-prerequisites"]:
361361
# Compute the build options for the UE4 build prerequisites image
362362
# (This is the only image that does not use any user-supplied tag suffix, since the tag always reflects any customisations)
363363
prereqsArgs = ["--build-arg", "BASEIMAGE=" + config.baseImage]
@@ -384,7 +384,7 @@ def build():
384384
logger.info("Skipping ue4-build-prerequisities image build.")
385385

386386
# Build the UE4 source image
387-
if config.buildTargetSource:
387+
if config.buildTargets["source"]:
388388
# Start the HTTP credential endpoint as a child process and wait for it to start
389389
if config.opts.get("credential_mode", "endpoint") == "endpoint":
390390
endpoint = CredentialEndpoint(username, password)
@@ -414,14 +414,14 @@ def build():
414414
else:
415415
logger.info("Skipping ue4-source image build.")
416416

417-
if config.buildTargetEngine or config.buildTargetMinimal:
417+
if config.buildTargets["engine"] or config.buildTargets["minimal"]:
418418
ue4BuildArgs = prereqConsumerArgs + [
419419
"--build-arg",
420420
"TAG={}".format(mainTags[1]),
421421
]
422422

423423
# Build the UE4 Engine source build image, unless requested otherwise by the user
424-
if config.buildTargetEngine:
424+
if config.buildTargets["engine"]:
425425
builder.build(
426426
"ue4-engine",
427427
mainTags,
@@ -432,7 +432,7 @@ def build():
432432
logger.info("Skipping ue4-engine image build.")
433433

434434
# Build the minimal UE4 CI image, unless requested otherwise by the user
435-
if config.buildTargetMinimal == True:
435+
if config.buildTargets["minimal"]:
436436
minimalArgs = (
437437
["--build-arg", "CHANGELIST={}".format(config.changelist)]
438438
if config.changelist is not None
@@ -449,7 +449,7 @@ def build():
449449
logger.info("Skipping ue4-minimal image build.")
450450

451451
# Build the full UE4 CI image, unless requested otherwise by the user
452-
if config.buildTargetFull:
452+
if config.buildTargets["full"]:
453453

454454
# If custom version strings were specified for ue4cli and/or conan-ue4cli, use them
455455
infrastructureFlags = []

ue4docker/infrastructure/BuildConfiguration.py

+17-13
Original file line numberDiff line numberDiff line change
@@ -324,32 +324,36 @@ def __init__(self, parser, argv):
324324
# build-prereq -> source -> engine
325325
# build-prereq -> source -> minimal -> full
326326

327-
self.buildTargetPrerequisites = False
328-
self.buildTargetSource = False
329-
self.buildTargetEngine = False
330-
self.buildTargetMinimal = False
331-
self.buildTargetFull = False
327+
# We initialize these with all the options, with the intent that you should be accessing them directly and not checking for existence
328+
# This is to avoid typos giving false-negatives; KeyError is reliable and tells you what you did wrong
329+
self.buildTargets = {
330+
"build-prerequisites": False,
331+
"source": False,
332+
"engine": False,
333+
"minimal": False,
334+
"full": False,
335+
}
332336

333337
if "full" in self.args.target or "all" in self.args.target:
334-
self.buildTargetFull = True
338+
self.buildTargets["full"] = True
335339
self.args.target += ["minimal"]
336340

337341
if "minimal" in self.args.target or "all" in self.args.target:
338-
self.buildTargetMinimal = True
342+
self.buildTargets["minimal"] = True
339343
self.args.target += ["source"]
340344

341345
if "engine" in self.args.target or "all" in self.args.target:
342-
self.buildTargetEngine = True
346+
self.buildTargets["engine"] = True
343347
self.args.target += ["source"]
344348

345349
if "source" in self.args.target or "all" in self.args.target:
346-
self.buildTargetSource = True
350+
self.buildTargets["source"] = True
347351
self.args.target += ["build-prerequisites"]
348352

349353
if "build-prerequisites" in self.args.target or "all" in self.args.target:
350-
self.buildTargetPrerequisites = True
354+
self.buildTargets["build-prerequisites"] = True
351355

352-
if not self.buildTargetPrerequisites:
356+
if not self.buildTargets["build-prerequisites"]:
353357
raise RuntimeError(
354358
"we're not building anything; this shouldn't even be possible, but is definitely not useful"
355359
)
@@ -366,7 +370,7 @@ def __init__(self, parser, argv):
366370
self.args.release = self.args.ue_version
367371

368372
# We care about the version number only if we're building source
369-
if self.buildTargetSource:
373+
if self.buildTargets["source"]:
370374
if self.args.release is None:
371375
raise RuntimeError("missing `--ue-version` when building source")
372376

@@ -483,7 +487,7 @@ def __init__(self, parser, argv):
483487
)
484488

485489
# We care about source_mode and credential_mode only if we're building source
486-
if self.buildTargetSource:
490+
if self.buildTargets["source"]:
487491
# Verify that the value for `source_mode` is valid if specified
488492
validSourceModes = ["git", "copy"]
489493
if self.opts.get("source_mode", "git") not in validSourceModes:

0 commit comments

Comments
 (0)