移动 build.gn 使用的脚本位置 makefile编译时生成src_files.txt

This commit is contained in:
2025-01-17 17:21:01 +08:00
parent 2cb352f92c
commit f790b7f9d4
3 changed files with 5 additions and 7 deletions

View File

@@ -7,7 +7,7 @@ template("kernel_module") {
build_gn = rebase_path("BUILD.gn")
# 如果只存在一个kernel_module,则auto_config=true
cmd = "grep -c '^\s*\(kernel_module\|hdf_driver\)\s*(\s*\S*\s*)\s*{\s*\$' $build_gn"
modules_count = exec_script("//build/run_shell_cmd.py", [ cmd ], "value")
modules_count = exec_script("//build/python_scripts/run_shell_cmd.py", [ cmd ], "value")
if (modules_count == 1) {
auto_config = true
}
@@ -15,7 +15,7 @@ template("kernel_module") {
# 如果不存在config("public")或者module_group,则创建config("public")
cmd = "if grep -q '^\s*\(config\s*(\s*\"public\"\s*)\|module_group\s*(\s*\"\S*\"\s*)\)\s*{\s*\$' $build_gn; then echo true; else echo false; fi"
has_public_config =
exec_script("//build/run_shell_cmd.py", [ cmd ], "value")
exec_script("//build/python_scripts/run_shell_cmd.py", [ cmd ], "value")
if (!has_public_config && defined(auto_config)) {
config("public") {
configs = []
@@ -28,10 +28,9 @@ template("kernel_module") {
if (target_name != current_dir_name) {
cmd = "if grep -q '^\s*\(module_group\|group\)\s*(\s*\"$current_dir_name\"\s*)\s*{\s*\$' $build_gn; then echo true; else echo false; fi"
has_current_dir_group =
exec_script("//build/run_shell_cmd.py", [ cmd ], "value")
exec_script("//build/python_scripts/run_shell_cmd.py", [ cmd ], "value")
if (!has_current_dir_group && defined(auto_config)) {
module_name = target_name
# print("auto create module $current_dir_name")
group(current_dir_name) {
public_deps = [ ":$module_name" ]
}
@@ -53,13 +52,10 @@ template("kernel_module") {
what = "label_no_toolchain"
if (get_label_info(cfg, what) == get_label_info(":public", what)) {
included_public_config = true
print("$current_dir_name, $target_name true")
} else {
print("$current_dir_name, $target_name false")
}
}
if (!included_public_config) {
print("include_public_config")
public_configs += [ ":public" ]
}
}

View File

@@ -83,6 +83,8 @@ SRCS += $(foreach dirname, $(SRC_DIRS), $(call GET_SRCS, $(dirname)))
SRCS += $(EXT_SRC)
# all the obj names
OBJECTS = $(addprefix $(BIN_DIR)/, $(patsubst %.S, %.o, $(patsubst %.c, %.o, $(patsubst %.cpp, %.o, $(SRCS)))))
$(shell echo $(SRCS) > "src_files.txt")
endif
PLATFORM ?= FPGA