rtems 6版本开始使用waf编译系统,不再使用autotool makefile编译,二者差别比较大
基本过程为:
1. 先生成一个默认的配置文件config.ini
./waf bspdefaults --rtems-bsps=i386/pc386 > config.ini
2. 再生成配置
./waf configure --rtems-bsps=i386/pc386 --rtems-config=./config.ini --rtems-tools=/root/development/rtems-i386-toolchain/6.1-rc4
3. 开始实质性的编译过程
./waf build
waf并非专为rtems开发,代码量相关不大,下面对相关命令做详细分析
WAF 编译过程分析
Waf 根据指定的BSP, 找到对应的TOP LEVEL grp.yml, grp.yml中包含了子 yml文件,一级级包含到最终编译
执行bspdefaults 之后动作,关联到wscript中 def bspdefaults
load_items_from_options 这里加载所有YML文件
例如如下格式的内容
SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
actions:
- get-boolean: null
- env-enable: null
build-type: option
copyrights:
- Copyright (C) 2020 embedded brains GmbH & Co. KG
default:
- enabled-by: true
value: true
description: |
Install the legacy application Makefile framework.
enabled-by: true
links: []
name: INSTALL_LEGACY_MAKEFILES
type: build
./waf bspdefaults 时
调用过程 wsscript
def bspdefaults(ctx):
load_items_from_options
load_items
ctors = {
"option": OptionItem,
load_items_in_directory
load_from_yaml(safe_load, ctx, data_by_uid, path, path)
或者
items[uid] = ctors[data["build-type"]](uid, data)
for arch in sorted(bsps):
for bsp in sorted(bsps[arch]):
variant = arch + "/" + bsp
if is_in_white_list(variant, white_list):
items[top_group].defaults(enabled)
defaults
do_defaults
default_value
for default in self.data["default"]: #查找yml中是否有这些关键字
if _is_enabled(enabled, default["enabled-by"]):
value = default["value"]
print ("------>self.uid:",self.uid) #添加生成的源 yml 文件打印
break
description = self.data["description"]
if description:
print(line)
bsp_item.defaults(enabled)
输出类似如下功能
[root@localhost rtems-6.1-rc4]# ./waf bspdefaults --rtems-bsps=i386/pc386
-->Load_items_from_optins, specs: None
-->top_group: /grp
[i386/pc386]
# Selects the compiler used to build the BSP (allowed values are "gcc" and
# "clang"). Please note that the values of some options depend on the compiler
# selection and changing the compiler may lead to unpredictable behaviour if
# these options are not adjusted as well. Use the --rtems-compiler command line
# option to get the default values for a particular compiler via
# ./waf bspdefaults.
COMPILER = gcc
-->top_group: /grp
------>self.uid: /cpukit/optprogramprefix
# Defines the program prefix of tools (compiler, assembler, linker)
# used to build RTEMS. This option may be used to build RTEMS with a
# vendor tool suite. Please note, support issues related to using this
# option with vendor tool suites should be directed to the vendor of
# the tools.
PROGRAM_PREFIX = ${ARCH}-rtems${__RTEMS_MAJOR__}-
-->bsp_item.uid: /bsps/i386/pc386/bsppc386
------>self.uid: /bsps/opto2
# Default optimization flags for C and C++ compilers.
OPTIMIZATION_FLAGS = -O2 -g -fdata-sections -ffunction-sections
------>self.uid: /bsps/i386/pc386/abi
# ABI flags
ABI_FLAGS = -mtune=i386
执行waf configure之后动作,关联到wscript中 def configure
./waf configure --rtems-bsps=i386/pc386 --rtems-config=./config.ini --rtems-tools=/root/development/rtems-i386-toolchain/6.1-rc4
相关PYTHON脚本如下
def configure(conf):
configure_variant
cic = ConfigItemContext(cp, path_list)
items[conf.env.TOPGROUP].configure(conf, cic)
class Item(object):
class OptionItem(Item):
do_configure
value = None
for action in self.data["actions"]:
print("-->Item do_configure:",self.uid + ".yml")
for action_arg in action.items():
print(" action_arg[0][1]:", action_arg[0], action_arg[1])
value = actions[action_arg[0]](conf, cic, value, action_arg[1])
def _find_program(self, conf, cic, value, arg):
return conf.find_program(value, path_list=cic.path_list)
//打印类如下信息
//-->Item do_configure: /cpukit/optgcc.yml
// action_arg[0][1]: find-program None
//Checking for program 'i386-rtems6-gcc' : /root/development/rtems-i386-toolchain/6.1-rc4/bin/i386-rtems6-gcc
bsp_item.configure(conf, cic)
打印信息部分截取如下:
Setting top to : /root/rtems-6.1-rc4
Setting out to : /root/rtems-6.1-rc4/build
Configure RTEMS version from file : VERSION
-->Load_items_from_optins, specs: None
-->from dir: ['spec/build']
Regenerate build specification cache (needs a couple of seconds)...
-->path_list: ['/root/development/rtems-i386-toolchain/6.1-rc4/bin', '/root/development/rtems-i386-toolchain/6.1-rc4', '/opt/rtems/6/bin', '/usr/lib64/qt-3.3/bin', '/root/perl5/bin', '/usr/local/sbin', '/usr/local/bin', '/usr/sbin', '/usr/bin', '/root/bin']
Configure board support package (BSP) : i386/pc386
-->conf.env.TOPGROUP: /grp
-->Item do_configure: /cpukit/optprogramprefix.yml
action_arg[0][1]: get-string None
-->Item do_configure: /cpukit/optprogramprefix.yml
action_arg[0][1]: substitute None
-->Item do_configure: /cpukit/optprogramprefix.yml
action_arg[0][1]: env-assign None
-->Item do_configure: /cpukit/optgcc.yml
action_arg[0][1]: set-value ${PROGRAM_PREFIX}gcc
-->Item do_configure: /cpukit/optgcc.yml
action_arg[0][1]: substitute None
-->Item do_configure: /cpukit/optgcc.yml
action_arg[0][1]: find-program None
Checking for program 'i386-rtems6-gcc' : /root/development/rtems-i386-toolchain/6.1-rc4/bin/i386-rtems6-gcc
action_arg[0][1]: env-assign LD
-->Item do_configure: /cpukit/optgcc.yml
action_arg[0][1]: script load = "ar g++ gas gcc"
if not is_windows_host:
load += " gccdeps"
conf.load(load)
Checking for program 'ar' : /root/development/rtems-i386-toolchain/6.1-rc4/bin/i386-rtems6-ar
Checking for program 'g++, c++' : /root/development/rtems-i386-toolchain/6.1-rc4/bin/i386-rtems6-g++
Checking for program 'ar' : /root/development/rtems-i386-toolchain/6.1-rc4/bin/i386-rtems6-ar
Checking for program 'gas, gcc' : /root/development/rtems-i386-toolchain/6.1-rc4/bin/i386-rtems6-gcc
Checking for program 'ar' : /root/development/rtems-i386-toolchain/6.1-rc4/bin/i386-rtems6-ar
Checking for program 'gcc, cc' : /root/development/rtems-i386-toolchain/6.1-rc4/bin/i386-rtems6-gcc
Checking for program 'ar' : /root/development/rtems-i386-toolchain/6.1-rc4/bin/i386-rtems6-ar
Checking for asm flags '-MMD' : yes
Checking for c flags '-MMD' : yes
Checking for cxx flags '-MMD' : yes
-->Item do_configure: /cpukit/optgcc.yml
action_arg[0][1]: set-value -qrtems
-->Item do_configure: /cpukit/optgcc.yml
action_arg[0][1]: env-append LDFLAGS
-->Item do_configure: /cpukit/optwarncxx.yml
action_arg[0][1]: env-append CXXFLAGS
-->Item do_configure: /cpukit/optincludes.yml
action_arg[0][1]: set-value cpukit/include cpukit/score/cpu/${ARCH}/include
action_arg[0][1]: env-append None
-->Item do_configure: /bsps/optldflags.yml
action_arg[0][1]: env-append PKGCONFIG_LDFLAGS
-->Item do_configure: /bsps/optldflagsbsp.yml
action_arg[0][1]: set-value ['-L${TOP}/bsps/${ARCH}/shared/start', '-L${TOP}/bsps/${ARCH}/${BSP_FAMILY}/start']
-->Item do_configure: /bsps/optldflagsbsp.yml
action_arg[0][1]: substitute None
-->Item do_configure: /bsps/optldflagsbsp.yml
-->Item do_configure: /bsps/optmake.yml
action_arg[0][1]: script def yesno(conf, enable):
if enable in conf.env.ENABLE:
return "yes"
return "no"
conf.env["RTEMS_HAS_MULTIPROCESSING"] = yesno(conf, "RTEMS_MULTIPROCESSING")
conf.env["RTEMS_HAS_POSIX_API"] = yesno(conf, "RTEMS_POSIX_API")
'configure' finished successfully (2.687s)
输出得文件如下:
[root@localhost rtems-6.1-rc4]# tree build/i386/pc386/
build/i386/pc386/
├── bsp.cfg
├── bsps
│ └── include
│ └── bspopts.h
├── cpukit
│ └── include
│ ├── config.h
│ └── rtems
│ ├── score
│ │ └── cpuopts.h
│ └── testopts.h
├── i386-rtems6-pc386.pc
├── Makefile.inc
├── pc386.cfg
└── target.cfg
执行Waf build之后的动作
总体流程,先准备好编译相关的TASK,然后等 def build 执行完,开始启动相关TASK
注意
相关代码
class Item(object):
build(self, bld, bic):
do_build(bld, bic)
build.py 162
def compile(self):
Logs.debug('build: compile()')
self.producer=Runner.Parallel(self,self.jobs)
self.producer.biter=self.get_build_iterator()
try:
self.producer.start()

1642

被折叠的 条评论
为什么被折叠?



