既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上物联网嵌入式知识点,真正体系化!
由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、电子书籍、讲解视频,并且后续会持续更新
"-g",
"-T",
"$ld\_script"
]
}
executable(“os”) {
configs = []
configs += [ “:os_config” ]
sources = []
deps = [
":os\_modules",
]
}
target = “
r
o
o
t
_
o
u
t
_
d
i
r
/
o
s
.
e
l
f
"
t
a
r
g
e
t
e
l
f
=
"
root\_out\_dir/os.elf" target_elf = "
root_out_dir/os.elf"targetelf="root_out_dir/image/os.elf”
target_bin = “
r
o
o
t
_
o
u
t
_
d
i
r
/
i
m
a
g
e
/
o
s
.
b
i
n
"
t
a
r
g
e
t
h
e
x
=
"
root\_out\_dir/image/os.bin" target_hex = "
root_out_dir/image/os.bin"targethex="root_out_dir/image/os.hex”
target_dump = “$root_out_dir/image/os.dump”
copy(“copy_os”) {
deps = [ “:os” ]
sources = [ “
t
a
r
g
e
t
"
]
o
u
t
p
u
t
s
=
[
"
target" ] outputs = [ "
target"]outputs=["target_elf” ]
}
action(“build_image”) {
deps = [
“:copy_os”,
]
script = "//build/py\_script/elf\_format.py"
sources = [
"$target\_elf",
]
outputs = [
"$target\_bin",
"$target\_hex",
"$target\_dump",
]
args = [
"--format\_tool",
"$crossdev",
"--elf",
rebase_path("$target\_elf"),
"--bin",
rebase_path("$target\_bin"),
"--hex",
rebase_path("$target\_hex"),
"--dump",
rebase_path("$target\_dump"),
"--dir",
rebase_path("$root\_out\_dir/image"),
"--flag",
"bd",
]
}
#### copy
copy为拷贝动作,定义在build/toolchain/BUILD.gn中
#### action
当生成可执行文件后,你还需要一些后续操作,这个时候你可以定义action,actoin实际上是通过python脚本来实现自定义操作
### build/config/BUILDCONFIG.gn
配置GN使用的编译器,配置toolchain变量来配置使用gcc或者clang等编译器
toolchain = “gcc”
#toolchain = “clang”
target_toolchain = “//build/toolchain:${toolchain}”
set_default_toolchain(target_toolchain)
### build/toolchain/BUILD.gn
配置gcc或者clang等其他编译的具体编译选项
#### gcc
gcc变量定义在build/config/compiler.gni头文件中
import(“//build/config/compiler.gni”)
toolchain(“gcc”) {
tool(“asm”) {
depfile = “{{output}}.d”
command = “${crossdev}gcc -MMD -MF $depfile {{defines}} {{include_dirs}} {{asmflags}} -c {{source}} -o {{output}}”
depsformat = “gcc”
description = “ASM {{output}}”
outputs =
[ “{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o” ]
}
tool("cc") {
depfile = "{{output}}.d"
command = "${crossdev}gcc -MMD -MF $depfile {{defines}} {{include\_dirs}} {{cflags}} {{cflags\_c}} -c {{source}} -o {{output}}"
depsformat = "gcc"
description = "CC {{output}}"
outputs =
[ "{{source\_out\_dir}}/{{target\_output\_name}}.{{source\_name\_part}}.o" ]
}
tool("cxx") {
depfile = "{{output}}.d"
command = "${crossdev}g++ -MMD -MF $depfile {{defines}} {{include\_dirs}} {{cflags}} {{cflags\_cc}} -c {{source}} -o {{output}}"
depsformat = "gcc"
description = "CXX {{output}}"
outputs =
[ "{{source\_out\_dir}}/{{target\_output\_name}}.{{source\_name\_part}}.o" ]
}
tool("link") {
outfile = "{{target\_output\_name}}{{output\_extension}}"
rspfile = "$outfile.rsp"
command = "${crossdev}ld {{ldflags}} -o $outfile --start-group @$rspfile {{solibs}} --end-group {{libs}}"
description = "LINK $outfile"
default_output_dir = "{{root\_out\_dir}}"
rspfile_content = "{{inputs}}"
outputs = [ outfile ]
default_output_extension = ".elf"
}
tool("alink") {
outfile = "{{target\_output\_name}}{{output\_extension}}"
rspfile = "$outfile.rsp"
command = "${crossdev}ar cr $outfile @$rspfile"
description = "AR $outfile"
default_output_dir = "{{root\_out\_dir}}"
rspfile_content = "{{inputs}}"
outputs = [ outfile ]
default_output_extension = ".a"
output_prefix = "lib"
}
tool("solink") {
outfile = "{{target\_output\_name}}{{output\_extension}}"
rspfile = "$outfile.rsp"
command = "${crossdev}gcc --shared -fPIC -o $outfile @$rspfile"
description = "SOLINK $outfile"
default_output_dir = "{{root\_out\_dir}}"
rspfile_content = "{{inputs}}"
outputs = [ outfile ]
default_output_extension = ".so"
output_prefix = "lib"
}
tool("stamp") {
command = "touch {{output}}"
description = "STAMP {{output}}"
}
tool("copy") {
command = "cp -af {{source}} {{output}}"
description = "COPY {{source}} {{output}}"
}
}
toolchain(“clang”) {
}
#### clang
### build/config/compiler.gni
#### gcc
gcc下通用的变量包括:
* crossdev:是否需要交叉编译
* defines:宏定义
* include\_dirs:头文件目录
* asmflags:汇编编译选项
* cflags:目标编译选项
* cflags\_c:C标准的编译选项
* cflags\_cc:C++标准编译选项
arch\_flags定义了所选编译器针对目标硬件的编译选项,包括不限于:
* arch\_cpu
* arch\_c
* debug
* cpu
* optimaztion
不同编译器对应不同cpu架构所支持的arch\_flags是不一样的,这里的arch\_flags只是gcc对应cpu的flags
>
> gcc支持的flags参考<https://gcc.gnu.org/onlinedocs/gcc/Option-Summary.html>
>
>
>
arch_cpuflags = []
arch_cpuflags = [ “-mcpu=cortex-a53” ]
arch_cflags = []
arch_cflags = [ “-nostdlib”,
“-nostdinc”,
“-fno-builtin”,
“-fno-common”,
“-fno-stack-protector”,
“-fno-strict-overflow”,
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上物联网嵌入式知识点,真正体系化!
由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、电子书籍、讲解视频,并且后续会持续更新
3)]
[外链图片转存中…(img-eQEaCYLj-1715652761495)]
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上物联网嵌入式知识点,真正体系化!
由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、电子书籍、讲解视频,并且后续会持续更新