Merge branch 'master' of gitee.com:openharmony/developtools_syscap_codec into master

Signed-off-by: chongteng wang <wangchongteng@huawei.com>
This commit is contained in:
chongteng wang
2024-01-15 01:49:24 +00:00
committed by Gitee
5 changed files with 51 additions and 11 deletions
+4
View File
@@ -319,6 +319,8 @@ typedef enum SystemCapabilityNum {
FILEMANAGEMENT_FILE_ENVIRONMENT_FOLDEROBTAIN,
FILEMANAGEMENT_USERFILESERVICE_FOLDERSELECTION,
FILEMANAGEMENT_APPFILESERVICE_FOLDERAUTHORIZATION,
MULTIMEDIA_MEDIA_AUDIOCODEC,
GRAPHICS_DRAWING,
MULTIMEDIA_AUDIO_SPATIALIZATION,
// Add before here
SYSCAP_BASIC_END = 500,
@@ -413,6 +415,7 @@ const static SyscapWithNum g_arraySyscap[] = {
{"SystemCapability.Multimedia.Media.AudioRecorder", MULTIMEDIA_MEDIA_AUDIORECORDER},
{"SystemCapability.Multimedia.Media.AudioDecoder", MULTIMEDIA_MEDIA_AUDIODECODER},
{"SystemCapability.Multimedia.Media.AudioEncoder", MULTIMEDIA_MEDIA_AUDIOENCODER},
{"SystemCapability.Multimedia.Media.AudioCodec", MULTIMEDIA_MEDIA_AUDIOCODEC},
{"SystemCapability.Multimedia.Media.VideoDecoder", MULTIMEDIA_MEDIA_VIDEODECODER},
{"SystemCapability.Multimedia.Media.VideoEncoder", MULTIMEDIA_MEDIA_VIDEOENCODER},
{"SystemCapability.Multimedia.Media.CodecBase", MULTIMEDIA_MEDIA_CODECBASE},
@@ -622,6 +625,7 @@ const static SyscapWithNum g_arraySyscap[] = {
{"SystemCapability.FileManagement.UserFileService.FolderSelection", FILEMANAGEMENT_USERFILESERVICE_FOLDERSELECTION},
{"SystemCapability.FileManagement.AppFileService.FolderAuthorization",
FILEMANAGEMENT_APPFILESERVICE_FOLDERAUTHORIZATION},
{"SystemCapability.Graphics.Drawing", GRAPHICS_DRAWING},
{"SystemCapability.Multimedia.Audio.Spatialization", MULTIMEDIA_AUDIO_SPATIALIZATION},
};
+6 -7
View File
@@ -327,7 +327,6 @@ static int32_t TransStringFormatAndSaveSyscap(struct FreeAfterDecodeRpcidInfo fr
cJSON *sysCapArray, const char *inputFile)
{
// trans to string format
freeAfterDecodeRpcidInfo.sysCapDefine = CreateWholeSyscapJsonObj();
sysCapArray = cJSON_GetObjectItem(freeAfterDecodeRpcidInfo.rpcidRoot, "syscap");
if (sysCapArray == NULL || !cJSON_IsArray(sysCapArray)) {
PRINT_ERR("Get syscap failed. Input file: %s\n", inputFile);
@@ -404,6 +403,7 @@ static void PartSysCapAndOutBuffer(struct FreeAfterDecodeRpcidInfo freeAfterDeco
uint16_t indexPri = 0;
cJSON *cJsonTemp = NULL;
freeAfterDecodeRpcidInfo.sysCapDefine = CreateWholeSyscapJsonObj();
(void)memset_s(priSyscapArray, freeAfterDecodeRpcidInfo.sysCapArraySize * SINGLE_SYSCAP_LEN,
0, freeAfterDecodeRpcidInfo.sysCapArraySize * SINGLE_SYSCAP_LEN);
freeAfterDecodeRpcidInfo.priSyscap = priSyscapArray;
@@ -492,7 +492,6 @@ char *DecodeRpcidToStringFormat(const char *inputFile)
PRINT_ERR("Prase rpcid to json failed. Input file: %s\n", inputFile);
return FreeAfterDecodeRpcidToString(freeAfterDecodeRpcidInfo, FREE_RPCID_ROOT_AFTER_DECODE_RPCID, outBuffer);
}
ret = TransStringFormatAndSaveSyscap(freeAfterDecodeRpcidInfo, sysCapArray, inputFile);
if (ret == -1) {
return FreeAfterDecodeRpcidToString(freeAfterDecodeRpcidInfo, FREE_WHOLE_SYSCAP_AFTER_DECODE_RPCID, outBuffer);
@@ -533,7 +532,7 @@ static int32_t CopySyscopToRet(struct PcidPriSyscapInfo pcidPriSyscapInfo, const
static int32_t CheckPcidEachBit(struct PcidPriSyscapInfo pcidPriSyscapInfo, CompareError *result,
const size_t allSyscapNum, uint32_t i, uint32_t blockBits)
{
int32_t flag = 0;
int32_t ret = 0;
for (uint8_t k = 0; k < INT_BIT; k++) {
if (blockBits & (1U << k)) {
char *tempSyscap = (char *)malloc(sizeof(char) * SINGLE_SYSCAP_LEN);
@@ -542,8 +541,8 @@ static int32_t CheckPcidEachBit(struct PcidPriSyscapInfo pcidPriSyscapInfo, Comp
FreeCompareError(result);
return -1;
}
flag = CopySyscopToRet(pcidPriSyscapInfo, allSyscapNum, tempSyscap, i, k);
if (flag != EOK) {
ret = CopySyscopToRet(pcidPriSyscapInfo, allSyscapNum, tempSyscap, i, k);
if (ret != EOK) {
PRINT_ERR("strcpy_s failed.\n");
FreeCompareError(result);
return -1;
@@ -551,11 +550,11 @@ static int32_t CheckPcidEachBit(struct PcidPriSyscapInfo pcidPriSyscapInfo, Comp
result->syscap[pcidPriSyscapInfo.ossyscapFlag++] = tempSyscap;
}
}
return 0;
return ret;
}
static int32_t ComparePcidWithOsSyscap(struct PcidPriSyscapInfo pcidPriSyscapInfo,
uint32_t pcidOsAarry[PCID_OUT_BUFFER], uint32_t rpcidOsAarry[PCID_OUT_BUFFER], CompareError *result,
const uint32_t pcidOsAarry[PCID_OUT_BUFFER], const uint32_t rpcidOsAarry[PCID_OUT_BUFFER], CompareError *result,
const size_t allSyscapNum)
{
uint32_t i;
+1 -1
View File
@@ -384,7 +384,6 @@ int32_t GetPriSyscap(PCIDMain *pcidMain, cJSON *sysCapObject, size_t contextBufL
static int32_t CheckSysCapObj(struct FreeDecodePcidJsonInfo freePcidJsonInfo, PCIDMain *pcidMain,
uint32_t contextBufLen, int32_t ret)
{
freePcidJsonInfo.flag = 0;
if (freePcidJsonInfo.sysCapObj == NULL) {
PRINT_ERR("cJSON_CreateObject failed\n");
freePcidJsonInfo.flag = -1;
@@ -456,6 +455,7 @@ int32_t DecodePCID(char *inputFile, char *outDirPath)
freePcidJsonInfo.contextBuffer = NULL;
freePcidJsonInfo.jsonRootObj = NULL;
freePcidJsonInfo.sysCapObj = NULL;
freePcidJsonInfo.flag = 0;
ret = GetFileContext(inputFile, &freePcidJsonInfo.contextBuffer, (uint32_t *)&contextBufLen);
if (ret != 0) {
+1
View File
@@ -450,6 +450,7 @@ int32_t EncodeRpcidscToString(char *inputFile, char *outDirPath)
freeAfterEncodeRpcidscInfo.osSysCapIndex = NULL;
freeAfterEncodeRpcidscInfo.sysCapDefine = NULL;
freeAfterEncodeRpcidscInfo.rpcidRoot = NULL;
freeAfterEncodeRpcidscInfo.outBuffer = NULL;
freeAfterEncodeRpcidscInfo.contextBuffer = NULL;
freeAfterEncodeRpcidscInfo.type = 0;
freeAfterEncodeRpcidscInfo.flag = 0;
+39 -3
View File
@@ -33,6 +33,12 @@ def get_args():
def dict_to_json(output_path: str, syscaps_dict: dict):
"""
output diff product syscaps json to output path
:param output_path:
:param syscaps_dict:
:return:
"""
print("start generate syscap json...")
flags = os.O_WRONLY | os.O_CREAT
modes = stat.S_IWUSR | stat.S_IRUSR
@@ -52,6 +58,12 @@ def check_syscap(syscap_str: str):
def bundle_syscap_list_handler(bundle_syscap_list: list, component_syscaps_list: list):
"""
check syscap
:param bundle_syscap_list:
:param component_syscaps_list:
:return:
"""
for component_syscap in component_syscaps_list:
component_syscap = check_syscap(component_syscap)
if component_syscap:
@@ -92,6 +104,11 @@ def path_component_to_bundle(path: str) -> str:
def handle_bundle_json_file(component_path_dict: dict):
"""
from product required part bundle.json to all products parts list
:param component_path_dict:
:return: all products parts list
"""
print("start collect syscap path...")
syscap_dict = dict()
errors_list = list()
@@ -130,6 +147,13 @@ def traversal_path(parts_path_info: dict, project_path: str, product_define_dict
def collect_all_product_component_syscap_dict(parts_path_info: dict, project_path: str, product_define_dict):
"""
get all syscap to dict
:param parts_path_info:
:param project_path:
:param product_define_dict:
:return:
"""
if parts_path_info:
print("start collect component path...")
component_path_dict = traversal_path(parts_path_info, project_path, product_define_dict)
@@ -140,6 +164,12 @@ def collect_all_product_component_syscap_dict(parts_path_info: dict, project_pat
def get_subsystem_info(subsystem_config_file, source_root_dir):
"""
get subsystem name and subsystem path from oh/build/subsystem_config.json
:param subsystem_config_file: subsystem_config_file path
:param source_root_dir: oh project path
:return: subsystem name and subsystem path
"""
subsystem_configs = scan(subsystem_config_file, source_root_dir)
_all_components_path = []
for _, value in subsystem_configs.get('subsystem').items():
@@ -226,7 +256,7 @@ def scan(subsystem_config_file, source_root_dir):
'source_path': source_root_dir,
'subsystem': _build_configs,
}
print('subsytem config scan completed')
print('subsystem config scan completed')
return scan_result
@@ -376,7 +406,12 @@ class LoadBuildConfig(object):
def get_parts_info(source_root_dir, subsystem_info, build_xts=False):
"""parts info, get info from build config file.
"""
get parts path info from subsystem info
:param source_root_dir: oh project path
:param subsystem_info:
:param build_xts:
:return: parts path info
"""
_phony_target = {}
_parts_path_info = {}
@@ -458,8 +493,9 @@ def get_product_define_dict(source_root_dir):
def output_path_handler(project_path):
output_path = os.path.join(project_path, 'interface', 'sdk-js', 'api', 'device-define-common')
folder = os.path.exists(output_path)
# 多线程创建文件夹问题
if not folder:
os.mkdir(output_path)
os.makedirs(output_path, exist_ok=True)
return output_path