def handle_project_files(context):
    # determine proj_path
    proj_path = context["dst_project_path"] + "/proj.mac/"
        
    # rename files and folders
    os.rename(proj_path + context["src_project_name"] + ".xcodeproj",
              proj_path + context["dst_project_name"] + ".xcodeproj" )
              
    # remove useless files.
    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
    replaces.replaceString(proj_path + "Info.plist",
                           context["src_package_name"], context["dst_package_name"])
    replaces.replaceString(proj_path + context["dst_project_name"] + ".xcodeproj/project.pbxproj",
                           context["src_project_name"], context["dst_project_name"])
    replaces.replaceString(proj_path + "Info.plist",
                           context["src_project_name"], context["dst_project_name"])

    # done!
    print "proj.mac         : Done!"
def handle_project_files(context):
    # determine proj_path
    proj_path = context["dst_project_path"] + "/proj.ios/"
    
    # determine src_package_name & dst_package_name
    if ("cpp" == context["language"]):
        context["src_package_name"] = "org.cocos2d-x.HelloCpp"
    elif ("lua" == context["language"]):
        context["src_package_name"] = "org.cocos2d-x.HelloLua"
    elif ("javascript" == context["language"]):
        context["src_package_name"] = "org.cocos2d-x.HelloJavascript"
    
    # rename files and folders
    os.rename(proj_path + context["src_project_name"] + ".xcodeproj",
              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" )

    # replaceString function is implemented in ../create-project.py
    import replaces
    # package_name should be replaced at first. Don't change this sequence
    replaces.replaceString(proj_path + "Info.plist",
                           context["src_package_name"], context["dst_package_name"])
    replaces.replaceString(proj_path + context["dst_project_name"] + ".xcodeproj/project.pbxproj",
                           context["src_project_name"], context["dst_project_name"])
    replaces.replaceString(proj_path + "Info.plist",
                           context["src_project_name"], context["dst_project_name"])

    # done!
    print "proj.ios         : Done!"
def handle_project_files(context):    
    # determine proj_path
    proj_path = context["dst_project_path"] + "/proj.blackberry/"
                        
    # replaceString function is implemented in ../create-project.py
    import replaces

    replaces.replaceString(proj_path + "bar-descriptor.xml", context["src_package_name"], context["dst_package_name"]) 
    
    replaces.replaceString(proj_path + ".cproject", context["src_project_name"], context["dst_project_name"]) 
    replaces.replaceString(proj_path + ".project",  context["src_project_name"], context["dst_project_name"])
    replaces.replaceString(proj_path + "bar-descriptor.xml",  context["src_project_name"], context["dst_project_name"])

    # done!
    print "proj.blackberry  : Done!"
def handle_project_files(context):    
    # determine proj_path
    proj_path = context["dst_project_path"] + "/proj.win32/"
                      
    # rename files and folders
    os.rename(proj_path + context["src_project_name"] + ".vcxproj",
              proj_path + context["dst_project_name"] + ".vcxproj")
    os.rename(proj_path + context["src_project_name"] + ".vcxproj.filters",
              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
    # package_name should be replaced at first. Don't change this sequence
    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!"
def handle_project_files(context):    
    # determine proj_path
    proj_path = context["dst_project_path"] + "/proj.linux/"
                        
    # replaceString function is implemented in ../create-project.py
    import replaces       
    replaces.replaceString(proj_path + ".cproject", context["src_project_name"], context["dst_project_name"]) 
    replaces.replaceString(proj_path + ".project",  context["src_project_name"], context["dst_project_name"])
    replaces.replaceString(proj_path + "Makefile",  context["src_project_name"], context["dst_project_name"])

    # done!
    print "proj.linux       : Done!"
def handle_project_files(context):    
    # determine proj_path
    proj_path = context["dst_project_path"] + "/proj.android/"
    
    # determine src_package_name & dst_package_name
    if ("cpp" == context["language"]):
        context["src_package_name"] = "org.cocos2dx.hellocpp"
    elif ("lua" == context["language"]):
        context["src_package_name"] = "org.cocos2dx.hellolua"
    elif ("javascript" == context["language"]):
        context["src_package_name"] = "org.cocos2dx.hellojavascript"
                  
    # rename files and folders
    src_pkg = context["src_package_name"].split('.')
    dst_pkg = context["dst_package_name"].split('.')

    os.rename(proj_path + "src/" + src_pkg[0],
              proj_path + "src/" + dst_pkg[0])
    os.rename(proj_path + "src/" + dst_pkg[0] + "/" + src_pkg[1],
              proj_path + "src/" + dst_pkg[0] + "/" + dst_pkg[1])
    os.rename(proj_path + "src/" + dst_pkg[0] + "/" + dst_pkg[1] + "/" + src_pkg[2],
              proj_path + "src/" + dst_pkg[0] + "/" + dst_pkg[1] + "/" + dst_pkg[2])
    os.rename(proj_path + "src/" + dst_pkg[0] + "/" + dst_pkg[1] + "/" + dst_pkg[2] + "/HelloJavascript.java",
              proj_path + "src/" + dst_pkg[0] + "/" + dst_pkg[1] + "/" + dst_pkg[2] + "/" + context["dst_project_name"] + ".java")

    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")

    # replaceString function is implemented in ../create-project.py
    import replaces
    # package_name should be replaced at first. Don't change this sequence
    replaces.replaceString(proj_path + "AndroidManifest.xml",   context["src_package_name"], context["dst_package_name"])
    replaces.replaceString(proj_path + "ndkgdb.sh",             context["src_package_name"], context["dst_package_name"])
    replaces.replaceString(dst_java_file_path,  context["src_package_name"], context["dst_package_name"])     
     
    replaces.replaceString(proj_path + ".project",              context["src_project_name"], context["dst_project_name"])
    replaces.replaceString(proj_path + "AndroidManifest.xml",   context["src_project_name"], context["dst_project_name"])
    replaces.replaceString(proj_path + "build.xml",             context["src_project_name"], context["dst_project_name"])
    replaces.replaceString(proj_path + "build_native.sh",       context["src_project_name"], context["dst_project_name"])
    replaces.replaceString(proj_path + "ndkgdb.sh",             context["src_project_name"], context["dst_project_name"])
    replaces.replaceString(proj_path + "res/values/strings.xml",context["src_project_name"], context["dst_project_name"])
    replaces.replaceString(dst_java_file_path,  context["src_project_name"], context["dst_project_name"])
    # done!
    print "proj.android     : Done!"
def handle_project_files(context):    
    # determine proj_path
    proj_path = context["dst_project_path"] + "/proj.android/"
                     
    # rename files and folders
    src_pkg = context["src_package_name"].split('.')
    dst_pkg = context["dst_package_name"].split('.')

    os.rename(proj_path + "src/" + src_pkg[0],
              proj_path + "src/" + dst_pkg[0])
    os.rename(proj_path + "src/" + dst_pkg[0] + "/" + src_pkg[1],
              proj_path + "src/" + dst_pkg[0] + "/" + dst_pkg[1])
    os.rename(proj_path + "src/" + dst_pkg[0] + "/" + dst_pkg[1] + "/" + src_pkg[2],
              proj_path + "src/" + dst_pkg[0] + "/" + dst_pkg[1] + "/" + dst_pkg[2])
    os.rename(proj_path + "src/" + dst_pkg[0] + "/" + dst_pkg[1] + "/" + dst_pkg[2] + "/" + context["src_project_name"] + ".java",
              proj_path + "src/" + dst_pkg[0] + "/" + dst_pkg[1] + "/" + dst_pkg[2] + "/" + context["dst_project_name"] + ".java")

    dst_java_file_path = proj_path + "src/" + dst_pkg[0] + "/" + dst_pkg[1] + "/" + dst_pkg[2] + "/" + context["dst_project_name"] + ".java"
      
    # remove useless files.
    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
    # package_name should be replaced at first. Don't change this sequence
    replaces.replaceString(proj_path + "AndroidManifest.xml",   context["src_package_name"], context["dst_package_name"])
    replaces.replaceString(dst_java_file_path,  context["src_package_name"], context["dst_package_name"])     
     
    replaces.replaceString(proj_path + ".project",              context["src_project_name"], context["dst_project_name"])
    replaces.replaceString(proj_path + "AndroidManifest.xml",   context["src_project_name"], context["dst_project_name"])
    replaces.replaceString(proj_path + "build.xml",             context["src_project_name"], context["dst_project_name"])
    replaces.replaceString(proj_path + "build_native.sh",       context["src_project_name"], context["dst_project_name"])
    replaces.replaceString(proj_path + "res/values/strings.xml",context["src_project_name"], context["dst_project_name"])
    replaces.replaceString(dst_java_file_path,  context["src_project_name"], context["dst_project_name"])
    # done!
    print "proj.android     : Done!"