modify BUILD.gn for compile liteos_m device.

Signed-off-by: yudechen <chenyude@huawei.com>
Change-Id: I6d304af15af0707a06a946188f2b7702653ee5fe
This commit is contained in:
yudechen
2022-10-25 16:39:08 +08:00
parent c76834e6ff
commit aefdfa5a3c
3 changed files with 58 additions and 234 deletions
+23 -60
View File
@@ -59,6 +59,9 @@ ohos_executable("syscap_tool_bin") {
if (is_mingw) {
defines += [ "_POSIX_" ]
}
if (defined(ohos_lite) && ohos_kernel_type == "liteos_m") {
cflags = [ "-DPATH_MAX=1024" ]
}
sources = [ "./src/main.c" ]
sources += sources_platform_common
@@ -74,71 +77,32 @@ ohos_executable("syscap_tool_bin") {
part_name = "syscap_codec"
}
ohos_executable("syscap_tool_test") {
install_enable = true
include_dirs = [ "src" ]
public_configs = [ ":pubilc" ]
defines = []
if (is_mingw) {
defines += [ "_POSIX_" ]
}
sources = [ "./test/syscap_tool_test.c" ]
sources += sources_platform_common
deps = [ "//third_party/bounds_checking_function:libsec_static" ]
if (defined(ohos_lite)) {
deps += [ "//build/lite/config/component/cJSON:cjson_static" ]
} else {
deps += [ "//third_party/cJSON:cjson_static" ]
}
subsystem_name = "developtools"
part_name = "syscap_codec"
}
ohos_shared_library("syscap_tool_shared") {
output_name = "syscap_codec"
include_dirs = [ "src" ]
public_configs = [ ":pubilc" ]
sources = sources_platform_common
deps = [ "//third_party/bounds_checking_function:libsec_static" ]
if (defined(ohos_lite)) {
deps += [ "//build/lite/config/component/cJSON:cjson_static" ]
} else {
deps += [ "//third_party/cJSON:cjson_static" ]
}
subsystem_name = "developtools"
part_name = "syscap_codec"
}
config("syscap_interface_public_config") {
include_dirs = [ "./interfaces/inner_api/" ]
}
if (defined(ohos_lite)) {
shared_library("syscap_interface_shared") {
include_dirs = [
"include",
"src",
]
public_configs = [ ":syscap_interface_public_config" ]
sources = [
"./interfaces/inner_api/syscap_interface.c",
"./src/endian_internal.c",
"./src/syscap_tool.c",
]
if (ohos_kernel_type == "liteos_m") {
group("syscap_interface_shared") {
}
} else {
shared_library("syscap_interface_shared") {
include_dirs = [
"include",
"src",
]
public_configs = [ ":syscap_interface_public_config" ]
sources = [
"./interfaces/inner_api/syscap_interface.c",
"./src/endian_internal.c",
"./src/syscap_tool.c",
]
deps = [
"//build/lite/config/component/cJSON:cjson_static",
"//third_party/bounds_checking_function:libsec_static",
]
deps = [
"//build/lite/config/component/cJSON:cjson_static",
"//third_party/bounds_checking_function:libsec_static",
]
}
}
} else {
ohos_shared_library("syscap_interface_shared") {
@@ -199,7 +163,6 @@ group("syscap_codec") {
":pcid_sc",
":syscap_define_check",
":syscap_interface_shared",
":syscap_tool_shared",
]
if (support_jsapi && is_standard_system) {
deps += [ "napi:systemcapability" ]
-143
View File
@@ -1,143 +0,0 @@
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <string.h>
#include <stdint.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <limits.h>
#include <sys/types.h>
#include <wait.h>
#include "syscap_tool.h"
#include "create_pcid.h"
char *g_testFilePcid = "{\n \"api_version\": 0,\n \"manufacturer_id\": 0,\n \"product\": \"rk3568\",\n" \
" \"syscap\": {\n \"os\": [\n \"SystemCapability.Account.AppAccount\",\n" \
" \"SystemCapability.Account.OsAccount\"\n ]\n },\n" \
" \"system_type\": \"standard\"\n}";
char *g_testFileRpcid = "{\n \"api_version\": 7,\n \"syscap\": [\n \"SystemCapability.hiviewdfx.hilog\",\n" \
" \"SystemCapability.communication.softbus\",\n \"SystemCapability.hisicon.flashlight\"\n ]\n}";
int32_t PrepareTestFile(char *fileName, char *fileContext)
{
int32_t ret;
FILE *fp = fopen(fileName, "wb");
if (fp == NULL) {
return -1;
}
size_t len = fwrite(fileContext, 1, strlen(fileContext), fp);
if (len != strlen(fileContext)) {
(void)fclose(fp);
return -1;
}
ret = fclose(fp);
if (ret != 0) {
return -1;
}
return 0;
}
int main(int argc, char **argv)
{
int32_t status;
char *pcidFileName = "SystemCapability.json";
char *rpcidFileName = "rpcid.json";
printf("###start syscap tool test###\n");
(void)unlink(pcidFileName);
(void)unlink(rpcidFileName);
(void)unlink("./rk3568.sc");
(void)unlink("./newPCID.sc");
(void)unlink("./rpcid.sc");
(void)unlink("./rk3568.json");
pid_t pid = fork();
if (pid == 0) {
printf("prepare test file...\n");
int32_t passCnt = 0;
int32_t ret = PrepareTestFile(pcidFileName, g_testFilePcid);
if (ret != 0) {
printf(" error: prepare pcid file failed\n");
exit(passCnt);
}
ret = PrepareTestFile(rpcidFileName, g_testFileRpcid);
if (ret != 0) {
printf(" error: prepare rpcid file failed\n");
exit(passCnt);
}
printf("1.test rpcid.json encode to rpcid.sc\n");
ret = RPCIDEncode(rpcidFileName, "./");
if (ret != 0) {
printf(" error: rpcid.json encode failed\n");
exit(passCnt);
}
passCnt++;
printf("pass\n");
printf("2.test rpcid.sc decode to rpcid.json\n");
ret = RPCIDDecode("rpcid.sc", "./");
if (ret != 0) {
printf(" error: rpcid.sc decode failed\n");
exit(passCnt);
}
passCnt++;
printf("pass\n");
printf("3.test pcid.json encode to pcid.sc\n");
ret = PCIDEncode(pcidFileName, "./");
if (ret != 0) {
printf(" error: pcid.json encode failed\n");
exit(passCnt);
}
passCnt++;
printf("pass\n");
printf("4.test pcid.sc decode to pcid.json\n");
ret = PCIDDecode("./rk3568.sc", "./");
if (ret != 0) {
printf(" error: pcid.sc decode failed\n");
exit(passCnt);
}
passCnt++;
printf("pass\n");
printf("5.test pcid.json encode to new PCID.sc\n");
ret = CreatePCID("./newPCID.sc", "./");
if (ret != 0) {
printf(" error: new pcid.sc encode failed\n");
exit(passCnt);
}
passCnt++;
printf("pass\n");
printf("6.test new pcid.sc decode to pcid.json\n");
ret = PCIDDecode("./newPCID.sc", "./");
if (ret != 0) {
printf(" error: new pcid.sc decode failed\n");
exit(passCnt);
}
passCnt++;
printf("pass\n");
exit(passCnt);
}
(void)wait(&status);
printf("summary: total 4 passed %d\n", WEXITSTATUS(status));
(void)unlink(pcidFileName);
(void)unlink(rpcidFileName);
(void)unlink("./rk3568.sc");
(void)unlink("./newPCID.sc");
(void)unlink("./rpcid.sc");
(void)unlink("./rk3568.json");
return 0;
}
+35 -31
View File
@@ -11,51 +11,55 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/lite/config/component/lite_component.gni")
if (defined(ohos_lite)) {
import("//build/lite/config/component/lite_component.gni")
import("//build/lite/config/test.gni")
test_output_root = "$root_out_dir/test/unittest/syscap_codec"
executable("test_syscap_napi_unittest") {
output_extension = "bin"
output_dir = test_output_root
if (ohos_kernel_type != "liteos_m") {
test_output_root = "$root_out_dir/test/unittest/syscap_codec"
include_dirs = [
"//commonlibrary/c_utils/base/include",
"//third_party/node/src",
"//third_party/googletest/include",
"//developtools/syscap_codec/src/",
"//developtools/syscap_codec/include/",
"//developtools/syscap_codec/interfaces/inner_api/",
"//developtools/syscap_codec/test/unittest/common/include/",
]
executable("test_syscap_napi_unittest") {
output_extension = "bin"
output_dir = test_output_root
cflags = [ "-g3" ]
include_dirs = [
"//commonlibrary/c_utils/base/include",
"//third_party/node/src",
"//third_party/googletest/include",
"//developtools/syscap_codec/src/",
"//developtools/syscap_codec/include/",
"//developtools/syscap_codec/interfaces/inner_api/",
"//developtools/syscap_codec/test/unittest/common/include/",
]
sources = [
"//developtools/syscap_codec/interfaces/inner_api/syscap_interface.c",
"//developtools/syscap_codec/src/create_pcid.c",
"//developtools/syscap_codec/src/endian_internal.c",
"//developtools/syscap_codec/src/syscap_tool.c",
"syscap_codec_test.cpp",
]
cflags = [ "-g3" ]
defines = [ "NAPI_TEST" ]
sources = [
"//developtools/syscap_codec/interfaces/inner_api/syscap_interface.c",
"//developtools/syscap_codec/src/create_pcid.c",
"//developtools/syscap_codec/src/endian_internal.c",
"//developtools/syscap_codec/src/syscap_tool.c",
"syscap_codec_test.cpp",
]
deps = [
"//base//hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
"//test/testfwk/developer_test/third_party/lib/cpp:gtest_main",
"//third_party/bounds_checking_function:libsec_static",
]
defines = [ "NAPI_TEST" ]
deps += [ "//build/lite/config/component/cJSON:cjson_static" ]
deps = [
"//base//hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
"//test/testfwk/developer_test/third_party/lib/cpp:gtest_main",
"//third_party/bounds_checking_function:libsec_static",
]
deps += [ "//build/lite/config/component/cJSON:cjson_static" ]
}
}
group("unittest") {
deps = [ ":test_syscap_napi_unittest" ]
if (ohos_kernel_type != "liteos_m") {
deps = [ ":test_syscap_napi_unittest" ]
}
}
} else {
import("//build/lite/config/component/lite_component.gni")
import("//build/ohos.gni")
import("//build/test.gni")