Exemple #1
0
def getAbspath(key):
    Common.assertExit(m_jsonObj[key], "config配置文件缺少参数key=" + key)

    if os.path.isabs(m_jsonObj[key]):
        return m_jsonObj[key]

    configDir = FileUtils.getFileDirectory(m_configPath)
    return FileUtils.getAbsoluteFromPath(configDir, m_jsonObj[key])
Exemple #2
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