对于gn来说,工具链被抽象为一系列的工具描述,我们要做的就是写对应的工具描述文件出来。
首先在工程根目录建立一个文件.gn(注意文件的名字为空,后缀为.gn),文件中配置工具链描述文件所在的路径
buildconfig = "//build/buildconfig.gn"
该变量定义了构建工具链描述文件所在的路径,//表示工程根目录。
在buildconfig.gn中定义工具链。
set_default_toolchain("//build/toolchain:armcc")
上面说到了,工具链就是一系列的描述,所以修改工具链也就是修改这一系列的描述,以下为一个典型的armcc的描述文件
toolchain("armcc") {
tool("cc") {
depfile = "{
{output}}.d"
command = "$MDK_DIR/ARM/ARMCC/bin/armcc.exe --c99 -g --apcs=interwork -DUSE_STDPERIPH_DRIVER --depend $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("asm") {
depfile = "{
{output}}.d"
command = "$MDK_DIR/ARM/ARMCC/bin/armasm.exe -g --apcs=interwork --xref --depend $depfile {
{include_dirs}} {
{asmflags}} {
{source}} -o {
{output}}"
depsformat = "gcc"
description = "ASM {
{output}}"
outputs = [
"{
{source_out_dir}}/{
{target_output_name}}.{
{source_name_part}}.o",
]
}
tool("alink") {
rspfile = "{
{output}}.rsp"
command = "$MDK_DIR/ARM/ARMCC/bin/armar.exe -r {
{output}} --via $rspfile"
description = "AR {
{target_output_name}}{
{output_extension}}"
rspfile_content = "{
{inputs}}"
outputs = [
"{
{target_out_dir}}/{
{target_output_name}}{
{output_extension}}",
]
default_output_extension = ".a"
output_prefix = "lib"
}
tool("link") {
outfile = "bin/{
{target_output_name}}{
{output_extension}}"
rspfile = "$outfile.rsp"
command = "$MDK_DIR/ARM/ARMCC/bin/armlink.exe {
{ldflags}} --info veneers --info unused --info totals --info sizes --symbols --callgraph --xref --strict --summary_stderr --info summarysizes --map --list bin/{
{target_output_name}}.map -o $outfile --via $rspfile {
{libs}}"
description = "LINK $outfile"
default_output_dir = "{
{root_out_dir}}"
rspfile_content = "{
{inputs}}"
default_output_extension = ".axf"
outputs = [
outfile,
]
}
tool("stamp") {
command = "cmd.exe /c echo > {
{output}}"
description = "STAMP {
{output}}"
}
tool("copy") {
command = "cp /y {
{source}} {
{output}}"
description = "COPY {
{source}} {
{output}}"
}
}
其可选的所有定义在该博客中进行介绍:
各个工具分开看,首先是编译器
tool("cc") {
depfile = "{
{output}}.d"
command = "$MDK_DIR/ARM/ARMCC/bin/armcc.exe --c99 -g --apcs=interwork -DUSE_STDPERIPH_DRIVER --depend $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("cc")表征为编译器,其依赖文件生成为.d文件command即为执行编译时需要运行的指令,编译器的固定参数的话可以直接写在toolchain的定义中,其他参数则由具体的编译实体定义,其中使用双大括号包起来的参数将在运行gn时进行展开以生成对应的inja文件。armcc的编译参数在此不进行解释,详细的作用自行查阅armcc的官方说明手册。
汇编器,汇编器与编译器类似,也没什么需要多说的。
tool("asm") {
depfile = "{
{output}}.d"
command = "$MDK_DIR/ARM/ARMCC/bin/armasm.exe -g --apcs=interwork --xref --depend $depfile {
{include_dirs}} {
{asmflags}} {
{source}} -o {
{output}}"
depsformat = "gcc"
description = "ASM {
{output}}"
outputs = [
"{
{source_out_dir}}/{
{target_output_name}}.{
{source_name_part}}.o",
]
}
静态库链接器
tool("alink") {
rspfile = "{
{output}}.rsp"
command = "$MDK_DIR/ARM/ARMCC/bin/armar.exe -r {
{output}} --via $rspfile"
description = "AR {
{target_output_name}}{
{output_extension}}"
rspfile_content = "{
{inputs}}"
outputs = [
"{
{target_out_dir}}/{
{target_output_name}}{
{output_extension}}",
]
default_output_extension = ".a"
output_prefix = "lib"
}
静态库链接器在arm工具链中为armar,其主要作用就是把.o文件打包成.a文件(即静态库文件),需要注意这个地方配置了rsp文件,原因是在静态库打包时,可能会存在命令行长度过长的问题(windows限制命令行最大程度为8192个字符),超出该长度的话会导致链接失效,因此将链接参数写入rsp文件,armar读取rsp文件来做链接,这样就不会有字符长度限制了。
链接器
tool("link") {
outfile = "bin/{
{target_output_name}}{
{output_extension}}"
rspfile = "$outfile.rsp"
command = "$MDK_DIR/ARM/ARMCC/bin/armlink.exe {
{ldflags}} --info veneers --info unused --info totals --info sizes --symbols --callgraph --xref --strict --summary_stderr --info summarysizes --map --list bin/{
{target_output_name}}.map -o $outfile --via $rspfile {
{libs}}"
description = "LINK $outfile"
default_output_dir = "{
{root_out_dir}}"
rspfile_content = "{
{inputs}}"
default_output_extension = ".axf"
outputs = [
outfile,
]
}
链接器在arm工具链中为armlink,起作用是完成完整链接,链接处最终生成文件axf,只要有了axf就可以进行下载和调试了!
其他工具
tool("stamp") {
command = "cmd.exe /c echo > {
{output}}"
description = "STAMP {
{output}}"
}
tool("copy") {
command = "cp /y {
{source}} {
{output}}"
description = "COPY {
{source}} {
{output}}"
}
其他工具主要包含了两个,stamp用于创建一个保存构建时间戳的文件,copy则用来进行必要的复制操作。
对于其中使用到的相关的工具链命令行参数均需要自行查阅对应的官方说明手册进行学习,这篇文章主要介绍构建系统,对于编译工具链的使用在此不进行赘述。
这样我们就配置好了最基本的armcc编译工具链,之后可以开始工程的架构了
文章浏览阅读3.8k次,点赞9次,收藏28次。直接上一个工作中碰到的问题,另外一个系统开启多线程调用我这边的接口,然后我这边会开启多线程批量查询第三方接口并且返回给调用方。使用的是两三年前别人遗留下来的方法,放到线上后发现确实是可以正常取到结果,但是一旦调用,CPU占用就直接100%(部署环境是win server服务器)。因此查看了下相关的老代码并使用JProfiler查看发现是在某个while循环的时候有问题。具体项目代码就不贴了,类似于下面这段代码。while(flag) {//your code;}这里的flag._main函数使用while(1)循环cpu占用99
文章浏览阅读347次。idea shift f6 快捷键无效_idea shift +f6快捷键不生效
文章浏览阅读135次。Ecmacript 中没有DOM 和 BOM核心模块Node为JavaScript提供了很多服务器级别,这些API绝大多数都被包装到了一个具名和核心模块中了,例如文件操作的 fs 核心模块 ,http服务构建的http 模块 path 路径操作模块 os 操作系统信息模块// 用来获取机器信息的var os = require('os')// 用来操作路径的var path = require('path')// 获取当前机器的 CPU 信息console.log(os.cpus._node模块中有很多核心模块,以下不属于核心模块,使用时需下载的是
文章浏览阅读10w+次,点赞435次,收藏3.4k次。SPSS 22 下载安装过程7.6 方差分析与回归分析的SPSS实现7.6.1 SPSS软件概述1 SPSS版本与安装2 SPSS界面3 SPSS特点4 SPSS数据7.6.2 SPSS与方差分析1 单因素方差分析2 双因素方差分析7.6.3 SPSS与回归分析SPSS回归分析过程牙膏价格问题的回归分析_化工数学模型数据回归软件
文章浏览阅读7.5k次。如何利用hutool工具包实现邮件发送功能呢?1、首先引入hutool依赖<dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-all</artifactId> <version>5.7.19</version></dependency>2、编写邮件发送工具类package com.pc.c..._hutool发送邮件
文章浏览阅读867次,点赞2次,收藏2次。docker安装elasticsearch,elasticsearch-head,kibana,ik分词器安装方式基本有两种,一种是pull的方式,一种是Dockerfile的方式,由于pull的方式pull下来后还需配置许多东西且不便于复用,个人比较喜欢使用Dockerfile的方式所有docker支持的镜像基本都在https://hub.docker.com/docker的官网上能找到合..._docker安装kibana连接elasticsearch并且elasticsearch有密码
文章浏览阅读1.3w次,点赞57次,收藏92次。整理 | 郑丽媛出品 | CSDN(ID:CSDNnews)近年来,随着机器学习的兴起,有一门编程语言逐渐变得火热——Python。得益于其针对机器学习提供了大量开源框架和第三方模块,内置..._beeware
文章浏览阅读7.9k次。//// ViewController.swift// Day_10_Timer//// Created by dongqiangfei on 2018/10/15.// Copyright 2018年 飞飞. All rights reserved.//import UIKitclass ViewController: UIViewController { ..._swift timer 暂停
文章浏览阅读986次,点赞2次,收藏2次。1.硬性等待让当前线程暂停执行,应用场景:代码执行速度太快了,但是UI元素没有立马加载出来,造成两者不同步,这时候就可以让代码等待一下,再去执行找元素的动作线程休眠,强制等待 Thread.sleep(long mills)package com.example.demo;import org.junit.jupiter.api.Test;import org.openqa.selenium.By;import org.openqa.selenium.firefox.Firefox.._元素三大等待
文章浏览阅读3k次,点赞4次,收藏14次。Java软件工程师职位分析_java岗位分析
文章浏览阅读2k次。Java:Unreachable code的解决方法_java unreachable code
文章浏览阅读1w次。1、html中设置标签data-*的值 标题 11111 222222、点击获取当前标签的data-url的值$('dd').on('click', function() { var urlVal = $(this).data('ur_如何根据data-*属性获取对应的标签对象