!4 liteos-m refactoring

Merge pull request !4 from likailong/likailong_20201113180138
This commit is contained in:
openharmony_ci 2020-11-16 14:52:12 +08:00 committed by Gitee
commit b281333da4
2 changed files with 196 additions and 172 deletions

View File

@ -1,18 +1,18 @@
# Copyright (c) 2020 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.
# Copyright (c) 2020 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.
import("//test/xts/tools/build/common.gni")
import("//build/lite/config/component/lite_component.gni")
import("//test/xts/tools/build/common.gni")
declare_args() {
ohos_xts_test_args = ""
@ -33,7 +33,8 @@ template("testsuite_base") {
if (defined(invoker.output_name)) {
_module_name = "${invoker.output_name}"
}
_output_file = rebase_path("${root_out_dir}/libs/libmodule_${_module_name}.a")
_output_file =
rebase_path("${root_out_dir}/libs/libmodule_${_module_name}.a")
_archive_filename = "lib${_module_name}.a"
target("static_library", "${_module_target_name}") {
forward_variables_from(invoker, "*")
@ -43,20 +44,21 @@ template("testsuite_base") {
if (defined(invoker.output_name)) {
_module_name = "${invoker.output_name}"
}
_extension=""
_extension = ""
if (defined(invoker.output_extension)) {
_extension = ".${invoker.output_extension}"
}
_output_file = rebase_path("${root_out_dir}/bin/${_module_target_name}${_extension}")
_output_file =
rebase_path("${root_out_dir}/bin/${_module_target_name}${_extension}")
_archive_filename = "${_module_name}${_extension}"
target("executable", "${_module_target_name}") {
forward_variables_from(invoker, "*")
}
} else if (_project_type == "hctest_prebuilt") {
_output_file = rebase_path("${root_out_dir}/libs/lib${_module_target_name}.a")
_output_file =
rebase_path("${root_out_dir}/libs/lib${_module_target_name}.a")
_archive_filename = "lib${_module_target_name}.a"
_deps += ["//test/xts/tools/hctest:hctest"]
_deps += [ "//test/xts/tools/hctest:hctest" ]
copy(_module_target_name) {
sources = invoker.sources
outputs = [ "${root_out_dir}/libs/lib${_module_target_name}.a" ]
@ -72,15 +74,19 @@ template("testsuite_base") {
_subsystem_name = ""
if (defined(invoker.subsystem_name)) {
_subsystem_name = invoker.subsystem_name
}else{
} else {
_local_path = rebase_path(".")
_args1 = [
"--method_name", "get_subsystem_name",
"--arguments", "path=${_local_path}"
"--method_name",
"get_subsystem_name",
"--arguments",
"path=${_local_path}",
]
_subsystem_name = exec_script(rebase_path("$BUILD_DIR_PREFIX/utils.py"), _args1, "trim string")
_subsystem_name = exec_script(rebase_path("$BUILD_DIR_PREFIX/utils.py"),
_args1,
"trim string")
}
target("testsuite_common", target_name){
target("testsuite_common", target_name) {
suite_name = _suite_name
project_type = _project_type
subsystem_name = _subsystem_name
@ -89,35 +95,34 @@ template("testsuite_base") {
archive_filename = _archive_filename
deps = _deps
}
}
template("hctest_suite") {
_include_dirs = [
"//test/xts/tools/hctest/include",
"//third_party/unity/src",
"//kernel/liteos_m/components/cmsis",
"//foundation/distributedschedule/interfaces/kits/samgr_lite/samgr"
"//kernel/liteos_m/kal",
"//foundation/distributedschedule/interfaces/kits/samgr_lite/samgr",
]
_deps = ["//test/xts/tools/hctest:hctest"]
_deps = [ "//test/xts/tools/hctest:hctest" ]
_defines = [ "UNITY_INCLUDE_CONFIG_H" ]
target("testsuite_base", "${target_name}") {
forward_variables_from(invoker, "*")
project_type = "hctest"
if (defined(include_dirs)){
if (defined(include_dirs)) {
include_dirs += _include_dirs
}else{
} else {
include_dirs = _include_dirs
}
if (defined(deps)){
if (defined(deps)) {
deps += _deps
}else{
} else {
deps = _deps
}
if (defined(defines)){
if (defined(defines)) {
defines += _defines
}else{
} else {
defines = _defines
}
}
@ -139,14 +144,14 @@ template("hcpptest_suite") {
output_extension = "bin"
_include_dirs = [
"//third_party/googletest/googletest/include",
"//third_party/googletest/googletest/src"
"//third_party/googletest/googletest/src",
]
if (defined(include_dirs)) {
include_dirs += _include_dirs
} else {
include_dirs = _include_dirs
}
_deps = ["//test/xts/tools/hcpptest:hcpptest_main"]
_deps = [ "//test/xts/tools/hcpptest:hcpptest_main" ]
if (defined(deps)) {
deps += _deps
} else {
@ -156,8 +161,7 @@ template("hcpptest_suite") {
}
template("pythontest_suite") {
assert(defined(invoker.script),
"script is required in target ${target_name}")
assert(defined(invoker.script), "script is required in target ${target_name}")
assert(defined(invoker.suite_name),
"suite_name is required in target ${target_name}")
_suite_name = invoker.suite_name
@ -166,13 +170,17 @@ template("pythontest_suite") {
_subsystem_name = ""
if (defined(invoker.subsystem_name)) {
_subsystem_name = invoker.subsystem_name
}else{
} else {
_local_path = rebase_path(".")
_args1 = [
"--method_name", "get_subsystem_name",
"--arguments", "path=${_local_path}"
"--method_name",
"get_subsystem_name",
"--arguments",
"path=${_local_path}",
]
_subsystem_name = exec_script(rebase_path("$BUILD_DIR_PREFIX/utils.py"), _args1, "trim string")
_subsystem_name = exec_script(rebase_path("$BUILD_DIR_PREFIX/utils.py"),
_args1,
"trim string")
}
_deps = []
if (defined(invoker.deps)) {
@ -199,8 +207,7 @@ template("pythontest_suite") {
}
template("test_suite") {
assert(defined(invoker.deps),
"deps is required in target ${target_name}")
assert(defined(invoker.deps), "deps is required in target ${target_name}")
_output = "${SUITE_OUTPUT_PREFIX}${target_name}.zip"
_suite_path = rebase_path("${SUITE_OUTPUT_PREFIX}${target_name}")
_prebuilts_files = ","
@ -209,10 +216,14 @@ template("test_suite") {
}
_gen_args = [
"archive_suite",
"--suite_path", _suite_path,
"--testcases_name", SUITE_TESTCASES_NAME,
"--prebuilts_resource", _prebuilts_files,
"--build_enabled", "true",
"--suite_path",
_suite_path,
"--testcases_name",
SUITE_TESTCASES_NAME,
"--prebuilts_resource",
_prebuilts_files,
"--build_enabled",
"true",
]
_deps = [ "//test/xdevice" ]
@ -223,17 +234,19 @@ template("test_suite") {
script = rebase_path("$BUILD_DIR_PREFIX/suite.py")
deps = _deps
args = _gen_args
outputs = [_output]
outputs = [ _output ]
}
if (defined(invoker.version)) {
_version = invoker.version
_out_dir = rebase_path("${_suite_path}/testcases")
_args1 = [
"--method_name", "record_test_component_info",
"--arguments", "out_dir=${_out_dir}#version=${_version}"
]
exec_script(rebase_path("$BUILD_DIR_PREFIX/utils.py"), _args1)
_version = invoker.version
_out_dir = rebase_path("${_suite_path}/testcases")
_args1 = [
"--method_name",
"record_test_component_info",
"--arguments",
"out_dir=${_out_dir}#version=${_version}",
]
exec_script(rebase_path("$BUILD_DIR_PREFIX/utils.py"), _args1)
}
}
@ -243,102 +256,115 @@ template("executable_suite") {
_suite_name = invoker.suite_name
_local_path = rebase_path(".")
_args1 = [
"--method_name", "get_subsystem_name",
"--arguments", "path=${_local_path}"
"--method_name",
"get_subsystem_name",
"--arguments",
"path=${_local_path}",
]
_subsystem_name = exec_script(rebase_path("$BUILD_DIR_PREFIX/utils.py"), _args1, "trim string")
_subsystem_name = exec_script(rebase_path("$BUILD_DIR_PREFIX/utils.py"),
_args1,
"trim string")
_extension=""
if (defined(invoker.output_extension)) {
_extension = ".${invoker.output_extension}"
}
_outputs_dir=""
if (defined(invoker.outputs_dir)) {
_outputs_dir = "${invoker.outputs_dir}"
_extension = ""
if (defined(invoker.output_extension)) {
_extension = ".${invoker.output_extension}"
}
_outputs_dir = ""
if (defined(invoker.outputs_dir)) {
_outputs_dir = "${invoker.outputs_dir}"
}
_module_target_name = "module_${target_name}"
_source_file = rebase_path("${root_out_dir}/bin/${target_name}${_extension}")
_origi_target = target_name
target("executable", "${_module_target_name}"){
forward_variables_from(invoker, "*")
output_name = _origi_target
target("executable", "${_module_target_name}") {
forward_variables_from(invoker, "*")
output_name = _origi_target
}
_output_file = rebase_path("${SUITE_OUTPUT_PREFIX}${_suite_name}/${SUITE_TESTCASES_NAME}/${_subsystem_name}/${_outputs_dir}")
_output_file = rebase_path(
"${SUITE_OUTPUT_PREFIX}${_suite_name}/${SUITE_TESTCASES_NAME}/${_subsystem_name}/${_outputs_dir}")
_args2 = [
"--method_name", "copy_file",
"--arguments", "output=${_output_file}#sources=${_source_file}"
"--method_name",
"copy_file",
"--arguments",
"output=${_output_file}#sources=${_source_file}",
]
action(target_name) {
script = rebase_path("$BUILD_DIR_PREFIX/utils.py")
deps = [":${_module_target_name}"]
deps = [ ":${_module_target_name}" ]
args = _args2
outputs = ["${SUITE_OUTPUT_PREFIX}${_suite_name}/${SUITE_TESTCASES_NAME}/${_subsystem_name}/${target_name}${_extension}"]
outputs = [ "${SUITE_OUTPUT_PREFIX}${_suite_name}/${SUITE_TESTCASES_NAME}/${_subsystem_name}/${target_name}${_extension}" ]
}
}
template("open_source_suite") {
assert(defined(invoker.suite_name),
"suite_name is required in target ${target_name}")
assert(defined(invoker.exec_command_path),
"exec_script_path is required in target ${target_name}")
_suite_name = invoker.suite_name
_exec_command_path = invoker.exec_command_path
_exec_sub_dir = invoker.exec_sub_dir
assert(defined(invoker.suite_name),
"suite_name is required in target ${target_name}")
assert(defined(invoker.exec_command_path),
"exec_script_path is required in target ${target_name}")
_suite_name = invoker.suite_name
_exec_command_path = invoker.exec_command_path
_exec_sub_dir = invoker.exec_sub_dir
_prebuild_command = invoker.prebuild_command
_prebuild_command = invoker.prebuild_command
_output_files = ""
if (defined(invoker.build_args)) {
foreach(target_file, invoker.build_args) {
_output_files = _output_files + rebase_path("${_exec_command_path}/${_exec_sub_dir}/${target_file}") + ","
}
} else {
_output_files = rebase_path("${_exec_command_path}")
}
_pre_build_deps = []
if (defined(invoker.deps)) {
_pre_build_deps += invoker.deps
}
target("build_ext_component", "prebuild_${target_name}") {
exec_path = rebase_path("${_exec_command_path}")
command = _prebuild_command
deps = _pre_build_deps
}
_subsystem_name = ""
if (defined(invoker.subsystem_name)) {
_subsystem_name = invoker.subsystem_name
}else{
_local_path = rebase_path(".")
_args1 = [
"--method_name", "get_subsystem_name",
"--arguments", "path=${_local_path}"
]
_subsystem_name = exec_script(rebase_path("$BUILD_DIR_PREFIX/utils.py"), _args1, "trim string")
}
_archive_filename = "${target_name}"
_project_dir = rebase_path(".")
_build_deps = [":prebuild_${target_name}"]
_outputs_dir = ""
if (defined(invoker.outputs_dir)) {
_outputs_dir = invoker.outputs_dir
}
target("testsuite_common", "${target_name}") {
suite_name = _suite_name
subsystem_name = _subsystem_name
project_type = "open_source_test"
project_dir = _project_dir
output_file = _output_files
archive_filename = _archive_filename
outputs_dir = _outputs_dir
deps = _build_deps
_output_files = ""
if (defined(invoker.build_args)) {
foreach(target_file, invoker.build_args) {
_output_files =
_output_files +
rebase_path("${_exec_command_path}/${_exec_sub_dir}/${target_file}") +
","
}
} else {
_output_files = rebase_path("${_exec_command_path}")
}
_pre_build_deps = []
if (defined(invoker.deps)) {
_pre_build_deps += invoker.deps
}
target("build_ext_component", "prebuild_${target_name}") {
exec_path = rebase_path("${_exec_command_path}")
command = _prebuild_command
deps = _pre_build_deps
}
_subsystem_name = ""
if (defined(invoker.subsystem_name)) {
_subsystem_name = invoker.subsystem_name
} else {
_local_path = rebase_path(".")
_args1 = [
"--method_name",
"get_subsystem_name",
"--arguments",
"path=${_local_path}",
]
_subsystem_name = exec_script(rebase_path("$BUILD_DIR_PREFIX/utils.py"),
_args1,
"trim string")
}
_archive_filename = "${target_name}"
_project_dir = rebase_path(".")
_build_deps = [ ":prebuild_${target_name}" ]
_outputs_dir = ""
if (defined(invoker.outputs_dir)) {
_outputs_dir = invoker.outputs_dir
}
target("testsuite_common", "${target_name}") {
suite_name = _suite_name
subsystem_name = _subsystem_name
project_type = "open_source_test"
project_dir = _project_dir
output_file = _output_files
archive_filename = _archive_filename
outputs_dir = _outputs_dir
deps = _build_deps
}
}

View File

@ -1,39 +1,37 @@
# Copyright (c) 2020 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.
static_library("hctest") {
sources = [
"//third_party/unity/src/unity.c",
"src/hctest_service.c",
"src/hctest.c"
]
include_dirs = [
"include",
"//third_party/unity/src",
"//utils/native/lite/include",
"//foundation/distributedschedule/interfaces/kits/samgr_lite/samgr",
"//kernel/liteos_m/components/cmsis",
"//base/startup/services/bootstrap_lite/source",
"//base/startup/interfaces/kits/syspara_lite",
]
public = [
"include/hctest.h",
"//third_party/unity/src/unity.h"
]
defines = [
"UNITY_INCLUDE_CONFIG_H",
]
cflags = [ "-Wno-error" ]
}
# Copyright (c) 2020 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.
static_library("hctest") {
sources = [
"//third_party/unity/src/unity.c",
"src/hctest.c",
"src/hctest_service.c",
]
include_dirs = [
"include",
"//third_party/unity/src",
"//utils/native/lite/include",
"//foundation/distributedschedule/interfaces/kits/samgr_lite/samgr",
"//kernel/liteos_m/kal",
"//base/startup/services/bootstrap_lite/source",
"//base/startup/interfaces/kits/syspara_lite",
]
public = [
"//third_party/unity/src/unity.h",
"include/hctest.h",
]
defines = [ "UNITY_INCLUDE_CONFIG_H" ]
cflags = [ "-Wno-error" ]
}