stm32移植鸿蒙os,移植鸿蒙系统到STM32L476RG_NUCLEO开发板的一点小经验

template("gcc_toolchain") {

toolchain(target_name) {

assert(defined(invoker.cc), "gcc toolchain must specify a \"cc\" value")

assert(defined(invoker.cxx), "gcc toolchain must specify a \"cxx\" value")

assert(defined(invoker.ld), "gcc toolchain must specify a \"ld\" value")

assert(defined(invoker.ar), "gcc toolchain must specify a \"ar\" value")

assert(defined(invoker.as), "clang toolchain must specify a \"as\" value")

assert(defined(invoker.cp), "clang toolchain must specify a \"cp\" value")

ar = invoker.ar

as = invoker.as

cc = invoker.cc

cxx = invoker.cxx

ld = invoker.ld

cp = invoker.cp

need_strip = false

if(defined(invoker.strip)) {

strip = invoker.strip

need_strip = true

}

if (defined(invoker.extra_ldflags) && invoker.extra_ldflags != "") {

extra_ldflags = ""

} else {

extra_ldflags = ""

}

tool("cc") {

command = "$cc -c {{cflags}} {{defines}} {{include_dirs}} {{cflags_c}} " +

# "-MMD -MP -MF‘{{source_out_dir}}/{{source_name_part}}.d’ " +

# "-Wa,-a,-ad,-alms={{source_out_dir}}/{{source_name_part}}.lst " +

"{{source}} -o {{output}}"

depsformat = "gcc"

description = "cross compiler {{output}}"

outputs = [

"{{source_out_dir}}/{{source_name_part}}.o",

]

}

tool("cxx") {

depfile = "{{output}}.d"

command = "$cxx -c {{cflags}} {{defines}} {{include_dirs}} {{cflags_c}} " +

# "-MMD -MP -MF‘{{source_out_dir}}/{{source_name_part}}.d’ " +

# "-Wa,-a,-ad,-alms={{source_out_dir}}/{{source_name_part}}.lst " +

"{{source}} -o {{output}}"

depsformat = "gcc"

description = "CXX {{output}}"

outputs = [

"{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o",

]

}

tool("asm") {

depfile = "{{output}}.d"

command = "$as -c {{cflags}} {{defines}} {{include_dirs}} {{asmflags}} {{source}} {{cflags_c}} " +

"-o {{output}}"

depsformat = "gcc"

description = "cross compiler {{output}}"

outputs = [

"{{source_out_dir}}/{{source_name_part}}.o"

]

}

tool("alink") {

outfile = "{{output_dir}}/{{target_output_name}}{{output_extension}}"

rspfile = "{{output}}.rsp"

rspfile_content = "{{inputs}}"

command = "$ar cr {{output}} @\"$rspfile\""

description = "AR {{output}}"

outputs = [

outfile

]

default_output_dir = "{{root_out_dir}}/libs"

default_output_extension = ".a"

output_prefix = "lib"

}

tool("link") {

outfile = "{{output_dir}}/bin/{{target_output_name}}.elf"

rspfile = "$outfile.rsp"

command = "$ld {{inputs}} {{ldflags}} $extra_ldflags -specs=nano.specs " +

# set ld file patch in vendor path

"-lc -lm -lnosys {{libs}} -Wl,-Map={{target_output_name}}.map,--cref " +

"-Wl,--gc-sections -o $outfile "

if(need_strip) {

command += "&& $cp -O binary -S $outfile {{output_dir}}/bin/{{target_output_name}}.bin"

}

description = "LINK $outfile"

default_output_dir = "{{root_out_dir}}"

rspfile_content = "{{inputs}}"

outputs = [

outfile

]

}

tool("stamp") {

if (host_os == "win") {

command = "cmd /c type nul > \"{{output}}\""

} else {

command = "/usr/bin/touch {{output}}"

}

description = "STAMP {{output}}"

}

tool("copy") {

command = "$cp -O binary -S {{source}} {{output}}.bin && echo $strip"

description = "COPY {{source}} {{output}}"

}

}

你可能感兴趣的:(stm32移植鸿蒙os)