More work on build-everything

This commit is contained in:
2024-11-11 14:14:52 -05:00
parent 78cdace910
commit e716c857fc

View File

@@ -25,6 +25,25 @@
import sys, os, json, shutil, subprocess import sys, os, json, shutil, subprocess
from pathlib import Path from pathlib import Path
#
# These things are operating system specific.
#
if sys.platform == "windows":
OS = "Windows"
DLL = "dll"
BAT = "bat"
DOT_EXE = ".exe"
USER = "Unknown"
BUILD_BAT = "Build.bat"
else:
OS = "Linux"
DLL = "so"
BAT = "sh"
DOT_EXE = ""
USER = os.environ["USER"]
BUILD_BAT = "Linux/Build.sh"
# #
# Some handy utility functions # Some handy utility functions
# #
@@ -42,75 +61,38 @@ def shell(dir, cmd):
subprocess.run(cmd, shell=True, check=True, cwd=dir) subprocess.run(cmd, shell=True, check=True, cwd=dir)
# #
# These things are operating system specific. # Find the two repositories and verify them.
# #
if sys.platform == "windows": INTEGRATION=os.path.dirname(os.path.abspath(sys.argv[0]))
OS = "Windows" UNREALENGINE=os.path.join(os.path.dirname(INTEGRATION), "UnrealEngine")
DLL = "dll"
BAT = "bat" if not os.path.isdir(f"{INTEGRATION}/Source/Integration"):
DOT_EXE = ".exe" sys.exit(f"Integration repository is not valid: {INTEGRATION}")
USER = "Unknown" if not os.path.isdir(f"{UNREALENGINE}/Engine/Source/Editor"):
REPOSITORY_PATH = [ "d:", "e:", "f:" ] sys.exit(f"Integration repository is not valid: {UNREALENGINE}")
BUILD_BAT = "Build.bat"
UNWRITABLE_DIR = "c:/Windows"
else:
OS = "Linux"
DLL = "so"
BAT = "sh"
DOT_EXE = ""
USER = os.environ["USER"]
REPOSITORY_PATH = [ os.environ["HOME"] ]
BUILD_BAT = "Linux/Build.sh"
UNWRITABLE_DIR = "/"
# #
# Find the two repositories. # Create the Saved/UnrealBuildTool directories. These will hold
# the file BuildConfiguration.xml
#
# Change directory to one of these in order to force ourselves
# to specify all paths explicitly.
# #
def find_repository(name, path): Path(f"{INTEGRATION}/Saved/UnrealBuildTool").mkdir(parents=True, exist_ok=True)
result = None Path(f"{UNREALENGINE}/Engine/Saved/UnrealBuildTool").mkdir(parents=True, exist_ok=True)
for place in path: os.chdir(f"{INTEGRATION}/Saved/UnrealBuildTool")
d = place + "/" + name
if os.path.isdir(d):
print("Found repository:",d)
if result is not None:
sys.exit("Found two repositories. Please remove duplicate.")
result = d
if result is None:
sys.exit(f"Could not find repository: {name}")
return result
UNREALENGINE=find_repository("UnrealEngine", REPOSITORY_PATH)
INTEGRATION=find_repository("integration", REPOSITORY_PATH)
#
# Make sure this script is running out of the expected repository.
#
if os.path.abspath(os.path.dirname(sys.argv[0])) != INTEGRATION:
print(sys.argv[0])
sys.exit(f"You must run this script out of {INTEGRATION}")
#
# Change directory to an unwritable unrelated directory.
# This will force us to use explicit paths everywhere.
#
os.chdir(UNWRITABLE_DIR)
# #
# Remove previously-generated files. # Remove previously-generated files.
# #
Path(f"{INTEGRATION}/Saved/UnrealBuildTool").mkdir(parents=True, exist_ok=True)
Path(f"{INTEGRATION}/Saved/UnrealBuildTool/BuildConfiguration.xml").unlink(missing_ok=True) Path(f"{INTEGRATION}/Saved/UnrealBuildTool/BuildConfiguration.xml").unlink(missing_ok=True)
Path(f"{INTEGRATION}/Integration.uproject").unlink(missing_ok=True) Path(f"{INTEGRATION}/Integration.uproject").unlink(missing_ok=True)
Path(f"{INTEGRATION}/Integration.code-workspace").unlink(missing_ok=True) Path(f"{INTEGRATION}/Integration.code-workspace").unlink(missing_ok=True)
Path(f"{INTEGRATION}/Makefile").unlink(missing_ok=True) Path(f"{INTEGRATION}/Makefile").unlink(missing_ok=True)
Path(f"{INTEGRATION}/Source/Integration/lpx-paths.hpp").unlink(missing_ok=True) Path(f"{INTEGRATION}/Source/Integration/lpx-paths.hpp").unlink(missing_ok=True)
Path(f"{UNREALENGINE}/Engine/Saved/UnrealBuildTool").mkdir(parents=True, exist_ok=True)
Path(f"{UNREALENGINE}/Engine/Saved/UnrealBuildTool/BuildConfiguration.xml").unlink(missing_ok=True) Path(f"{UNREALENGINE}/Engine/Saved/UnrealBuildTool/BuildConfiguration.xml").unlink(missing_ok=True)
# #