mirror of https://github.com/axmolengine/axmol.git
Python support for win32 adxe compile command
This commit is contained in:
parent
c4dc07d1aa
commit
a7fe3e01a9
|
@ -7,6 +7,12 @@ import shutil
|
|||
import adxe
|
||||
import re
|
||||
|
||||
if sys.platform == 'win32':
|
||||
if(sys.version_info.major >= 3):
|
||||
import winreg
|
||||
else:
|
||||
import _winreg as winreg
|
||||
|
||||
VS_VERSION_MAP = {
|
||||
2012 : "11.0",
|
||||
2013 : "12.0",
|
||||
|
@ -16,9 +22,7 @@ VS_VERSION_MAP = {
|
|||
}
|
||||
|
||||
def get_msbuild_path(vs_version):
|
||||
if adxe.os_is_win32():
|
||||
import _winreg
|
||||
else:
|
||||
if not adxe.os_is_win32():
|
||||
return None
|
||||
|
||||
if isinstance(vs_version, int):
|
||||
|
@ -37,21 +41,21 @@ def get_msbuild_path(vs_version):
|
|||
# If the system is 64bit, find VS in both 32bit & 64bit registry
|
||||
# If the system is 32bit, only find VS in 32bit registry
|
||||
if adxe.os_is_32bit_windows():
|
||||
reg_flag_list = [ _winreg.KEY_WOW64_32KEY ]
|
||||
reg_flag_list = [ winreg.KEY_WOW64_32KEY ]
|
||||
else:
|
||||
reg_flag_list = [ _winreg.KEY_WOW64_64KEY, _winreg.KEY_WOW64_32KEY ]
|
||||
reg_flag_list = [ winreg.KEY_WOW64_64KEY, winreg.KEY_WOW64_32KEY ]
|
||||
|
||||
# Find VS path
|
||||
msbuild_path = None
|
||||
for reg_flag in reg_flag_list:
|
||||
try:
|
||||
vs = _winreg.OpenKey(
|
||||
_winreg.HKEY_LOCAL_MACHINE,
|
||||
vs = winreg.OpenKey(
|
||||
winreg.HKEY_LOCAL_MACHINE,
|
||||
r"SOFTWARE\Microsoft\MSBuild\ToolsVersions\%s" % vs_ver,
|
||||
0,
|
||||
_winreg.KEY_READ | reg_flag
|
||||
winreg.KEY_READ | reg_flag
|
||||
)
|
||||
msbuild_path, type = _winreg.QueryValueEx(vs, 'MSBuildToolsPath')
|
||||
msbuild_path, type = winreg.QueryValueEx(vs, 'MSBuildToolsPath')
|
||||
except:
|
||||
continue
|
||||
|
||||
|
@ -65,9 +69,7 @@ def get_msbuild_path(vs_version):
|
|||
return msbuild_path
|
||||
|
||||
def get_devenv_path(vs_version):
|
||||
if adxe.os_is_win32():
|
||||
import _winreg
|
||||
else:
|
||||
if not adxe.os_is_win32():
|
||||
return None
|
||||
|
||||
if isinstance(vs_version, int):
|
||||
|
@ -86,26 +88,26 @@ def get_devenv_path(vs_version):
|
|||
# If the system is 64bit, find VS in both 32bit & 64bit registry
|
||||
# If the system is 32bit, only find VS in 32bit registry
|
||||
if adxe.os_is_32bit_windows():
|
||||
reg_flag_list = [ _winreg.KEY_WOW64_32KEY ]
|
||||
reg_flag_list = [ winreg.KEY_WOW64_32KEY ]
|
||||
else:
|
||||
reg_flag_list = [ _winreg.KEY_WOW64_64KEY, _winreg.KEY_WOW64_32KEY ]
|
||||
reg_flag_list = [ winreg.KEY_WOW64_64KEY, winreg.KEY_WOW64_32KEY ]
|
||||
|
||||
devenv_path = None
|
||||
for reg_flag in reg_flag_list:
|
||||
try:
|
||||
vs = _winreg.OpenKey(
|
||||
_winreg.HKEY_LOCAL_MACHINE,
|
||||
vs = winreg.OpenKey(
|
||||
winreg.HKEY_LOCAL_MACHINE,
|
||||
r"SOFTWARE\Microsoft\VisualStudio",
|
||||
0,
|
||||
_winreg.KEY_READ | reg_flag
|
||||
winreg.KEY_READ | reg_flag
|
||||
)
|
||||
except:
|
||||
continue
|
||||
|
||||
# find specified VS
|
||||
try:
|
||||
key = _winreg.OpenKey(vs, r"SxS\VS7")
|
||||
devenv_path, type = _winreg.QueryValueEx(key, vs_ver)
|
||||
key = winreg.OpenKey(vs, r"SxS\VS7")
|
||||
devenv_path, type = winreg.QueryValueEx(key, vs_ver)
|
||||
except:
|
||||
pass
|
||||
|
||||
|
@ -121,26 +123,24 @@ def get_devenv_path(vs_version):
|
|||
def get_vs_versions():
|
||||
# Get the VS versions
|
||||
ret = []
|
||||
if adxe.os_is_win32():
|
||||
import _winreg
|
||||
else:
|
||||
if not adxe.os_is_win32():
|
||||
return ret
|
||||
|
||||
# If the system is 64bit, find VS in both 32bit & 64bit registry
|
||||
# If the system is 32bit, only find VS in 32bit registry
|
||||
if adxe.os_is_32bit_windows():
|
||||
reg_flag_list = [ _winreg.KEY_WOW64_32KEY ]
|
||||
reg_flag_list = [ winreg.KEY_WOW64_32KEY ]
|
||||
else:
|
||||
reg_flag_list = [ _winreg.KEY_WOW64_64KEY, _winreg.KEY_WOW64_32KEY ]
|
||||
reg_flag_list = [ winreg.KEY_WOW64_64KEY, winreg.KEY_WOW64_32KEY ]
|
||||
|
||||
version_pattern = re.compile(r'(\d+)\.(\d+)')
|
||||
for reg_flag in reg_flag_list:
|
||||
try:
|
||||
vs = _winreg.OpenKey(
|
||||
_winreg.HKEY_LOCAL_MACHINE,
|
||||
vs = winreg.OpenKey(
|
||||
winreg.HKEY_LOCAL_MACHINE,
|
||||
r"SOFTWARE\Microsoft\VisualStudio",
|
||||
0,
|
||||
_winreg.KEY_READ | reg_flag
|
||||
winreg.KEY_READ | reg_flag
|
||||
)
|
||||
except:
|
||||
continue
|
||||
|
@ -149,7 +149,7 @@ def get_vs_versions():
|
|||
while True:
|
||||
# enum the keys in vs reg
|
||||
try:
|
||||
version = _winreg.EnumKey(vs, i)
|
||||
version = winreg.EnumKey(vs, i)
|
||||
except:
|
||||
break
|
||||
i += 1
|
||||
|
|
|
@ -87,12 +87,15 @@ class CCPluginDeploy(adxe.CCPlugin):
|
|||
self.project_name = compile_dep.project_name
|
||||
|
||||
def find_xap_deploy_tool(self):
|
||||
import _winreg
|
||||
if(sys.version_info.major >= 3):
|
||||
import winreg
|
||||
else:
|
||||
import _winreg as winreg
|
||||
import re
|
||||
if adxe.os_is_32bit_windows():
|
||||
reg_flag_list = [ _winreg.KEY_WOW64_32KEY ]
|
||||
reg_flag_list = [ winreg.KEY_WOW64_32KEY ]
|
||||
else:
|
||||
reg_flag_list = [ _winreg.KEY_WOW64_64KEY, _winreg.KEY_WOW64_32KEY ]
|
||||
reg_flag_list = [ winreg.KEY_WOW64_64KEY, winreg.KEY_WOW64_32KEY ]
|
||||
|
||||
pattern = re.compile(r"v(\d+).(\d+)")
|
||||
find_ret = None
|
||||
|
@ -100,13 +103,13 @@ class CCPluginDeploy(adxe.CCPlugin):
|
|||
find_minor = -1
|
||||
for reg_flag in reg_flag_list:
|
||||
adxe.Logging.info(MultiLanguage.get_string('DEPLOY_INFO_FIND_XAP_FMT',
|
||||
("32bit" if reg_flag == _winreg.KEY_WOW64_32KEY else "64bit")))
|
||||
("32bit" if reg_flag == winreg.KEY_WOW64_32KEY else "64bit")))
|
||||
try:
|
||||
wp = _winreg.OpenKey(
|
||||
_winreg.HKEY_LOCAL_MACHINE,
|
||||
wp = winreg.OpenKey(
|
||||
winreg.HKEY_LOCAL_MACHINE,
|
||||
r"SOFTWARE\Microsoft\Microsoft SDKs\WindowsPhone",
|
||||
0,
|
||||
_winreg.KEY_READ | reg_flag
|
||||
winreg.KEY_READ | reg_flag
|
||||
)
|
||||
except:
|
||||
# windows phone not found, continue
|
||||
|
@ -115,7 +118,7 @@ class CCPluginDeploy(adxe.CCPlugin):
|
|||
i = 0
|
||||
while True:
|
||||
try:
|
||||
version = _winreg.EnumKey(wp, i)
|
||||
version = winreg.EnumKey(wp, i)
|
||||
except:
|
||||
break
|
||||
|
||||
|
@ -126,8 +129,8 @@ class CCPluginDeploy(adxe.CCPlugin):
|
|||
minor = int(match.group(2))
|
||||
if major > 7:
|
||||
try:
|
||||
key = _winreg.OpenKey(wp, "%s\Install Path" % version)
|
||||
value, type = _winreg.QueryValueEx(key, "Install Path")
|
||||
key = winreg.OpenKey(wp, "%s\Install Path" % version)
|
||||
value, type = winreg.QueryValueEx(key, "Install Path")
|
||||
tool_path = os.path.join(value, "Tools", "XAP Deployment", "XapDeployCmd.exe")
|
||||
if os.path.isfile(tool_path):
|
||||
if (find_ret is None) or (major > find_major) or (major == find_major and minor > find_minor):
|
||||
|
|
Loading…
Reference in New Issue