From 730d174f39869429b890aa50838456927f47a77d Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 31 Jan 2022 09:10:38 +0800 Subject: [PATCH] Use Python 3 for the quick start scripts --- tool/quick_start/__init__.py | 0 tool/quick_start/common.py | 2 +- tool/quick_start/common_config.py | 2 +- tool/quick_start/configure_code_build.py | 5 +++ tool/quick_start/configure_toolchains.py | 33 +++++++++++++++++--- tool/quick_start/find_external.py | 2 +- tool/quick_start/find_max.py | 7 +++-- tool/quick_start/find_targets.py | 33 ++++++++++++++++++++ tool/quick_start/find_toolchain.py | 2 +- tool/quick_start/print_summary.py | 39 +++++++++--------------- tool/quick_start/test.bat | 8 ++--- 11 files changed, 92 insertions(+), 41 deletions(-) create mode 100644 tool/quick_start/__init__.py create mode 100644 tool/quick_start/configure_code_build.py create mode 100644 tool/quick_start/find_targets.py diff --git a/tool/quick_start/__init__.py b/tool/quick_start/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tool/quick_start/common.py b/tool/quick_start/common.py index 1b034a432..39cb16dbf 100644 --- a/tool/quick_start/common.py +++ b/tool/quick_start/common.py @@ -1,5 +1,5 @@ -from common_config import * +from . common_config import * import os diff --git a/tool/quick_start/common_config.py b/tool/quick_start/common_config.py index ac399034e..a1057910e 100644 --- a/tool/quick_start/common_config.py +++ b/tool/quick_start/common_config.py @@ -1,5 +1,5 @@ -from common_root import * +from .common_root import * import os, json, socket diff --git a/tool/quick_start/configure_code_build.py b/tool/quick_start/configure_code_build.py new file mode 100644 index 000000000..a82c74145 --- /dev/null +++ b/tool/quick_start/configure_code_build.py @@ -0,0 +1,5 @@ + +# This generates the build scripts for all targets + + +# end of file diff --git a/tool/quick_start/configure_toolchains.py b/tool/quick_start/configure_toolchains.py index b01965722..7dce737d7 100644 --- a/tool/quick_start/configure_toolchains.py +++ b/tool/quick_start/configure_toolchains.py @@ -1,9 +1,12 @@ # This script generates a configuration file listing all the available toolchains -from common import * -from find_vstudio import * -from find_external import * +import sys, os +sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) + +from quick_start.common import * +from quick_start.find_vstudio import * +from quick_start.find_external import * Toolchains = {} @@ -36,8 +39,26 @@ for ts in SortedToolsets: if not len(toolchain["Prefix"]) and vs["Version"] >= 14: toolchain["Hunter"] = True toolchain["CMake"] = [] - if vs["Version"] < 14: - toolchain["CMake"] += [ "-DWINSDK_VERSION=6.0A" ] + # Set the SDK version + # https://en.wikipedia.org/wiki/Microsoft_Windows_SDK + # C:\Program Files (x86)\Windows Kits\10 + if vs["Version"] < 14 and not ts.endswith("_xp"): + if vs["Version"] >= 12: # 2013 + toolchain["CMake"] += [ "-DWINSDK_VERSION=8.1A" ] + elif vs["Version"] >= 11: # 2012 + toolchain["CMake"] += [ "-DWINSDK_VERSION=8.0A" ] + elif vs["Version"] >= 10: # 2010 + toolchain["CMake"] += [ "-DWINSDK_VERSION=7.0A" ] + elif vs["Version"] >= 9: + # C:\Program Files\Microsoft SDKs\Windows\v6.0A + if os.path.isfile("C:\\Program Files\\Microsoft SDKs\\Windows\\v6.0A\\Include\\Msi.h"): + toolchain["CMake"] += [ "-DWINSDK_DIR=C:\\Program Files\\Microsoft SDKs\\Windows\\v6.0A" ] + toolchain["CMake"] += [ "-DWINSDK_VERSION=6.0A" ] + else: + # C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2 + if os.path.isfile("C:\\Program Files\\Microsoft Platform SDK for Windows Server 2003 R2\\Include\\Msi.h"): + toolchain["CMake"] += [ "-DWINSDK_DIR=C:/Program Files/Microsoft Platform SDK for Windows Server 2003 R2" ] + toolchain["CMake"] += [ "-DWINSDK_VERSION=5.2" ] toolchain["EnvPath"] = FindBinPaths(toolchain["Prefix"]) toolchain["EnvSet"] = [] # For XP support, simply target SDK 7.1A @@ -97,6 +118,8 @@ for ts in SortedToolsets: copyToolchain["Prefix"] = [] copyToolchain["EnvPath"] = [] copyToolchain["EnvSet"] += [ "CL=/DLIBXML_STATIC;%CL%" ] + if "LuaVersion" in copyToolchain: + del copyToolchain["LuaVersion"] Toolchains[toolchain["OS"] + "/VS/" + ts + "/" + platform + "/H"] = copyToolchain with open(os.path.join(NeLConfigDir, "toolchains_" + socket.gethostname().lower() + "_default.json"), 'w') as fo: diff --git a/tool/quick_start/find_external.py b/tool/quick_start/find_external.py index 40c776540..45d759fdb 100644 --- a/tool/quick_start/find_external.py +++ b/tool/quick_start/find_external.py @@ -2,7 +2,7 @@ # This script detects all external library paths # Useful for locating all dynamic libraries -from common_config import * +from .common_config import * import os diff --git a/tool/quick_start/find_max.py b/tool/quick_start/find_max.py index de1db92c1..6a00c83ea 100644 --- a/tool/quick_start/find_max.py +++ b/tool/quick_start/find_max.py @@ -2,12 +2,13 @@ # Script finds latest max installation, user directory, and max SDKs import os +from itertools import chain def HasPluginMax(path): return os.path.isfile(os.path.join(path, "3dsmax.exe")) and (os.path.isfile(os.path.join(path, "plugins/nelexport_r.dlu")) or os.path.isfile(os.path.join(path, "plugins/nelexport_d.dlu")) or os.path.isfile(os.path.join(path, "plugins/nelexport.dlu"))) def FindPluginMax(): - for i in range(2038, 2007, -1) + range(9, 2, -1): + for i in chain(range(2038, 2007, -1), range(9, 2, -1)): path = os.getenv('ADSK_3DSMAX_x64_' + str(i)) if path and HasPluginMax(path): return os.path.normpath(path) @@ -19,7 +20,7 @@ def FindPluginMax(): return os.path.normpath(path) def FindLatestMax(): - for i in range(2038, 2007, -1) + range(9, 2, -1): + for i in chain(range(2038, 2007, -1), range(9, 2, -1)): path = os.getenv('ADSK_3DSMAX_x64_' + str(i)) if path and os.path.isfile(os.path.join(path, "3dsmax.exe")): return os.path.normpath(path) @@ -101,7 +102,7 @@ def FindMaxSDKs(): res = [] set = {} remap = {} - for i in range(3, 10) + range(2008, 2039): + for i in chain(range(3, 10), range(2008, 2039)): found = FindMaxSDK(i) if found: set[i] = True diff --git a/tool/quick_start/find_targets.py b/tool/quick_start/find_targets.py new file mode 100644 index 000000000..14a79ce6a --- /dev/null +++ b/tool/quick_start/find_targets.py @@ -0,0 +1,33 @@ + +from .find_toolchain import * +from .find_max import * + +NeLTargetClientDev = FindToolchainEx(NeLToolchainNative) +NeLTargetServerDev = FindToolchainEx(NeLToolchainNative) +NeLTargetClient = {} +for client in NeLConfig["Toolchain"]["Client"]: + NeLTargetClient[client] = FindToolchainEx(NeLConfig["Toolchain"]["Client"][client]) +NeLTargetServer = FindToolchainEx(NeLConfig["Toolchain"]["Server"]) +NeLTargetTools = FindToolchainEx(NeLToolchainNative) +NeLTargetSamples = FindToolchainEx(NeLToolchainNative) +NelTargetPluginMax = {} +remapMaxCompatible = {} +foundMax = {} +for maxSdk in FoundMaxSDKs: + if "Compatible" in maxSdk: + # Skip unnecessary builds + if maxSdk["Compatible"] in foundMax: + continue + filters = [ { "Toolset": maxSdk["Toolset"], "Platform": maxSdk["Platform"], "HasMFC": True, "Hunter": True }, { "Toolset": maxSdk["Toolset"], "Platform": maxSdk["Platform"], "HasMFC": True } ] + foundTs = FindToolchainEx(filters) + if foundTs: + foundMax[maxSdk["Version"]] = True + if "Compatible" in maxSdk: + foundMax[maxSdk["Compatible"]] = True + NelTargetPluginMax[str(maxSdk["Version"]) + "_" + maxSdk["Platform"]] = foundTs + del filters + del foundTs +del remapMaxCompatible +del foundMax + +# end of file \ No newline at end of file diff --git a/tool/quick_start/find_toolchain.py b/tool/quick_start/find_toolchain.py index d3f70211d..9dd72fc9f 100644 --- a/tool/quick_start/find_toolchain.py +++ b/tool/quick_start/find_toolchain.py @@ -1,7 +1,7 @@ # This script finds the best toolchains for each purpose -from common import * +from .common import * def FindToolchain(filter): toolchains = {} diff --git a/tool/quick_start/print_summary.py b/tool/quick_start/print_summary.py index 9c7a03aed..a20891639 100644 --- a/tool/quick_start/print_summary.py +++ b/tool/quick_start/print_summary.py @@ -1,9 +1,10 @@ -from find_toolchain import * -from find_max import * +import sys, os +sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) -def printBuildTarget(name, filters): - tn = FindToolchainEx(filters) +from quick_start.find_targets import * + +def printBuildTarget(name, tn): if tn: tc = NeLToolchains[tn] withHunter = "" @@ -14,26 +15,14 @@ def printBuildTarget(name, filters): print(" " + name + ": NOT FOUND") print("Build targets:") -printBuildTarget("client_dev", NeLToolchainNative) -printBuildTarget("server_dev", NeLToolchainNative) -for client in NeLConfig["Toolchain"]["Client"]: - printBuildTarget(client, NeLConfig["Toolchain"]["Client"][client]) -printBuildTarget("server", NeLConfig["Toolchain"]["Server"]) -printBuildTarget("tools", NeLToolchainNative) -printBuildTarget("samples", NeLToolchainNative) -remapMaxCompatible = {} -foundMax = {} -for maxSdk in FoundMaxSDKs: - if "Compatible" in maxSdk: - # Skip unnecessary builds - if maxSdk["Compatible"] in foundMax: - continue - filters = [ { "Toolset": maxSdk["Toolset"], "Platform": maxSdk["Platform"], "HasMFC": True, "Hunter": True }, { "Toolset": maxSdk["Toolset"], "Platform": maxSdk["Platform"], "HasMFC": True } ] - if FindToolchainEx(filters): - foundMax[maxSdk["Version"]] = True - if "Compatible" in maxSdk: - foundMax[maxSdk["Compatible"]] = True - printBuildTarget("plugin_max/" + str(maxSdk["Version"]) + "_" + maxSdk["Platform"], filters) -# plugin_max +printBuildTarget("client_dev", NeLTargetClientDev) +printBuildTarget("server_dev", NeLTargetServerDev) +for client in NeLTargetClient: + printBuildTarget(client, NeLTargetClient[client]) +printBuildTarget("server", NeLTargetServer) +printBuildTarget("tools", NeLTargetTools) +printBuildTarget("samples", NeLTargetSamples) +for pluginMax in NelTargetPluginMax: + printBuildTarget("plugin_max/" + pluginMax, NelTargetPluginMax[pluginMax]) # end of file diff --git a/tool/quick_start/test.bat b/tool/quick_start/test.bat index 9f20a6908..63e8e85e3 100644 --- a/tool/quick_start/test.bat +++ b/tool/quick_start/test.bat @@ -1,4 +1,4 @@ -..\..\..\external\python27\python.exe configure_toolchains.py -..\..\..\external\python27\python.exe find_toolchain.py -..\..\..\external\python27\python.exe find_max.py -..\..\..\external\python27\python.exe print_summary.py +rem ..\..\..\external\python3\python.exe configure_toolchains.py +rem ..\..\..\external\python3\python.exe find_toolchain.py +rem ..\..\..\external\python3\python.exe find_max.py +..\..\..\external\python3\python.exe print_summary.py