diff options
author | Chris Johns <chrisj@rtems.org> | 2012-09-19 17:48:49 +1000 |
---|---|---|
committer | Chris Johns <chrisj@rtems.org> | 2012-09-19 17:48:49 +1000 |
commit | 8fdda700410d848a8546bb31052b6f902c168af6 (patch) | |
tree | a9070107cbc2571c2b4e1f31815417058b7ab8e3 | |
parent | cd6e786d3d3ea0e728174cc17c48ad29c580731e (diff) |
Fix the global symbol generation dependence order.
-rw-r--r-- | wscript | 136 |
1 files changed, 71 insertions, 65 deletions
@@ -25,19 +25,15 @@ def init(ctx): def options(opt): rtems.options(opt) - opt.add_option('--gsyms-embedded', - action = 'store_true', - default = False, - dest = 'gsym_embedded', - help = 'Embedded the global symbols in the executable (buggy).') - def configure(conf): - rtems.configure(conf) + conf.find_program('awk') + conf.env.GSYMS_AWK = '%s/mksyms.awk' % (conf.srcnode.abspath()) + conf.env.GSYMS_FLAGS = '--embed' conf.env.ASCIIDOC = conf.find_program(['asciidoc.py'], mandatory = False) conf.env.ASCIIDOC_FLAGS = ['-b', 'html', '-a', 'data-uri', '-a', 'icons', '-a', 'max-width=55em-a'] - conf.env.GSYM_EMBEDDED = conf.options.gsym_embedded + rtems.configure(conf) def build(bld): rtems.build(bld) @@ -45,22 +41,43 @@ def build(bld): arch_bsp = bld.get_env()['RTEMS_ARCH_BSP'] arch = bld.get_env()['RTEMS_ARCH'] + # + # The include paths and defines. + # bld.includes = ['.', 'libbsd/include', 'libbsd/include/arch/' + arch] - bld.defines = ['PACKAGE_VERSION="' + version + '"'] - if bld.env.GSYM_EMBEDDED: - bld.defines += ['RTL_GSYM_EMBEDDED=1'] + bld.cflags = ['-g'] - rtl_bspinit(bld, arch) - rtl_root_fs(bld) - rtl_gsyms(bld) + # + # The ARM as special BSP initialise code. + # + if arch == 'arm': + bld(target = 'bspinit', + features = 'c', + includes = bld.includes, + defines = bld.defines, + source = ['bspinit.c']) - bld(target = 'rtl', - features = 'c cstlib', + # + # Create the root file system. + # + bld(target = 'fs-root.tar', + source = ['shell-init'], + rule = 'tar cf - ${SRC} > ${TGT}') + bld.objects(name = 'rootfs', + target = 'fs-root-tarfile.o', + source = 'fs-root.tar', + rule = '${OBJCOPY} -I binary -B ${RTEMS_ARCH} ${OBJCOPY_FLAGS} ${SRC} ${TGT}') + + # + # The RTL library. + # + bld(features = 'c cstlib', + target = 'rtl', includes = bld.includes, - cflags = '-g', + cflags = bld.cflags, source = ['dlfcn.c', 'dlfcn-shell.c', 'rtl.c', @@ -82,12 +99,14 @@ def build(bld): bsp_include_base = '${PREFIX}/%s' % (rtems.arch_bsp_include_path(arch_bsp)) + # + # Installing the library and headers. + # bld.install_files("%s" % (bsp_include_base), ['libbsd/include/dlfcn.h', 'libbsd/include/err.h', 'libbsd/include/link.h', 'libbsd/include/link_elf.h']) - bld.install_files("%s/sys" % (bsp_include_base), ['libbsd/include/sys/ansi.h', 'libbsd/include/sys/cdefs.h', @@ -95,7 +114,6 @@ def build(bld): 'libbsd/include/sys/exec_elf.h', 'libbsd/include/sys/featuretest.h', 'libbsd/include/sys/nb-queue.h']) - bld.install_files("%s/machine" % (bsp_include_base), ['libbsd/include/arch/%s/machine/ansi.h' % (arch), 'libbsd/include/arch/%s/machine/asm.h' % (arch), @@ -103,15 +121,45 @@ def build(bld): 'libbsd/include/arch/%s/machine/elf_machdep.h' % (arch), 'libbsd/include/arch/%s/machine/int_types.h' % (arch)]) - bld(target = 'rtld', - features = 'c cprogram', + # + # Create an RTEMS kernel to boot and test with. The kernel contains the RTL + # loader and shell commands to use it. + # + # The following performs a prelink (which is actually just a normal link) + # without a global symbol table to create an ELF file with the + # symbols. This is processed to create a C file of global symbols and + # finally the second link occurs with the global symbol table to create the + # executable to install. + # + bld(features = 'c', + target = 'app', source = ['init.c', 'main.c', 'fs-root-tarfile.o'], includes = bld.includes, defines = bld.defines, - cflags = '-g', - use = ['rtl', 'bspinit', 'rootfs'], + cflags = bld.cflags) + + bld(features = 'c cprogram', + target = 'rtld.prelink', + includes = bld.includes, + defines = bld.defines, + cflags = bld.cflags, + use = ['app', 'rtl', 'bspinit', 'rootfs'], + install_path = None) + + bld(name = 'gsyms', + target = 'rtld-gsyms.c', + source = 'rtld.prelink', + rule = '${NM} -g ${SRC} | ${AWK} -f ${GSYMS_AWK} ${GSYMS_FLAGS} > ${TGT}') + + bld(features = 'c cprogram', + target = 'rtld', + source = ['rtld-gsyms.c'], + includes = bld.includes, + defines = bld.defines, + cflags = bld.cflags, + use = ['app', 'rtl', 'bspinit', 'rootfs'], install_path = '${PREFIX}/%s/samples' % (rtems.arch_bsp_path(arch_bsp))) if bld.env.ASCIIDOC: @@ -124,14 +172,6 @@ def rebuild(ctx): def tags(ctx): ctx.exec_command('etags $(find . -name \*.[sSch])', shell = True) -def rtl_bspinit(bld, arch): - if arch == 'arm': - bld(target = 'bspinit', - features = 'c', - includes = bld.includes, - defines = bld.defines, - source = ['bspinit.c']) - def mmap_source(bld, arch_bsp): bld(target = 'mmap', features = 'c cstlib', @@ -140,40 +180,6 @@ def mmap_source(bld, arch_bsp): 'munmap.c'], install_path = '${PREFIX}/%s' % (rtems.arch_bsp_lib_path(arch_bsp))) -def rtl_root_fs(bld): - bld(target = 'fs-root.tar', - source = ['shell-init'], - rule = 'tar cf - ${SRC} > ${TGT}') - bld.objects(name = 'rootfs', - target = 'fs-root-tarfile.o', - source = 'fs-root.tar', - rule = '${OBJCOPY} -I binary -B ${RTEMS_ARCH} ${OBJCOPY_FLAGS} ${SRC} ${TGT}') - -def rtl_gsyms(bld): - import os.path - src = os.path.join(bld.get_variant_dir(), 'gsyms.c') - if os.path.exists(src): - if os.path.exists(os.path.join(bld.get_variant_dir(), 'rtld')): - import os - sb = os.stat(src) - if sb.st_size == 0: - if bld.env.GSYM_EMBEDDED: - flags = '--embed' - else: - flags = '' - bld(name = 'gsyms', - target = 'gsyms.c', - always = True, - rule = '${NM} -g rtld | awk -f ../../mksyms.awk - ' + flags + ' > ${TGT}') - else: - open(src, 'a').close() - bld(target = 'rtld-gsyms', - features = 'c', - includes = bld.includes, - defines = bld.defines, - source = ['rtld-gsyms.c'], - depends_on = 'gsyms') - import waflib.TaskGen waflib.TaskGen.declare_chain(name = 'html', rule = '${ASCIIDOC} ${ASCIIDOC_FLAGS} -o ${TGT} ${SRC}', |