提交 a562180a 编写于 作者: W wenjun

add OpenHarmony 1.0 baseline

上级 0a20618b
### 该问题是怎么引起的?
### 重现步骤
### 报错信息
### 相关的Issue
### 原因(目的、解决的问题等)
### 描述(做了什么,变更了什么)
### 测试用例(新增、改动、可能影响的功能)
__pycache__/
*.py[cod]
\ No newline at end of file
# 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.
# The location of the build configuration file.
buildconfig = "//build/lite/config/BUILDCONFIG.gn"
# The source root location.
root = "//build/lite"
# 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("//build/lite/toolchain/${ohos_build_compiler}.gni")
import("//build/lite/ndk/ndk.gni")
group("ohos") {
deps = []
product_cfg = read_file("//build/lite/product/${product}.json", "json")
foreach(subsystem, product_cfg.subsystem) {
foreach(component, subsystem.component) {
deps += [ component.dir ]
}
}
}
group("ndk") {
# Add native API targets
deps = []
if (ohos_build_ndk) {
deps += [
"//build/lite/ndk:ndk"
]
}
}
action("gen_rootfs") {
deps = [ ":ohos" ]
script = "//build/lite/gen_rootfs.py"
outputs = [ "$target_gen_dir/gen_rootfs.log" ]
out_dir = rebase_path(root_build_dir, ".")
compiler_dir = ohos_build_compiler_dir + "/bin/"
ohos_build_compiler_so_strip = compiler_dir + ohos_build_compiler_so_strip
ohos_build_compiler_bin_strip = compiler_dir + ohos_build_compiler_bin_strip
args = [
"--path=$out_dir",
"--board=$board_name",
"--kernel=$ohos_kernel_type",
"--compile_so=$ohos_build_compiler_so_strip",
"--compile_bin=$ohos_build_compiler_bin_strip"
]
}
\ No newline at end of file
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
\ No newline at end of file
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# 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.
#
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# 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 sys
import argparse
import importlib
import logging
import os
def main():
if not __package__:
path = os.path.join(os.path.dirname(__file__), os.pardir)
sys.path.insert(0, path)
parser = argparse.ArgumentParser(usage="lite [COMMAND]",
description='lite build system')
subparsers = parser.add_subparsers()
parser_list = []
parser_list.append({
'name': 'compile',
'help': 'Build source code'
})
parser_list.append({
'name': 'filter',
'help': 'Filter out non-open source code'
})
for each in parser_list:
module_parser = subparsers.add_parser(name=each.get('name'),
help=each.get('help'))
module = importlib.import_module('.{}'.format(each.get('name')),
'lite')
module.add_options(module_parser)
module_parser.set_defaults(command=module.exec_command)
args = parser.parse_args()
try:
status = args.command(args)
except KeyboardInterrupt:
logging.warning('interrupted')
status = -1
except Exception as e:
logging.error(e)
status = -1
return status
if __name__ == "__main__":
sys.exit(main())
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# 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 sys
import argparse
import importlib
import logging
import os
def usage():
msg = "\n python build.py ipcamera_hi3516dv300\n "\
"python build.py ipcamera_hi3518ev300\n "\
"python build.py wifiiot"
return msg
def main():
if not __package__:
path = os.path.join(os.path.abspath(os.path.dirname(__file__)),
'build')
sys.path.insert(0, path)
parser = argparse.ArgumentParser(usage=usage())
parser_list = []
parser_list.append({
'name': 'compile',
'help': 'Build source code'
})
for each in parser_list:
module = importlib.import_module('.{}'.format(each.get('name')),
'lite')
module.add_options(parser)
parser.set_defaults(command=module.exec_command)
args = parser.parse_args()
try:
status = args.command(args)
except KeyboardInterrupt:
logging.warning('interrupted')
status = -1
except Exception as e:
print(e)
parser.print_help()
status = -1
return status
if __name__ == "__main__":
sys.exit(main())
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# 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 os
import sys
from subprocess import Popen
import argparse
import shlex
def cmd_exec(command):
cmd = shlex.split(command)
proc = Popen(cmd)
proc.wait()
ret_code = proc.returncode
if ret_code != 0:
raise Exception("{} failed, return code is {}".format(cmd, ret_code))
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--path', help='Build path.')
parser.add_argument('--prebuilts', help='Build prebuilts.')
parser.add_argument('--command', help='Build command.')
parser.add_argument('--enable', help='enable python.', nargs='*')
args = parser.parse_args()
if args.enable:
if args.enable[0] == 'false':
return
if args.path:
curr_dir = os.getcwd()
os.chdir(args.path)
if args.prebuilts:
cmd_exec(args.prebuilts)
if args.command:
if '&&' in args.command:
command = args.command.split('&&')
for data in command:
cmd_exec(data)
else:
cmd_exec(args.command)
os.chdir(curr_dir)
if __name__ == '__main__':
sys.exit(main())
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# 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.
#
from utils import CallbackDict
from compile_process import config_create
from compile_process import run_build
from config import Config
def add_options(parser):
parser.add_argument('product', help='Name of the product', nargs='*')
parser.add_argument('-b', '--build_type', help='release or debug version.',
nargs=1, default=['release'])
parser.add_argument('-t', '--test', help='Compile test suit', nargs='*')
parser.add_argument('-n', '--ndk', help='Compile ndk', action='store_true')
def exec_command(args):
callback_dict = CallbackDict()
# parse product
if args.product:
config = Config(args)
callback_dict.register(config.product, config_create)
callback_dict.register(config.product, run_build)
callback_dict.excute(config.product,
config=config,
args=args)
else:
raise Exception("Error: product not found.")
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# 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 os
import shutil
from utils import makedirs
from utils import read_json_file
from config import Compile
def run_build(**kwargs):
print("\n=== start build ===\n")
config = kwargs['config']
compile = Compile()
compile.compile(config)
print("ohos {} build success!".format(config.product))
def parse_product_json(config):
product = config.product
product_json = os.path.join(config.get_build_path(), 'product',
'{}.json'.format(product))
json_content = read_json_file(product_json)
Compile.get_tool_path(config, json_content)
return load_subsystem_feature(json_content, config)
def check_build(config):
# Delete and create output directory
out_path = config.get_out_path()
if os.path.exists(out_path):
shutil.rmtree(out_path)
makedirs(out_path)
return parse_product_json(config)
def load_subsystem_feature(json_content, config):
for subsystem in json_content['subsystem']:
for component in subsystem['component']:
for feature in component['features']:
config.args_list.append(feature)
return True
def config_create(**kwargs):
config = kwargs['config']
check_build(config)
return True
[env]
build_path=
gn_path=
out_path=
gn_args=
gn_cmd=%(gn_path)s gen %(out_path)s --root=. --dotfile=build/lite/.gn --args='%(gn_args)s'
ninja_path=
ninja_cmd=%(ninja_path)s -w dupbuild=warn -C %(out_path)s
[gn_args]
product=
product_args=product = "%(product)s"
ndk_args=ohos_build_ndk = true
build_type=
build_type_args=ohos_build_type = "%(build_type)s"
test=
test_args=ohos_xts_test_args = "%(test)s"
compiler_path=
compiler_args=ohos_build_compiler_dir="%(compiler_path)s"
[ndk]
ndk_path=
clang_path=./prebuilts/clang/harmonyos/linux-x86_64/llvm/bin/clang
ninja_path=./prebuilts/build-tools/linux-x86/bin/ninja
gn_path=./prebuilts/build-tools/linux-x86/bin/gn
\ No newline at end of file
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# 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 os
import distutils.spawn
from utils import exec_command
from utils import check_output
try:
# Python3
from configparser import ConfigParser
except ImportError:
# Python2
from ConfigParser import ConfigParser
class Config():
def __init__(self, args):
self.product = args.product[0]
self.build_type = args.build_type[0]
self.__set_path()
self.config = os.path.join(self.get_build_path(), 'config.ini')
self.log_path = os.path.join(self.get_out_path(), 'build.log')
self.cfg = ConfigParser()
self.cfg.read(self.config)
self.args_list = []
self.__test_cmd_check(args.test)
self.__ndk_check(args.ndk)
def __set_path(self):
self.__root_path = os.getcwd()
self.__build_path = os.path.join(self.__root_path, 'build', 'lite')
if not os.path.exists(self.__build_path):
raise Exception('Error: {} not exist, please check.'.format(
self.__build_path))
self.__out_path = os.path.join(self.__root_path, 'out', self.product)
def get_root_path(self):
if self.__root_path is None:
raise Exception('Error: set root_path first.')
return self.__root_path
def get_build_path(self):
if self.__build_path is None:
raise Exception('Error: set build_path first.')
return self.__build_path
def get_out_path(self):
if self.__out_path is None:
raise Exception('Error: set out_path first.')
return self.__out_path
def get_cmd(self, gn_path, ninja_path):
if not os.path.exists(self.config):
raise Exception('Error: {} not exist, please check.'.format(
self.config))
return self.__parse_compile_config(gn_path, ninja_path)
def __parse_compile_config(self, gn_path, ninja_path):
self.cfg.set('env', 'build_path', self.get_build_path())
self.cfg.set('env', 'out_path', self.get_out_path())
self.cfg.set('env', 'gn_path', gn_path)
self.cfg.set('env', 'ninja_path', ninja_path)
self.cfg.set('env', 'gn_args', self.get_gn_args())
return [self.cfg.get('env', 'gn_cmd'),
self.cfg.get('env', 'ninja_cmd')]
def __test_cmd_check(self, test_args):
if test_args:
cmd_list = ['xts']
if test_args[0] in cmd_list:
if len(test_args) > 1:
self.cfg.set('gn_args', 'test', test_args[1])
self.args_list.append(self.cfg.get('gn_args', 'test_args'))
else:
raise Exception('Error: wrong input of test')
def __ndk_check(self, ndk):
if ndk:
self.args_list.append(self.cfg.get('gn_args', 'ndk_args'))
def get_gn_args(self):
self.cfg.set('gn_args', 'product', self.product)
self.cfg.set('gn_args', 'build_type', self.build_type)
self.args_list.append(self.cfg.get('gn_args', 'product_args'))
self.args_list.append(self.cfg.get('gn_args', 'build_type_args'))
return " ".join(self.args_list)
class Compile():
compiler_path = None
gn_path = None
ninja_path = None
sysroot_path = None
def compile(self, config):
cmd_list = config.get_cmd(self.gn_path, self.ninja_path)
for cmd in cmd_list:
exec_command(cmd, log_path=config.log_path, shell=True)
@classmethod
def get_tool_path(cls, config, json_content):
compiler = json_content['compiler']
if compiler == "clang":
compiler_bin = "clang"
elif compiler == "gcc":
compiler_bin = "riscv32-unknown-elf-gcc"
else:
raise Exception('Error: Unsupport compiler {}.'.format(compiler))
cls.compiler_path = distutils.spawn.find_executable(compiler_bin)
if cls.compiler_path is None:
compiler_cfg_path = config.cfg.get('ndk', '{}_path'
.format(compiler_bin))
if os.path.exists(compiler_cfg_path):
cls.compiler_path = os.path.abspath(compiler_cfg_path)
else:
raise Exception('Error: Can\'t find compiler {}, '
'install it please.'.format(compiler_bin))
cls.check_compiler(compiler, config)
cls.gn_path = distutils.spawn.find_executable('gn')
if cls.gn_path is None:
gn_cfg_path = config.cfg.get('ndk', 'gn_path')
if os.path.exists(gn_cfg_path):
cls.gn_path = gn_cfg_path
else:
raise Exception('Error: Can\'t find gn, install it please.')
cls.ninja_path = distutils.spawn.find_executable('ninja')
if cls.ninja_path is None:
ninja_cfg_path = config.cfg.get('ndk', 'ninja_path')
if os.path.exists(ninja_cfg_path):
cls.ninja_path = ninja_cfg_path
else:
raise Exception('Error: Can\'t find ninja, install it please.')
@classmethod
def check_compiler(cls, compiler, config):
if compiler == 'gcc':
return True
cmd = [cls.compiler_path, '-v']
ret = check_output(cmd)
if 'OHOS' not in ret:
raise Exception('Error: {} is not OHOS compiler, please install'
' compiler.'.format(cls.compiler_path))
compiler_path = os.path.join(os.path.dirname(cls.compiler_path),
os.pardir)
config.cfg.set('gn_args', 'compiler_path', compiler_path)
config.args_list.append(config.cfg.get('gn_args', 'compiler_args'))
return True
# 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.
config("cpu_arch") {
cflags = []
if (target_cpu == "cortex-a7") {
cflags += [
"-march=armv7-a",
"-mfloat-abi=softfp"
]
} else if (target_cpu == "riscv32") {
cflags += [
"-mabi=ilp32",
"-march=rv32imc"
]
}
asmflags = cflags
cflags_cc = cflags
ldflags = cflags
}
config("language_c") {
cflags_c = [
"-std=c99"
]
}
config("language_cpp") {
cflags_cc = [
"-std=c++11"
]
}
config("kernel_macros") {
if (ohos_kernel_type == "liteos_a") {
defines = [
"__LITEOS__",
"__LITEOS_A__",
]
} else if (ohos_kernel_type == "liteos_m") {
defines = [
"__LITEOS__",
"__LITEOS_M__"
]
} else if (ohos_kernel_type == "liteos_riscv") {
defines = [
"__LITEOS__",
"__LITEOS_RISCV__"
]
} else if (ohos_kernel_type == "linux") {
defines = [ "__LINUX__" ]
}
}
config("werror") {
cflags = [
"-Werror"
]
cflags_cc = cflags
}
config("common") {
defines = [ "_XOPEN_SOURCE=700" ]
cflags = [
"-nostdlib",
"-fno-common",
"-fno-builtin",
"-fno-strict-aliasing",
]
cflags_cc = cflags
ldflags = [
"-lc"
]
cflags += [ "-fsigned-char" ]
}
config("security") {
defines = [
"_FORTIFY_SOURCE=2"
]
cflags = [
"-fstack-protector-all"
]
cflags_cc = cflags
ldflags = [
"-Wl,-z,now",
"-Wl,-z,relro",
"-Wl,-z,noexecstack"
]
}
config("exceptions") {
cflags_cc = [ "-fexceptions" ]
cflags_objcc = cflags_cc
}
config("no_exceptions") {
cflags_cc = [ "-fno-exceptions" ]
cflags_objcc = cflags_cc
ldflags = cflags_cc
}
config("stack_protector") {
cflags = [ "-fstack-protector-all" ]
cflags_cc = cflags
}
config("static_pie_config") {
cflags = [ "-fPIE" ]
cflags_cc = cflags
}
config("shared_library_config") {
cflags = [ "-fPIC" ]
cflags_cc = cflags
}
config("pie_executable_config") {
ldflags = [ "-pie" ]
}
config("clang") {
include_dirs = [
"${ohos_build_compiler_dir}/include/c++/v1",
"//prebuilts/lite/sysroot/usr/include/arm-liteos",
]
cflags = [
"--target=arm-liteos",
"--sysroot=${ohos_root_path}prebuilts/lite/sysroot"
]
cflags_cc = cflags
ldflags = cflags
ldflags += [
"-L${ohos_build_compiler_dir}/lib/arm-liteos/c++",
"-L${ohos_root_path}prebuilts/lite/sysroot/usr/lib/arm-liteos",
"-L${ohos_build_compiler_dir}/lib/clang/9.0.0/lib/arm-liteos",
"-L${ohos_build_compiler_dir}/lib/arm-liteos/c++",
"-lclang_rt.builtins",
"-lc++",
"-lc++abi"
]
}
config("release") {
defines = [
"OHOS_RELEASE",
]
cflags = [
"-Oz",
"-flto"
]
cflags_cc = cflags
}
config("debug") {
defines = [
"OHOS_DEBUG",
]
cflags = [
"-Oz",
"-flto"
]
cflags_cc = cflags
}
config("default_link_path") {
out_dir = rebase_path(root_build_dir)
ldflags = [
"-L${out_dir}",
"-Wl,-rpath-link=${out_dir}"
]
}
config("liteos_a") {
configs = [
":common",
":werror",
"kernel/liteos/cortex_a:default",
":clang",
":cpu_arch",
":security",
":exceptions",
":default_link_path"
]
if (ohos_build_type == "release") {
configs += [ ":release" ]
} else if (ohos_build_type == "debug") {
configs += [ ":debug" ]
}
}
config("liteos_riscv") {
configs = [
":common",
":werror",
"kernel/liteos/cortex_m:riscv32",
":cpu_arch",
":default_link_path"
]
}
\ No newline at end of file
#
# 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("//build/lite/ohos_var.gni")
import("//build/lite/config/boards/${board_name}.gni")
if (target_os == "") {
target_os = "ohos"
}
if (target_cpu == "") {
target_cpu = board_cpu
}
if(target_os == "ohos") {
if(ohos_kernel_type == "liteos_a") {
set_default_toolchain("//build/lite/toolchain:linux_x86_64_clang")
default_target_configs = [ "//build/lite/config:liteos_a" ]
} else if (ohos_kernel_type == "liteos_riscv") {
set_default_toolchain("//build/lite/toolchain:linux_x86_64_riscv32_gcc")
default_target_configs = [ "//build/lite/config:liteos_riscv" ]
}
default_target_configs += [
"//build/lite/config:language_c",
"//build/lite/config:language_cpp",
"//build/lite/config:kernel_macros"
]
}
default_shared_library_configs = default_target_configs + [ "//build/lite/config:shared_library_config" ]
default_static_library_configs = default_target_configs + [ "//build/lite/config:static_pie_config" ]
default_executable_configs = default_static_library_configs + [ "//build/lite/config:pie_executable_config" ]
set_defaults("executable") {
configs = default_executable_configs
}
set_defaults("static_library") {
configs = default_static_library_configs
}
set_defaults("shared_library") {
configs = default_shared_library_configs
}
set_defaults("source_set") {
configs = default_target_configs
}
# 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.
board_arch = "armv7-a"
board_cpu = "cortex-a7"
# 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.
board_arch = "armv7-a"
board_cpu = "cortex-a7"
# 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.
board_arch = "rv32imc"
board_cpu = "riscv32"
# 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.
template("lite_library") {
assert(defined(invoker.target_type), "Library target_type is required.")
assert(defined(invoker.sources), "Library sources is required.")
target_type = invoker.target_type
shared_lib = (target_type == "shared_library")
if (shared_lib && ohos_kernel_type == "liteos_riscv") {
group(target_name) {
if(defined(invoker.sources)) {
assert(invoker.sources != "")
}
if(defined(invoker.public_configs)) {
assert(invoker.public_configs != "")
}
if(defined(invoker.public_deps)) {
assert(invoker.public_deps != "")
}
if(defined(invoker.output_name)) {
assert(invoker.output_name!= "")
}
}
} else {
target(target_type, target_name) {
forward_variables_from(invoker, "*")
cflags = []
cflags_cc = []
ldflags = []
if (defined(invoker.cflags)) {
cflags += invoker.cflags
}
if (defined(invoker.cflags_cc)) {
cflags_cc += invoker.cflags_cc
ldflags += ["-lstdc++"]
}
if (defined(invoker.ldflags)) {
ldflags += invoker.ldflags
}
shared_lib = (target_type == "shared_library")
if(shared_lib) {
cflags += [ "-fPIC" ]
cflags_cc += [ "-fPIC" ]
} else {
cflags += [ "-fPIE" ]
cflags_cc += [ "-fPIE" ]
}
}
}
}
# Defines a component
#
# The lite_subsystem template defines all the modules contained in a subsystem
#
# Parameters
#
# component_features (required)
# [list of scopes] Defines all features in the component.
template("lite_component") {
assert(defined(invoker.features), "Component features is required.")
forward_variables_from(invoker, "*")
if (!defined(invoker.target_type)) {
target_type = "group"
} else if (invoker.target_type == "static_library") {
target_type = "group"
} else {
target_type = invoker.target_type
}
assert(target_type != "")
target(target_type, target_name) {
deps = []
# add component deps
if(defined(invoker.deps)) {
deps += invoker.deps
}
# add component features
foreach(feature_label, features) {
deps += [ feature_label ]
}
}
}
template("build_ext_component")
{
if(defined(invoker.version)) {
print(invoker.version)
}
action(target_name){
deps = []
if(defined(invoker.deps)) {
deps += invoker.deps
}
args = []
if(defined(invoker.exec_path)) {
args += [
"--path=${invoker.exec_path}"
]
}
if(defined(invoker.enable)) {
args += [
"--enable=${invoker.enable}"
]
}
if(defined(invoker.prebuilts)) {
args += [
"--prebuilts=${invoker.prebuilts}"
]
}
if(defined(invoker.command)) {
args += [
"--command=${invoker.command}"
]
}
script = "//build/lite/build_ext_components.py"
outputs = [ "$target_out_dir/${target_name}_build_ext_components.txt" ]
}
}
template("ohos_tools") {
target(invoker.target_type, target_name) {
forward_variables_from(invoker, "*")
output_dir = "$root_out_dir/tools/$target_name"
if (ohos_kernel_type == "liteos_a" || ohos_kernel_type == "linux") {
configs -= [ "//build/lite/config:ohos" ]
} else if (ohos_kernel_type == "liteos_riscv") {
configs -= [ "//build/lite/config:liteos" ]
}
configs -= [ "//build/lite/config:pie_executable_config" ]
configs -= [ "//build/lite/config:static_pie_config" ]
configs += [ "//build/lite/config:tools" ]
}
}
template("generate_notice_file") {
assert(defined(invoker.module_name), "module_name in required.")
assert(defined(invoker.module_source_dir_list), "module_source_dir_list in required.")
assert(target_name != "")
forward_variables_from(invoker,
[
"module_name",
"module_source_dir_list",
])
gen_script = rebase_path("//build/lite/gen_module_notice_file.py")
foreach(module_source_dir, module_source_dir_list) {
arguments = []
arguments = [
"--root-out-dir",
rebase_path(root_out_dir),
"--module-source-dir",
rebase_path(module_source_dir),
"--module-relative-source-dir",
rebase_path(module_source_dir, "//"),
"--target-name",
module_name,
]
ret_msg = ""
ret_msg = exec_script(gen_script, arguments, "list lines")
if (ret_msg != "") {
foreach(msg, ret_msg) {
print(msg)
}
}
}
}
# 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.
config("default") {
cflags = [
"-mno-unaligned-access",
"-fno-omit-frame-pointer",
]
cflags_cc = cflags
}
# 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.
config("riscv32") {
defines = []
cflags = []
include_dirs = []
defines = [
"LOS_COMPILE_LDM",
"PRODUCT_USR_SOFT_VER_STR=\"None\"",
"CYGPKG_POSIX_SIGNALS",
"__ECOS__",
"__RTOS_",
"PRODUCT_CFG_HAVE_FEATURE_SYS_ERR_INFO",
"__LITEOS__",
"LIB_CONFIGURABLE",
"LOSCFG_SHELL",
"LOSCFG_CACHE_STATICS",
"CUSTOM_AT_COMMAND",
"LOS_COMPILE_LDM",
"LOS_CONFIG_IPERF3",
"CMSIS_OS_VER=2",
"SECUREC_ENABLE_SCANF_FILE=0",
"CONFIG_AT_COMMAND",
"PRODUCT_CFG_CHIP_VER_STR=\"Hi3861V100\"",
"CHIP_VER_Hi3861",
"PRODUCT_CFG_SOFT_VER_STR=\"Hi3861\"",
"HI_BOARD_ASIC",
"HI_ON_FLASH",
"LITEOS_WIFI_IOT_VERSION",
]
cflags = [
"-falign-functions=2",
"-msave-restore",
"-fno-optimize-strlen",
"-freorder-blocks-algorithm=simple",
"-fno-schedule-insns",
"-fno-inline-small-functions",
"-fno-inline-functions-called-once",
"-mtune=size",
"-mno-small-data-limit=0",
"-fno-aggressive-loop-optimizations",
"-std=c99",
"-Wpointer-arith",
"-Wstrict-prototypes",
"-fstack-protector-all",
"-Os",
"-ffunction-sections",
"-fdata-sections",
"-fno-exceptions",
"-fno-short-enums",
"-Wextra",
"-Wall",
"-Wundef",
"-U",
"PRODUCT_CFG_BUILD_TIME",
]
include_dirs += [
"//vendor/hisi/hi3861/hi3861/include",
"//vendor/hisi/hi3861/hi3861/platform/include",
"//vendor/hisi/hi3861/hi3861/platform/system/include",
"//vendor/hisi/hi3861/hi3861/config",
"//vendor/hisi/hi3861/hi3861/config/nv",
"//utils/native/lite/include",
"//vendor/hisi/hi3861/hi3861/platform/os/Huawei_LiteOS/kernel/base/include",
"//vendor/hisi/hi3861/hi3861/platform/os/Huawei_LiteOS/targets/hi3861v100/include",
"//vendor/hisi/hi3861/hi3861/platform/os/Huawei_LiteOS/kernel/include",
"//vendor/hisi/hi3861/hi3861/platform/os/Huawei_LiteOS/arch/risc-v/rv32im",
"//vendor/hisi/hi3861/hi3861/platform/os/Huawei_LiteOS/components/lib/libm/include",
"//vendor/hisi/hi3861/hi3861/platform/os/Huawei_LiteOS/components/lib/libsec/include",
"//vendor/hisi/hi3861/hi3861/platform/os/Huawei_LiteOS/net/wpa_supplicant-2.7/src/common",
"//vendor/hisi/hi3861/hi3861/platform/os/Huawei_LiteOS/targets/hi3861v100/plat/riscv",
"//vendor/hisi/hi3861/hi3861/platform/os/Huawei_LiteOS/kernel/include",
"//vendor/hisi/hi3861/hi3861/platform/os/Huawei_LiteOS/kernel/extended/runstop",
"//vendor/hisi/hi3861/hi3861/platform/os/Huawei_LiteOS/components/posix/include",
"//vendor/hisi/hi3861/hi3861/platform/os/Huawei_LiteOS/components/linux/include",
"//vendor/hisi/hi3861/hi3861/platform/os/Huawei_LiteOS/net/lwip_sack/include",
"//vendor/hisi/hi3861/hi3861/platform/os/Huawei_LiteOS/components/lib/libc/musl/include",
"//vendor/hisi/hi3861/hi3861/platform/os/Huawei_LiteOS/components/lib/libc/musl/arch/generic",
"//vendor/hisi/hi3861/hi3861/platform/os/Huawei_LiteOS/components/lib/libc/musl/arch/riscv32",
"//vendor/hisi/hi3861/hi3861/platform/os/Huawei_LiteOS/components/lib/libc/hw/include",
"//vendor/hisi/hi3861/hi3861/platform/os/Huawei_LiteOS/components/lib/libc/nuttx/include",
"//vendor/hisi/hi3861/hi3861/platform/os/Huawei_LiteOS/components/lib/libsec/include",
"//vendor/hisi/hi3861/hi3861/platform/os/Huawei_LiteOS/targets/hi3861v100/config",
"//vendor/hisi/hi3861/hi3861/platform/os/Huawei_LiteOS/targets/hi3861v100/user",
"//vendor/hisi/hi3861/hi3861/platform/os/Huawei_LiteOS/targets/hi3861v100/plat",
"//vendor/hisi/hi3861/hi3861/platform/os/Huawei_LiteOS/targets/hi3861v100/extend/include",
"//vendor/hisi/hi3861/hi3861/platform/os/Huawei_LiteOS/arch",
"//vendor/hisi/hi3861/hi3861/platform/os/Huawei_LiteOS/components/lib/libc/bionic/libm",
"//vendor/hisi/hi3861/hi3861/platform/os/Huawei_LiteOS/shell/include",
"//vendor/hisi/hi3861/hi3861/platform/os/Huawei_LiteOS/net/telnet/include",
]
}
#
# 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.
#
declare_args() {
# build feature ability, dependent window
enable_ohos_appexecfwk_feature_ability = true
}
#
# 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.
#
# Defines a subsystem
#
# The lite_subsystem template defines all the modules contained in a subsystem
#
# Parameters
#
# subsystem_components (required)
# [list of scopes] Defines all modules in the subsystem.
#
template("lite_subsystem") {
assert(defined(invoker.subsystem_components), "subsystem_components in required.")
lite_subsystem_components = invoker.subsystem_components
group(target_name) {
deps = []
if(defined(invoker.deps)) {
deps += invoker.deps
}
# add subsystem packages
foreach(pkg_label, lite_subsystem_components) {
deps += [ pkg_label ]
}
}
}
template("lite_subsystem_test") {
assert(defined(invoker.subsystem_components), "subsystem_components in required.")
lite_subsystem_components = invoker.subsystem_components
group(target_name) {
deps = []
if(defined(invoker.deps)) {
deps += invoker.deps
}
# add subsystem packages
foreach(pkg_label, lite_subsystem_components) {
deps += [ pkg_label ]
}
}
}
template("lite_subsystem_sdk") {
assert(defined(invoker.interface_header), "interface_header in required.")
assert(defined(invoker.sdk_libs_path), "sdk_libs_path in required.")
assert(defined(invoker.subsystem_name), "subsystem_name in required.")
interface_header = invoker.interface_header
sdk_libs_path = invoker.sdk_libs_path
subsystem_name = invoker.subsystem_name
deps = [ ":${subsystem_name}" ]
outdir = rebase_path("$root_out_dir/${subsystem_name}")
prebuilts = "mkdir -p $outdir/interface $outdir/sdk_libs"
command = "cp -r $interface_header $outdir/interface && cp -r $sdk_libs_path $outdir/sdk_libs"
exec_path = rebase_path(".", root_build_dir)
action(target_name){
args = [
"--path=$exec_path",
"--prebuilts=$prebuilts",
"--command=$command",
"--enable=$LOSCFG_SDK_BUILD"
]
script = "//build/lite/build_ext_components.py"
outputs = [ "$target_out_dir/sdk_build_file_log.txt" ]
}
}
template("lite_vendor_sdk") {
prebuilts = invoker.prebuilts
command = invoker.command
exec_path = rebase_path(".", root_build_dir)
action(target_name){
args = [
"--path=$exec_path",
"--prebuilts=$prebuilts",
"--command=$command",
"--enable=$LOSCFG_SDK_BUILD"
]
script = "//build/lite/build_ext_components.py"
outputs = [ "$target_out_dir/sdk_build_file_log.txt" ]
}
}
# 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.
# liteos c test template
test_common_include_dirs = [
"//third_party/googletest/googletest/include",
]
test_liteos_include_dirs = [
"//utils/native/lite/include",
"//drivers/liteos/platform/board/hisi/common",
"//kernel/liteos_a/kernel/include",
"//third_party/bounds_checking_function/include",
]
template("unittest") {
executable(target_name) {
output_dir = "${root_out_dir}/test/unittest"
forward_variables_from(invoker,"*")
if (!defined(include_dirs)) {
include_dirs = []
}
include_dirs += test_common_include_dirs
if (ohos_kernel_type == "liteos_a") {
include_dirs += test_liteos_include_dirs
}
if (!defined(deps)) {
deps = []
}
if (ohos_kernel_type == "liteos_a") {
deps += [
"//test/developertest/third_party/lib/cpp:gtest_main",
]
}
if (!defined(configs)) {
configs = []
}
cflags = [ "-Wno-error" ]
ldflags = []
if(defined(invoker.ldflags)) {
ldflags += invoker.ldflags
}
if (ohos_build_compiler != "clang") {
ldflags += [ "-lstdc++" ]
}
}
}
template("moduletest") {
executable(target_name) {
output_dir = "${root_out_dir}/test/moduletest"
forward_variables_from(invoker, "*")
if (!defined(include_dirs)) {
include_dirs = []
}
include_dirs += test_common_include_dirs
if (ohos_kernel_type == "liteos_a") {
include_dirs += test_liteos_include_dirs
}
if (!defined(deps)) {
deps = []
}
if (ohos_kernel_type == "liteos_a") {
deps += [
"//test/developertest/third_party/lib/cpp:gtest_main",
]
}
if (!defined(configs)) {
configs = []
}
cflags = [ "-Wno-error" ]
ldflags = []
if(defined(invoker.ldflags)) {
ldflags += invoker.ldflags
}
if (ohos_build_compiler != "clang") {
ldflags += [ "-lstdc++" ]
}
}
}
template("subsystem_test") {
assert(defined(invoker.test_components), "Test Components is required.")
group(target_name) {
deps = []
if(defined(invoker.test_components)) {
deps += invoker.test_components
}
}
}
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# 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 os
import shutil
from utils import file_write
from utils import CallbackDict, makedirs
from utils import read_json_file
def args_gn_create(config):
# Delete and create output directory
out_path = config.get_out_path()
if os.path.exists(out_path):
shutil.rmtree(out_path)
makedirs(out_path)
def args_gn_write(config):
product_args_path = os.path.join(config.get_out_path(), 'args.gn')
ndk = config.ndk
build_type = config.build_type
file_write(product_args_path, 'at', 'product = "{}"\n'.format(
config.product))
# Add import to the file header
if ndk is not None:
ndk_gn_args = ('ohos_build_ndk = true\n'
'ohos_build_ndk_target_host = "{}"'
'\n'.format(ndk))
file_write(product_args_path, 'at', ndk_gn_args)
if config.test_args:
file_write(product_args_path, 'at',
'ohos_xts_test_args = "{}"\n'.format(config.test_args[1]))
file_write(product_args_path, 'at',
'ohos_build_type = "{}"\n'.format(build_type))
for feature in CallbackDict.args_list:
file_write(product_args_path, 'at', '{}\n'.format(feature))
def load_subsystem_feature(config):
product = config.product
product_json = os.path.join(os.path.dirname(os.path.abspath(__file__)),
'product', '{}.json'.format(product))
json_content = read_json_file(product_json)
for subsystem in json_content['subsystem']:
for component in subsystem['component']:
for feature in component['features']:
CallbackDict.args_list.append(feature)
def config_create(**kwargs):
config = kwargs['config']
args_gn_create(config)
load_subsystem_feature(config)
args_gn_write(config)
return True
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# 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 argparse
import os
import shutil
import sys
from utils import makedirs
def copytree(src, dst, symlinks=False, ignore=None):
for item in os.listdir(src):
if '.git' in item or '.repo' in item:
continue
src_path = os.path.join(src, item)
dst_path = os.path.join(dst, item)
if os.path.isdir(src_path):
try:
shutil.copytree(src_path, dst_path, symlinks)
except Exception as e:
print('Warning :{}\nIgnore invalid symlink!'.format(
str(e.args[0])))
else:
shutil.copy2(src_path, dst_path)
def main():
parser = argparse.ArgumentParser(
description='A common diretory and file copy.')
parser.add_argument(
'--src_type',
help='src tyepe to copy.')
parser.add_argument(
'--src',
help='List the sources to copy.',
required=True)
parser.add_argument(
'--dest_dir',
help='Path that the sources should be copied to.',
required=True)
args = parser.parse_args()
out_dir = args.dest_dir
if not os.path.exists(out_dir):
makedirs(out_dir)
if args.src_type == "file" or os.path.isfile(args.src):
shutil.copy(args.src, out_dir)
return 0
source_dir = args.src
assert os.path.exists(source_dir)
copytree(source_dir, out_dir)
return 0
if __name__ == '__main__':
sys.exit(main())
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# 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.
#
from utils import CallbackDict
from filter_process import code_filter
def add_options(parser):
parser.add_argument('-c', '--config', help='Config for code filtering',
nargs='*')
parser.add_argument('--no_commit_msg', help='Remove commit msg',
action='store_true')
parser.add_argument('-p', '--path', help='Code targer path after '
'filtering out', nargs='*')
def exec_command(args):
callback_dict = CallbackDict()
target = 'filter'
if args.config:
callback_dict.config = args.config[0]
no_commit_msg = args.no_commit_msg
if args.path:
target_path = args.path[0]
else:
target_path = 'ohos_opensource'
callback_dict.register(target, code_filter)
callback_dict.excute(target,
callback_dict=callback_dict,
no_commit_msg=no_commit_msg,
target_path=target_path)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# 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 sys
import os
import shutil
from utils import read_json_file
from xml.etree.ElementTree import parse
from utils import remove_path
def is_opensource(bundle):
"""Get opensource infomation from bundle.json."""
bundle_data = read_json_file(bundle)
bundle_publish = bundle_data.get('publishAs')
if not bundle_publish:
raise Exception('Could not find "publishAs" in {}'.format(bundle))
if bundle_publish == 'source':
return True
return False
def filter_out_code(code_path):
if not os.path.exists(code_path):
raise Exception('Could not find code path: {}'.format(code_path))
shutil.rmtree(code_path)
def get_source_list(tag):
if tag is None:
return None
source_list = []
for source in tag.iterfind('project'):
path = source.attrib['path']
source_list.append(path)
return source_list
def get_filter_list(xml):
"""Parse the config xml and get selected code path."""
filter_xml = parse(xml)
opensource_tag = filter_xml.find('opensource')
non_opensource_tag = filter_xml.find('non_opensource')
opensource_list = get_source_list(opensource_tag)
non_opensource_list = get_source_list(non_opensource_tag)
return opensource_list, non_opensource_list
def check_ignore(no_commit_msg):
if no_commit_msg:
ignore = shutil.ignore_patterns('.git', '.repo')
else:
ignore = None
return ignore
def filter_by_bundle(config, path, no_commit_msg):
"""Filter out code by bundle.json in every code repository."""
cwd_path = os.getcwd()
ignore = check_ignore(no_commit_msg)
shutil.copytree(cwd_path, path, symlinks=False, ignore=ignore)
for relpath, dirs, files in os.walk(path):
if config in files:
full_path = os.path.join(path, relpath, config)
bundle_path = os.path.normpath(os.path.abspath(full_path))
if not is_opensource(bundle_path):
code_path = os.path.join(path, relpath)
filter_out_code(code_path)
def filter_by_path(config, path, no_commit_msg):
"""Filter out code by the config."""
if not os.path.exists(config):
raise Exception("Could not find config: {}".format(config))
opensouce_list, non_opensource_list = get_filter_list(config)
# remove target path if exsits
remove_path(path)
cwd_path = os.getcwd()
ignore = check_ignore(no_commit_msg)
# copy opensource code directly
if opensouce_list:
for each in opensouce_list:
source_path = os.path.join(cwd_path, each)
dst_path = os.path.join(path, each)
if os.path.isfile(source_path):
shutil.copy(source_path, dst_path)
else:
try:
shutil.copytree(source_path, dst_path, symlinks=False,
ignore=ignore)
except Exception as e:
print(e.args[0])
if non_opensource_list:
for source_code in non_opensource_list:
source_path = os.path.join(path, source_code)
if os.path.exists(source_path):
shutil.rmtree(source_path)
# copy whole source code to target path and remove selected code in config
elif non_opensource_list:
shutil.copytree(cwd_path, path, symlinks=False, ignore=ignore)
for source_code in non_opensource_list:
source_path = os.path.join(path, source_code)
if os.path.exists(source_path):
shutil.rmtree(source_path)
def code_filter(**kwargs):
"""
description: Filter out code by config or bundle.json
param:
callback_dict: building class, contains the path of config
or bundle.json
no_commit_msg: true if remove git message, like .git and .repo
target_path: target code path after filtering out
return: NA
"""
callback_dict = kwargs['callback_dict']
no_commit_msg = kwargs['no_commit_msg']
target_path = kwargs['target_path']
if callback_dict.config is None:
target_config = 'bundle.json'
filter_by_bundle(target_config, target_path, no_commit_msg)
else:
target_config = callback_dict.config
filter_by_path(target_config, target_path, no_commit_msg)
if __name__ == "__main__":
sys.exit(0)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# 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 sys
import argparse
import os
from utils import read_json_file
from utils import makedirs
from utils import encode
from utils import decode
def is_top_dir(src_path):
return os.path.exists(os.path.join(src_path, '.gn'))
def find_config_parent_file(src_dir, target_cfg):
if (not os.path.isdir(src_dir)) or is_top_dir(src_dir):
return ''
for file in os.listdir(src_dir):
file_path = os.path.join(src_dir, file)
if os.path.isfile(file_path):
if os.path.basename(file_path) == target_cfg:
return src_dir
return find_config_parent_file(os.path.dirname(src_dir), target_cfg)
def get_notice_file_name(readme_file_path, copyright_file,
module_relative_src_path):
if not os.path.exists(readme_file_path) or os.path.isdir(readme_file_path):
return '', '', '', ''
opensource_config = read_json_file(readme_file_path)
if opensource_config is None:
return '', '', '', ''
license_file = ''
license_name = None
software_name = None
for info in opensource_config:
license_file = info.get('License File')
license_name = info.get('License')
software_name = '{} {}'.format(info.get('Name'), info.get('Version Number'))
license_file_path = os.path.join(os.path.dirname(readme_file_path),
license_file.strip())
if not os.path.exists(license_file_path):
return '', '', '', ''
copyright_file_path = os.path.join(os.path.dirname(copyright_file),
copyright_file.strip())
if not os.path.exists(copyright_file_path):
return '', '', '', ''
return license_file_path, license_name, software_name, copyright_file_path
def get_opensource_config_file(module_source_dir, root_out_dir, target_cfg):
config_file = ''
expect_file = os.path.join(module_source_dir, target_cfg)
if os.path.exists(expect_file):
config_file = expect_file
else:
relpath = os.path.relpath(module_source_dir, root_out_dir)
parent_cfg_dir = find_config_parent_file(os.path.dirname(relpath),
target_cfg)
if parent_cfg_dir != '':
config_file = os.path.join(parent_cfg_dir, target_cfg)
return config_file
def get_notice_file(module_source_dir, root_out_dir,
module_relative_source_dir):
cfg_file = get_opensource_config_file(module_source_dir, root_out_dir,
'README.OpenSource')
copyright_file = get_opensource_config_file(module_source_dir,
root_out_dir,
'COPYRIGHT.OpenSource')
if cfg_file == '':
return '', '', '', ''
if copyright_file == '':
return '', '', '', ''
return get_notice_file_name(cfg_file, copyright_file,
module_relative_source_dir)
def get_notice_file_dest_path(root_out_dir, target_name):
nf_dest_list = []
nf_dest_dir = os.path.join(root_out_dir, 'NOTICE_FILE', target_name)
license_num = 1
while os.path.exists(os.path.join(nf_dest_dir,
"LICENSE{}.txt".format(license_num))):
license_num += 1
nf_dest_list.append(os.path.join(nf_dest_dir,
"LICENSE{}.txt".format(license_num)))
return nf_dest_list
def create_dest_file(filename):
dir_name = os.path.dirname(filename)
if not os.path.exists(dir_name):
makedirs(dir_name)
def gen_license(target_path, nf_dict, nf_src, cp_src):
target_license_path = os.path.join(target_path, 'NOTICE')
makedirs(target_path)
with open(nf_src, 'rt') as f:
nf_dict["license_content"] = decode(f.read())
with open(cp_src, 'rt') as f:
nf_dict["copyright"] = decode(f.read())
with open(target_license_path, 'at') as f:
f.write("Software: {}\n\n".format(encode(nf_dict["software"])))
f.write("Copyright notice: \n{}\n".format(
encode(nf_dict["copyright"])))
f.write("License: {}\n{}\n\n".format(
encode(nf_dict["license_name"]),
encode(nf_dict["license_content"])))
def generate_notice_file(root_out_dir, module_source_dir,
module_relative_source_dir, target_name):
nf_src = ''
nf_dict = {
"software": '',
"copyright": '',
"license_name": '',
"license_content": ''
}
nf_src, nf_dict["license_name"], nf_dict["software"], cp_src = \
get_notice_file(module_source_dir, root_out_dir,
module_relative_source_dir)
target_path = os.path.join(root_out_dir, 'NOTICE_FILE', target_name)
if os.path.exists(nf_src) and os.path.exists(cp_src):
gen_license(target_path, nf_dict, nf_src, cp_src)
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--root-out-dir', help='', required=True)
parser.add_argument('--module-source-dir', help='', required=True)
parser.add_argument('--module-relative-source-dir', help='', required=True)
parser.add_argument('--target-name', help='', required=True)
args = parser.parse_args()
if 'third_party/' not in args.module_relative_source_dir:
return 0
generate_notice_file(args.root_out_dir,
args.module_source_dir,
args.module_relative_source_dir,
args.target_name)
return 0
if __name__ == '__main__':
sys.exit(main())
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# 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 sys
import os
import shutil
import argparse
from utils import exec_command
from utils import makedirs
import platform
import tarfile
def move_file(old_path, new_path):
if os.path.exists(old_path):
shutil.copytree(old_path, new_path)
def is_needed_copy(file, ignore_list):
for ignore in ignore_list:
if file.endswith(ignore):
return False
return True
def copy(source, target, ignore_list):
for file in os.listdir(source):
if is_needed_copy(file, ignore_list) and \
os.path.isfile(os.path.join(source, file)):
source_file = os.path.join(source, file)
shutil.copy(source_file, target)
def mv_usr_libs(path):
libs = [lib for lib in os.listdir(path) if lib.startswith('lib') and
lib.endswith('.so')]
target_path = os.path.join(path, 'libs/usr')
if not os.path.exists(target_path):
makedirs(target_path)
for lib in libs:
source_file = os.path.join(path, lib)
shutil.move(source_file, target_path)
def check_strip(path, strip_cmd, log):
if strip_cmd == "":
return
strip_cmd_list = strip_cmd.split(" ")
for relpath, _, files in os.walk(path):
for file in files:
full_path = os.path.join(path, relpath, file)
if os.path.isfile(full_path):
cmd = strip_cmd_list + [full_path]
exec_command(cmd, log_path=log)
def tee_into_userfs(output_path, userfs):
vendor_bin_source_dir = os.path.join(output_path, 'vendor/bin')
if not os.path.exists(vendor_bin_source_dir):
return
sec_storage_dir = os.path.join(userfs, 'data/sec_storage_data')
makedirs(sec_storage_dir)
sec_storage_root_dir = os.path.join(userfs, 'sec_storage')
makedirs(sec_storage_root_dir)
def list_all_files(rootdir):
_files = []
filelist = os.listdir(rootdir)
for i in filelist:
path = os.path.join(rootdir, i)
if os.path.isdir(path):
_files.append(path)
_files.extend(list_all_files(path))
if os.path.isfile(path):
_files.append(path)
return _files
def chmod_files_mode(root_dir, dir_mode, file_mode):
if os.path.isdir(root_dir):
os.chmod(root_dir, dir_mode)
filelist = list_all_files(root_dir)
for i in filelist:
if os.path.isdir(i):
os.chmod(i, dir_mode)
if os.path.isfile(i):
os.chmod(i, file_mode)
def change_rootfs_filemode(path):
# change all files filemode
chmod_files_mode(path, 493, 365)
# change special dirs filemode
tmppath = os.path.join(path, "bin")
if os.path.exists(tmppath):
chmod_files_mode(tmppath, 365, 365)
tmppath = os.path.join(path, "usr")
if os.path.exists(tmppath):
chmod_files_mode(tmppath, 365, 365)
tmppath = os.path.join(path, "lib")
if os.path.exists(tmppath):
chmod_files_mode(tmppath, 365, 365)
tmppath = os.path.join(path, "vendor")
if os.path.exists(tmppath):
chmod_files_mode(tmppath, 365, 292)
tmppath = os.path.join(path, "system")
if os.path.exists(tmppath):
chmod_files_mode(tmppath, 365, 292)
tmppath = os.path.join(path, "etc")
if os.path.exists(tmppath):
chmod_files_mode(tmppath, 365, 292)
tmppath = os.path.join(path, "vendor/bin")
if os.path.exists(tmppath):
chmod_files_mode(tmppath, 365, 365)
# change special files filemode
tmppath = os.path.join(path, "etc/init.cfg")
if os.path.exists(tmppath):
os.chmod(tmppath, 256)
tmppath = os.path.join(path, "bin/init")
if os.path.exists(tmppath):
os.chmod(tmppath, 320)
tmppath = os.path.join(path, "bin/shell")
if os.path.exists(tmppath):
os.chmod(tmppath, 320)
def create_file_symlink(file_name, src_dir, dst_dir):
src = os.path.join(src_dir, file_name)
dst = os.path.join(dst_dir, file_name)
tmppath = os.path.join("/usr/lib/", file_name)
if os.path.exists(src):
os.symlink(tmppath, dst)
def create_symlinks_for_dv(path):
src_path = os.path.join(path, "usr/lib")
dst_path = os.path.join(path, "lib")
create_file_symlink("libmbedtls_shared.so", src_path, dst_path)
create_file_symlink("libcjson_shared.so", src_path, dst_path)
create_file_symlink("libsys_parameter.so", src_path, dst_path)
create_file_symlink("libsec_shared.so", src_path, dst_path)
create_file_symlink("libsamgr.so", src_path, dst_path)
create_file_symlink("libliteipc_adapter.so", src_path, dst_path)
create_file_symlink("libhilog_a_shared.so", src_path, dst_path)
def change_rootfs_filemode_linux(path):
tmppath = os.path.join(path, "lib")
chmod_files_mode(tmppath, 493, 420)
tmppath = os.path.join(path, "lib/ld-uClibc-0.9.33.2.so")
if os.path.exists(tmppath):
os.chmod(tmppath, 365)
tmppath = os.path.join(path, "lib/ld-2.24.so")
if os.path.exists(tmppath):
os.chmod(tmppath, 365)
tmppath = os.path.join(path, "usr")
os.chmod(tmppath, 493)
tmppath = os.path.join(path, "usr/lib")
chmod_files_mode(tmppath, 493, 420)
tmppath = os.path.join(path, "etc/init.cfg")
os.chmod(tmppath, 256)
if "dv300" in path:
create_symlinks_for_dv(path)
def change_userfs_filemode(path):
# change all files filemode
chmod_files_mode(path, 493, 365)
# change special files filemode
tmppath = os.path.join(path, "etc/cameradev.ini")
if os.path.exists(tmppath):
os.chmod(tmppath, 420)
def remove_file_in_rootfs(output_path):
rootfs_app = os.path.join(output_path, 'rootfs/app')
rootfs_data = os.path.join(output_path, 'rootfs/data')
if os.path.exists(rootfs_app):
shutil.rmtree(rootfs_app)
if os.path.exists(rootfs_data):
shutil.rmtree(rootfs_data)
def make_rootfs_tar(tar_filename, source_dir):
with tarfile.open(tar_filename, "w") as tar:
tar.add(source_dir, arcname=os.path.basename(source_dir))
def gen_rootfs(mkfs, fstype, output_path, rootfs_dirs_dict, kernel):
mv_usr_libs(output_path)
rootfs = os.path.join(output_path, 'rootfs')
rootfs_tar = os.path.join(output_path, 'rootfs.tar')
if not os.path.exists(rootfs):
print('rootfs dir not exist in {}'.format(rootfs))
return 0
log = os.path.join(output_path, 'build.log')
for path_part, value_list in rootfs_dirs_dict.items():
source_path = os.path.join(output_path, path_part)
target_path = os.path.join(rootfs, value_list[0])
strip_cmd = value_list[2]
if os.path.exists(source_path):
if not os.path.exists(target_path):
makedirs(target_path)
ignore_list = value_list[1]
copy(source_path, target_path, ignore_list)
check_strip(target_path, strip_cmd, log)
if kernel == "linux":
change_rootfs_filemode_linux(rootfs)
cmd = [mkfs, rootfs, "jffs2"]
exec_command(cmd, log_path=log)
if kernel == "liteos_a":
remove_file_in_rootfs(output_path)
change_rootfs_filemode(rootfs)
cmd = [mkfs, rootfs, fstype]
exec_command(cmd, log_path=log)
make_rootfs_tar(rootfs_tar, rootfs)
if os.path.exists(rootfs):
chmod_files_mode(rootfs, 511, 511)
shutil.rmtree(rootfs)
return 0
def make_userfs_dir(dir_path):
if not os.path.exists(dir_path):
makedirs(dir_path)
if not os.path.exists(dir_path):
print('make' + str(dir_path) + 'fail')
return -1
def move_rootfs_to_userfs(output_path):
rootfs_app = os.path.join(output_path, 'rootfs/app')
rootfs_data = os.path.join(output_path, 'rootfs/data')
userfs_app = os.path.join(output_path, 'userfs/app')
userfs_data = os.path.join(output_path, 'userfs/data')
move_file(rootfs_app, userfs_app)
move_file(rootfs_data, userfs_data)
def gen_userfs(mkfs, fstype, output_path, userfs_dirs_dict):
userfs = os.path.join(output_path, 'userfs')
userfs_etc = os.path.join(output_path, 'userfs/etc')
if make_userfs_dir(userfs):
return 0
if make_userfs_dir(userfs_etc):
return 0
move_rootfs_to_userfs(output_path)
log = os.path.join(output_path, 'build.log')
tee_into_userfs(output_path, userfs)
for path_part, value_list in userfs_dirs_dict.items():
source_path = os.path.join(output_path, path_part)
target_path = os.path.join(userfs, value_list[0])
strip_cmd = value_list[2]
if os.path.exists(source_path):
if not os.path.exists(target_path):
makedirs(target_path)
ignore_list = value_list[1]
copy(source_path, target_path, ignore_list)
check_strip(target_path, strip_cmd, log)
change_userfs_filemode(userfs)
if fstype == "vfat":
cmd = [mkfs, userfs, fstype, '52428800']
else:
cmd = [mkfs, userfs, fstype]
exec_command(cmd, log_path=log)
return 0
def main():
parser = argparse.ArgumentParser(description='Generate rootfs')
parser.add_argument('--path', help='Build output path')
parser.add_argument('--board', help='Board type')
parser.add_argument('--kernel', help='OHOS kernel type')
parser.add_argument('--compile_so', help='So strip command')
parser.add_argument('--compile_bin', help='Bin strip command')
args = parser.parse_args()
if args.board == 'hi3861v100':
return
if args.path:
output_path = os.path.abspath(args.path)
mkfs = os.path.join(
output_path,
'../../kernel/liteos_a/tools/scripts/make_rootfs/rootfsimg.sh')
if not os.path.exists(mkfs):
print('mkfs not exist in {}'.format(mkfs))
return -1
else:
return -1
if args.board:
if args.board == 'hi3516dv300':
fstype = 'vfat'
else:
fstype = 'jffs2'
else:
return -1
so_strip_cmd = args.compile_so
bin_strip_cmd = args.compile_bin
kernel = args.kernel
rootfs_dirs_dict = {
'bin': ['bin', ['Test.bin', 'TestSuite.bin'], bin_strip_cmd],
'libs': ['lib', ['.a'], so_strip_cmd],
'libs/usr': ['usr/lib', ['.a'], so_strip_cmd],
'bin/usr': ['usr/bin', [], bin_strip_cmd],
'vendor/bin': ['vendor/bin', [], ""],
'vendor/lib': ['vendor/lib', [], ""],
'vendor/firmware/hisilicon': ['vendor/firmware/hisilicon', [], ""],
'obj/vendor/huawei/camera/init_configs/config': ['etc', [], ""],
'system/internal': ['system/internal', [], ""],
'etc': ['etc', [], ""]
}
userfs_dirs_dict = {
'obj/base/security/services/app_verify/config':
['data/verify', [], ""],
'storage/etc': ['etc', [], ""],
'data': ['data', [], ""]
}
if kernel == "liteos_a":
ret = gen_userfs(mkfs, fstype, output_path, userfs_dirs_dict)
if ret:
return -1
return gen_rootfs(mkfs, fstype, output_path, rootfs_dirs_dict, kernel)
if __name__ == "__main__":
sys.exit(main())
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# 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 argparse
from datetime import datetime
import time
import sys
def get_build_time():
build_time = datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S,%f")
time_seconds, micro_seconds = build_time.split(',')
time_array = time.strptime(time_seconds, "%Y-%m-%d %H:%M:%S")
print(int(time.mktime(time_array) * 1000 + int(micro_seconds) * 10))
return 0
def main():
parser = argparse.ArgumentParser()
parser.add_argument('-t', '--time', help='Get build time',
action='store_true')
args = parser.parse_args()
if args.time:
return get_build_time()
if __name__ == "__main__":
sys.exit(main())
# 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("//build/lite/ndk/ndk.gni")
ndk_toolchains("build_script")
{
src_type = "file"
src_dir = [
"//build/lite/ndk/build/BUILD.gn",
"//build/lite/ndk/build/build.py",
"//build/lite/ndk/README.md",
"//build/lite/ndk/build/.gn",
]
dest_dir = [
"$root_out_dir/ndk",
"$root_out_dir/ndk",
"$root_out_dir/ndk",
"$root_out_dir/ndk/build",
]
}
ndk_toolchains("source") {
src_dir = [
"//build/lite/ndk/sample",
"//build/lite/ndk/build/config",
"//build/lite/ndk/build/toolchain"
]
dest_dir = [
"$root_out_dir/ndk/sample",
"$root_out_dir/ndk/build/config",
"$root_out_dir/ndk/build/toolchain"
]
if (ohos_build_compiler == "clang") {
src_dir += [
"//prebuilts/lite/sysroot/usr/lib",
"//prebuilts/lite/sysroot/usr/include"
]
dest_dir += [
"$root_out_dir/ndk/sysroot/usr/lib",
"$root_out_dir/ndk/sysroot/usr/include"
]
}
}
group("ndk_build") {
deps = [
":source",
":build_script",
"//foundation/communication/services/softbus_lite:softbus_lite_ndk",
"//base/startup/services/bootstrap_lite:bootstrap_lite_ndk",
"//utils/native/lite:native_api",
"//base/startup/frameworks/syspara_lite/parameter:parameter_notes",
]
if (ohos_kernel_type != "liteos_riscv") {
deps += [
"//base/security/interfaces/kits/iam_lite:permission_notes",
"//base/hiviewdfx/frameworks/hilog_lite/featured:hilog_ndk",
"//foundation/distributedschedule/services/samgr_lite:samgr_lite_ndk",
"//foundation/graphic/lite:ndk_build",
"//foundation/aafwk/frameworks/ability_lite:ability_notes",
"//foundation/appexecfwk/frameworks/bundle_lite:bundle_notes",
"//foundation/multimedia/services/media_lite:media_ndk",
"//base/startup/frameworks/syspara_lite/token:token_notes",
"//foundation/communication/frameworks/ipc_lite:liteipc_ndk",
"//third_party/mbedtls:mbedtls_ndk",
"//third_party/cJSON:cjson_ndk",
"//drivers/hdf/lite/hdi:native_api",
"//third_party/wpa_supplicant/wpa_supplicant-2.9:wpa_supplicant",
]
if (ohos_build_type == "debug") {
deps += [
"//prebuilts/lite/sysroot/apidoc:lite_kernel_ndk"
]
}
} else {
deps += [
"$ohos_vendor_adapter_dir/hals/communication/wifi_lite/wifiservice:wifiservice_ndk",
"//base/iot_hardware/frameworks/wifiiot_lite/src:iothardware_ndk",
"//prebuilts/lite/sysroot/apidoc:lite_kernel_ndk",
"//base/hiviewdfx/frameworks/hilog_lite/mini:hilog_lite_ndk",
]
}
}
action("ndk") {
if (ohos_build_ndk) {
deps = ["doc"]
script = "//build/lite//ndk/archive_ndk.py"
depfile = "${target_gen_dir}/${target_name}.d"
ndk_name =
"$ohos_build_ndk_target_host-$ohos_build_compiler-$ohos_build_ndk_version"
args = [
"--src_dir",
rebase_path("$root_build_dir/ndk"),
"--name",
ndk_name,
"--dest_dir",
rebase_path("$root_build_dir/packages/ndk")
]
outputs = [ "$root_build_dir/packages/ndk/$ndk_name.zip" ]
}
}
# 轻鸿蒙NDK使用指南
## 简介
NDK = Native Development Kit, 主要包括系统提供的c/c++接口库文件,编译工具链,工具和接口描述文档。
## 目录结构
├── build **编译框架**
│ ├── config
│ └── toolchain
├── doc **native api接口描述文档**
├── gcc **编译工具链**
│ ├── arm-linux-ohoseabi -> arm-linux-musleabi
│ ├── arm-linux-musleabi
│ ├── bin
│ ├── host_bin
│ ├── lib
│ ├── libexec
│ ├── runtime_musl
│ └── target
├── prebuilts **构建工具**
│ └── build-tools
├── sample **用户编译样例**
│ ├── include
│ └── src
└── sysroot **Native API**
└── usr
## 编译框架
### 编译命令
编译使用gn构建系统,在根目录执行:`python build.py`即可启动编译。支持的命令如下:
**build:** `python build.py ```python build.py build`
**clean:** `python build.py clean`
**debug/release**:`python build.py -v debug/release`
debug和release版本的区别:
debug版本:-g
release版本:-O2 + strip符号表
### 默认编译选项
1、安全编译选项:-fstack-protector-all,PIE,PIC,_FORTIFY_SOURCE=2,-Wl,-z,now,-Wl,-z,relro,-Wl,-z,noexecstack
2、告警级别:-Werror
### 应用编译示例
1、创建应用目录,并在目录下创建BUILD.gn:
```
# 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("hello_world") { # 应用库文件target,也可是shared_library
sources = [
"src/hello_world.c",
]
include_dirs = [
"include",
]
}
executable("sample") { # 应用可执行文件target
ldflags = [
"-lsys_parameter", # 应用需要使用的库
"-lsec_shared"
]
deps = [
":hello_world",
]
}
```
2、将sample加入到编译入口,编译入口为根目录下的BUILD.gn:
```
# 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("//build/toolchain/${ohos_build_compiler}.gni")
group("ohos") {
deps = []
if (target_os == "ohos") {
deps += [
"//sample" # 新加的应用
]
}
}
```
3、编译输出:out/bin
## 烧录和运行
1、请先烧录内核和文件系统
2、将应用程序nfs或者tftp到usr/bin目录下, 运行即可
\ No newline at end of file
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# 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 argparse
import os
import sys
import shutil
sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir))
from utils import makedirs # noqa: E402
def make_archive(source, destination):
base = os.path.basename(destination)
fields = base.split('.')
name = fields[0] + '.' + fields[1] + '.' + fields[2]
file_format = fields[3]
archive_from = os.path.dirname(source)
archive_to = os.path.basename(source.strip(os.sep))
print('Zipping: ', source, destination, archive_from, archive_to)
shutil.make_archive(name, file_format, archive_from, archive_to)
shutil.move('%s.%s' % (name, file_format), destination)
def main():
parser = argparse.ArgumentParser(
description='NDK archive tool.')
parser.add_argument(
'--src_dir',
help='NDK source path.',
required=True)
parser.add_argument(
'--name',
help='NDK name.',
required=True)
parser.add_argument(
'--dest_dir',
help='NDK zip dest path.',
required=True)
args = parser.parse_args()
src = args.src_dir
assert os.path.exists(src), \
'NDK build diretory not exist, please confirm NDK build result.'
dest = args.dest_dir
if not os.path.exists(dest):
makedirs(dest)
else:
shutil.rmtree(dest)
name = args.name
print(dest, name)
make_archive(src, dest + '-' + name + '.zip')
return 0
if __name__ == '__main__':
sys.exit(main())
# 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.
# The location of the build configuration file.
buildconfig = "//build/config/BUILDCONFIG.gn"
# 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("//build/toolchain/${ohos_build_compiler}.gni")
group("ohos") {
deps = []
if (target_os == "ohos") {
deps += [
"//sample"
]
}
}
\ No newline at end of file
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# 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 os
import sys
import argparse
import platform
import subprocess
import time
def exec_command(cmd, log_path='out/build.log', **kwargs):
process = subprocess.Popen(cmd)
process.wait()
ret_code = process.returncode
if ret_code != 0:
raise Exception("{} failed, return code is {}".format(cmd, ret_code))
def main():
parser = argparse.ArgumentParser()
parser.add_argument('action', help='action, build or clean path.',
nargs='*')
parser.add_argument('-v', '--build_type', help='Release or debug version.',
nargs='*')
args = parser.parse_args()
product_path = './out/'
log_path = os.path.join(product_path, 'compile.log')
args.action = ['build'] if not args.action else args.action
if args.action[0] == 'build':
gn_cmd = ''
ninja_cmd = ''
print("\n=== start build ===\n")
if platform.system().find('Windows') == 0:
gn_cmd = ['gn.exe', 'gen', product_path, '--root=.',
'--dotfile=build/.gn']
ninja_cmd = ['ninja.exe',
'-C', product_path]
else:
gn_cmd = ['gn', 'gen', product_path, '--root=.',
'--dotfile=build/.gn']
if args.build_type == 'debug':
gn_cmd += ['--args=ohos_build_type=\"debug\"']
ninja_cmd = ['ninja', '-C', product_path]
print("=== gn working ===\n")
exec_command(gn_cmd, log_path)
time.sleep(2)
print("\n=== ninja working ===")
exec_command(ninja_cmd, log_path)
print("build success!")
elif args.action[0] == 'clean':
clean_cmd = ''
if not os.path.exists(product_path):
print('Nothing to clean! No build found.')
return 0
print("\n=== start clean ===\n")
if platform.system().find('Windows') == 0:
clean_cmd = ['ninja.exe', '-C', product_path, '-t', 'clean']
else:
clean_cmd = ['ninja', '-C', product_path, '-t', 'clean']
print("=== clean working ===\n")
exec_command(clean_cmd, log_path)
print("clean success!")
if __name__ == '__main__':
sys.exit(main())
# 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.
config("cpu_arch") {
cflags = []
if (target_cpu == "cortex-a7") {
cflags += [
"-mcpu=cortex-a7",
"-mfloat-abi=softfp",
"-mfpu=neon-vfpv4"
]
} else if (target_cpu == "cortex-m4") {
cflags += [
"-mcpu=cortex-m4",
"-march=armv7e-m",
"-mthumb"
]
}
asmflags = cflags
cflags_cc = cflags
}
config("base") {
defines = [
"_FORTIFY_SOURCE=2"
]
if (ohos_kernel_type == "liteos_a" || ohos_kernel_type == "liteos_m" || ohos_kernel_type == "liteos_riscv") {
defines += [
"__LITEOS__",
]
} else if (ohos_kernel_type == "linux_4_9") {
defines += [
"__LINUX__",
]
}
cflags = [
"-fno-omit-frame-pointer",
"-nostdlib",
"-mno-unaligned-access",
"-fno-builtin",
"-Werror",
]
cflags_cc = cflags
cflags += [
"-std=c99"
]
ldflags = [
"-lc",
"-Wl,-z,now",
"-Wl,-z,relro",
"-Wl,-z,noexecstack"
]
}
config("exceptions") {
cflags_cc = [ "-fexceptions" ]
cflags_objcc = cflags_cc
}
config("no_exceptions") {
cflags_cc = [ "-fno-exceptions" ]
cflags_objcc = cflags_cc
ldflags = cflags_cc
}
config("stack_protector") {
cflags = [ "-fstack-protector-all" ]
cflags_cc = cflags
}
config("static_pie_config") {
cflags = [ "-fPIE" ]
cflags_cc = cflags
}
config("shared_library_config") {
cflags = [ "-fPIC" ]
cflags_cc = cflags
}
config("pie_executable_config") {
ldflags = [ "-pie" ]
}
config("clang") {
include_dirs = [
"//llvm/include/c++/v1",
"//sysroot/usr/include/arm-liteos",
]
cflags = [
"--target=arm-liteos",
"-mcpu=cortex-a7",
"-march=armv7-a",
"-mfloat-abi=softfp",
"--sysroot=${ohos_root_path}sysroot"
]
cflags_cc = cflags
ldflags = cflags
ldflags += [
"-L../llvm/lib/arm-liteos/c++",
"-L../sysroot/usr/lib/arm-liteos",
"-L../llvm/lib/clang/9.0.0/lib/arm-liteos",
"-L../llvm/lib/arm-liteos/c++",
"-lclang_rt.builtins",
"-lc",
"-lc++",
"-lc++abi",
"--sysroot=${ohos_root_path}sysroot"
]
}
config("clang_release") {
cflags = [
"-Oz",
"-flto"
]
cflags_cc = cflags
}
config("release") {
defines = [
"OHOS_RELEASE",
]
cflags = [
"-O2"
]
cflags_cc = cflags
}
config("debug") {
defines = [
"OHOS_DEBUG",
]
cflags = [
"-g"
]
cflags_cc = cflags
}
config("gcc") {
include_dirs = []
if (ohos_kernel_type == "liteos_a") {
include_dirs += [
"//gcc/target/usr/include",
]
ldflags = [
"-L$ohos_root_path/gcc/target/usr/lib"
]
}
}
config("sysroot") {
include_dirs = [
"//sysroot/usr/include"
]
ldflags = [
"-L$ohos_root_path/sysroot/usr/lib"
]
}
config("ohos") {
configs = [
":base",
":cpu_arch",
":stack_protector",
":exceptions",
":sysroot"
]
if (ohos_build_type == "release") {
configs += [ ":release" ]
} else if (ohos_build_type == "debug") {
configs += [ ":debug" ]
}
if (ohos_build_compiler == "gcc") {
configs += [ ":gcc" ]
} else if (ohos_build_compiler == "clang") {
configs += [":clang"]
if(ohos_build_type == "release") {
configs += [":clang_release"]
}
}
}
config("tools") {
# Add tools configs if any
}
\ No newline at end of file
# 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("//build/config/variable.gni")
if (target_os == "") {
target_os = "ohos"
}
if (target_cpu == "") {
target_cpu = "cortex-a7"
}
host_toolchains = [
"//build/toolchain:host_linux_x86_64_gcc"
]
if(target_os == "ohos") {
if(ohos_kernel_type == "liteos_a") {
if(ohos_build_compiler == "gcc") {
set_default_toolchain("//build/toolchain:linux_x86_64_ohos_gcc")
} else {
set_default_toolchain("//build/toolchain:linux_x86_64_clang")
}
default_target_configs = [ "//build/config:ohos" ]
} else if (ohos_kernel_type == "liteos_riscv") {
set_default_toolchain("//build/config:liteos")
} else if (ohos_kernel_type == "linux" && board_name == "hi3518ev300") {
set_default_toolchain("//build/toolchain:linux_x86_64_himix100_gcc")
default_target_configs = [ "//build/config:ohos" ]
} else if (ohos_kernel_type == "linux" && board_name == "hi3516dv300") {
set_default_toolchain("//build/lite/toolchain:linux_x86_64_himix200_gcc")
default_target_configs = [ "//build/config:ohos" ]
}
} else if (target_os == "linux") {
set_default_toolchain("//build/toolchain:host_linux_x86_64_gcc")
}
default_shared_library_configs = default_target_configs + [ "//build/config:shared_library_config" ]
default_static_library_configs = default_target_configs + [ "//build/config:static_pie_config" ]
default_executable_configs = default_static_library_configs + [ "//build/config:pie_executable_config" ]
set_defaults("executable") {
configs = default_executable_configs
}
set_defaults("static_library") {
configs = default_static_library_configs
}
set_defaults("shared_library") {
configs = default_shared_library_configs
}
set_defaults("source_set") {
configs = default_target_configs
}
# 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.
# Description: Define the global variables for all components
declare_args() {
# "debug" or "release"
ohos_build_type = "release"
}
declare_args() {
# Supported board: "hi3516dv300", "hi3518ev300", "hi3861v100"
board_name = "hi3518ev300"
target_arch = ""
# Supported compiler: gcc, clang
ohos_build_compiler = "clang"
# Supported kernel:
# cortex-m(liteos_m), liteos for cortex-a(liteos_a), liteos for riscv(liteos_riscv), linux kernel(linux_4_9)
ohos_kernel_type = "liteos_a"
ohos_root_path = rebase_path("//")
}
\ No newline at end of file
# 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("//build/toolchain/${ohos_build_compiler}.gni")
if(ohos_build_compiler == "gcc") {
gcc_toolchain("linux_x86_64_ohos_gcc") {
cc = "$ohos_build_compiler_dir/arm-linux-ohoseabi-gcc"
cxx = "$ohos_build_compiler_dir/arm-linux-ohoseabi-g++"
ar = "$ohos_build_compiler_dir/arm-linux-ohoseabi-ar"
ld = cc
if (ohos_build_type == "release") {
strip = "$ohos_build_compiler_dir/arm-linux-ohoseabi-strip --strip-unneeded"
}
}
gcc_toolchain("host_linux_x86_64_gcc") {
cc = "gcc"
cxx = "g++"
ar = "ar"
ld = cxx
strip = "strip"
}
}
if (ohos_build_compiler == "clang") {
clang_toolchain("linux_x86_64_clang") {
cc = "$ohos_build_compiler_dir/clang"
cxx = "$ohos_build_compiler_dir/clang++"
ar = "$ohos_build_compiler_dir/llvm-ar"
as = "$ohos_build_compiler_dir/llvm-as"
ld = cc
if (ohos_build_type == "release") {
strip = "$ohos_build_compiler_dir/llvm-objcopy --strip-all"
}
}
clang_toolchain("win_x86_64_clang") {
cc = "$ohos_build_compiler_dir/clang"
cxx = "$ohos_build_compiler_dir/clang++"
ar = "$ohos_build_compiler_dir/llvm-ar"
as = "$ohos_build_compiler_dir/llvm-as"
ld = cc
if (ohos_build_type == "release") {
strip = "$ohos_build_compiler_dir/llvm-objcopy --strip-all"
}
}
}
# 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.
ohos_build_compiler = "clang"
ohos_build_compiler_dir = rebase_path("//llvm/bin", root_build_dir)
ohos_build_compiler_prefix = "clang"
ohos_build_compiler_so_strip = "llvm-objcopy --strip-all"
ohos_build_compiler_bin_strip = "llvm-objcopy --strip-all"
template("clang_toolchain") {
toolchain(target_name) {
assert(defined(invoker.cc), "clang toolchain must specify a \"cc\" value")
assert(defined(invoker.cxx), "clang toolchain must specify a \"cxx\" value")
assert(defined(invoker.ar), "clang toolchain must specify a \"ar\" value")
assert(defined(invoker.as), "clang toolchain must specify a \"as\" value")
assert(defined(invoker.ld), "clang toolchain must specify a \"ld\" value")
cc = invoker.cc
cxx = invoker.cxx
ar = invoker.ar
as = invoker.as
ld = invoker.ld
need_strip = false
if(defined(invoker.strip)) {
strip = invoker.strip
need_strip = true
}
tool("cc") {
command = "$cc {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}"
depsformat = "gcc"
description = "clang {{output}}"
outputs = [
"{{source_out_dir}}/{{source_name_part}}.o",
]
}
tool("cxx") {
depfile = "{{output}}.d"
command = "$cxx {{defines}} {{include_dirs}} {{cflags_cc}} -c {{source}} -o {{output}}"
depsformat = "gcc"
description = "clang++ {{output}}"
outputs = [
"{{source_out_dir}}/{{source_name_part}}.o",
]
}
tool("asm") {
depfile = "{{output}}.d"
command = "$as {{include_dirs}} {{asmflags}} -c {{source}} -o {{output}}"
depsformat = "gcc"
description = "ASM {{output}}"
outputs = [
"{{source_out_dir}}/{{source_name_part}}.o",
]
}
tool("alink") {
outfile = "{{output_dir}}/{{target_output_name}}{{output_extension}}"
rspfile = "{{output}}.rsp"
rspfile_content = "{{inputs}}"
command = "$ar -r {{output}} @\"$rspfile\""
description = "AR {{output}}"
outputs = [
outfile,
]
default_output_dir = "{{root_out_dir}}/libs"
default_output_extension = ".a"
output_prefix = "lib"
}
tool("solink") {
outfile = "{{output_dir}}/{{target_output_name}}{{output_extension}}"
rspfile = "$outfile.rsp"
rspfile_content = "{{inputs}}"
command = "$ld -shared {{ldflags}} {{inputs}} -o $outfile"
if (need_strip) {
unstripped_outfile = outfile
command += " && $strip" + " \"$unstripped_outfile\" \"$outfile\""
}
default_output_extension = ".so"
description = "SOLINK $outfile"
default_output_dir = "{{root_out_dir}}"
output_prefix = "lib"
outputs = [
outfile
]
}
tool("link") {
outfile = "bin/{{target_output_name}}{{output_extension}}"
rspfile = "$outfile.rsp"
custom_ld_flags = " "
command = "$cc {{ldflags}} {{inputs}} $custom_ld_flags -o $outfile"
if (need_strip) {
command += " && $strip $outfile"
}
description = "LLVM LINK $outfile"
default_output_dir = "{{root_out_dir}}/bin"
rspfile_content = "{{inputs}}"
outputs = [
outfile
]
}
tool("stamp") {
if (host_os == "win") {
command = "cmd /c type nul > \"{{output}}\""
} else {
command = "/usr/bin/touch {{output}}"
}
description = "STAMP {{output}}"
}
tool("copy") {
command = "cp -afd {{source}} {{output}}"
description = "COPY {{source}} {{output}}"
}
}
}
\ No newline at end of file
# 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.
ohos_build_compiler = "gcc"
ohos_build_compiler_dir = rebase_path("//gcc/bin", root_build_dir)
ohos_build_compiler_prefix = "arm-linux-ohoseabi"
ohos_build_compiler_so_strip = "$ohos_build_compiler_prefix-strip --strip-unneeded"
ohos_build_compiler_bin_strip = "$ohos_build_compiler_prefix-strip --strip-unneeded"
template("gcc_toolchain") {
toolchain(target_name) {
assert(defined(invoker.ar), "gcc toolchain must specify a \"ar\" value")
assert(defined(invoker.cc), "gcc toolchain must specify a \"cc\" value")
assert(defined(invoker.cxx), "gcc toolchain must specify a \"cxx\" value")
assert(defined(invoker.ld), "gcc toolchain must specify a \"ld\" value")
cc = invoker.cc
cxx = invoker.cxx
ar = invoker.ar
ld = invoker.ld
need_strip = false
if(defined(invoker.strip)) {
strip = invoker.strip
need_strip = true
}
if (defined(invoker.extra_ldflags) && invoker.extra_ldflags != "") {
extra_ldflags = " " + invoker.extra_ldflags
} else {
extra_ldflags = ""
}
tool("cc") {
command = "$cc {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}"
depsformat = "gcc"
description = "cross compiler {{output}}"
outputs = [
"{{source_out_dir}}/{{source_name_part}}.o",
]
}
tool("cxx") {
depfile = "{{output}}.d"
command = "$cxx {{defines}} {{include_dirs}} {{cflags_cc}} -c {{source}} -o {{output}}"
depsformat = "gcc"
description = "CXX {{output}}"
outputs = [
"{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o",
]
}
tool("asm") {
depfile = "{{output}}.d"
command = "$cc {{defines}} {{include_dirs}} {{asmflags}} {{source}} -c -o {{output}}"
depsformat = "gcc"
description = "cross compiler {{output}}"
outputs = [
"{{source_out_dir}}/{{source_name_part}}.o"
]
}
tool("alink") {
outfile = "{{output_dir}}/{{target_output_name}}{{output_extension}}"
rspfile = "{{output}}.rsp"
rspfile_content = "{{inputs}}"
command = "$ar cr {{output}} @\"$rspfile\""
description = "AR {{output}}"
outputs = [
outfile
]
default_output_dir = "{{root_out_dir}}/libs"
default_output_extension = ".a"
output_prefix = "lib"
}
tool("solink") {
outfile = "{{output_dir}}/{{target_output_name}}{{output_extension}}"
rspfile = "{{output}}.rsp"
rspfile_content = "{{inputs}}"
command = "$ld -shared {{ldflags}} $extra_ldflags " +
"-Wl,--start-group {{inputs}} {{libs}} -Wl,--end-group -o $outfile"
if(need_strip) {
command += "&& $strip $outfile"
}
description = "SOLINK $outfile"
outputs = [
outfile
]
default_output_dir = "{{root_out_dir}}"
default_output_extension = ".so"
output_prefix = "lib"
}
tool("link") {
outfile = "{{output_dir}}/bin/{{target_output_name}}{{output_extension}}"
rspfile = "$outfile.rsp"
command = "$ld {{ldflags}} $extra_ldflags " +
"-Wl,--start-group {{inputs}} {{libs}} -Wl,--end-group -o $outfile "
if(need_strip) {
command += "&& $strip $outfile"
}
description = "LINK $outfile"
default_output_dir = "{{root_out_dir}}"
rspfile_content = "{{inputs}}"
outputs = [
outfile
]
}
tool("stamp") {
if (host_os == "win") {
command = "cmd /c type nul > \"{{output}}\""
} else {
command = "/usr/bin/touch {{output}}"
}
description = "STAMP {{output}}"
}
tool("copy") {
command = "cp -afd {{source}} {{output}}"
description = "COPY {{source}} {{output}}"
}
}
}
\ No newline at end of file
# 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.
ohos_build_compiler = "riscv"
ohos_build_compiler_prefix = "riscv32-unknown-elf"
ohos_build_compiler_dir_linux = ""
ohos_build_compiler_dir_win = ""
ohos_build_compiler_so_strip = ""
ohos_build_compiler_bin_strip = ""
# NOTE: riscv compiler not available, need install on host manually
#
# 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.
#
action("doc") {
deps = ["//build/lite/ndk:ndk_build"]
script = "//build/lite/ndk/doc/gen_doc.py"
depfile = "${target_gen_dir}/${target_name}.d"
exclude_dir = "*/gcc/* \ */arm-liteos/*"
doxygen_file = "//build/lite/ndk/doc/config/Doxyfile_C"
args = [
"--exclude_dir",
exclude_dir,
"--working-dir",
rebase_path("$root_build_dir/ndk"),
"--version",
ohos_version,
"--output",
rebase_path("$root_build_dir/ndk/doc"),
"--doxygen-file",
rebase_path(doxygen_file, root_build_dir),
]
outputs = [ "$root_build_dir/ndk/doc/index.html" ]
}
\ No newline at end of file
此差异已折叠。
此差异已折叠。
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# 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 os
import sys
import shutil
import re
import tempfile
import argparse
import distutils.spawn
sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir))
from utils import check_output, makedirs # noqa: E402
def gen_doc(args):
html_output_dir = args.output
contents = None
with tempfile.NamedTemporaryFile(
suffix=os.path.basename(args.doxygen_file)) as doxygen_file:
shutil.copyfile(args.doxygen_file, doxygen_file.name)
with open(doxygen_file.name, 'r') as file:
contents = file.read()
if contents is None:
raise Exception('Failed to read %s' % args.doxygen_file)
keys = {
'%VERSION%':
args.version,
'%EXCLUDE_DIR%':
args.exclude_dir,
'%OUTPUT_DIR%':
os.path.relpath(html_output_dir, args.working_dir)
}
for (key, value) in list(keys.items()):
value = value.replace('\\', '\\\\')
contents = re.sub(key, value, contents)
with open(doxygen_file.name, 'w') as file:
file.write(contents)
old_cwd = os.getcwd()
try:
# if no ndk headers exist, return.
if os.path.exists(args.working_dir) is not True:
print("no ndk headers exist, return")
return
os.chdir(args.working_dir)
doxygen_path = distutils.spawn.find_executable('doxygen')
if doxygen_path is None:
print(
"Warning: Failed to find doxygen, please install doxygen "
"with \"sudo apt-get install doxygen\" on Ubuntu"
)
return
html_output_dir = os.path.relpath(html_output_dir,
args.working_dir)
if not os.path.exists(html_output_dir):
makedirs(html_output_dir)
cmd = [doxygen_path, doxygen_file.name]
check_output(cmd)
finally:
os.chdir(old_cwd)
def main():
parser = argparse.ArgumentParser(description='Generate ndk docs')
parser.add_argument('--version', help='OHOS version', required=True)
parser.add_argument('--exclude_dir', help='doxygen exclude dirs',
required=True)
parser.add_argument('--doxygen-file', help='doxygen config file')
parser.add_argument('--output', help='output index.html')
parser.add_argument(
'--working-dir',
help='the directory where doxygen command will be executed')
args = parser.parse_args()
return gen_doc(args)
if __name__ == "__main__":
sys.exit(main())
# 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.
# Description: Native Development Kit Template
declare_args() {
ohos_build_ndk = false
ohos_build_ndk_target_host = "linux-x86_64"
ohos_build_ndk_version = "1.0.0"
}
ndk_out_dir = "$root_out_dir/ndk"
ndk_headers_out_dir = "$ndk_out_dir/sysroot/usr/include"
ndk_libraries_out_dir = "$ndk_out_dir/sysroot/usr/lib"
ndk_docs_out_dir = "$ndk_out_dir/docs"
windows_system = "windows-x86_64"
linux_system = "linux-x86_64"
ndk_toolchain = "gcc"
if (ohos_build_compiler == "clang") {
ndk_toolchain = "llvm"
}
ndk_windows_specific_out_dir = "${ndk_out_dir}/$ndk_toolchain"
ndk_linux_specific_out_dir = "${ndk_out_dir}/$ndk_toolchain"
ndk_windows_toolchains_out_dir = "${ndk_windows_specific_out_dir}"
ndk_windows_tools_out_dir = "${ndk_out_dir}/$windows_system/tools"
ndk_linux_toolchains_out_dir = "${ndk_linux_specific_out_dir}"
ndk_linux_tools_out_dir = "${ndk_out_dir}/$linux_system/tools"
template("copy_files") {
assert(defined(invoker.src) && defined(invoker.dest_dir),
"sources and dest_dir are neccessary")
if (defined(invoker.src_type)) {
src_type = invoker.src_type
} else {
src_type = "dir"
}
_deps = []
if (defined(invoker.deps)) {
_deps += invoker.deps
}
src = invoker.src
dst = invoker.dest_dir
action("$target_name$src") {
deps = _deps
script = "//build/lite/copy_files.py"
args = [
"--src_type",
src_type,
"--src",
rebase_path("$src"),
"--dest_dir",
rebase_path("$dst"),
]
outputs = [ "$target_gen_dir/${target_name}_copy_files.log" ]
}
}
# Generate NDK library.
template("ndk_lib") {
_deps = []
if (defined(invoker.deps)) {
_deps += invoker.deps
}
_head_files = []
if (defined(invoker.head_files)) {
_head_files = invoker.head_files
}
if (defined(invoker.lib_extension)) {
_extension = invoker.lib_extension
} else {
_extension = ".a"
}
assert(_extension != "")
group(target_name) {
deps = _deps
}
if (ohos_build_ndk) {
foreach(src_deps, _deps) {
lib_name = get_label_info(src_deps, "name")
copy_files("$target_name" + "_copy") {
deps = _deps
src_type = "file"
if (_extension == ".a") {
src = "$root_out_dir/libs/lib$lib_name$_extension"
} else {
src = "$root_out_dir/lib$lib_name$_extension"
}
dest_dir = "$ndk_libraries_out_dir"
}
}
foreach(src_dir, _head_files) {
copy_files(target_name) {
src = src_dir
dest_dir = "$ndk_headers_out_dir"
}
}
}
}
# Specify ndk toolchains
#
# Input variables:
# dest_dir: Copy destination where sources are copied to.
# src_dir: Copy Source directories.
# src_type: file or path
#
template("ndk_toolchains") {
assert(defined(invoker.src_dir) && defined(invoker.dest_dir),
"sources and dest_dir are neccessary")
if (ohos_build_ndk) {
group(target_name) {}
indexSrc = 0
indexDst = 0
foreach(src_dir, invoker.src_dir) {
indexDst = 0
foreach(dst, invoker.dest_dir) {
if (indexDst == indexSrc) {
copy_files("$src_dir") {
if (defined(invoker.src_type)) {
src_type = invoker.src_type
} else {
src_type = "dir"
}
src = src_dir
dest_dir = dst
}
}
indexDst = indexDst + 1
}
indexSrc = indexSrc + 1
}
}
}
# 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("hello_world") {
sources = [
"src/hello_world.c",
]
include_dirs = [
"include",
]
}
executable("sample") {
ldflags = [
# libraries needed by app, e.g.: "-lsys_parameter", "-lsec_shared"
]
deps = [
":hello_world",
]
}
/*
* 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.
*/
#include <stdio.h>
int main(void)
{
printf("\n************************************************\n");
printf("\n\t\tHello OHOS!\n");
printf("\n************************************************\n\n");
return 0;
}
# 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.
declare_args() {
product = ""
# "debug" or "release"
ohos_build_type = "debug"
ohos_build_compiler_dir = ""
}
product_config = read_file("//build/lite/product/${product}.json", "json")
# OHOS version
ohos_version = product_config.ohos_version
ohos_build_user = "jenkins"
ohos_build_host = host_os
ohos_build_time = exec_script("//build/lite/gn_scripts.py", ["-t"], "value")
ohos_build_roothash = ""
ohos_root_path = rebase_path("//")
ohos_lite = true
# Supported board: "hi3516dv300", "hi3518ev300", "hi3861v100"
board_name = product_config.board
# Supported compiler: gcc, clang
ohos_build_compiler = product_config.compiler
# Supported kernel: "liteos_a", "liteos_riscv"
ohos_kernel_type = product_config.kernel
ohos_vendor_adapter_dir = product_config.vendor_adapter_dir
ohos_third_party_dir = product_config.third_party_dir
SECTIONS
{
. = ALIGN(0x8000);
/* zInit code and data - will be freed after init */
.zInit :
{
__commu_dispatch_table_start = .;
KEEP (*(.commu.handlers))
__commu_dispatch_table_end = .;
. = ALIGN(4);
__sio_creators_start = .;
KEEP (*(.sio.creators))
__sio_creators_end = .;
__hdf_devices_start = .;
KEEP (*(.hdf.devices))
__hdf_devices_end = .;
__zinitcall_bsp_start = .;
KEEP (*(.zinitcall.bsp0.init))
KEEP (*(.zinitcall.bsp1.init))
KEEP (*(.zinitcall.bsp2.init))
KEEP (*(.zinitcall.bsp3.init))
KEEP (*(.zinitcall.bsp4.init))
__zinitcall_bsp_end = .;
__zinitcall_device_start = .;
KEEP (*(.zinitcall.device0.init))
KEEP (*(.zinitcall.device1.init))
KEEP (*(.zinitcall.device2.init))
KEEP (*(.zinitcall.device3.init))
KEEP (*(.zinitcall.device4.init))
__zinitcall_device_end = .;
__zinitcall_core_start = .;
KEEP (*(.zinitcall.core0.init))
KEEP (*(.zinitcall.core1.init))
KEEP (*(.zinitcall.core2.init))
KEEP (*(.zinitcall.core3.init))
KEEP (*(.zinitcall.core4.init))
__zinitcall_core_end = .;
__zinitcall_sys_service_start = .;
KEEP (*(.zinitcall.sys.service0.init))
KEEP (*(.zinitcall.sys.service1.init))
KEEP (*(.zinitcall.sys.service2.init))
KEEP (*(.zinitcall.sys.service3.init))
KEEP (*(.zinitcall.sys.service4.init))
__zinitcall_sys_service_end = .;
__zinitcall_sys_feature_start = .;
KEEP (*(.zinitcall.sys.feature0.init))
KEEP (*(.zinitcall.sys.feature1.init))
KEEP (*(.zinitcall.sys.feature2.init))
KEEP (*(.zinitcall.sys.feature3.init))
KEEP (*(.zinitcall.sys.feature4.init))
__zinitcall_sys_feature_end = .;
__zinitcall_run_start = .;
KEEP (*(.zinitcall.run0.init))
KEEP (*(.zinitcall.run1.init))
KEEP (*(.zinitcall.run2.init))
KEEP (*(.zinitcall.run3.init))
KEEP (*(.zinitcall.run4.init))
__zinitcall_run_end = .;
__zinitcall_app_service_start = .;
KEEP (*(.zinitcall.app.service0.init))
KEEP (*(.zinitcall.app.service1.init))
KEEP (*(.zinitcall.app.service2.init))
KEEP (*(.zinitcall.app.service3.init))
KEEP (*(.zinitcall.app.service4.init))
__zinitcall_app_service_end = .;
__zinitcall_app_feature_start = .;
KEEP (*(.zinitcall.app.feature0.init))
KEEP (*(.zinitcall.app.feature1.init))
KEEP (*(.zinitcall.app.feature2.init))
KEEP (*(.zinitcall.app.feature3.init))
KEEP (*(.zinitcall.app.feature4.init))
__zinitcall_app_feature_end = .;
__zinitcall_test_start = .;
KEEP (*(.zinitcall.test0.init))
KEEP (*(.zinitcall.test1.init))
KEEP (*(.zinitcall.test2.init))
KEEP (*(.zinitcall.test3.init))
KEEP (*(.zinitcall.test4.init))
__zinitcall_test_end = .;
__zinitcall_exit_start = .;
KEEP (*(.zinitcall.exit0.init))
KEEP (*(.zinitcall.exit1.init))
KEEP (*(.zinitcall.exit2.init))
KEEP (*(.zinitcall.exit3.init))
KEEP (*(.zinitcall.exit4.init))
__zinitcall_exit_end = .;
}
}
INSERT AFTER .text;
{
"subsystems": [
{
"subsystem": "kernel",
"optional": "false",
"components": [
{
"component": "liteos_a",
"optional": "false",
"targets": [
"//kernel/liteos_a:kernel"
],
"features": [],
"deps": {
"components": [
"hdf",
"hilog_a",
"oem_smartvision"
],
"third_party": [
"freebsd",
"lwip",
"bounds_checking_function",
"fatfs",
"linux_kernel",
"musl",
"nuttx",
"zlib",
"mtd_utils"
]
}
}
]
},
{
"subsystem": "drivers",
"optional": "false",
"components": [
{
"component": "hdf",
"optional": "false",
"targets": [
"//drivers/hdf/lite/posix:hdf_posix",
"//drivers/hdf/lite/manager:hdf_manager",
"//vendor/huawei/hdf/wifi:wifi_firmware",
"//vendor/huawei/hdf/display/hdi:hdi_display",
"//vendor/huawei/hdf/input/hdi:hdi_input"
],
"features": [],
"deps": {
"third_party": [
"bounds_checking_function"
]
}
}
]
},
{
"subsystem": "startup",
"optional": "true",
"components": [
{
"component": "syspara",
"optional": "true",
"targets": [
"//base/startup/frameworks/syspara_lite/parameter:parameter"
],
"features": [],
"deps": {
"third_party": [
"bounds_checking_function"
],
"components": [
"oem_smartvision"
]
}
},
{
"component": "bootstrap",
"optional": "true",
"targets": [
"//base/startup/services/bootstrap_lite/source:bootstrap"
],
"features": [],
"deps": {
"third_party": [
"bounds_checking_function"
],
"components": [
"system_ability_manager",
"utils"
]
}
},
{
"component": "token",
"optional": "true",
"targets": [
"//base/startup/frameworks/syspara_lite/token:token"
],
"features": [],
"deps": {
"components": [
"oem_iotlink",
"hilog_a"
],
"third_party": []
}
},
{
"component": "init",
"optional": "false",
"targets": [
"//base/startup/services/init_lite:init_lite",
"//vendor/huawei/camera/init_configs:init_config"
],
"features": [],
"deps": {
"components": [
"syspara"
],
"third_party": [
"bounds_checking_function",
"cjson"
]
}
},
{
"component": "appspawn",
"optional": "true",
"targets": [
"//base/startup/services/appspawn_lite:appspawn_lite"
],
"features": [],
"deps": {
"components": [
"ipc",
"system_ability_manager"
],
"third_party": [
"bounds_checking_function",
"cjson"
]
}
}
]
},
{
"subsystem": "utils",
"optional": "true",
"components": [
{
"component": "utils",
"optional": "true",
"targets": [
"//utils/native/lite/kv_store:kv_store"
],
"features": [],
"deps": {
"third_party": [
"bounds_checking_function"
]
}
}
]
},
{
"subsystem": "global",
"optional": "true",
"components": [
{
"component": "global_resource_manager",
"optional": "true",
"targets": [
"//base/global/frameworks/resmgr_lite:global_manager_lite"
],
"features": [],
"deps": {
"third_party": [
"bounds_checking_function"
]
}
}
]
},
{
"subsystem": "ace",
"optional": "true",
"components": [
{
"component": "js_frameworks",
"optional": "true",
"targets": [
"//foundation/ace/frameworks/lite:jsfwk"
],
"features": [],
"deps": {
"components": [
"hilog_a",
"crypto",
"graphic",
"camera",
"player",
"utils",
"audio_manager"
],
"third_party": [
"bounds_checking_function",
"jerryscript",
"cjson"
]
}
}
]
},
{
"subsystem": "aafwk",
"optional": "true",
"components": [
{
"component": "ability",
"optional": "true",
"targets": [
"//foundation/aafwk/frameworks/ability_lite:aafwk_abilitykit_lite",
"//foundation/aafwk/frameworks/ability_lite:aafwk_abilityMain_lite",
"//foundation/aafwk/frameworks/abilitymgr_lite:aafwk_abilityManager_lite",
"//foundation/aafwk/services/abilitymgr_lite:aafwk_services_lite"
],
"features": [
{"enable_ohos_appexecfwk_feature_ability": "true"}
],
"deps": {
"components": [
"hilog_a",
"bundle_mgr",
"system_ability_manager",
"distributed_scheduler",
"graphic",
"utils",
"ipc"
],
"third_party": [
"cjson",
"bounds_checking_function"
]
}
}
]
},
{
"subsystem": "applications",
"optional": "true",
"components": [
{
"component": "camera_sample_app",
"optional": "true",
"targets": [
"//applications/sample/camera/app:camera_app",
"//applications/sample/camera/communication:sample",
"//applications/sample/camera/hap:copy_hap"
],
"features": [],
"deps": {
"components": [
"system_ability_manager",
"utils",
"graphic",
"syspara",
"ipc"
],
"third_party": [
"wpa_supplicant"
]
}
}
]
},
{
"subsystem": "hiviewdfx",
"optional": "true",
"components": [
{
"component": "hilog_a",
"optional": "false",
"targets": [
"//base/hiviewdfx/frameworks/hilog_lite/featured:hilog_static",
"//base/hiviewdfx/frameworks/hilog_lite/featured:hilog_shared",
"//base/hiviewdfx/services/hilogcat_lite/hilogcat:hilogcat_static",
"//base/hiviewdfx/services/hilogcat_lite/apphilogcat:apphilogcat_static"
],
"features": [],
"deps": {
"third_party": [
"bounds_checking_function"
]
}
}
]
},
{
"subsystem": "distributedschedule",
"optional": "true",
"components": [
{
"component": "system_ability_manager",
"optional": "false",
"targets": [
"//foundation/distributedschedule/services/samgr_lite:samgr"
],
"features": [],
"deps": {
"componets": [
"hilog_a",
"ipc",
"iam"
],
"third_party": [
"bounds_checking_function"
]
}
},
{
"component": "foundation",
"optional": "true",
"targets": [
"//foundation/distributedschedule/services/safwk_lite:safwk_lite"
],
"features": [],
"deps": {
"componets": [
"system_ability_manager",
"ipc",
"hilog_a",
"bundle_mgr",
"iam",
"ability",
"utils",
"distributed_scheduler"
]
}
},
{
"component": "distributed_scheduler",
"optional": "true",
"targets": [
"//foundation/distributedschedule/services/dtbschedmgr_lite:dtbschedmgr"
],
"features": [],
"deps": {
"componets": [
"system_ability_manager",
"hilog_a",
"soft_bus",
"bundle_mgr",
"ipc",
"utils"
],
"third_party": [
"bounds_checking_function",
"cjson"
]
}
}
]
},
{
"subsystem": "security",
"optional": "true",
"components": [
{
"component": "hichainsdk",
"optional": "true",
"targets": [
"//base/security/frameworks/hichainsdk_lite:hichainsdk"
],
"features": [],
"deps": {
"third_party": [
"cjson",
"bounds_checking_function"
],
"components": [
"huks"
]
}
},
{
"component": "huks",
"optional": "true",
"targets": [
"//base/security/frameworks/huks_lite:huks_sdk"
],
"features": [],
"deps": {
"third_party": [
"mbedtls",
"openssl",
"bounds_checking_function"
]
}
},
{
"component": "secure_os",
"optional": "true",
"targets": [
"//base/security/services/secure_os/teecd"
],
"features": [
{ "enable_tee_ree": "false" }
],
"deps": {
"third_party": [
"bounds_checking_function"
]
}
},
{
"component": "iam",
"optional": "true",
"targets": [
"//base/security/services/iam_lite:pms_lite"
],
"features": [],
"deps": {
"components": [
"hilog_a",
"ipc",
"system_ability_manager"
],
"third_party": [
"bounds_checking_function",
"cjson"
]
}
},
{
"component": "app_verify",
"optional": "true",
"targets": [
"//base/security/frameworks/app_verify:verify"
],
"features": [],
"deps": {
"components": [
"hilog_a",
"syspara"
],
"third_party": [
"bounds_checking_function",
"mbedtls"
]
}
},
{
"component": "crypto",
"optional": "true",
"targets": [
"//base/security/frameworks/crypto_lite/cipher:cipher_shared"
],
"features": [],
"deps": {
"components": [
"hilog"
],
"third_party": [
"bounds_checking_function",
"cjson",
"mbedtls"
]
}
}
]
},
{
"subsystem": "multimedia",
"optional": "true",
"components": [
{
"component": "media_service",
"optional": "true",
"targets": [
"//foundation/multimedia/services/media_lite:media_lite"
],
"features": [],
"deps": {
"components": [
"hdf",
"hi3516dv300_adapter"
],
"third_party": [
"bounds_checking_function"
]
}
},
{
"component": "media_sample",
"optional": "true",
"targets": [
"//applications/sample/camera/media:media_sample"
],
"features": [],
"deps": {}
},
{
"component": "camera",
"optional": "true",
"targets": [
"//foundation/multimedia/frameworks/camera_lite:camera"
],
"features": [],
"deps": {
"components": [
"hilog_a",
"iam",
"hdf",
"graphic",
"hi3516dv300_adapter"
],
"third_party": [
"bounds_checking_function"
]
}
},
{
"component": "player",
"optional": "true",
"targets": [
"//foundation/multimedia/frameworks/player_lite:player"
],
"features": [],
"deps": {
"components": [
"hilog_a",
"iam",
"hdf",
"graphic",
"hi3516dv300_adapter"
],
"third_party": [
"bounds_checking_function",
"iniparser"
]
}
},
{
"component": "audio_manager",
"optional": "true",
"targets": [
"//foundation/multimedia/frameworks/audio_lite:audio_capturer"
],
"features": [],
"deps": {
"components": [
"hdf",
"graphic"
],
"third_party": [
"bounds_checking_function"
]
}
},
{
"component": "recoder",
"optional": "true",
"targets": [
"//foundation/multimedia/frameworks/recorder_lite:recorder"
],
"features": [],
"deps": {
"components": [
"graphic",
"iam"
],
"third_party": [
"bounds_checking_function"
]
}
}
]
},
{
"subsystem": "graphic",
"optional": "true",
"components": [
{
"component": "graphic",
"optional": "true",
"targets": [
"//foundation/graphic/lite/frameworks/surface:litesurface",
"//foundation/graphic/lite/utils:litegraphicutils",
"//foundation/graphic/lite/frameworks/ui:liteui",
"//foundation/graphic/lite/services/ims:liteims",
"//foundation/graphic/lite/services/wms:litewms"
],
"features": [],
"deps": {
"components": [
"hdf",
"graphic",
"hilog_a"
],
"third_party": [
"bounds_checking_function",
"cjson",
"libjpeg",
"libpng",
"freetype"
]
}
}
]
},
{
"subsystem": "communication",
"optional": "true",
"components": [
{
"component": "ipc",
"optional": "true",
"targets": [
"//foundation/communication/frameworks/ipc_lite:liteipc"
],
"features": [],
"deps": {
"third_party": [
"bounds_checking_function",
"utils"
]
}
},
{
"component": "soft_bus",
"optional": "true",
"targets": [
"//foundation/communication/services/softbus_lite:softbus"
],
"features": [],
"deps": {
"components": [
"hichainsdk",
"iam",
"system_ability_manager"
],
"third_party": [
"cjson",
"bounds_checking_function",
"mbedtls"
]
}
}
]
},
{
"subsystem": "appexecfwk",
"optional": "true",
"components": [
{
"component": "bundle_mgr",
"optional": "true",
"targets": [
"//foundation/appexecfwk/services/bundlemgr_lite:appexecfwk_services_lite",
"//foundation/appexecfwk/frameworks/bundle_lite:appexecfwk_kits_lite"
],
"features": [],
"deps": {
"components": [
"iam",
"app_verify",
"hilog_a",
"system_ability_manager",
"global_resource_manager",
"graphic",
"utils"
],
"third_party": [
"cjson",
"zlib"
]
}
}
]
},
{
"subsystem": "vendor",
"optional": "false",
"components": [
{
"component": "hi3516dv300",
"optional": "false",
"targets": [
"//vendor/hisi/hi35xx/hi35xx_init/hi3516dv300:hi3516dv300_image",
"//vendor/hisi/hi35xx/hardware:hardware_media_sdk",
"//vendor/hisi/hi35xx/middleware:middleware_source_sdk"
],
"features": [],
"deps": {}
},
{
"component": "hi3516dv300_adapter",
"optional": "false",
"targets": [
"//vendor/hisi/hi35xx/hi3516dv300/hi3516dv300_adapter/hals/multimedia:hdi_media"
],
"features": [],
"deps": {}
},
{
"component": "hi3516dv300_uboot",
"optional": "false",
"targets": [],
"features": [],
"deps": {}
},
{
"component": "oem_smartvision",
"optional": "false",
"targets": [],
"features": [],
"deps": {}
}
]
},
{
"subsystem": "test",
"optional": "true",
"components": [
{
"component": "xts",
"optional": "true",
"targets": [
"//test/xts/acts",
"//test/xts/tools"
],
"features": [],
"deps": {}
},
{
"component": "developer_test",
"optional": "true",
"targets": [
"//test/developertest:test"
],
"features": [],
"deps": {}
}
]
}
]
}
SECTIONS
{
. = ALIGN(0x8000);
/* zInit code and data - will be freed after init */
.zInit :
{
__commu_dispatch_table_start = .;
KEEP (*(.commu.handlers))
__commu_dispatch_table_end = .;
. = ALIGN(4);
__sio_creators_start = .;
KEEP (*(.sio.creators))
__sio_creators_end = .;
__hdf_devices_start = .;
KEEP (*(.hdf.devices))
__hdf_devices_end = .;
__zinitcall_bsp_start = .;
KEEP (*(.zinitcall.bsp0.init))
KEEP (*(.zinitcall.bsp1.init))
KEEP (*(.zinitcall.bsp2.init))
KEEP (*(.zinitcall.bsp3.init))
KEEP (*(.zinitcall.bsp4.init))
__zinitcall_bsp_end = .;
__zinitcall_device_start = .;
KEEP (*(.zinitcall.device0.init))
KEEP (*(.zinitcall.device1.init))
KEEP (*(.zinitcall.device2.init))
KEEP (*(.zinitcall.device3.init))
KEEP (*(.zinitcall.device4.init))
__zinitcall_device_end = .;
__zinitcall_core_start = .;
KEEP (*(.zinitcall.core0.init))
KEEP (*(.zinitcall.core1.init))
KEEP (*(.zinitcall.core2.init))
KEEP (*(.zinitcall.core3.init))
KEEP (*(.zinitcall.core4.init))
__zinitcall_core_end = .;
__zinitcall_sys_service_start = .;
KEEP (*(.zinitcall.sys.service0.init))
KEEP (*(.zinitcall.sys.service1.init))
KEEP (*(.zinitcall.sys.service2.init))
KEEP (*(.zinitcall.sys.service3.init))
KEEP (*(.zinitcall.sys.service4.init))
__zinitcall_sys_service_end = .;
__zinitcall_sys_feature_start = .;
KEEP (*(.zinitcall.sys.feature0.init))
KEEP (*(.zinitcall.sys.feature1.init))
KEEP (*(.zinitcall.sys.feature2.init))
KEEP (*(.zinitcall.sys.feature3.init))
KEEP (*(.zinitcall.sys.feature4.init))
__zinitcall_sys_feature_end = .;
__zinitcall_run_start = .;
KEEP (*(.zinitcall.run0.init))
KEEP (*(.zinitcall.run1.init))
KEEP (*(.zinitcall.run2.init))
KEEP (*(.zinitcall.run3.init))
KEEP (*(.zinitcall.run4.init))
__zinitcall_run_end = .;
__zinitcall_app_service_start = .;
KEEP (*(.zinitcall.app.service0.init))
KEEP (*(.zinitcall.app.service1.init))
KEEP (*(.zinitcall.app.service2.init))
KEEP (*(.zinitcall.app.service3.init))
KEEP (*(.zinitcall.app.service4.init))
__zinitcall_app_service_end = .;
__zinitcall_app_feature_start = .;
KEEP (*(.zinitcall.app.feature0.init))
KEEP (*(.zinitcall.app.feature1.init))
KEEP (*(.zinitcall.app.feature2.init))
KEEP (*(.zinitcall.app.feature3.init))
KEEP (*(.zinitcall.app.feature4.init))
__zinitcall_app_feature_end = .;
__zinitcall_test_start = .;
KEEP (*(.zinitcall.test0.init))
KEEP (*(.zinitcall.test1.init))
KEEP (*(.zinitcall.test2.init))
KEEP (*(.zinitcall.test3.init))
KEEP (*(.zinitcall.test4.init))
__zinitcall_test_end = .;
__zinitcall_exit_start = .;
KEEP (*(.zinitcall.exit0.init))
KEEP (*(.zinitcall.exit1.init))
KEEP (*(.zinitcall.exit2.init))
KEEP (*(.zinitcall.exit3.init))
KEEP (*(.zinitcall.exit4.init))
__zinitcall_exit_end = .;
}
}
INSERT AFTER .text;
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
详见:https://gitee.com/openharmony/docs/blob/master/readme/编译构建子系统README.md
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册