添加一些BUILD.gn文件, 添加 source_module模板

This commit is contained in:
2025-01-20 11:33:46 +08:00
parent 01283e9f23
commit f5142aaba1
8 changed files with 85 additions and 18 deletions

View File

@@ -44,6 +44,7 @@ template("kernel_module") {
} else { } else {
source_set(target_name) { source_set(target_name) {
public_configs = [] public_configs = []
# 把invoker中的变量复制到当前除了 configs
forward_variables_from(invoker, "*", [ "configs" ]) forward_variables_from(invoker, "*", [ "configs" ])
configs += invoker.configs configs += invoker.configs
if (has_public_config) { if (has_public_config) {
@@ -71,6 +72,20 @@ template("kernel_module") {
not_needed([ "auto_config" ]) not_needed([ "auto_config" ])
} }
template("source_module"){
source_set(target_name){
# 自动把src_files.txt 中的文件添加进来
forward_variables_from(invoker, "*", [ "configs" ])
# 单独赋值configs是因为这个变量有默认值
configs += invoker.configs
src=exec_script("//build/python_scripts/read_files.py",[rebase_path("."),"src_files.txt","src"],"string")
source_list=string_split(src)
sources+=source_list
inc=exec_script("//build/python_scripts/read_files.py",[rebase_path("."),"src_files.txt","inc"],"string")
inc_list=string_split(inc)
include_dirs+=inc_list
}
}
template("config") { template("config") {
@@ -118,4 +133,10 @@ set_defaults("kernel_module"){
] ]
} }
set_defaults("source_module"){
configs = [
# 把这个目录的配置设置为公共配置
"//ap:public"
]
}

View File

@@ -11,9 +11,16 @@
import("//build/buildcfg.gni") import("//build/buildcfg.gni")
module_name = "kl_sdk" module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) { module_group(module_name) {
modules = ["pkt","io_lib","utils",":kl_sdk"]
}
module_name1 = "kl_sdk"
source_module(module_name1) {
sources = [] sources = []
include_dirs = [] include_dirs = []
} }

8
common/io_lib/BUILD.gn Normal file
View File

@@ -0,0 +1,8 @@
import("//build/buildcfg.gni")
module_name = "kl_sdk"
kernel_module(module_name) {
sources=[]
include_dirs=[]
}

8
common/pkt/BUILD.gn Normal file
View File

@@ -0,0 +1,8 @@
import("//build/buildcfg.gni")
module_name = "kl_sdk"
kernel_module(module_name) {
sources=[]
include_dirs=[]
}

8
common/utils/BUILD.gn Normal file
View File

@@ -0,0 +1,8 @@
import("//build/buildcfg.gni")
module_name = "kl_sdk"
kernel_module(module_name) {
sources=[]
include_dirs=[]
}

View File

@@ -368,18 +368,18 @@ def lex(text:bytes,file_name:str=""):
else: else:
buff.append(c_old&0xff) buff.append(c_old&0xff)
c_old=c c_old=c
if not (lex_obj.deal_macro(buff)): # 处理宏 # if not (lex_obj.deal_macro(buff)): # 处理宏
is_space=True # is_space=True
while True: # while True:
c=lex_obj.get_next_char() # c=lex_obj.get_next_char()
if(is_space and c==TOKEN('#')): # if(is_space and c==TOKEN('#')):
break # break
if(c==-1): # if(c==-1):
break # break
if not isspace(c): # if not isspace(c):
is_space=False # is_space=False
elif(c==TOKEN('\n')): # elif(c==TOKEN('\n')):
is_space=True # is_space=True
elif isinstr(c,"/"): elif isinstr(c,"/"):
c=lex_obj.get_next_char() c=lex_obj.get_next_char()
if(c==TOKEN("/")): if(c==TOKEN("/")):
@@ -420,8 +420,8 @@ def lex(text:bytes,file_name:str=""):
else: else:
lex_obj.save_one_char_token(TOKEN(".")) lex_obj.save_one_char_token(TOKEN("."))
else: else:
raise Exception(f"未知的字符 {bytes([c])}, {lex_obj.file_name}:{lex_obj.line},{lex_obj.pos}") # raise Exception(f"未知的字符 {bytes([c])}, {lex_obj.file_name}:{lex_obj.line},{lex_obj.pos}")
# c=lex_obj.get_next_char() c=lex_obj.get_next_char()
# if(line_old==lex_obj.line and pos_old==lex_obj.pos): # if(line_old==lex_obj.line and pos_old==lex_obj.pos):
# print(f"pointer not move.") # print(f"pointer not move.")
# print(line_old,pos_old) # print(line_old,pos_old)

View File

@@ -11,9 +11,16 @@
import("//build/buildcfg.gni") import("//build/buildcfg.gni")
module_name = "kl_sdk" module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) { module_group(module_name) {
modules = ["riscv3",":kl_sdk"]
}
module_name1 = "kl_sdk"
source_module(module_name1) {
sources = [] sources = []
include_dirs = [] include_dirs = []
} }

8
startup/riscv3/BUILD.gn Normal file
View File

@@ -0,0 +1,8 @@
import("//build/buildcfg.gni")
module_name = "kl_sdk"
kernel_module(module_name) {
sources = []
include_dirs = []
}