Exemple #1
0
def getExportOptionsPlist():
    optionsDic = {
        Archive_Type_Key_AdHoc: "certificate/AdHocExportOptionsPlist.plist",
        Archive_Type_Key_AppStore:
        "certificate/AppStoreExportOptionsPlist.plist",
    }

    plistName = optionsDic[m_archiveType]
    curDir = FileUtils.getScriptDirectory()
    return os.path.join(curDir, plistName)
Exemple #2
0
def modifyLibsName(file_recorder, tmp_files):
    libs = [
        '../IM_SDK/ios/libYvImSdk.102j.a', '../IM_SDK/ios/libYvToolsManager.a',
        '../library.chat.ios/libchat.a',
        '../../libHall/prebuilt/ios/libhall IOS.a', 'ios/sdks/h5/libJXPApi.a',
        'ios/sdks/tracking/TrackingIO.a', 'ios/sdks/wechat/libWeChatSDK.a'
    ]
    projFilePath = getProjectConfigPath()
    for lib in libs:
        full_path = os.path.join(m_projectDir, lib)
        dir_name, file_name = os.path.split(full_path)
        base_name, ext = os.path.splitext(file_name)

        file_recorder.record_file(full_path)
        ts_str = datetime.datetime.fromtimestamp(
            time.time()).strftime('%Y%m%d%H%M%S')
        dst_file = '%s/%s-%s%s' % (dir_name, base_name, ts_str, ext)
        FileUtils.copyFile(full_path, dst_file)
        tmp_files.append(dst_file)

        Sed.replaceContent(file_name, os.path.basename(dst_file), projFilePath)
Exemple #3
0
def createNewProj(file_recorder, tmp_files):
    srcDir = os.path.join(m_projectDir, "../%s.xcodeproj" % m_projectName)
    dstDir = os.path.join(m_projectDir, "../%s.xcodeproj" % m_newProjName)
    FileUtils.copyDirctory(srcDir, dstDir)

    tmp_files.append(dstDir)

    # # 拷贝配置文件
    # srcFile = os.path.join(m_projectDir, "WeiLeProjV3-mobile.entitlements")
    # Common.assertExit(os.path.isfile(srcFile), "文件 %s 不存在" % srcFile)
    # dstFile = os.path.join(m_projectDir, "%s-mobile.entitlements" % m_newProjName)
    # FileUtils.copyFile(srcFile, dstFile)
    # tmp_files.append(dstFile)

    # 修改工程名字
    projFilePath = getProjectConfigPath()
    Sed.replaceContent(m_projectName, m_newProjName, projFilePath)

    # 移除临时文件
    for item in os.listdir(dstDir):
        full_path = os.path.join(dstDir, item)
        if full_path == projFilePath:
            continue

        if os.path.isdir(full_path):
            FileUtils.removeDirectory(full_path)
        elif os.path.isfile(full_path):
            FileUtils.removeFile(full_path)
Exemple #4
0
def modifyCocosMacros(file_recorder):
    curDir = FileUtils.getScriptDirectory()
    filepath = os.path.join(
        curDir, "../../frameworks/cocos2d-x/cocos/platform/CCPlatformMacros.h")
    file_recorder.record_file(filepath)

    cur_time_str = datetime.datetime.fromtimestamp(
        time.time()).strftime('%Y%m%d_%H%M%S')
    md5Hash = hashlib.md5(m_jsonObj["pkg_name"] + cur_time_str)
    md5Hashed = md5Hash.hexdigest()

    Sed.replaceContent("#define UINQUEID MYUINQUEID",
                       "#define UINQUEID " + md5Hashed, filepath)
Exemple #5
0
def modifyGetuiId(file_recorder):
    curDir = FileUtils.getScriptDirectory()
    filepath = os.path.join(
        curDir,
        "../../frameworks/runtime-src/proj.ios_mac/ios/AppController.mm")
    # file_recorder.record_file(filepath)

    target_str = r'getuiAppId = @\"%s\"' % m_jsonObj["getui_appId"]
    Sed.replaceContent(r'getuiAppId = @\".*\"', target_str, filepath)
    target_str = r'getuiAppKey = @\"%s\"' % m_jsonObj["getui_appKey"]
    Sed.replaceContent(r'getuiAppKey = @\".*\"', target_str, filepath)
    target_str = r'getuiAppSecret = @\"%s\"' % m_jsonObj["getui_appSecret"]
    Sed.replaceContent(r'getuiAppSecret = @\".*\"', target_str, filepath)
Exemple #6
0
def loadConfig():
    global m_appPath
    global m_jsonObj

    Common.assertExit(len(sys.argv[1:]) != 0, "请传入配置文件绝对路径")
    Common.assertExit(os.path.isdir(sys.argv[1]), "传入参数文件夹不存在")
    m_appPath = sys.argv[1]

    configPath = FileUtils.getAbsolutePath("config.json")
    m_jsonObj = JsonObj()
    m_jsonObj.loadFromFilePath(configPath)

    Common.assertExit(Common.isArrayType(m_jsonObj[kGames]), "必须设置参数games")
    Common.assertExit(m_jsonObj[kCfgFiles], "必须设置参数cfg_files")
    Common.assertExit(m_jsonObj[kPkgName], "必须设置参数pkg_name")
    Common.assertExit(m_jsonObj[kRegion], "必须设置参数region")
Exemple #7
0
def addH5PaySupport(file_recorder):
    curDir = FileUtils.getScriptDirectory()

    # 修改代码
    codePath = os.path.join(
        curDir,
        "../../frameworks/runtime-src/proj.ios_mac/ios/sdks/SdkManager.mm")
    file_recorder.record_file(codePath)

    f = open(codePath)
    content = f.read()
    f.close()
    content = content.replace('//#import "JXPApi.h"', '#import "JXPApi.h"')
    content = content.replace('// [JXPApi PApiRequestURL',
                              '[JXPApi PApiRequestURL')
    f = open(codePath, 'w')
    f.write(content)
    f.close()

    # 修改 xcode 工程
    projPath = getProjectConfigPath()
    file_recorder.record_file(projPath)

    sys.path.append(os.path.join(os.path.dirname(__file__), 'obscure'))
    from modify_pbxproj import XcodeProject
    pbx_obj = XcodeProject.Load(projPath)
    h5Folder = os.path.join(
        curDir, "../../frameworks/runtime-src/proj.ios_mac/ios/sdks/h5")

    iosGroup = pbx_obj.get_or_create_group('ios')
    sdkGroup = pbx_obj.get_or_create_group('sdks', parent=iosGroup)
    h5Group = pbx_obj.get_or_create_group('h5', parent=sdkGroup)

    for f in os.listdir(h5Folder):
        fullPath = os.path.join(h5Folder, f)
        name, ext = os.path.splitext(fullPath)
        if ext == '.h' or ext == '.a':
            pbx_obj.add_file_if_doesnt_exist(fullPath,
                                             parent=h5Group,
                                             target='%s-mobile' %
                                             m_newProjName)

    if pbx_obj.modified:
        pbx_obj.save()
Exemple #8
0
def copyConfigFile(file_recorder):
    targetConfigFile = FileUtils.getAbsolutePath("./shell_script/config.json")
    file_recorder.record_file(targetConfigFile)
    FileUtils.copyFile(m_configPath, targetConfigFile)

    configDir = FileUtils.getFileDirectory(m_configPath)
    sourceCfgDir = os.path.join(configDir, "cfg")
    Common.assertExit(os.path.isdir(sourceCfgDir),
                      "cfg配置文件夹不存在" + sourceCfgDir)

    # 检查 cfg_package 中是否定义了 APPLE_ID
    cfg_pkg_file = os.path.join(sourceCfgDir, "cfg_package.lua")
    Common.assertExit(os.path.isfile(cfg_pkg_file),
                      "cfg配置文件夹中不存在 cfg_package 文件")
    f = open(cfg_pkg_file)
    content = f.read()
    f.close()
    if content.find("APPLE_ID") == -1:
        Common.assertExit(False, "cfg_package 中未配置 APPLE_ID ")

    targetCfgDir = FileUtils.getAbsolutePath("./shell_script/cfg")
    file_recorder.record_folder(targetCfgDir)
    FileUtils.replaceCopyDirctory(sourceCfgDir, targetCfgDir)
Exemple #9
0
def getIpaDir():
    if m_outputPath is not None:
        return m_outputPath

    return os.path.join(FileUtils.getDesktopPath(), "Package")
Exemple #10
0
def createIpaDir():
    ipaDir = getIpaDir()
    FileUtils.createDirectory(ipaDir)
Exemple #11
0
        # 修改Bundle Id
        modifyBundleId()

        # 清理目标工程
        cleanTarget()

        # 更新exportOptionsPlist配置
        refreshExportOptionsPlist(file_recorder)

        # 编译工程
        buildTarget()

        # 打成ipa包
        createIPA()
    except:
        pass
    finally:
        # file_recorder.do_rollback()

        for item in tmp_files:
            if os.path.isfile(item):
                FileUtils.removeFile(item)
            elif os.path.isdir(item):
                FileUtils.removeDirectory(item)
            else:
                print("%s 不是文件/文件夹,删除失败" % item)

        # output the spend time
        end_time = time.time()
        print('\n总共用时: %.2f 秒\n' % (end_time - begin_time))
Exemple #12
0
def loadConfig():
    global m_projectDir
    global m_infoPlistPath
    global m_notify_info_plist_path
    global m_projectName
    global m_schemeName
    global m_versionName
    global m_buildName
    global m_newDisplayName
    global m_newBundleId
    global m_newNotifyBundleId
    global m_archiveType
    global m_profilePath
    global m_notifProfilePath
    global m_configPath
    global m_jsonObj
    global m_outputPath
    global m_games
    global m_newProjName
    global m_newSchemeName
    global m_isNoDingXiang  # 是否不使用顶象加固

    Common.assertExit(len(sys.argv[1:]) != 0, "请传入配置文件绝对路径")
    Common.assertExit(os.path.isfile(sys.argv[1]), "传入参数文件不存在")
    m_configPath = sys.argv[1]

    # print "使用测试配置"
    # m_configPath = "/Users/weile/Desktop/SVN/tools/PackIOS/proj_template/config.json"

    m_jsonObj.loadFromFilePath(m_configPath)

    m_isNoDingXiang = m_jsonObj["isNoDingXiang"]

    m_projectDir = getAbspath("project_dir")
    m_infoPlistPath = getAbspath("info_plist_path")

    m_notify_info_plist_path = FileUtils.getAbsoluteFromPath(
        m_projectDir, "notificationService/Info.plist")

    m_archiveType = m_jsonObj["archive_type"]
    Common.assertExit(m_archiveType == 'AdHoc' or m_archiveType == 'AppStore',
                      "archive_type参数只能是AdHoc和AppStore")
    paths = {
        Archive_Type_Key_AdHoc: getAbspath("profile_path_AdHoc"),
        Archive_Type_Key_AppStore: getAbspath("profile_path_AppStore"),
    }
    m_profilePath = paths[m_archiveType]
    Common.assertExit(os.path.isfile(m_profilePath), "配置证书文件不存在,请检查配置")

    notifyPaths = {
        Archive_Type_Key_AdHoc: getAbspath("notifProfile_path_AdHoc"),
        Archive_Type_Key_AppStore: getAbspath("notifProfile_path_AppStore"),
    }
    m_notifProfilePath = notifyPaths[m_archiveType]
    Common.assertExit(os.path.isfile(m_notifProfilePath),
                      "NotificationService证书文件不存在,请检查配置")

    m_projectName = m_jsonObj["project_name"]
    m_schemeName = m_jsonObj["scheme_name"]
    m_versionName = m_jsonObj["version_name"]
    m_buildName = m_jsonObj["build_name"]
    m_newDisplayName = m_jsonObj["game_name"]
    m_newBundleId = m_jsonObj["pkg_name"]
    m_newNotifyBundleId = m_newBundleId + ".notifyService"
    m_games = m_jsonObj["games"]
    m_newProjName = m_jsonObj["proj_name_new"]

    Common.assertExit(m_jsonObj["app_scheme"], "必须配置app_scheme参数")
    Common.assertExit(m_jsonObj["weixin_id"], "必须配置weixin_id参数")
    Common.assertExit(m_newProjName, "必须配置 proj_name_new 参数")
    Common.assertExit(m_projectName != m_newProjName,
                      "proj_name_new 与 project_name 的值不能相同")

    m_newSchemeName = "%s-mobile" % m_newProjName

    if m_jsonObj["track_id"] is None:
        # track_id 必须配置。如果配置为空字符串,效果与不集成热云 SDK 一致
        Common.assertExit(False, "必须配置track_id参数,请联系商务获取热云的 app key")
    if (not m_jsonObj["getui_appId"] or not m_jsonObj["getui_appKey"]
            or not m_jsonObj["getui_appSecret"]
        ) and m_jsonObj["turnOffPush"] != "1":
        # getui 必须配置。如不需要getui需要在config.json文件里添加"turnOffPush": "1"
        Common.assertExit(False, "必须配置getui参数,个推后台获取")

    Common.assertExit(m_jsonObj["region"],
                      '必须配置region参数,值为地区码字符串。如:"region":"23"')
    Common.assertExit(m_jsonObj["build_name"], "必须配置build_name参数")

    if m_jsonObj["output"]:
        m_outputPath = getAbspath("output")
    else:
        m_outputPath = None
Exemple #13
0
def copyLaunchImages(file_recorder):
    sourceDir = getAbspath("launch_iamge_source")
    targetDir = getAbspath("launch_iamge_target")
    file_recorder.record_folder(targetDir)
    FileUtils.copyDirctory(sourceDir, targetDir)
Exemple #14
0
def copyIcons(file_recorder):
    sourceDir = getAbspath("icons_source")
    targetDir = os.path.join(m_projectDir,
                             'ios/Images.xcassets/AppIcon.appiconset')
    file_recorder.record_folder(targetDir)
    FileUtils.copyDirctory(sourceDir, targetDir)
Exemple #15
0
# -*- coding: UTF-8 -*-
#!/usr/bin/python
#coding:utf-8
import os
import sys

sys.path.append('../')
sys.path.append(os.path.dirname(os.path.dirname(__file__)))
from python_libs.FileUtils import FileUtils

if __name__ == "__main__":
    pythonDir = FileUtils.getAbsolutePath("..")
    pythonPath = os.path.join(pythonDir, "main.py")

    configDir = FileUtils.getScriptDirectory()
    configPath = os.path.join(configDir, "config.json")
    cmd = "python " + pythonPath + " " + configPath

    os.system(cmd)