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

@@ -1,6 +1,19 @@
import("//build/buildcfg.gni") import("//build/buildcfg.gni")
module_name = get_path_info(rebase_path("."), "name") module_name = get_path_info(rebase_path("."), "name")
executable("out"){
deps=[":$module_name"]
}
module_group(module_name) { module_group(module_name) {
modules = [ modules = [
"ap", "ap",

View File

@@ -81,6 +81,8 @@ config("public") {
"//import/wq_vtb/ext_inc", "//import/wq_vtb/ext_inc",
"//plc/inc", "//plc/inc",
"//driver/inc", "//driver/inc",
"//os/freertos/src/include",
"//os/freertos/src/portable/RISCV",
] ]
if (target == "kunlun3") { if (target == "kunlun3") {

View File

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

View File

@@ -23,6 +23,7 @@ template("kernel_module") {
} }
# 如果不存在module_group或group,则建立group # 如果不存在module_group或group,则建立group
# 如果用其他名称创建module则自动生成一个以目录名称命名的module
current_dir_name = get_path_info(rebase_path("."), "file") current_dir_name = get_path_info(rebase_path("."), "file")
if (target_name != current_dir_name) { 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" 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") exec_script("//build/run_shell_cmd.py", [ cmd ], "value")
if (!has_current_dir_group && defined(auto_config)) { if (!has_current_dir_group && defined(auto_config)) {
module_name = target_name module_name = target_name
# print("auto create module $current_dir_name")
group(current_dir_name) { group(current_dir_name) {
public_deps = [ ":$module_name" ] public_deps = [ ":$module_name" ]
} }
@@ -51,9 +53,13 @@ template("kernel_module") {
what = "label_no_toolchain" what = "label_no_toolchain"
if (get_label_info(cfg, what) == get_label_info(":public", what)) { if (get_label_info(cfg, what) == get_label_info(":public", what)) {
included_public_config = true included_public_config = true
print("$current_dir_name, $target_name true")
} else {
print("$current_dir_name, $target_name false")
} }
} }
if (!included_public_config) { if (!included_public_config) {
print("include_public_config")
public_configs += [ ":public" ] public_configs += [ ":public" ]
} }
} }
@@ -104,6 +110,8 @@ template("module_group") {
# 使用这个模板时的默认配置 # 使用这个模板时的默认配置
set_defaults("kernel_module"){ set_defaults("kernel_module"){
configs = [ configs = [
# 把这个目录的配置设置为公共配置
"//ap:public"
] ]
} }

View File

@@ -64,5 +64,7 @@ kernel_module(module_name) {
"//import/mbedtls/include", "//import/mbedtls/include",
"//common/lzma", "//common/lzma",
"//common/plc_lib/inc", "//common/plc_lib/inc",
"//import/lwip/lwip/src/include",
"//import/lwip/ports/include",
] ]
} }

View File

@@ -83,12 +83,10 @@ typedef struct _clk_div_gp_t {
uint32_t g_cpu_freq = 150000000; uint32_t g_cpu_freq = 150000000;
#define IRAM_ATTR2 __attribute__((section(".iram")))
/* /*
* Clock source selecte & div for each IP, refrence to clk_frq_group. * Clock source selecte & div for each IP, refrence to clk_frq_group.
*/ */
static clk_div_gp_t IRAM_ATTR2 clk_div_group[CLK_FRQ_GP_IDX_MAX] = static clk_div_gp_t IRAM_ATTR clk_div_group[CLK_FRQ_GP_IDX_MAX] =
{ {
/* Core_sel APB_sel sfc_div smc_div apb_div rsv[3] */ /* Core_sel APB_sel sfc_div smc_div apb_div rsv[3] */
{0, 0, 0, 0, 0, {0}}, /* disable plc */ {0, 0, 0, 0, 0, {0}}, /* disable plc */
@@ -101,7 +99,7 @@ static clk_div_gp_t IRAM_ATTR2 clk_div_group[CLK_FRQ_GP_IDX_MAX] =
static void IRAM_ATTR2 clk_system_calibration(void) static void IRAM_ATTR clk_system_calibration(void)
{ {
if (!scratch_p_get_clk_calibration()) { if (!scratch_p_get_clk_calibration()) {
ana_mdll_loopmode_set(0); ana_mdll_loopmode_set(0);
@@ -113,7 +111,7 @@ static void IRAM_ATTR2 clk_system_calibration(void)
ana_mdll_loopmode_set(1); ana_mdll_loopmode_set(1);
} }
static void IRAM_ATTR2 clk_system_set_all_xtal(void) static void IRAM_ATTR clk_system_set_all_xtal(void)
{ {
/* APB/AHB select xtal 25M, APB div = 0. */ /* APB/AHB select xtal 25M, APB div = 0. */
ahb_clk_clock_set(0, 0, 0); ahb_clk_clock_set(0, 0, 0);
@@ -128,7 +126,7 @@ static void IRAM_ATTR2 clk_system_set_all_xtal(void)
ahb_clk_mpll_set(0, 0); ahb_clk_mpll_set(0, 0);
} }
static void IRAM_ATTR2 clk_system_set_all_pll(uint32_t index) static void IRAM_ATTR clk_system_set_all_pll(uint32_t index)
{ {
/* Do calibration. */ /* Do calibration. */
clk_system_calibration(); clk_system_calibration();

View File

@@ -28,6 +28,8 @@ kernel_module(module_name) {
"freertos/src/portable/MemMang/heap_5/heap_5.c" "freertos/src/portable/MemMang/heap_5/heap_5.c"
] ]
include_dirs = [ include_dirs = [
"freertos/src/include", "freertos/src/portable/RISCV", "//startup/riscv/inc" "//os/freertos/src/include",
"//os/freertos/src/portable/RISCV",
"//startup/riscv/inc",
] ]
} }