mirror of https://github.com/axmolengine/axmol.git
fixed #1733, the python script perfectly works, tested on both osx and windows
This pull request fixed: - Handling the difference of line ending between osx and windows - remove os.popen("rm -rf" + …) usage which can not cross desktop platforms, uses shutil.rmtree instead
This commit is contained in:
parent
d119d3686e
commit
8915b4787d
|
@ -108,6 +108,6 @@ for platform in platforms_list:
|
|||
exec "import creator_%s.handle_project_files" % (platform)
|
||||
exec "creator_%s.handle_project_files.handle_project_files(context)" % (platform)
|
||||
|
||||
print "New project has been created in this path: " + context["dst_project_path"]
|
||||
print "New project has been created in this path: " + context["dst_project_path"].replace("/tools/project-creator/../..", "")
|
||||
print "Have Fun!"
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
# Android
|
||||
|
||||
import os
|
||||
import shutil
|
||||
|
||||
def handle_project_files(context):
|
||||
# determine proj_path
|
||||
|
@ -34,12 +35,17 @@ def handle_project_files(context):
|
|||
|
||||
dst_java_file_path = proj_path + "src/" + dst_pkg[0] + "/" + dst_pkg[1] + "/" + dst_pkg[2] + "/" + context["dst_project_name"] + ".java"
|
||||
|
||||
|
||||
# remove useless files.
|
||||
os.popen("rm -rf " + proj_path + "assets")
|
||||
os.popen("rm -rf " + proj_path + "bin")
|
||||
os.popen("rm -rf " + proj_path + "gen")
|
||||
os.popen("rm -rf " + proj_path + "obj")
|
||||
removes = [
|
||||
"assets",
|
||||
"bin",
|
||||
"libs",
|
||||
"gen",
|
||||
"obj",
|
||||
]
|
||||
for i in range(0, len(removes)):
|
||||
if (os.path.exists(proj_path + removes[i]) == True):
|
||||
shutil.rmtree(proj_path + removes[i])
|
||||
|
||||
# replaceString function is implemented in ../create-project.py
|
||||
import replaces
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
# iOS
|
||||
|
||||
import os
|
||||
import shutil
|
||||
|
||||
def handle_project_files(context):
|
||||
# determine proj_path
|
||||
|
@ -24,10 +25,14 @@ def handle_project_files(context):
|
|||
proj_path + context["dst_project_name"] + ".xcodeproj" )
|
||||
|
||||
# remove useless files.
|
||||
os.popen("rm -rf " + proj_path + context["dst_project_name"] + ".xcodeproj/project.xcworkspace")
|
||||
os.popen("rm -rf " + proj_path + context["dst_project_name"] + ".xcodeproj/xcuserdata" )
|
||||
os.popen("rm -rf " + proj_path + "build" )
|
||||
|
||||
removes = [
|
||||
context["dst_project_name"] + ".xcodeproj/project.xcworkspace",
|
||||
context["dst_project_name"] + ".xcodeproj/xcuserdata",
|
||||
]
|
||||
for i in range(0, len(removes)):
|
||||
if (os.path.exists(proj_path + removes[i]) == True):
|
||||
shutil.rmtree(proj_path + removes[i])
|
||||
|
||||
# replaceString function is implemented in ../create-project.py
|
||||
import replaces
|
||||
# package_name should be replaced at first. Don't change this sequence
|
||||
|
|
|
@ -18,6 +18,8 @@ def handle_project_files(context):
|
|||
proj_path + context["dst_project_name"] + ".vcxproj.filters")
|
||||
os.rename(proj_path + context["src_project_name"] + ".vcxproj.user",
|
||||
proj_path + context["dst_project_name"] + ".vcxproj.user")
|
||||
os.rename(proj_path + context["src_project_name"] + ".sln",
|
||||
proj_path + context["dst_project_name"] + ".sln")
|
||||
|
||||
# replaceString function is implemented in ../create-project.py
|
||||
import replaces
|
||||
|
@ -25,6 +27,7 @@ def handle_project_files(context):
|
|||
replaces.replaceString(proj_path + context["dst_project_name"] + ".vcxproj", context["src_project_name"], context["dst_project_name"])
|
||||
replaces.replaceString(proj_path + context["dst_project_name"] + ".vcxproj.filters", context["src_project_name"], context["dst_project_name"])
|
||||
replaces.replaceString(proj_path + context["dst_project_name"] + ".vcxproj.user", context["src_project_name"], context["dst_project_name"])
|
||||
replaces.replaceString(proj_path + context["dst_project_name"] + ".sln", context["src_project_name"], context["dst_project_name"])
|
||||
replaces.replaceString(proj_path + "main.cpp", context["src_project_name"], context["dst_project_name"])
|
||||
# done!
|
||||
print "proj.win32 : Done!"
|
||||
|
|
|
@ -5,14 +5,14 @@
|
|||
|
||||
def replaceString(filepath, src_string, dst_string):
|
||||
content = ""
|
||||
f1 = open(filepath, "r")
|
||||
f1 = open(filepath, "rb")
|
||||
for line in f1:
|
||||
if src_string in line:
|
||||
content += line.replace(src_string, dst_string)
|
||||
else:
|
||||
content += line
|
||||
f1.close()
|
||||
f2 = open(filepath, "w")
|
||||
f2 = open(filepath, "wb")
|
||||
f2.write(content)
|
||||
f2.close()
|
||||
# end of replaceString(filepath, src, dst) function
|
||||
|
|
Loading…
Reference in New Issue