Ejemplo n.º 1
0
    def _get_pro_build_config(self):
        # 指定项目地址
        params = {}

        params[ProjectBuilder.JPUSH_APPKEY_FLAG] = self.ori_build_config[build_base.BuildConfigParser.JPUSH_APPKEY_FLAG]
        params[ProjectBuilder.ENV_MODE_FLAG] = \
            self.ori_build_config[build_base.BuildConfigParser.ENV_FLAG][build_base.BuildConfigParser.MAP_FLAG][
                self.ver_env]

        # 将时间格式化
        curr_time = time.localtime()
        time_str = time.strftime('%Y%m%d_%H%M%S', curr_time)

        output_directory = self.work_path + os.sep + self.ori_build_config[build_base.BuildConfigParser.WORKSPACE_FLAG][
            build_base.BuildConfigParser.TARGET_PATH_FLAG]
        output_directory = file_util.normalpath(output_directory)
        output_directory = output_directory + os.sep + self.ver_env + os.sep + time_str
        params[build_base.ProjectBuilder.OUTPUT_DIRECTORY_FLAG] = output_directory

        self.output_directory = params[build_base.ProjectBuilder.OUTPUT_DIRECTORY_FLAG]

        params[build_base.ProjectBuilder.VER_NAME_FLAG] = self.ver_name
        params[build_base.ProjectBuilder.VER_CODE_FLAG] = self.ver_code
        params[build_base.ProjectBuilder.ENV_FLAG] = self.ori_build_config[build_base.BuildConfigParser.ENV_FLAG]

        # 获取加固配置信息
        params[ProjectBuilder.PROTECT_FLAG] = self.ori_build_config[build_base.BuildConfigParser.PROTECT_FLAG]
        is_need_infos = params[ProjectBuilder.PROTECT_FLAG][ProjectBuilder.IS_NEED_FLAG]
        for k in is_need_infos:
            is_need_infos[k] = str_util.get_bool(is_need_infos[k])
        params[ProjectBuilder.SIGNER_FLAG] = self.ori_build_config[build_base.BuildConfigParser.SIGNER_FLAG]

        # 指定输出归档文件地址
        date_str = time.strftime('%Y%m%d', curr_time)

        if self.is_debug:
            mode_flag = apk_builder.DEBUG_FLAG

            # 指定输出apk名称
            params[build_base.ProjectBuilder.OUTPUT_NAME_FLAG] = "{}-{}-{}-{}.apk".format(self.ver_name, self.ver_code,
                                                                                          mode_flag, date_str)
        else:
            mode_flag = apk_builder.RELEASE_FLAG

            # 指定输出apk名称
            params[build_base.ProjectBuilder.OUTPUT_NAME_FLAG] = "{}-{}-{}.apk".format(self.ver_name, self.ver_code,
                                                                                       date_str)

        params[build_base.ProjectBuilder.TYPE_FLAG] = mode_flag
        self.apk_output_path = params[build_base.ProjectBuilder.OUTPUT_DIRECTORY_FLAG] + os.sep + params[
            build_base.ProjectBuilder.OUTPUT_NAME_FLAG]

        pprint.pprint(params)

        return params
Ejemplo n.º 2
0
    def _get_whole_ver_name(self, beta_label_map, label_map):
        beta_label = 'beta'
        ver_no_label = ''

        # 确定是否要展示beta标签
        beta_label_switch = str_utils.get_bool(beta_label_map[self.env_mode])
        if not beta_label_switch:
            beta_label = ''
        else:
            ver_no_label = '_{:02d}'.format(self.ver_no)

        # 确定是否要展示标识环境的标签
        net_env_label = ''
        env_label = label_map[self.ver_env]
        if env_label:
            net_env_label = '_{}'.format(env_label)

        whole_ver_name = '{}{}{}{}'.format(self.ver_name, beta_label, net_env_label, ver_no_label)
        return whole_ver_name
Ejemplo n.º 3
0
    def _get_pro_build_config(self):
        # 指定项目地址
        params = dict()

        params[BuilderLabel.PRJ_ROOT_FLAG] = self.prj_root
        params[BuilderLabel.MAIN_FLAG] = self.ori_build_config[BuildConfigLabel.WORKSPACE_FLAG][
            BuildConfigLabel.MAIN_FLAG]

        params[BuilderLabel.CHANNEL_FLAG] = self.channel

        params[BuilderLabel.NET_ENV_FLAG] = self.ver_env
        params[BuilderLabel.ENV_MODE_FLAG] = \
            self.ori_build_config[BuildConfigLabel.ENV_FLAG][BuildConfigLabel.MAP_FLAG][self.ver_env]
        self.env_mode = params[BuilderLabel.ENV_MODE_FLAG]
        params[BuilderLabel.ARM64_FLAG] = self.is_arm64
        params[BuilderLabel.FOR_GOOGLE_FLAG] = self.for_google
        params[BuilderLabel.JPUSH_APPKEY_FLAG] = self.jpush_appkey
        
        # 获取网络api version配置信息
        if BuildConfigLabel.API_VER_FLAG in self.ori_build_config[BuildConfigLabel.ENV_FLAG]:
            self.api_ver_config = self.ori_build_config[BuildConfigLabel.ENV_FLAG][BuildConfigLabel.API_VER_FLAG]

        # 获取加固配置信息
        params[BuilderLabel.PROTECT_FLAG] = self.ori_build_config[BuildConfigLabel.PROTECT_FLAG]
        is_need_infos = params[BuilderLabel.PROTECT_FLAG][BuilderLabel.IS_NEED_FLAG]
        for k in is_need_infos:
            is_need_infos[k] = str_utils.get_bool(is_need_infos[k])

        params[BuilderLabel.SIGNER_FLAG] = self.ori_build_config[BuildConfigLabel.SIGNER_FLAG]
        params[BuilderLabel.COVERAGE_FLAG] = self.ori_build_config[BuildConfigLabel.COVERAGE_FLAG]

        # 将时间格式化
        curr_time = time.localtime()
        time_str = time.strftime('%Y%m%d_%H%M%S', curr_time)

        output_directory = os.path.join(self.work_path, self.ori_build_config[BuildConfigLabel.WORKSPACE_FLAG][
            BuildConfigLabel.TARGET_PATH_FLAG])
        output_directory = file_util.normalpath(output_directory)
        self.curr_env_output_root = os.path.join(output_directory, self.ver_env)
        output_directory = os.path.join(output_directory, self.ver_env, time_str)
        params[BuilderLabel.OUTPUT_DIRECTORY_FLAG] = output_directory

        self.output_directory = params[BuilderLabel.OUTPUT_DIRECTORY_FLAG]

        params[BuilderLabel.VER_NAME_FLAG] = self.ver_name
        params[BuilderLabel.VER_CODE_FLAG] = self.ver_code
        params[BuilderLabel.VER_NO_FLAG] = self.ver_no
        params[BuilderLabel.API_VER_FLAG] = self.api_ver
        params[BuilderLabel.APP_CODE_FLAG] = self.app_code
        params[BuilderLabel.IS_TEST_FLAG] = self.is_test

        params[BuilderLabel.ENV_FLAG] = self.ori_build_config[BuildConfigLabel.ENV_FLAG]

        params[BuilderLabel.APP_NAME_FLAG] = self.app_name
        params[BuilderLabel.DEMO_LABEL_FLAG] = self.demo_label

        # 指定输出归档文件地址
        date_str = time.strftime('%Y%m%d', curr_time)

        label_map = self.ori_build_config[BuildConfigLabel.ENV_FLAG][BuildConfigLabel.LABEL_FLAG]
        beta_label_map = self.ori_build_config[BuildConfigLabel.ENV_FLAG][BuildConfigLabel.BETA_LABEL_FLAG]
        self.whole_ver_name = self._get_whole_ver_name(beta_label_map, label_map)
        if self.is_debug:
            mode_flag = apk_builder.DEBUG_FLAG

            # 指定输出apk名称
            params[BuilderLabel.OUTPUT_NAME_FLAG] = "{}-{}-{}-{}.apk".format(self.whole_ver_name, self.ver_code,
                                                                             mode_flag,
                                                                             date_str)
        else:
            mode_flag = apk_builder.RELEASE_FLAG

            # 指定输出apk名称
            params[BuilderLabel.OUTPUT_NAME_FLAG] = "{}-{}-{}.apk".format(self.whole_ver_name, self.ver_code, date_str)

        params[BuilderLabel.TYPE_FLAG] = mode_flag
        self.apk_output_path = os.path.join(params[BuilderLabel.OUTPUT_DIRECTORY_FLAG],
                                            params[BuilderLabel.OUTPUT_NAME_FLAG])

        pprint.pprint(params)

        return params