mirror of
https://git.rtems.org/rtems-tools/
synced 2025-05-17 15:21:42 +08:00
303 lines
10 KiB
Python
303 lines
10 KiB
Python
#
|
|
# RTEMS Tools Project (http://www.rtems.org/)
|
|
# Copyright 2014-2016 Chris Johns (chrisj@rtems.org)
|
|
# All rights reserved.
|
|
#
|
|
# This file is part of the RTEMS Tools package in 'rtems-tools'.
|
|
#
|
|
# Permission to use, copy, modify, and/or distribute this software for any
|
|
# purpose with or without fee is hereby granted, provided that the above
|
|
# copyright notice and this permission notice appear in all copies.
|
|
#
|
|
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
#
|
|
|
|
#
|
|
# RTEMS Toolkit build script.
|
|
#
|
|
import sys
|
|
|
|
#
|
|
# Waf system setup. Allow more than one build in the same tree.
|
|
#
|
|
top = '.'
|
|
out = 'build-' + sys.platform
|
|
|
|
def init(ctx):
|
|
pass
|
|
|
|
def options(opt):
|
|
opt.load('compiler_c')
|
|
opt.load('compiler_cxx')
|
|
|
|
def configure(conf):
|
|
conf.load('compiler_c')
|
|
conf.load('compiler_cxx')
|
|
conf_libiberty(conf)
|
|
conf_libelf(conf)
|
|
|
|
conf.find_program('m4')
|
|
|
|
conf.check(header_name = 'sys/wait.h', features = 'c', mandatory = False)
|
|
conf.check_cc(function_name = 'kill', header_name="signal.h",
|
|
features = 'c', mandatory = False)
|
|
conf.write_config_header('config.h')
|
|
|
|
def build(bld):
|
|
#
|
|
# The local configuration.
|
|
#
|
|
conf = {}
|
|
|
|
#
|
|
# The include paths.
|
|
#
|
|
conf['includes'] = ['elftoolchain/libelf', 'elftoolchain/common', 'libiberty']
|
|
if bld.env.DEST_OS == 'win32':
|
|
conf['includes'] += ['win32']
|
|
|
|
#
|
|
# Build flags.
|
|
#
|
|
conf['warningflags'] = ['-Wall', '-Wextra', '-pedantic']
|
|
conf['optflags'] = bld.env.C_OPTS
|
|
conf['cflags'] = ['-pipe', '-g'] + conf['optflags']
|
|
conf['cxxflags'] = ['-pipe', '-g'] + conf['optflags']
|
|
conf['linkflags'] = ['-g']
|
|
|
|
#
|
|
# Create each of the modules as object files each with their own
|
|
# configurations.
|
|
#
|
|
bld_libelf(bld, conf)
|
|
bld_libiberty(bld, conf)
|
|
|
|
#
|
|
# RLD source.
|
|
#
|
|
rld_source = ['ConvertUTF.c',
|
|
'pkgconfig.cpp',
|
|
'rld-buffer.cpp',
|
|
'rld-cc.cpp',
|
|
'rld-compression.cpp',
|
|
'rld-config.cpp',
|
|
'rld-elf.cpp',
|
|
'rld-files.cpp',
|
|
'rld-outputter.cpp',
|
|
'rld-path.cpp',
|
|
'rld-process.cpp',
|
|
'rld-rap.cpp',
|
|
'rld-resolver.cpp',
|
|
'rld-rtems.cpp',
|
|
'rld-symbols.cpp',
|
|
'rld.cpp']
|
|
|
|
#
|
|
# RTEMS Utilities.
|
|
#
|
|
rtems_utils = ['rtems-utils.cpp']
|
|
|
|
#
|
|
# Compression.
|
|
#
|
|
compression = ['fastlz.c']
|
|
|
|
#
|
|
# RTL static library
|
|
#
|
|
bld.stlib(target = 'rld',
|
|
install_path = None,
|
|
source = rld_source + rtems_utils + compression,
|
|
defines = ['HAVE_CONFIG_H=1',
|
|
'RTEMS_VERSION=\"%s\"' % (bld.env.RTEMS_VERSION),
|
|
'RTEMS_RELEASE=\"%s\"' % (bld.env.RTEMS_RELEASE),
|
|
'FASTLZ_LEVEL=1'],
|
|
includes = ['.'] + conf['includes'],
|
|
cflags = conf['cflags'] + conf['warningflags'],
|
|
cxxflags = conf['cxxflags'] + conf['warningflags'],
|
|
linkflags = conf['linkflags'])
|
|
|
|
#
|
|
# The Python toolkit.
|
|
#
|
|
bld(features = 'py',
|
|
source = ['__init__.py',
|
|
'check.py',
|
|
'config.py',
|
|
'darwin.py',
|
|
'error.py',
|
|
'execute.py',
|
|
'freebsd.py',
|
|
'git.py',
|
|
'linux.py',
|
|
'log.py',
|
|
'macros.py',
|
|
'mailer.py',
|
|
'options.py',
|
|
'path.py',
|
|
'stacktraces.py',
|
|
'version.py',
|
|
'windows.py'],
|
|
install_from = '.',
|
|
install_path = '${PREFIX}/share/rtems/rtemstoolkit')
|
|
|
|
def rebuild(ctx):
|
|
import waflib.Options
|
|
waflib.Options.commands.extend(['clean', 'build'])
|
|
|
|
def tags(ctx):
|
|
ctx.exec_command('etags $(find . -name \*.[sSch])', shell = True)
|
|
|
|
#
|
|
# Libelf module.
|
|
#
|
|
def conf_libelf(conf):
|
|
pass
|
|
|
|
def bld_libelf(bld, conf):
|
|
libelf = 'elftoolchain/libelf/'
|
|
m4_rule = '${M4} -D SRCDIR=../rtemstoolkit/' + libelf[:-1] + ' ${SRC} > ${TGT}'
|
|
if bld.env.DEST_OS == 'win32':
|
|
includes = ['win32']
|
|
else:
|
|
includes = []
|
|
|
|
bld(target = 'libelf_convert.c', source = libelf + 'libelf_convert.m4', rule = m4_rule)
|
|
bld(target = 'libelf_fsize.c', source = libelf + 'libelf_fsize.m4', rule = m4_rule)
|
|
bld(target = 'libelf_msize.c', source = libelf + 'libelf_msize.m4', rule = m4_rule)
|
|
|
|
host_source = []
|
|
|
|
if bld.env.DEST_OS == 'linux':
|
|
common = 'elftoolchain/common/'
|
|
bld(target = common + 'native-elf-format.h',
|
|
source = common + 'native-elf-format',
|
|
name = 'native-elf-format',
|
|
rule = './${SRC} > ${TGT}')
|
|
bld.add_group ()
|
|
elif bld.env.DEST_OS == 'win32':
|
|
host_source += [libelf + 'mmap_win32.c']
|
|
|
|
bld.stlib(target = 'elf',
|
|
features = 'c',
|
|
install_path = None,
|
|
uses = ['native-elf-format'],
|
|
includes = [bld.bldnode.abspath(),
|
|
'elftoolchain/libelf', 'elftoolchain/common'] + includes,
|
|
cflags = conf['cflags'],
|
|
source =[libelf + 'elf.c',
|
|
libelf + 'elf_begin.c',
|
|
libelf + 'elf_cntl.c',
|
|
libelf + 'elf_end.c',
|
|
libelf + 'elf_errmsg.c',
|
|
libelf + 'elf_errno.c',
|
|
libelf + 'elf_data.c',
|
|
libelf + 'elf_fill.c',
|
|
libelf + 'elf_flag.c',
|
|
libelf + 'elf_getarhdr.c',
|
|
libelf + 'elf_getarsym.c',
|
|
libelf + 'elf_getbase.c',
|
|
libelf + 'elf_getident.c',
|
|
libelf + 'elf_hash.c',
|
|
libelf + 'elf_kind.c',
|
|
libelf + 'elf_memory.c',
|
|
libelf + 'elf_next.c',
|
|
libelf + 'elf_rand.c',
|
|
libelf + 'elf_rawfile.c',
|
|
libelf + 'elf_phnum.c',
|
|
libelf + 'elf_shnum.c',
|
|
libelf + 'elf_shstrndx.c',
|
|
libelf + 'elf_scn.c',
|
|
libelf + 'elf_strptr.c',
|
|
libelf + 'elf_update.c',
|
|
libelf + 'elf_version.c',
|
|
libelf + 'gelf_cap.c',
|
|
libelf + 'gelf_checksum.c',
|
|
libelf + 'gelf_dyn.c',
|
|
libelf + 'gelf_ehdr.c',
|
|
libelf + 'gelf_getclass.c',
|
|
libelf + 'gelf_fsize.c',
|
|
libelf + 'gelf_move.c',
|
|
libelf + 'gelf_phdr.c',
|
|
libelf + 'gelf_rel.c',
|
|
libelf + 'gelf_rela.c',
|
|
libelf + 'gelf_shdr.c',
|
|
libelf + 'gelf_sym.c',
|
|
libelf + 'gelf_syminfo.c',
|
|
libelf + 'gelf_symshndx.c',
|
|
libelf + 'gelf_xlate.c',
|
|
libelf + 'libelf_align.c',
|
|
libelf + 'libelf_allocate.c',
|
|
libelf + 'libelf_ar.c',
|
|
libelf + 'libelf_ar_util.c',
|
|
libelf + 'libelf_checksum.c',
|
|
libelf + 'libelf_data.c',
|
|
libelf + 'libelf_ehdr.c',
|
|
libelf + 'libelf_extended.c',
|
|
libelf + 'libelf_phdr.c',
|
|
libelf + 'libelf_shdr.c',
|
|
libelf + 'libelf_xlate.c',
|
|
'libelf_convert.c',
|
|
'libelf_fsize.c',
|
|
'libelf_msize.c'] + host_source)
|
|
|
|
#
|
|
# Libiberty module.
|
|
#
|
|
def conf_libiberty(conf):
|
|
conf.check(header_name='alloca.h', features = 'c', mandatory = False)
|
|
conf.check(header_name='fcntl.h', features = 'c', mandatory = False)
|
|
conf.check(header_name='process.h', features = 'c', mandatory = False)
|
|
conf.check(header_name='stdlib.h', features = 'c')
|
|
conf.check(header_name='string.h', features = 'c')
|
|
conf.check(header_name='strings.h', features = 'c', mandatory = False)
|
|
conf.check(header_name='sys/file.h', features = 'c', mandatory = False)
|
|
conf.check(header_name='sys/stat.h', features = 'c', mandatory = False)
|
|
conf.check(header_name='sys/time.h', features = 'c', mandatory = False)
|
|
conf.check(header_name='sys/types.h', features = 'c', mandatory = False)
|
|
conf.check(header_name='sys/wait.h', features = 'c', mandatory = False)
|
|
conf.check(header_name='unistd.h', features = 'c', mandatory = False)
|
|
conf.check(header_name='vfork.h', features = 'c', mandatory = False)
|
|
|
|
conf.check_cc(function_name='getrusage',
|
|
header_name="sys/time.h sys/resource.h",
|
|
features = 'c', mandatory = False)
|
|
|
|
conf.write_config_header('libiberty/config.h')
|
|
|
|
def bld_libiberty(bld, conf):
|
|
if bld.env.DEST_OS == 'win32':
|
|
pex_host = 'libiberty/pex-win32.c'
|
|
else:
|
|
pex_host = 'libiberty/pex-unix.c'
|
|
bld.stlib(target = 'iberty',
|
|
features = 'c',
|
|
install_path = None,
|
|
includes = ['libiberty'],
|
|
cflags = conf['cflags'],
|
|
defines = ['HAVE_CONFIG_H=1'],
|
|
source =['libiberty/concat.c',
|
|
'libiberty/cplus-dem.c',
|
|
'libiberty/cp-demangle.c',
|
|
'libiberty/make-temp-file.c',
|
|
'libiberty/mkstemps.c',
|
|
'libiberty/safe-ctype.c',
|
|
'libiberty/stpcpy.c',
|
|
'libiberty/pex-common.c',
|
|
'libiberty/pex-one.c',
|
|
pex_host])
|
|
|
|
#
|
|
# The doxy command.
|
|
#
|
|
from waflib import Build
|
|
class doxy(Build.BuildContext):
|
|
fun = 'build'
|
|
cmd = 'doxy'
|