build.gn 可以编译 链接失败

This commit is contained in:
2025-01-16 19:52:28 +08:00
parent 639024a1a6
commit 83882c7ac2
7 changed files with 33 additions and 7 deletions

View File

@@ -12,6 +12,7 @@ config("compiler_defaults") {
cflags = [
"-mabi=ilp32f",
"-march=rv32imafc",
"-Os",
"-falign-functions=2",
"-msave-restore",
"-fno-optimize-strlen",

View File

@@ -23,6 +23,7 @@ template("kernel_module") {
}
# 如果不存在module_group或group,则建立group
# 如果用其他名称创建module则自动生成一个以目录名称命名的module
current_dir_name = get_path_info(rebase_path("."), "file")
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"
@@ -30,6 +31,7 @@ template("kernel_module") {
exec_script("//build/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" ]
}
@@ -51,9 +53,13 @@ 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" ]
}
}
@@ -104,6 +110,8 @@ template("module_group") {
# 使用这个模板时的默认配置
set_defaults("kernel_module"){
configs = [
# 把这个目录的配置设置为公共配置
"//ap:public"
]
}