From 234a0ced42ddbbe6af12ab7ca5e6b3d9bddc8ae2 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Thu, 27 Jan 2022 14:46:54 +0800 Subject: [PATCH] Python scripts for quick start --- tool/quick_start/LICENSE.md | 24 ++++++++ tool/quick_start/common_config.py | 61 +++++++++++++++++++ tool/quick_start/common_root.py | 22 +++++++ tool/quick_start/config_default.json | 23 ++++++++ tool/quick_start/find_vstudio.py | 87 ++++++++++++++++++++++++++++ tool/quick_start/test.bat | 1 + 6 files changed, 218 insertions(+) create mode 100644 tool/quick_start/LICENSE.md create mode 100644 tool/quick_start/common_config.py create mode 100644 tool/quick_start/common_root.py create mode 100644 tool/quick_start/config_default.json create mode 100644 tool/quick_start/find_vstudio.py create mode 100644 tool/quick_start/test.bat diff --git a/tool/quick_start/LICENSE.md b/tool/quick_start/LICENSE.md new file mode 100644 index 000000000..fdddb29aa --- /dev/null +++ b/tool/quick_start/LICENSE.md @@ -0,0 +1,24 @@ +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to diff --git a/tool/quick_start/common_config.py b/tool/quick_start/common_config.py new file mode 100644 index 000000000..52db9116d --- /dev/null +++ b/tool/quick_start/common_config.py @@ -0,0 +1,61 @@ + +from common_root import * + +import os, json + +fi = open(os.path.join(NeLQuickStartDir, "config_default.json"), "r") +NeLConfig = json.load(fi) +fi.close() + +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"] = {} +NeLConfig["Paths"]["Tools"].update(NeLUserConfig["Paths"]["Tools"]) +NeLUserConfig["Paths"]["Tools"] = NeLConfig["Paths"]["Tools"] +NeLConfig["Paths"].update(NeLUserConfig["Paths"]) +NeLUserConfig["Paths"] = NeLConfig["Paths"] +NeLConfig.update(NeLUserConfig) +fi.close() + +del NeLUserConfig +del fi + +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.") +NeLExternalDir = os.path.join(NeLRootDir, NeLConfig["Paths"]["External"]) +if not os.path.isdir(NeLExternalDir): + exit("NeL External directory (" + NeLExternalDir + ") does not exist.") + +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"]) + +#print(NeLRootDir) +#print(NeLConfigDir) +#print(NeLConfig["Domain"]) +#print(NeLConfig["Paths"]["Code"]) + +#print(NeLExternalDir) diff --git a/tool/quick_start/common_root.py b/tool/quick_start/common_root.py new file mode 100644 index 000000000..a4a207f34 --- /dev/null +++ b/tool/quick_start/common_root.py @@ -0,0 +1,22 @@ + +import os + +NeLQuickStartDir = os.path.dirname(os.path.realpath(__file__)) + +def findNeLRootRecurse(dirPath): + configDir = os.path.join(dirPath, ".nel") + if os.path.isdir(configDir): + return dirPath + parentPath = os.path.dirname(dirPath) + if parentPath == dirPath: + exit("NeL Root folder (.nel) not found in folder hierarchy.") + return findNeLRootRecurse(parentPath) + +def findNeLRoot(): + return findNeLRootRecurse(NeLQuickStartDir) + +NeLRootDir = findNeLRoot() +NeLConfigDir = os.path.join(NeLRootDir, ".nel") + +del findNeLRootRecurse +del findNeLRoot diff --git a/tool/quick_start/config_default.json b/tool/quick_start/config_default.json new file mode 100644 index 000000000..f9c2d0f57 --- /dev/null +++ b/tool/quick_start/config_default.json @@ -0,0 +1,23 @@ +{ + "Domain": "default", + "Paths": { + "Code": "code", + "Leveldesign": "leveldesign", + "Graphics": "graphics", + "Sound": "sound", + "Build": "build", + "Pipeline": "pipeline", + "External": "external", + "Tools": { + "Python27": "external/python27", + "RRDtool": "external/rrdtool", + "MariaDB": "external/mariadb", + "Nginx": "external/nginx", + "PHP": "external/php", + "phpMyAdmin": "external/phpmyadmin", + "3dsMax": "C:\\Program Files\\Autodesk\\3ds Max 2022", + "VisualStudio32": "C:\\Program Files (x86)\\Microsoft Visual Studio 9.0", + "VisualStudio64": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional", + } + } +} \ No newline at end of file diff --git a/tool/quick_start/find_vstudio.py b/tool/quick_start/find_vstudio.py new file mode 100644 index 000000000..314dc7b2f --- /dev/null +++ b/tool/quick_start/find_vstudio.py @@ -0,0 +1,87 @@ + +# This script finds all Visual Studio installations +# [ { DisplayName, Path, HasMFC } ] + +import os + +FoundVisualStudio = [] + +# C:\Program Files (x86)\Microsoft Visual Studio\VC98 +# "C:\Program Files (x86)\Microsoft Visual Studio\VC98\MFC\Include\AFX.H" + +VSVersions = {} +VSVersions[8] = 2005 +VSVersions[9] = 2008 +VSVersions[10] = 2010 +VSVersions[11] = 2012 +VSVersions[12] = 2013 +VSVersions[13] = 2014 +VSVersions[14] = 2015 +#VSVersions[15] = 2017 +#VSVersions[16] = 2019 +#VSVersions[17] = 2022 + +# "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\atlmfc\include\afx.h" +# "C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.16.27023\atlmfc\include\afx.h" +# "C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\*\atlmfc\include\afx.h" +def HasMFC(dir): + if os.path.isfile(os.path.join(dir, "VC\\atlmfc\\include\\afx.h")): + return True + msvcTools = os.path.join(dir, "VC\\Tools\\MSVC") + res = [] + if os.path.isdir(msvcTools): + for version in os.listdir(msvcTools): + if version.startswith("."): + continue + versionPath = os.path.join(msvcTools, version) + if os.path.isdir(versionPath): + headerPath = os.path.join(versionPath, "atlmfc\\include\\afx.h") + if os.path.isfile(headerPath): + res += [ version ] + if len(res): + return res + return False + +# "C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\IDE\VCExpress.exe" # Visual C++ 2005 Express +# C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\devenv.exe" # Visual Studio 2022 Professional +# C:\Program Files\Microsoft Visual Studio\*\*\Common7\IDE\devenv.exe" +# "C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe" # Visual Studio 2008 Professional Edition +# Community, Professional, Enterprise +# Scan all folders 8 to 14, 8.0 to 14.0 +for majorVersion in range(8, 15): + folderA = "C:\\Program Files (x86)\\Microsoft Visual Studio " + str(majorVersion) + folderB = folderA + ".0" + if os.path.isfile(os.path.join(folderA, "Common7\IDE\VCExpress.exe")): + FoundVisualStudio += [ { "DisplayName": "Visual C++ " + str(VSVersions[majorVersion]) + " Express", "Path": folderA, "HasMFC": HasMFC(folderB) } ] + if os.path.isfile(os.path.join(folderB, "Common7\IDE\VCExpress.exe")): + FoundVisualStudio += [ { "DisplayName": "Visual C++ " + str(VSVersions[majorVersion]) + " Express", "Path": folderB, "HasMFC": HasMFC(folderB) } ] + if os.path.isfile(os.path.join(folderA, "Common7\IDE\devenv.exe")): + FoundVisualStudio += [ { "DisplayName": "Visual Studio " + str(VSVersions[majorVersion]), "Path": folderA, "HasMFC": HasMFC(folderB) } ] + if os.path.isfile(os.path.join(folderB, "Common7\IDE\devenv.exe")): + FoundVisualStudio += [ { "DisplayName": "Visual Studio " + str(VSVersions[majorVersion]), "Path": folderB, "HasMFC": HasMFC(folderB) } ] + +# Scan all folders 2017 to 2022 +for yearVersion in os.listdir("C:\\Program Files (x86)\\Microsoft Visual Studio"): + if yearVersion.startswith("."): + continue + yearPath = os.path.join("C:\\Program Files (x86)\\Microsoft Visual Studio", yearVersion) + if os.path.isdir(yearPath): + for edition in os.listdir(yearPath): + if edition.startswith("."): + continue + editionPath = os.path.join(yearPath, edition) + if os.path.isdir(editionPath) and os.path.isfile(os.path.join(editionPath, "Common7\IDE\devenv.exe")): + FoundVisualStudio += [ { "DisplayName": "Visual Studio " + yearVersion + " " + edition, "Path": editionPath, "HasMFC": HasMFC(editionPath) } ] +for yearVersion in os.listdir("C:\\Program Files\\Microsoft Visual Studio"): + if yearVersion.startswith("."): + continue + yearPath = os.path.join("C:\\Program Files\\Microsoft Visual Studio", yearVersion) + if os.path.isdir(yearPath): + for edition in os.listdir(yearPath): + if edition.startswith("."): + continue + editionPath = os.path.join(yearPath, edition) + if os.path.isdir(editionPath) and os.path.isfile(os.path.join(editionPath, "Common7\IDE\devenv.exe")): + FoundVisualStudio += [ { "DisplayName": "Visual Studio " + yearVersion + " " + edition, "Path": editionPath, "HasMFC": HasMFC(editionPath) } ] + +# print(FoundVisualStudio) diff --git a/tool/quick_start/test.bat b/tool/quick_start/test.bat new file mode 100644 index 000000000..4bb5a8678 --- /dev/null +++ b/tool/quick_start/test.bat @@ -0,0 +1 @@ +..\..\..\external\python27\python.exe find_vstudio.py