From 3893d2aec6b3c1838bc5ce843007ee5e1a172215 Mon Sep 17 00:00:00 2001 From: Marat Radchenko Date: Fri, 1 Sep 2023 17:43:20 +0300 Subject: [PATCH] resolves #313 restore ue4-engine image Also, drop deprecated for more than a year `--no-full`/`--no-minimal` options and just use `--target`. --- docs/ue4-docker-build.adoc | 10 +-- src/ue4docker/build.py | 18 ++++-- src/ue4docker/clean.py | 18 ++++-- .../infrastructure/BuildConfiguration.py | 61 ++++--------------- .../dockerfiles/ue4-engine/linux/Dockerfile | 15 +++++ .../dockerfiles/ue4-engine/windows/Dockerfile | 17 ++++++ 6 files changed, 73 insertions(+), 66 deletions(-) create mode 100644 ue4docker/dockerfiles/ue4-engine/linux/Dockerfile create mode 100644 ue4docker/dockerfiles/ue4-engine/windows/Dockerfile diff --git a/docs/ue4-docker-build.adoc b/docs/ue4-docker-build.adoc index e0c5a8b5..9a2b34ef 100644 --- a/docs/ue4-docker-build.adoc +++ b/docs/ue4-docker-build.adoc @@ -87,12 +87,6 @@ Monitor resource usage during builds (useful for debugging) *--no-cache*:: Disable Docker build cache -*--no-full*:: -Don't build the ue4-full image (deprecated, use *--target* _target_ instead) - -*--no-minimal*:: -Don't build the ue4-minimal image (deprecated, use *--target* _target_ instead) - *--opt* _opt_:: Set an advanced configuration option (can be specified multiple times to specify multiple options) @@ -111,9 +105,11 @@ Add a suffix to the tags of the built images *--target* _target_:: Tells ue4-docker to build specific image (including its dependencies). + -Supported values: `all`, `build-prerequisites`, `full`, `minimal`, `source`. +Supported values: `all`, `build-prerequisites`, `full`, `minimal`, `source`, `engine`. + You can specify the `--target` option multiple times. ++ +Defaults to `minimal`. *-ue4cli* _ue4cli_:: Override the default version of ue4cli installed in the ue4-full image diff --git a/src/ue4docker/build.py b/src/ue4docker/build.py index 19a9bf4c..dbb7289d 100644 --- a/src/ue4docker/build.py +++ b/src/ue4docker/build.py @@ -439,11 +439,19 @@ def build(): else: logger.info("Skipping ue4-source image build.") - if config.buildTargets["minimal"]: - ue4BuildArgs = prereqConsumerArgs + [ - "--build-arg", - "TAG={}".format(mainTags[1]), - ] + ue4BuildArgs = prereqConsumerArgs + [ + "--build-arg", + "TAG={}".format(mainTags[1]), + ] + + # Build the UE4 Engine source build image, unless requested otherwise by the user + if config.buildTargets["engine"]: + builder.build_builtin_image( + "ue4-engine", + mainTags, + commonArgs + config.platformArgs + ue4BuildArgs, + ) + builtImages.append("ue4-engine") # Build the minimal UE4 CI image, unless requested otherwise by the user if config.buildTargets["minimal"]: diff --git a/src/ue4docker/clean.py b/src/ue4docker/clean.py index d01edfe8..303f5c91 100644 --- a/src/ue4docker/clean.py +++ b/src/ue4docker/clean.py @@ -28,6 +28,7 @@ def clean(): "-tag", default=None, help="Only clean images with the specified tag" ) parser.add_argument("--source", action="store_true", help="Clean ue4-source images") + parser.add_argument("--engine", action="store_true", help="Clean ue4-engine images") parser.add_argument( "--all", action="store_true", help="Clean all ue4-docker images" ) @@ -52,7 +53,7 @@ def clean(): cleaner.cleanMultiple(dangling, args.dry_run) # If requested, remove ue4-source images - if args.source == True: + if args.source: _cleanMatching( cleaner, GlobalConfiguration.resolveTag("ue4-source"), @@ -60,17 +61,26 @@ def clean(): args.dry_run, ) + # If requested, remove ue4-engine images + if args.engine: + _cleanMatching( + cleaner, + GlobalConfiguration.resolveTag("ue4-engine"), + args.tag, + args.dry_run, + ) + # If requested, remove everything - if args.all == True: + if args.all: _cleanMatching( cleaner, GlobalConfiguration.resolveTag("ue4-*"), args.tag, args.dry_run ) # If requested, run `docker system prune` - if args.prune == True: + if args.prune: logger.action("Running `docker system prune`...") pruneCommand = ["docker", "system", "prune", "-f"] - if args.dry_run == True: + if args.dry_run: print(pruneCommand) else: subprocess.call(pruneCommand) diff --git a/src/ue4docker/infrastructure/BuildConfiguration.py b/src/ue4docker/infrastructure/BuildConfiguration.py index a602f86c..616c5204 100644 --- a/src/ue4docker/infrastructure/BuildConfiguration.py +++ b/src/ue4docker/infrastructure/BuildConfiguration.py @@ -125,23 +125,14 @@ def addArguments(parser): action="store_true", help="Print `docker build` commands instead of running them", ) - parser.add_argument( - "--no-minimal", - action="store_true", - help="Don't build the ue4-minimal image (deprecated, use --target instead)", - ) - parser.add_argument( - "--no-full", - action="store_true", - help="Don't build the ue4-full image (deprecated, use --target instead)", - ) parser.add_argument( "--no-cache", action="store_true", help="Disable Docker build cache" ) parser.add_argument( "--target", action="append", - help="Add a target to the build list. Valid targets are `build-prerequisites`, `source`, `engine`, `minimal`, `full`, and `all`. May be specified multiple times or comma-separated. Defaults to `all`.", + default=[], + help="Add a target to the build list. Valid targets are `build-prerequisites`, `source`, `engine`, `minimal`, `full`, and `all`. May be specified multiple times or comma-separated. Defaults to `minimal`.", ) parser.add_argument( "--random-memory", @@ -282,47 +273,12 @@ def __init__(self, parser, argv, logger): self.args = parser.parse_args(argv) self.changelist = self.args.changelist - # Figure out what targets we have; this is needed to find out if we need --ue-version. - using_target_specifier_old = self.args.no_minimal or self.args.no_full - using_target_specifier_new = self.args.target is not None - - # If we specified nothing, it's the same as specifying `minimal` - if not using_target_specifier_old and not using_target_specifier_new: + if len(self.args.target) <= 0: self.args.target = ["minimal"] - elif using_target_specifier_old and not using_target_specifier_new: - # Convert these to the new style - logger.warning( - "Using deprecated `--no-*` target specifiers; recommend changing to `--target`", - False, - ) - - # no-minimal implies no-full - if self.args.no_minimal: - self.args.no_full = True - # Change into target descriptors - self.args.target = [] - - if not self.args.no_full: - self.args.target += ["full"] - - if not self.args.no_minimal: - self.args.target += ["minimal"] - - # disabling these was never supported - self.args.target += ["source"] - self.args.target += ["build-prerequisites"] - - elif using_target_specifier_new and not using_target_specifier_old: - # these can be token-delimited, so let's just split them apart and then remerge them into one list - split = [item.split(",") for item in self.args.target] - self.args.target = [item for sublist in split for item in sublist] - - elif using_target_specifier_old and using_target_specifier_new: - # uhoh - raise RuntimeError( - "specified both `--target` and the old `--no-*` options; please use only `--target`!" - ) + # these can be token-delimited, so let's just split them apart and then remerge them into one list + split_target = [item.split(",") for item in self.args.target] + self.args.target = [item for sublist in split_target for item in sublist] # Now that we have our options in `self.args.target`, evaluate our dependencies # In a theoretical ideal world this should be code-driven; if you find yourself adding a lot more code to this, consider a redesign! @@ -336,6 +292,7 @@ def __init__(self, parser, argv, logger): self.buildTargets = { "build-prerequisites": False, "source": False, + "engine": False, "minimal": False, "full": False, } @@ -355,6 +312,10 @@ def __init__(self, parser, argv, logger): self.buildTargets["minimal"] = True active_targets.add("source") + if "engine" in active_targets or "all" in active_targets: + self.buildTargets["engine"] = True + active_targets.add("source") + if "source" in active_targets or "all" in active_targets: self.buildTargets["source"] = True active_targets.add("build-prerequisites") diff --git a/ue4docker/dockerfiles/ue4-engine/linux/Dockerfile b/ue4docker/dockerfiles/ue4-engine/linux/Dockerfile new file mode 100644 index 00000000..c92b8575 --- /dev/null +++ b/ue4docker/dockerfiles/ue4-engine/linux/Dockerfile @@ -0,0 +1,15 @@ +{% if combine %} +FROM source as engine +{% else %} +ARG NAMESPACE +ARG TAG +ARG PREREQS_TAG +FROM ${NAMESPACE}/ue4-source:${TAG}-${PREREQS_TAG} +{% endif %} + +# Build UBT and build the Engine +# TODO: Fix UE4 compatibility +RUN ./Engine/Build/BatchFiles/Linux/Build.sh UE4Editor Linux Development -WaitMutex +RUN ./Engine/Build/BatchFiles/Linux/Build.sh UnrealEditor Linux Development -WaitMutex +RUN ./Engine/Build/BatchFiles/Linux/Build.sh ShaderCompileWorker Linux Development -WaitMutex +RUN ./Engine/Build/BatchFiles/Linux/Build.sh UnrealPak Linux Development -WaitMutex diff --git a/ue4docker/dockerfiles/ue4-engine/windows/Dockerfile b/ue4docker/dockerfiles/ue4-engine/windows/Dockerfile new file mode 100644 index 00000000..caf4e51c --- /dev/null +++ b/ue4docker/dockerfiles/ue4-engine/windows/Dockerfile @@ -0,0 +1,17 @@ +# escape=` +{% if combine %} +FROM source as engine +{% else %} +ARG NAMESPACE +ARG TAG +ARG PREREQS_TAG +FROM ${NAMESPACE}/ue4-source:${TAG}-${PREREQS_TAG} +{% endif %} + +# Build UBT and build the Engine +RUN GenerateProjectFiles.bat +# TODO: Fix UE4 compatibility +# RUN .\Engine\Build\BatchFiles\Build.bat UE4Editor Win64 Development -WaitMutex +RUN .\Engine\Build\BatchFiles\Build.bat UnrealEditor Win64 Development -WaitMutex +RUN .\Engine\Build\BatchFiles\Build.bat ShaderCompileWorker Win64 Development -WaitMutex +RUN .\Engine\Build\BatchFiles\Build.bat UnrealPak Win64 Development -WaitMutex