diff --git a/include/codec_config/syscap_define.h b/include/codec_config/syscap_define.h index 1e42cbd..6742934 100644 --- a/include/codec_config/syscap_define.h +++ b/include/codec_config/syscap_define.h @@ -343,6 +343,11 @@ typedef enum SystemCapabilityNum { RESOURCESCHEDULE_SYSTEMLOAD, MSDP_MULTIMODAL_AWARENESS, ABILITY_APP_STARTUP, + MULTIMEDIA_AVSESSION_EXTENDEDDISPLAYCAST, + MULTIMODALINPUT_INPUT_INFRAREDEMITTER, + MULTIMEDIA_MEDIA_AVTRANSCODER, + MULTIMEDIA_IMAGEEFFECT_CORE, + DRIVER_DDK_EXTENSION, // Add before here SYSCAP_BASIC_END = 500, } SyscapNum; @@ -596,6 +601,7 @@ const static SyscapWithNum g_arraySyscap[] = { {"SystemCapability.Multimedia.AVSession.Core", MULTIMEDIA_AVSESSION_CORE}, {"SystemCapability.Multimedia.AVSession.Manager", MULTIMEDIA_AVSESSION_MANAGER}, {"SystemCapability.Multimedia.AVSession.AVCast", MULTIMEDIA_AVSESSION_AVCAST}, + {"SystemCapability.Multimedia.AVSession.ExtendedDisplayCast", MULTIMEDIA_AVSESSION_EXTENDEDDISPLAYCAST}, {"SystemCapability.Multimedia.Audio.Tone", MULTIMEDIA_AUDIO_TONE}, {"SystemCapability.Multimedia.Audio.Interrupt", MULTIMEDIA_AUDIO_INTERRUPT}, {"SystemCapability.Cloud.AAID", CLOUD_AAID}, @@ -668,7 +674,11 @@ const static SyscapWithNum g_arraySyscap[] = { {"SystemCapability.Resourceschedule.Ffrt.Core", RESOURCESCHEDULE_FFRT_CORE}, {"SystemCapability.AI.MindSporeLite", AI_MINDSPORELITE}, {"SystemCapability.Ability.AppStartup", ABILITY_APP_STARTUP}, + {"SystemCapability.Multimedia.Media.AVTransCoder", MULTIMEDIA_MEDIA_AVTRANSCODER}, {"SystemCapability.Base", BASE}, + {"SystemCapability.MultimodalInput.Input.InfraredEmitter", MULTIMODALINPUT_INPUT_INFRAREDEMITTER}, + {"SystemCapability.Multimedia.ImageEffect.Core", MULTIMEDIA_IMAGEEFFECT_CORE}, + {"SystemCapability.Driver.DDK.Extension", DRIVER_DDK_EXTENSION}, }; #ifdef __cplusplus diff --git a/interfaces/inner_api/syscap_interface.c b/interfaces/inner_api/syscap_interface.c index b407613..e7e32bb 100644 --- a/interfaces/inner_api/syscap_interface.c +++ b/interfaces/inner_api/syscap_interface.c @@ -57,7 +57,7 @@ typedef struct ProductCompatibilityID { uint8_t osSyscap[OS_SYSCAP_BYTES]; } PCIDMain; -static const char *g_pcidPath = "/system/etc/pcid.sc"; +static const char *PCID_PATH = "/system/etc/pcid.sc"; struct FreeAfterDecodeRpcidInfo { char *priSyscap; @@ -89,7 +89,7 @@ bool EncodeOsSyscap(char *output, int len) return false; } - ret = GetFileContext(g_pcidPath, &contextBuffer, &bufferLen); + ret = GetFileContext(PCID_PATH, &contextBuffer, &bufferLen); if (ret != 0) { PRINT_ERR("GetFileContext failed, input file : /system/etc/pcid.sc\n"); return false; @@ -113,12 +113,16 @@ bool EncodePrivateSyscap(char **output, int *outputLen) char *outputStr = NULL; uint32_t bufferLen; - ret = GetFileContext(g_pcidPath, &contextBuffer, &bufferLen); + ret = GetFileContext(PCID_PATH, &contextBuffer, &bufferLen); if (ret != 0) { PRINT_ERR("GetFileContext failed, input file : /system/etc/pcid.sc\n"); return false; } + if (bufferLen < (PCID_MAIN_BYTES + 1) || bufferLen > INT32_MAX) { + PRINT_ERR("Parameter bufferLen out of range."); + return false; + } uint32_t priLen = bufferLen - PCID_MAIN_BYTES - 1; if ((int)priLen <= 0) { *outputLen = 0; @@ -177,18 +181,19 @@ bool DecodeOsSyscap(const char input[PCID_MAIN_BYTES], char (**output)[SINGLE_SY for (i = 0; i < countOfSyscap; i++) { for (j = 0; j < sizeof(g_arraySyscap) / sizeof(SyscapWithNum); j++) { - if (g_arraySyscap[j].num == indexOfSyscap[i]) { - nRet = strcpy_s(*strSyscap, SINGLE_SYSCAP_LEN, g_arraySyscap[j].str); - if (nRet != EOK) { - printf("strcpy_s failed. error = %d\n", nRet); - *outputCnt = 0; - free(strSyscap); - strSyscap = NULL; - return false; - } - strSyscap++; - break; + if (g_arraySyscap[j].num != indexOfSyscap[i]) { + continue; } + nRet = strcpy_s(*strSyscap, SINGLE_SYSCAP_LEN, g_arraySyscap[j].str); + if (nRet != EOK) { + printf("strcpy_s failed. error = %d\n", nRet); + *outputCnt = 0; + free(strSyscap); + strSyscap = NULL; + return false; + } + strSyscap++; + break; } } @@ -316,8 +321,6 @@ static int32_t ParseRpcidToJson(char *input, uint32_t inputLen, cJSON *rpcidJson ret = -1; goto FREE_SYSCAP_OUT; } - - return 0; FREE_SYSCAP_OUT: cJSON_Delete(sysCapJson); return ret; @@ -344,6 +347,7 @@ static int32_t TransStringFormatAndSaveSyscap(struct FreeAfterDecodeRpcidInfo fr PRINT_ERR("malloc failed.\n"); return -1; } + free(freeAfterDecodeRpcidInfo.osSysCapIndex); return 0; } @@ -521,6 +525,9 @@ static int32_t CopySyscopToRet(struct PcidPriSyscapInfo *pcidPriSyscapInfo, cons break; } } + if(t == allSyscapNum){ + return -1; + } pcidPriSyscapInfo->ret = strcpy_s(tempSyscap, sizeof(char) * SINGLE_SYSCAP_LEN, g_arraySyscap[t].str); // 2, header of pcid & rpcid if (pcidPriSyscapInfo->ret != EOK) { diff --git a/src/create_pcid.c b/src/create_pcid.c index 8f37087..5176caf 100644 --- a/src/create_pcid.c +++ b/src/create_pcid.c @@ -222,7 +222,7 @@ static int32_t CheckConvertedContextSaveAsFile(char *outDirPath, PCIDMain *pcidB } static int32_t FreeAfterCreatePCID(PCIDMain *pcidBuffer, cJSON *allOsSyscapObj, char *contextBuffer, - int32_t type, int32_t ret) + int32_t type, int32_t ret) { if (type == FREE_CREATE_PCID_BUFFER_OUT) { free(pcidBuffer); @@ -232,6 +232,13 @@ static int32_t FreeAfterCreatePCID(PCIDMain *pcidBuffer, cJSON *allOsSyscapObj, return ret; } +static int32_t PreFreeAfterCreatePCID(PCIDMain *pcidBuffer, cJSON *allOsSyscapObj, cJSON *jsonRootObj, + char *contextBuffer, int32_t type) +{ + cJSON_Delete(jsonRootObj); + return FreeAfterCreatePCID(pcidBuffer, allOsSyscapObj, contextBuffer, type, -1); +} + int32_t CreatePCID(char *inputFile, char *outDirPath) { uint32_t privateCapSize, osCapSize; @@ -248,33 +255,33 @@ int32_t CreatePCID(char *inputFile, char *outDirPath) cJSON *jsonRootObj = cJSON_ParseWithLength(contextBuffer, contextBufLen); if (jsonRootObj == NULL) { PRINT_ERR("cJSON_Parse failed, context buffer is:\n%s\n", contextBuffer); - return FreeAfterCreatePCID(NULL, allOsSyscapObj, contextBuffer, 0, -1); + return PreFreeAfterCreatePCID(NULL, allOsSyscapObj, jsonRootObj, contextBuffer, 0); } cJSON *jsonSyscapObj = cJSON_GetObjectItem(jsonRootObj, "syscap"); if (jsonSyscapObj == NULL || !cJSON_IsObject(jsonSyscapObj)) { PRINT_ERR("get \"syscap\" object failed\n"); - return FreeAfterCreatePCID(NULL, allOsSyscapObj, contextBuffer, 0, -1); + return PreFreeAfterCreatePCID(NULL, allOsSyscapObj, jsonRootObj, contextBuffer, 0); } cJSON *jsonOsSyscapObj = cJSON_GetObjectItem(jsonSyscapObj, "os"); cJSON *jsonPriSyscapObj = cJSON_GetObjectItem(jsonSyscapObj, "private"); ret = GetOsAndPriSyscapSize(jsonOsSyscapObj, jsonPriSyscapObj, &osCapSize, &privateCapSize); if (ret != 0) { - return FreeAfterCreatePCID(NULL, allOsSyscapObj, contextBuffer, 0, ret); + return PreFreeAfterCreatePCID(NULL, allOsSyscapObj, jsonRootObj, contextBuffer, 0); } uint16_t allPriSyscapStrLen = 0; ret = GetPriSyscapLen(privateCapSize, jsonPriSyscapObj, &allPriSyscapStrLen); if (ret != 0) { - return FreeAfterCreatePCID(NULL, allOsSyscapObj, contextBuffer, 0, ret); + return PreFreeAfterCreatePCID(NULL, allOsSyscapObj, jsonRootObj, contextBuffer, 0); } uint16_t pcidLength = sizeof(PCIDMain) + allPriSyscapStrLen + 1; PCIDMain *pcidBuffer = (PCIDMain *)malloc(pcidLength); if (pcidBuffer == NULL) { PRINT_ERR("malloc for pcid buffer failed\n"); - return FreeAfterCreatePCID(NULL, allOsSyscapObj, contextBuffer, 0, -1); + return PreFreeAfterCreatePCID(NULL, allOsSyscapObj, jsonRootObj, contextBuffer, 0); } (void)memset_s(pcidBuffer, pcidLength, 0, pcidLength); @@ -282,10 +289,12 @@ int32_t CreatePCID(char *inputFile, char *outDirPath) ret += SetPriSyscap(pcidBuffer, jsonPriSyscapObj, privateCapSize, allPriSyscapStrLen); ret += SetPCIDHeader(pcidBuffer, jsonRootObj); if (ret != 0) { - return FreeAfterCreatePCID(pcidBuffer, allOsSyscapObj, contextBuffer, FREE_CREATE_PCID_BUFFER_OUT, ret); + return PreFreeAfterCreatePCID(pcidBuffer, allOsSyscapObj, jsonRootObj, contextBuffer, + FREE_CREATE_PCID_BUFFER_OUT); } ret = CheckConvertedContextSaveAsFile(outDirPath, pcidBuffer, pcidLength, ret); + cJSON_Delete(jsonRootObj); return FreeAfterCreatePCID(pcidBuffer, allOsSyscapObj, contextBuffer, FREE_CREATE_PCID_BUFFER_OUT, ret); } @@ -305,6 +314,7 @@ int32_t GetOsSyscap(PCIDMain *pcidMain, cJSON *sysCapObject) errno_t nRet = memcpy_s(osSyscap, OS_SYSCAP_BYTES, (uint8_t *)pcidMain + 8, OS_SYSCAP_BYTES); if (nRet != EOK) { PRINT_ERR("memcpy_s failed."); + cJSON_Delete(capVectorPtr); return -1; } @@ -335,6 +345,12 @@ int32_t GetOsSyscap(PCIDMain *pcidMain, cJSON *sysCapObject) return 0; } +static int32_t GetPriSyscapResult(cJSON* capVectorPtr, int32_t ret) +{ + cJSON_Delete(capVectorPtr); + return ret; +} + int32_t GetPriSyscap(PCIDMain *pcidMain, cJSON *sysCapObject, size_t contextBufLen) { cJSON *capVectorPtr = cJSON_CreateArray(); @@ -343,12 +359,17 @@ int32_t GetPriSyscap(PCIDMain *pcidMain, cJSON *sysCapObject, size_t contextBufL return -1; } + if (contextBufLen < 0 || contextBufLen > UINT32_MAX) { + PRINT_ERR("the data privateSyscapLen is out of scope."); + return GetPriSyscapResult(capVectorPtr, -1); + } + int32_t privateSyscapLen = (int32_t)(contextBufLen - sizeof(PCIDMain) - 1); - if (privateSyscapLen < 0) { + if (privateSyscapLen < 0 || privateSyscapLen > INT32_MAX) { PRINT_ERR("parse private syscap failed."); - return -1; + return GetPriSyscapResult(capVectorPtr, -1); } else if (privateSyscapLen == 0) { - return 0; + return GetPriSyscapResult(capVectorPtr, 0); } char fullCapStr[SINGLE_SYSCAP_LEN] = {0}; @@ -361,11 +382,11 @@ int32_t GetPriSyscap(PCIDMain *pcidMain, cJSON *sysCapObject, size_t contextBufL int32_t ret = sprintf_s(fullCapStr, SINGLE_SYSCAP_LEN, "SystemCapability.%s", priSyscapStr); if (ret == -1) { printf("sprintf_s failed\n"); - return -1; + return GetPriSyscapResult(capVectorPtr, -1); } if (!cJSON_AddItemToArray(capVectorPtr, cJSON_CreateString(fullCapStr))) { printf("cJSON_AddItemToArray or cJSON_CreateString failed\n"); - return -1; + return GetPriSyscapResult(capVectorPtr, -1); } tempPriSyscapStr = priSyscapStr; ptrPrivateSyscap++; @@ -375,9 +396,8 @@ int32_t GetPriSyscap(PCIDMain *pcidMain, cJSON *sysCapObject, size_t contextBufL } if (!cJSON_AddItemToObject(sysCapObject, "private", capVectorPtr)) { PRINT_ERR("cJSON_AddItemToObject failed\n"); - return -1; + return GetPriSyscapResult(capVectorPtr, -1); } - return 0; } @@ -507,6 +527,7 @@ int32_t DecodePCID(char *inputFile, char *outDirPath) if (ret != 0) { PRINT_ERR("ConvertedContextSaveAsFile failed, outDirPath:%s, filename:%s\n", outDirPath, outputFileName); } + free(strJson); return FreeAfterDecodePCID(freePcidJsonInfo, FREE_DECODE_PCID_CONVERT_OUT, ret); } @@ -643,9 +664,10 @@ static int32_t AddPriSyscapToJsonObj(char *priSyscapString, uint32_t priSyscapSt if (priSyscapStringLen == 0) { if (!cJSON_AddItemToObject(sysCapObj, "private", sysCapArray)) { PRINT_ERR("Add private syscap array to json failed.\n"); - free(sysCapArray); + cJSON_Delete(sysCapArray); return -1; } + cJSON_Delete(sysCapArray); return 0; } @@ -653,37 +675,48 @@ static int32_t AddPriSyscapToJsonObj(char *priSyscapString, uint32_t priSyscapSt while (token != NULL) { if (!cJSON_AddItemToArray(sysCapArray, cJSON_CreateString(token))) { PRINT_ERR("Add private syscap string to json failed.\n"); - free(sysCapArray); + cJSON_Delete(sysCapArray); return -1; } token = strtok(NULL, ","); } if (!cJSON_AddItemToObject(sysCapObj, "private", sysCapArray)) { PRINT_ERR("Add private syscap array to json failed.\n"); - free(sysCapArray); + cJSON_Delete(sysCapArray); return -1; } return 0; } +static int32_t GetSyscapStr(char *input, char const *priSyscapStr, uint32_t* osSyscap, uint32_t *pcidHeader) +{ + char *ctx = NULL; + uint32_t fileContextLen; + if (GetFileContext(input, &ctx, (uint32_t *)&fileContextLen) != 0) { + PRINT_ERR("GetFileContext failed, input file : %s\n", input); + free(ctx); + return -1; + } + if (ParseStringSyscap(ctx, osSyscap, OS_SYSCAP_NUM, pcidHeader, PCID_HEADER) != 0) { + PRINT_ERR("Parse string syscap failed.\n"); + free(ctx); + return -1; + } + priSyscapStr = ctx; + free(ctx); + return 0; +} + int32_t DecodeStringPCIDToJson(char *input, char *outDirPath) { int32_t ret = -1; uint32_t osSyscap[OS_SYSCAP_NUM] = {0}; uint32_t pcidHeader[PCID_HEADER]; - uint32_t fileContextLen; - char *ctx = NULL; char *priSyscapStr = NULL; - - if (GetFileContext(input, &ctx, (uint32_t *)&fileContextLen) != 0) { - PRINT_ERR("GetFileContext failed, input file : %s\n", input); - goto PARSE_FAILED; + ret = GetSyscapStr(input, priSyscapStr, osSyscap, pcidHeader); + if (ret == -1) { + return ret; } - if (ParseStringSyscap(ctx, osSyscap, OS_SYSCAP_NUM, pcidHeader, PCID_HEADER) != 0) { - PRINT_ERR("Parse string syscap failed.\n"); - goto PARSE_FAILED; - } - priSyscapStr = ctx; // add to json object cJSON *sysCapObj = cJSON_CreateObject(); @@ -706,6 +739,10 @@ int32_t DecodeStringPCIDToJson(char *input, char *outDirPath) } // save as json file char *jsonBuffer = cJSON_Print(rootObj); + if (jsonBuffer == NULL) { + PRINT_ERR("json buffer is null.\n"); + goto ADD_JSON_FAILED; + } const char outputFileName[] = "pcid.json"; if (ConvertedContextSaveAsFile(outDirPath, outputFileName, jsonBuffer, strlen(jsonBuffer)) != 0) { @@ -714,12 +751,11 @@ int32_t DecodeStringPCIDToJson(char *input, char *outDirPath) } ret = 0; - SAVE_FAILED: +SAVE_FAILED: free(jsonBuffer); - ADD_JSON_FAILED: +ADD_JSON_FAILED: + cJSON_Delete(sysCapObj); cJSON_Delete(rootObj); - PARSE_FAILED: - free(ctx); return ret; } @@ -758,12 +794,14 @@ static int32_t GetEncodePCIDOut(uint16_t priSyscapCount, uint32_t privateSyscapL ret = sprintf_s(output, outputLen, "%u", mainSyscap[0]); if (ret == -1) { PRINT_ERR("sprintf_s failed\n"); + free(output); return FreeAfterEncodePCID(freePcidInfo, FREE_ENCODE_PCID_OUT, ret); } for (i = 1; i < PCID_OUT_BUFFER; i++) { ret = sprintf_s(output, outputLen, "%s,%u", output, mainSyscap[i]); if (ret == -1) { PRINT_ERR("sprintf_s failed\n"); + free(output); return FreeAfterEncodePCID(freePcidInfo, FREE_ENCODE_PCID_OUT, ret); } } @@ -771,6 +809,7 @@ static int32_t GetEncodePCIDOut(uint16_t priSyscapCount, uint32_t privateSyscapL ret = sprintf_s(output, outputLen, "%s,%s", output, freePcidInfo.priSyscapFull + i * SINGLE_SYSCAP_LEN); if (ret == -1) { PRINT_ERR("sprintf_s failed\n"); + free(output); return FreeAfterEncodePCID(freePcidInfo, FREE_ENCODE_PCID_OUT, ret); } } @@ -781,6 +820,7 @@ static int32_t GetEncodePCIDOut(uint16_t priSyscapCount, uint32_t privateSyscapL PRINT_ERR("ConvertedContextSaveAsFile failed, outDirPath:%s, filename:%s\n", freePcidInfo.outDirPathFinal, outputFileName); } + free(output); return FreeAfterEncodePCID(freePcidInfo, FREE_ENCODE_PCID_OUT, ret); } diff --git a/src/main.c b/src/main.c index a54d331..44fd992 100644 --- a/src/main.c +++ b/src/main.c @@ -37,6 +37,7 @@ #define INPUT_FILE 8 #define OUTPUT_FILE 9 #define HELP 10 +#define INPUT_FILE_NUM 4 static void PrintHelp(void); static void PrintVersion(void); @@ -85,7 +86,7 @@ int main(int argc, char **argv) break; } if (flag == 'C') { - if (argc != 4 || optind < 0 || optind >= argc) { // 4, argc of ./syscap_tool -C f1 f2 + if (argc != INPUT_FILE_NUM || optind < 0 || optind >= argc) { // 4, argc of ./syscap_tool -C f1 f2 PRINT_ERR("Input file too few or too many.\n"); return -1; } @@ -126,7 +127,13 @@ int32_t OperateByBitMap(char *const *argv, uint16_t bitMap, char *outputpath) case 0x10E: // 0x10E, -Rdsi inputfile printf("-Rdsi is not support currently.\n"); break; case 0x80: // 0x80, -v - (void)OutputVersion(argv[optind], optind); break; + if (optind < 0 || optind >= INPUT_FILE_NUM) { + PRINT_ERR("Input file too few or too many.\n"); + return -1; + } else { + (void)OutputVersion(argv[optind], optind); + break; + } default: (void)OutputHelp(); } diff --git a/src/syscap_tool.c b/src/syscap_tool.c index 421e9d1..e7b1314 100644 --- a/src/syscap_tool.c +++ b/src/syscap_tool.c @@ -261,8 +261,10 @@ int32_t RPCIDDecode(char *inputFile, char *outputPath) ret = ConvertedContextSaveAsFile(outputPath, "rpcid.json", convertedBuffer, strlen(convertedBuffer)); if (ret != 0) { PRINT_ERR("ConvertedContextSaveAsFile failed, outputPath:%s, filename:rpcid.json\n", outputPath); + free(convertedBuffer); goto FREE_RPCID_ROOT; } + free(convertedBuffer); FREE_RPCID_ROOT: cJSON_Delete(rpcidRoot); diff --git a/tools/syscap_collector.py b/tools/syscap_collector.py index be014c1..47be694 100755 --- a/tools/syscap_collector.py +++ b/tools/syscap_collector.py @@ -33,14 +33,6 @@ def get_args(): return args -def adjust_syscaps_list(sys_list: list, product: str): - # 调整syscaps_list:如果产品属于standard类,则去掉其中以.Lite结尾的syscap - standard_product = ["default", "ipcamera", "pc", "tablet"] - if product in standard_product: - sys_list = [syscap for syscap in sys_list if not syscap.endswith(".Lite")] - return sys_list - - def dict_to_json(output_path: str, syscaps_dict: dict): """ output diff product syscaps json to output path @@ -59,7 +51,6 @@ def dict_to_json(output_path: str, syscaps_dict: dict): syscaps_list = list(set(syscaps_list)) filename = os.path.join(output_path, f'{product_name}.json') with os.fdopen(os.open(filename, flags, modes), 'w') as f: - syscaps_list = adjust_syscaps_list(syscaps_list, product_name) json.dump({'SysCaps': syscaps_list}, f, indent=4) print("end...") @@ -304,15 +295,6 @@ class BundlePartObj(object): self._build_config_file = bundle_config_file self._loading_config() - def _loading_config(self): - if not os.path.exists(self._build_config_file): - raise Exception("file '{}' doesn't exist.".format( - self._build_config_file), "2011") - self.bundle_info = _read_json_file(self._build_config_file) - if not self.bundle_info: - raise Exception("read file '{}' failed.".format( - self._build_config_file), "2011") - def to_ohos_build(self): _component_info = self.bundle_info.get('component') _subsystem_name = _component_info.get('subsystem') @@ -349,6 +331,15 @@ class BundlePartObj(object): _ohos_build_info['parts'] = {_part_name: _part_info} return _ohos_build_info + def _loading_config(self): + if not os.path.exists(self._build_config_file): + raise Exception("file '{}' doesn't exist.".format( + self._build_config_file), "2011") + self.bundle_info = _read_json_file(self._build_config_file) + if not self.bundle_info: + raise Exception("read file '{}' failed.".format( + self._build_config_file), "2011") + class LoadBuildConfig(object): """load build config file and parse configuration info.""" @@ -368,6 +359,26 @@ class LoadBuildConfig(object): self._parts_module_list = {} self._parts_deps = {} + def parse(self): + """parse part info from build config file.""" + if self._is_load: + return + subsystem_config, parts_path_dict = self._merge_build_config() + parts_config = subsystem_config.get('parts') + self._parts_module_list.update(parts_config) + self._parts_path_dict = parts_path_dict + self._is_load = True + + def parts_path_info(self): + """parts to path info.""" + self.parse() + return self._parts_path_dict + + def parts_info_filter(self, save_part): + if save_part is None: + raise Exception + self._parts_info_dict = { + key: value for key, value in self._parts_info_dict.items() if key in save_part} def _merge_build_config(self): _build_files = self._build_info.get('build_files') is_thirdparty_subsystem = False @@ -398,27 +409,6 @@ class LoadBuildConfig(object): subsystem_config['parts'] = parts_info return subsystem_config, parts_path_dict - def parse(self): - """parse part info from build config file.""" - if self._is_load: - return - subsystem_config, parts_path_dict = self._merge_build_config() - parts_config = subsystem_config.get('parts') - self._parts_module_list.update(parts_config) - self._parts_path_dict = parts_path_dict - self._is_load = True - - def parts_path_info(self): - """parts to path info.""" - self.parse() - return self._parts_path_dict - - def parts_info_filter(self, save_part): - if save_part is None: - raise Exception - self._parts_info_dict = { - key: value for key, value in self._parts_info_dict.items() if key in save_part} - def get_parts_info(source_root_dir, subsystem_info, build_xts=False): """ diff --git a/tools/syscap_config_merge.py b/tools/syscap_config_merge.py index c3d676e..9ab45de 100755 --- a/tools/syscap_config_merge.py +++ b/tools/syscap_config_merge.py @@ -18,6 +18,7 @@ 1. 扩展syscap头文件的枚举定义,须在开始位置标记最小值,且必须大于等于500。 ''' import argparse +import os LICENCE = '''/* * Copyright (c) 2023 Huawei Device Co., Ltd. @@ -151,6 +152,6 @@ if __name__ == '__main__': output_file = args.output full = assemble_header_file(base_file, extern_file) - with open(output_file, 'w') as out: + with os.fdopen(os.open(output_file, os.O_WRONLY | os.O_CREAT, mode=0o640), 'w') as out: out.writelines(full)