提交 47593dcd 编写于 作者: H handyohos

feat: update parameter values in BUILD.gn

1)新增ohos_prebuilt_para模版,可通过extra_paras更新默认的para文件中的参数值
2)该模版同时可以去掉para文件中的注释
Signed-off-by: Nhandyohos <zhangxiaotian@huawei.com>
Change-Id: I588f158a12a654d3d832127dd0010e8d22db24a7
上级 c7d69e01
......@@ -100,43 +100,11 @@ if (defined(ohos_lite)) {
}
}
copy("ohos.para") {
sources = [ "//base/startup/init_lite/services/etc/param/ohos.para" ]
outputs = [ "$root_out_dir/system/etc/param/ohos.para" ]
}
copy("ohos.para.dac") {
sources = [ "//base/startup/init_lite/services/etc/param/ohos.para.dac" ]
outputs = [ "$root_out_dir/system/etc/param/ohos.para.dac" ]
}
copy("ohos.const") {
sources =
[ "//base/startup/init_lite/services/etc/param/ohos_const/ohos.para" ]
outputs = [ "$root_out_dir/system/etc/param/ohos_const/ohos.para" ]
}
copy("ohos.passwd") {
sources = [ "//base/startup/init_lite/services/etc_lite/passwd" ]
outputs = [ "$root_out_dir/etc/passwd" ]
}
copy("ohos.group") {
sources = [ "//base/startup/init_lite/services/etc_lite/group" ]
outputs = [ "$root_out_dir/etc/group" ]
}
group("init_lite") {
deps = [
":lite_init",
":ohos.const",
":ohos.para",
":ohos.para.dac",
"etc:etc_files",
]
if (ohos_kernel_type == "linux") {
deps += [
":ohos.group",
":ohos.passwd",
]
}
}
} else {
import("//base/startup/init_lite/begetd.gni")
......@@ -269,7 +237,7 @@ if (defined(ohos_lite)) {
group("startup_init") {
deps = [
":init",
":init_etc",
"etc:etc_files",
"//base/startup/init_lite/services/param:param_client",
"//base/startup/init_lite/services/param:param_init",
]
......@@ -281,192 +249,4 @@ if (defined(ohos_lite)) {
]
}
}
# init etc files group
ohos_prebuilt_etc("init.cfg") {
if (!enable_ramdisk) {
source =
"//base/startup/init_lite/services/etc/init.without_two_stages.cfg"
} else {
source = "//base/startup/init_lite/services/etc/init.cfg"
}
part_name = "init"
}
ohos_prebuilt_etc("misc.cfg") {
source = "//base/startup/init_lite/services/etc/misc.cfg"
relative_install_dir = "init"
part_name = "init"
}
ohos_prebuilt_etc("watchdog.cfg") {
source = "//base/startup/init_lite/services/etc/watchdog.cfg"
relative_install_dir = "init"
part_name = "init"
}
ohos_prebuilt_etc("console.cfg") {
source = "//base/startup/init_lite/services/etc/console.cfg"
relative_install_dir = "init"
part_name = "init"
}
ohos_prebuilt_etc("ueventd.cfg") {
source = "//base/startup/init_lite/services/etc/ueventd.cfg"
relative_install_dir = "init"
part_name = "init"
}
ohos_prebuilt_etc("passwd") {
source = "//base/startup/init_lite/services/etc/passwd"
install_images = [
"system",
"updater",
]
part_name = "init"
}
ohos_prebuilt_etc("group") {
source = "//base/startup/init_lite/services/etc/group"
install_images = [
"system",
"updater",
]
part_name = "init"
}
ohos_prebuilt_etc("init.usb.cfg") {
source = "//base/startup/init_lite/services/etc/init.usb.cfg"
part_name = "init"
}
ohos_prebuilt_etc("init.usb.configfs.cfg") {
source = "//base/startup/init_lite/services/etc/init.usb.configfs.cfg"
part_name = "init"
}
ohos_prebuilt_etc("ohos.para") {
source = "//base/startup/init_lite/services/etc/param/ohos.para"
part_name = "init"
module_install_dir = "etc/param"
}
ohos_prebuilt_etc("ohos.para.dac") {
source = "//base/startup/init_lite/services/etc/param/ohos.para.dac"
part_name = "init"
module_install_dir = "etc/param"
}
ohos_prebuilt_etc("ohos_const.para") {
source = "//base/startup/init_lite/services/etc/param/ohos_const/ohos.para"
part_name = "init"
module_install_dir = "etc/param/ohos_const"
}
ohos_prebuilt_etc("boot.group") {
source = "//base/startup/init_lite/services/etc/device.boot.group.cfg"
part_name = "init"
}
ohos_prebuilt_etc("charing.group") {
source = "//base/startup/init_lite/services/etc/device.charing.group.cfg"
part_name = "init"
}
ohos_prebuilt_etc("syscap.para") {
source =
"${preloader_output_dir}/${product_name}/system/etc/param/syscap.para"
module_install_dir = "etc/param/"
part_name = "init"
}
ohos_prebuilt_etc("syscap.json") {
source = "${preloader_output_dir}/${product_name}/system/etc/syscap.json"
part_name = "init"
}
ohos_prebuilt_etc("systemcapability.json") {
source = "${preloader_output_dir}/${product_name}/system/etc/SystemCapability.json"
part_name = "init"
}
ohos_prebuilt_etc("system-sandbox.json") {
if (target_cpu == "arm64") {
source = "//base/startup/init_lite/interfaces/innerkits/sandbox/system-sandbox64.json"
} else {
source = "//base/startup/init_lite/interfaces/innerkits/sandbox/system-sandbox.json"
}
part_name = "init"
module_install_dir = "etc/sandbox"
}
ohos_prebuilt_etc("chipset-sandbox.json") {
if (target_cpu == "arm64") {
source = "//base/startup/init_lite/interfaces/innerkits/sandbox/chipset-sandbox64.json"
} else {
source = "//base/startup/init_lite/interfaces/innerkits/sandbox/chipset-sandbox.json"
}
part_name = "init"
module_install_dir = "etc/sandbox"
}
ohos_prebuilt_etc("privapp-sandbox.json") {
if (target_cpu == "arm64") {
source = "//base/startup/init_lite/interfaces/innerkits/sandbox/privapp-sandbox64.json"
} else {
source = "//base/startup/init_lite/interfaces/innerkits/sandbox/privapp-sandbox.json"
}
part_name = "init"
module_install_dir = "etc/sandbox"
}
ohos_prebuilt_etc("app-sandbox.json") {
if (target_cpu == "arm64") {
source = "//base/startup/init_lite/interfaces/innerkits/sandbox/app-sandbox64.json"
} else {
source = "//base/startup/init_lite/interfaces/innerkits/sandbox/app-sandbox.json"
}
part_name = "init"
module_install_dir = "etc/sandbox"
}
ohos_prebuilt_etc("appdata-sandbox.json") {
source = "//base/startup/appspawn_standard/appdata-sandbox.json"
part_name = "init"
module_install_dir = "etc/sandbox"
}
ohos_prebuilt_etc("init.reboot") {
source = "//base/startup/init_lite/services/etc/init.reboot.cfg"
part_name = "init"
module_install_dir = "etc/init"
}
group("init_etc") {
deps = [
":app-sandbox.json",
":appdata-sandbox.json",
":boot.group",
":charing.group",
":chipset-sandbox.json",
":console.cfg",
":group",
":init.cfg",
":init.reboot",
":init.usb.cfg",
":init.usb.configfs.cfg",
":misc.cfg",
":ohos.para",
":ohos.para.dac",
":ohos_const.para",
":passwd",
":privapp-sandbox.json",
":syscap.json",
":syscap.para",
":system-sandbox.json",
":systemcapability.json",
":ueventd.cfg",
":watchdog.cfg",
]
}
}
# Copyright (c) 2020-2021 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.
if (defined(ohos_lite)) {
copy("ohos.para") {
sources = [ "//base/startup/init_lite/services/etc/param/ohos.para" ]
outputs = [ "$root_out_dir/system/etc/param/ohos.para" ]
}
copy("ohos.para.dac") {
sources = [ "//base/startup/init_lite/services/etc/param/ohos.para.dac" ]
outputs = [ "$root_out_dir/system/etc/param/ohos.para.dac" ]
}
copy("ohos.const") {
sources =
[ "//base/startup/init_lite/services/etc/param/ohos_const/ohos.para" ]
outputs = [ "$root_out_dir/system/etc/param/ohos_const/ohos.para" ]
}
copy("ohos.passwd") {
sources = [ "//base/startup/init_lite/services/etc_lite/passwd" ]
outputs = [ "$root_out_dir/etc/passwd" ]
}
copy("ohos.group") {
sources = [ "//base/startup/init_lite/services/etc_lite/group" ]
outputs = [ "$root_out_dir/etc/group" ]
}
group("etc_files") {
deps = [
":ohos.const",
":ohos.para",
":ohos.para.dac",
]
if (ohos_kernel_type == "linux") {
deps += [
":ohos.group",
":ohos.passwd",
]
}
}
} else {
import("//base/startup/init_lite/services/etc/param/param_fixer.gni")
import("//build/ohos.gni")
# init etc files group
ohos_prebuilt_etc("init.cfg") {
if (!enable_ramdisk) {
source =
"//base/startup/init_lite/services/etc/init.without_two_stages.cfg"
} else {
source = "//base/startup/init_lite/services/etc/init.cfg"
}
part_name = "init"
}
ohos_prebuilt_etc("misc.cfg") {
source = "//base/startup/init_lite/services/etc/misc.cfg"
relative_install_dir = "init"
part_name = "init"
}
ohos_prebuilt_etc("watchdog.cfg") {
source = "//base/startup/init_lite/services/etc/watchdog.cfg"
relative_install_dir = "init"
part_name = "init"
}
ohos_prebuilt_etc("console.cfg") {
source = "//base/startup/init_lite/services/etc/console.cfg"
relative_install_dir = "init"
part_name = "init"
}
ohos_prebuilt_etc("ueventd.cfg") {
source = "//base/startup/init_lite/services/etc/ueventd.cfg"
relative_install_dir = "init"
part_name = "init"
}
ohos_prebuilt_etc("passwd") {
source = "//base/startup/init_lite/services/etc/passwd"
install_images = [
"system",
"updater",
]
part_name = "init"
}
ohos_prebuilt_etc("group") {
source = "//base/startup/init_lite/services/etc/group"
install_images = [
"system",
"updater",
]
part_name = "init"
}
ohos_prebuilt_etc("init.usb.cfg") {
source = "//base/startup/init_lite/services/etc/init.usb.cfg"
part_name = "init"
}
ohos_prebuilt_etc("init.usb.configfs.cfg") {
source = "//base/startup/init_lite/services/etc/init.usb.configfs.cfg"
part_name = "init"
}
ohos_prebuilt_para("ohos.para") {
source = "//base/startup/init_lite/services/etc/param/ohos.para"
part_name = "init"
if (target_cpu == "arm64") {
extra_paras = "const.product.cpu.abilist=arm64-v8a"
}
module_install_dir = "etc/param"
}
ohos_prebuilt_etc("ohos.para.dac") {
source = "//base/startup/init_lite/services/etc/param/ohos.para.dac"
part_name = "init"
module_install_dir = "etc/param"
}
ohos_prebuilt_etc("ohos_const.para") {
source = "//base/startup/init_lite/services/etc/param/ohos_const/ohos.para"
part_name = "init"
module_install_dir = "etc/param/ohos_const"
}
ohos_prebuilt_etc("boot.group") {
source = "//base/startup/init_lite/services/etc/device.boot.group.cfg"
part_name = "init"
}
ohos_prebuilt_etc("charing.group") {
source = "//base/startup/init_lite/services/etc/device.charing.group.cfg"
part_name = "init"
}
ohos_prebuilt_etc("syscap.para") {
source =
"${preloader_output_dir}/${product_name}/system/etc/param/syscap.para"
module_install_dir = "etc/param/"
part_name = "init"
}
ohos_prebuilt_etc("syscap.json") {
source = "${preloader_output_dir}/${product_name}/system/etc/syscap.json"
part_name = "init"
}
ohos_prebuilt_etc("systemcapability.json") {
source = "${preloader_output_dir}/${product_name}/system/etc/SystemCapability.json"
part_name = "init"
}
ohos_prebuilt_etc("system-sandbox.json") {
if (target_cpu == "arm64") {
source = "//base/startup/init_lite/interfaces/innerkits/sandbox/system-sandbox64.json"
} else {
source = "//base/startup/init_lite/interfaces/innerkits/sandbox/system-sandbox.json"
}
part_name = "init"
module_install_dir = "etc/sandbox"
}
ohos_prebuilt_etc("chipset-sandbox.json") {
if (target_cpu == "arm64") {
source = "//base/startup/init_lite/interfaces/innerkits/sandbox/chipset-sandbox64.json"
} else {
source = "//base/startup/init_lite/interfaces/innerkits/sandbox/chipset-sandbox.json"
}
part_name = "init"
module_install_dir = "etc/sandbox"
}
ohos_prebuilt_etc("privapp-sandbox.json") {
if (target_cpu == "arm64") {
source = "//base/startup/init_lite/interfaces/innerkits/sandbox/privapp-sandbox64.json"
} else {
source = "//base/startup/init_lite/interfaces/innerkits/sandbox/privapp-sandbox.json"
}
part_name = "init"
module_install_dir = "etc/sandbox"
}
ohos_prebuilt_etc("app-sandbox.json") {
if (target_cpu == "arm64") {
source = "//base/startup/init_lite/interfaces/innerkits/sandbox/app-sandbox64.json"
} else {
source = "//base/startup/init_lite/interfaces/innerkits/sandbox/app-sandbox.json"
}
part_name = "init"
module_install_dir = "etc/sandbox"
}
ohos_prebuilt_etc("appdata-sandbox.json") {
source = "//base/startup/appspawn_standard/appdata-sandbox.json"
part_name = "init"
module_install_dir = "etc/sandbox"
}
ohos_prebuilt_etc("init.reboot") {
source = "//base/startup/init_lite/services/etc/init.reboot.cfg"
part_name = "init"
module_install_dir = "etc/init"
}
group("etc_files") {
deps = [
":app-sandbox.json",
":appdata-sandbox.json",
":boot.group",
":charing.group",
":chipset-sandbox.json",
":console.cfg",
":group",
":init.cfg",
":init.reboot",
":init.usb.cfg",
":init.usb.configfs.cfg",
":misc.cfg",
":ohos.para",
":ohos.para.dac",
":ohos_const.para",
":passwd",
":privapp-sandbox.json",
":syscap.json",
":syscap.para",
":system-sandbox.json",
":systemcapability.json",
":ueventd.cfg",
":watchdog.cfg",
]
}
}
# Copyright (c) 2021 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/python.gni")
import("//build/templates/common/copy.gni")
template("ohos_prebuilt_para") {
assert(defined(invoker.source), "source must be defined for ${target_name}.")
_fixed_param_target = "${target_name}_param_fixed"
_fixed_param_file = target_gen_dir + "/${target_name}.fixed/" +
get_path_info(_fixed_param_target, "file")
_output_para_file = get_path_info(invoker.source, "file")
action_with_pydeps(_fixed_param_target) {
deps = []
script = "//base/startup/init_lite/services/etc/param/param_fixer.py"
depfile = "${target_gen_dir}/${target_name}.d"
args = [
"--output",
rebase_path(_fixed_param_file, root_build_dir),
"--source-file",
rebase_path(invoker.source, root_build_dir),
"--depfile",
rebase_path(depfile, root_build_dir),
]
if (defined(invoker.extra_paras)) {
args += [
"--extra",
invoker.extra_paras,
]
}
inputs = [ invoker.source ]
outputs = [ _fixed_param_file ]
}
ohos_copy(target_name) {
deps = [ ":$_fixed_param_target" ]
forward_variables_from(invoker,
[
"testonly",
"visibility",
"deps",
"public_configs",
"subsystem_name",
"part_name",
# For generate_module_info
"install_images",
"module_install_dir",
"relative_install_dir",
"symlink_target_name",
# Open source license related
"license_file",
"license_as_sources",
])
set_sources_assignment_filter([])
sources = [ _fixed_param_file ]
outputs = [ "${target_out_dir}/${_output_para_file}" ]
module_type = "etc"
install_enable = true
if (defined(invoker.install_enable)) {
install_enable = invoker.install_enable
}
}
}
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2021 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 optparse
import os
import sys
import json
sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, os.pardir, os.pardir, os.pardir, os.pardir, "build"))
from scripts.util import build_utils # noqa: E402
def parse_args(args):
args = build_utils.expand_file_args(args)
parser = optparse.OptionParser()
build_utils.add_depfile_option(parser)
parser.add_option('--output', help='fixed para file')
parser.add_option('--source-file', help='source para file')
parser.add_option('--extra', help='extra params')
options, _ = parser.parse_args(args)
return options
def parse_params(line, contents):
line = line.strip()
pos = line.find('=')
if pos <= 0:
return
name = line[:pos]
value = line[pos+1:]
name = name.strip()
value = value.strip()
contents[name] = value
def parse_extra_params(extras, contents):
lines = extras.split(" ")
for line in lines:
line = line.strip()
parse_params(line, contents)
def fix_para_file(options):
contents = {}
# Read source file
with open(options.source_file, 'r') as f:
lines = f.readlines()
for line in lines:
line = line.strip()
# Strip comments
if line.startswith('#') or not line:
continue
parse_params(line, contents)
if options.extra:
parse_extra_params(options.extra, contents)
with open(options.output, 'w') as f:
for key in contents:
f.write(key + "=" + contents[key] + '\n')
def main(args):
options = parse_args(args)
depfile_deps = ([options.source_file])
build_utils.call_and_write_depfile_if_stale(
lambda: fix_para_file(options),
options,
input_paths=depfile_deps,
output_paths=([options.output]),
force=False,
add_pydeps=False)
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))
# Generated by running:
# build/print_python_deps.py --root base/startup/init_lite/services/etc/param --output base/startup/init_lite/services/etc/param/param_fixer.pydeps base/startup/init_lite/services/etc/param/param_fixer.py
../../../../../../build/gn_helpers.py
../../../../../../build/scripts/__init__.py
../../../../../../build/scripts/util/__init__.py
../../../../../../build/scripts/util/build_utils.py
../../../../../../build/scripts/util/md5_check.py
../../../../../../build/scripts/util/pycache.py
param_fixer.py
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册