Merge pull request #12781 from natural-law/v3.7-release

[ci skip] Use msbuild to generating engine prebuilt libs on win32.
This commit is contained in:
子龙山人 2015-07-10 17:03:53 +08:00
commit a4ea35b0c7
3 changed files with 19 additions and 25 deletions

View File

@ -96,12 +96,13 @@ class CocosLibsCompiler(object):
# generate prebuilt mk files
self.modify_binary_mk()
def build_win32_proj(self, cmd_path, sln_path, proj_name, mode):
def build_win32_proj(self, cmd_path, sln_path, proj_name):
build_cmd = " ".join([
"\"%s\"" % cmd_path,
"\"%s\"" % sln_path,
"/%s \"Release|Win32\"" % mode,
"/Project \"%s\"" % proj_name
"/t:%s" % proj_name,
"/property:Configuration=Release",
"/m"
])
utils_cocos.execute_command(build_cmd)
@ -157,7 +158,7 @@ class CocosLibsCompiler(object):
clean_cmd = " ".join([
"\"%s\"" % vs_command,
"\"%s\"" % proj_path,
"/clean \"Release|Win32\""
"/t:Clean /p:Configuration=Release"
])
utils_cocos.execute_command(clean_cmd)
@ -184,15 +185,7 @@ class CocosLibsCompiler(object):
else:
for proj_name in win32_proj_info[key][CocosLibsCompiler.KEY_VS_BUILD_TARGETS]:
# build the projects
self.build_win32_proj(vs_command, proj_path, proj_name, "build")
lib_file_path = os.path.join(build_folder_path, "%s.lib" % proj_name)
if not os.path.exists(lib_file_path):
# if the lib is not generated, rebuild the project
self.build_win32_proj(vs_command, proj_path, proj_name, "rebuild")
if not os.path.exists(lib_file_path):
raise Exception("Library %s not generated as expected!" % lib_file_path)
self.build_win32_proj(vs_command, proj_path, proj_name)
# copy the libs into prebuilt dir
for file_name in os.listdir(build_folder_path):
@ -208,7 +201,9 @@ class CocosLibsCompiler(object):
for proj_name in win32_proj_info[key][CocosLibsCompiler.KEY_VS_RENAME_TARGETS]:
src_name = os.path.join(win32_output_dir, "%s.lib" % proj_name)
dst_name = os.path.join(win32_output_dir, "%s%s.lib" % (proj_name, suffix))
if os.path.exists(src_name):
if not os.path.exists(src_name):
raise Exception("Library %s not generated as expected!" % src_name)
if os.path.exists(dst_name):
os.remove(dst_name)
os.rename(src_name, dst_name)

View File

@ -17,7 +17,7 @@
"vs_projs_info" : {
"tools/simulator/frameworks/runtime-src/proj.win32/simulator.sln" : {
"build_targets" : [
"simulator"
"libluacocos2d", "libjscocos2d", "libsimulator"
],
"rename_targets" : [
"libSpine", "libbox2d", "libbullet", "librecast",

View File

@ -92,26 +92,25 @@ def get_vs_cmd_path(vs_version):
reg_flag_list = [ _winreg.KEY_WOW64_64KEY, _winreg.KEY_WOW64_32KEY ]
# Find VS path
vsPath = None
msbuild_path = None
for reg_flag in reg_flag_list:
try:
vs = _winreg.OpenKey(
_winreg.HKEY_LOCAL_MACHINE,
r"SOFTWARE\Microsoft\VisualStudio",
r"SOFTWARE\Microsoft\MSBuild\ToolsVersions\%s" % vs_ver,
0,
_winreg.KEY_READ | reg_flag
)
key = _winreg.OpenKey(vs, r"SxS\VS7")
vsPath, type = _winreg.QueryValueEx(key, vs_ver)
msbuild_path, type = _winreg.QueryValueEx(vs, 'MSBuildToolsPath')
except:
continue
if vsPath is not None:
if msbuild_path is not None and os.path.exists(msbuild_path):
break
# generate devenv path
if vsPath is not None:
commandPath = os.path.join(vsPath, "Common7", "IDE", "devenv")
if msbuild_path is not None:
commandPath = os.path.join(msbuild_path, "MSBuild.exe")
else:
commandPath = None