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

View File

@ -17,7 +17,7 @@
"vs_projs_info" : { "vs_projs_info" : {
"tools/simulator/frameworks/runtime-src/proj.win32/simulator.sln" : { "tools/simulator/frameworks/runtime-src/proj.win32/simulator.sln" : {
"build_targets" : [ "build_targets" : [
"simulator" "libluacocos2d", "libjscocos2d", "libsimulator"
], ],
"rename_targets" : [ "rename_targets" : [
"libSpine", "libbox2d", "libbullet", "librecast", "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 ] reg_flag_list = [ _winreg.KEY_WOW64_64KEY, _winreg.KEY_WOW64_32KEY ]
# Find VS path # Find VS path
vsPath = None msbuild_path = None
for reg_flag in reg_flag_list: for reg_flag in reg_flag_list:
try: try:
vs = _winreg.OpenKey( vs = _winreg.OpenKey(
_winreg.HKEY_LOCAL_MACHINE, _winreg.HKEY_LOCAL_MACHINE,
r"SOFTWARE\Microsoft\VisualStudio", r"SOFTWARE\Microsoft\MSBuild\ToolsVersions\%s" % vs_ver,
0, 0,
_winreg.KEY_READ | reg_flag _winreg.KEY_READ | reg_flag
) )
key = _winreg.OpenKey(vs, r"SxS\VS7") msbuild_path, type = _winreg.QueryValueEx(vs, 'MSBuildToolsPath')
vsPath, type = _winreg.QueryValueEx(key, vs_ver)
except: except:
continue continue
if vsPath is not None: if msbuild_path is not None and os.path.exists(msbuild_path):
break break
# generate devenv path # generate devenv path
if vsPath is not None: if msbuild_path is not None:
commandPath = os.path.join(vsPath, "Common7", "IDE", "devenv") commandPath = os.path.join(msbuild_path, "MSBuild.exe")
else: else:
commandPath = None commandPath = None