From da648d8fc2bb8229271044c36d2d1dc1adae9f7f Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 29 Jan 2022 15:29:27 +0800 Subject: [PATCH] Separate build per hostname in case of multiboot --- tool/quick_start/common.py | 41 +++++++++--------------- tool/quick_start/common_config.py | 28 ++++++++++------ tool/quick_start/config_default.json | 19 ++++------- tool/quick_start/configure_toolchains.py | 6 +++- 4 files changed, 46 insertions(+), 48 deletions(-) diff --git a/tool/quick_start/common.py b/tool/quick_start/common.py index 672c9d81d..9f487d535 100644 --- a/tool/quick_start/common.py +++ b/tool/quick_start/common.py @@ -3,32 +3,21 @@ from common_config import * import os -NeLCodeDir = os.path.join(NeLRootDir, NeLConfig["Paths"]["Code"]) -if not os.path.isdir(NeLCodeDir): - exit("NeL Code directory (" + NeLCodeDir + ") does not exist.") -NeLLeveldesignDir = os.path.join(NeLRootDir, NeLConfig["Paths"]["Leveldesign"]) -if not os.path.isdir(NeLLeveldesignDir): - exit("NeL Leveldesign directory (" + NeLLeveldesignDir + ") does not exist.") -NeLGraphicsDir = os.path.join(NeLRootDir, NeLConfig["Paths"]["Graphics"]) -if not os.path.isdir(NeLGraphicsDir): - exit("NeL Graphics directory (" + NeLGraphicsDir + ") does not exist.") -NeLSoundDir = os.path.join(NeLRootDir, NeLConfig["Paths"]["Sound"]) -if not os.path.isdir(NeLSoundDir): - exit("NeL Sound directory (" + NeLSoundDir + ") does not exist.") -NeLBuildDir = os.path.join(NeLRootDir, NeLConfig["Paths"]["Build"]) -if not os.path.isdir(NeLBuildDir): - exit("NeL Build directory (" + NeLBuildDir + ") does not exist.") -NeLPipelineDir = os.path.join(NeLRootDir, NeLConfig["Paths"]["Pipeline"]) -if not os.path.isdir(NeLPipelineDir): - exit("NeL Pipeline directory (" + NeLPipelineDir + ") does not exist.") +NeLCodeDir = os.path.join(NeLRootDir, "code") +NeLLeveldesignDir = os.path.join(NeLRootDir, "leveldesign") +NeLGraphicsDir = os.path.join(NeLRootDir, "graphics") +NeLSoundDir = os.path.join(NeLRootDir, "sound") +NeLBuildDir = os.path.join(NeLRootDir, "build_" + NeLHostId) +NeLPipelineDir = os.path.join(NeLRootDir, "pipeline") -NeLPython27Dir = os.path.join(NeLRootDir, NeLConfig["Paths"]["Tools"]["Python27"]) -NeLRRDtoolDir = os.path.join(NeLRootDir, NeLConfig["Paths"]["Tools"]["RRDtool"]) -NeLMariaDBDir = os.path.join(NeLRootDir, NeLConfig["Paths"]["Tools"]["MariaDB"]) -NeLNginxDir = os.path.join(NeLRootDir, NeLConfig["Paths"]["Tools"]["Nginx"]) -NeLPHPDir = os.path.join(NeLRootDir, NeLConfig["Paths"]["Tools"]["PHP"]) -NeLphpMyAdminDir = os.path.join(NeLRootDir, NeLConfig["Paths"]["Tools"]["phpMyAdmin"]) -NeL3dsMaxDir = os.path.join(NeLRootDir, NeLConfig["Paths"]["Tools"]["3dsMax"]) +# TODO: OS +NeLPython27Dir = os.path.join(NeLRootDir, NeLConfig["Paths"]["Win64"]["Python27"]) +NeLRRDtoolDir = os.path.join(NeLRootDir, NeLConfig["Paths"]["Win64"]["RRDtool"]) +NeLMariaDBDir = os.path.join(NeLRootDir, NeLConfig["Paths"]["Win64"]["MariaDB"]) +NeLNginxDir = os.path.join(NeLRootDir, NeLConfig["Paths"]["Win64"]["Nginx"]) +NeLPHPDir = os.path.join(NeLRootDir, NeLConfig["Paths"]["Win64"]["PHP"]) +NeLphpMyAdminDir = os.path.join(NeLRootDir, NeLConfig["Paths"]["Win64"]["phpMyAdmin"]) +NeL3dsMaxDir = os.path.join(NeLRootDir, NeLConfig["Paths"]["Win64"]["3dsMax"]) #print(NeLRootDir) #print(NeLConfigDir) @@ -36,3 +25,5 @@ NeL3dsMaxDir = os.path.join(NeLRootDir, NeLConfig["Paths"]["Tools"]["3dsMax"]) #print(NeLConfig["Paths"]["Code"]) #print(NeLExternalDir) + +print(NeLBuildDir) diff --git a/tool/quick_start/common_config.py b/tool/quick_start/common_config.py index 0a2df0412..7bbb91adf 100644 --- a/tool/quick_start/common_config.py +++ b/tool/quick_start/common_config.py @@ -1,7 +1,7 @@ from common_root import * -import os, json +import os, json, socket fi = open(os.path.join(NeLQuickStartDir, "config_default.json"), "r") NeLConfig = json.load(fi) @@ -11,12 +11,12 @@ fi = open(os.path.join(NeLConfigDir, "config.json"), "r") NeLUserConfig = json.load(fi) if not "Paths" in NeLUserConfig: NeLUserConfig["Paths"] = {} -if not "Tools" in NeLUserConfig["Paths"]: - NeLUserConfig["Paths"]["Tools"] = {} +if not "Win64" in NeLUserConfig["Paths"]: + NeLUserConfig["Paths"]["Win64"] = {} if not "Toolchain" in NeLUserConfig: NeLUserConfig["Toolchain"] = {} -NeLConfig["Paths"]["Tools"].update(NeLUserConfig["Paths"]["Tools"]) -NeLUserConfig["Paths"]["Tools"] = NeLConfig["Paths"]["Tools"] +NeLConfig["Paths"]["Win64"].update(NeLUserConfig["Paths"]["Win64"]) +NeLUserConfig["Paths"]["Win64"] = NeLConfig["Paths"]["Win64"] NeLConfig["Paths"].update(NeLUserConfig["Paths"]) NeLUserConfig["Paths"] = NeLConfig["Paths"] NeLConfig["Toolchain"].update(NeLUserConfig["Toolchain"]) @@ -24,15 +24,25 @@ NeLUserConfig["Toolchain"] = NeLConfig["Toolchain"] NeLConfig.update(NeLUserConfig) fi.close() -if os.path.isfile(os.path.join(NeLConfigDir, "toolchains_default.json")): - fi = open(os.path.join(NeLConfigDir, "toolchains_default.json"), "r") +NeLHostName = socket.gethostname() + +# Path-safe ID from hostname +# Used for separating build directories in multiboot development scenario +# Release builds should always be done from the same box, ideally +NeLHostId = NeLHostName.lower() +if "HostId" in NeLConfig: + # Override if specified + NeLHostId = NeLConfig["HostId"] + +if os.path.isfile(os.path.join(NeLConfigDir, "toolchains_" + NeLHostId + "_default.json")): + fi = open(os.path.join(NeLConfigDir, "toolchains_" + NeLHostId + "_default.json"), "r") NeLToolchains = json.load(fi) fi.close() else: NeLToolchains = {} -if os.path.isfile(os.path.join(NeLConfigDir, "toolchains.json")): - fi = open(os.path.join(NeLConfigDir, "toolchains.json"), "r") +if os.path.isfile(os.path.join(NeLConfigDir, "toolchains_" + NeLHostId + ".json")): + fi = open(os.path.join(NeLConfigDir, "toolchains_" + NeLHostId + ".json"), "r") NeLToolchains.update(json.load(fi)) fi.close() diff --git a/tool/quick_start/config_default.json b/tool/quick_start/config_default.json index 7b9e6130b..cc4404b4b 100644 --- a/tool/quick_start/config_default.json +++ b/tool/quick_start/config_default.json @@ -1,23 +1,16 @@ { - "Domain": "default", + "Domains": [ "default" ], "Paths": { - "Code": "code", - "Leveldesign": "leveldesign", - "Graphics": "graphics", - "Sound": "sound", - "Build": "build", - "Pipeline": "pipeline", - "Tools": { + "Win64": { "Python27": "external/python27", "RRDtool": "external/rrdtool", "MariaDB": "external/mariadb", "Nginx": "external/nginx", "PHP": "external/php", - "phpMyAdmin": "external/phpmyadmin" - }, - "3dsMax": "", - "3dsMaxLocal": "", - "WinePrefix": "" + "phpMyAdmin": "external/phpmyadmin", + "3dsMax": "", + "3dsMaxLocal": "" + } }, "Toolchain": { "Preference": [ diff --git a/tool/quick_start/configure_toolchains.py b/tool/quick_start/configure_toolchains.py index 3c3aa37f7..08b5bf564 100644 --- a/tool/quick_start/configure_toolchains.py +++ b/tool/quick_start/configure_toolchains.py @@ -70,7 +70,11 @@ for ts in SortedToolsets: if toolchain["VCVars"] and (len(toolchain["Prefix"]) or "Hunter" in toolchain): Toolchains[toolchain["OS"] + "/VS/" + ts + "/" + platform] = toolchain -with open(os.path.join(NeLConfigDir, "toolchains_default.json"), 'w') as fo: +with open(os.path.join(NeLConfigDir, "toolchains_" + socket.gethostname().lower() + "_default.json"), 'w') as fo: json.dump(Toolchains, fo, indent=2) +if not os.path.isfile("toolchains_" + socket.gethostname().lower() + ".json"): + with open(os.path.join(NeLConfigDir, "toolchains_" + socket.gethostname().lower() + ".json"), 'w') as fo: + json.dump({}, fo, indent=2) + # end of file