diff options
Diffstat (limited to 'libbsd/libdl/wscript')
-rw-r--r-- | libbsd/libdl/wscript | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/libbsd/libdl/wscript b/libbsd/libdl/wscript new file mode 100644 index 0000000..22e1185 --- /dev/null +++ b/libbsd/libdl/wscript @@ -0,0 +1,126 @@ +# Copyright 2018 Chris Johns (chrisj@rtems.org) +# +# This file's license is 2-clause BSD as in this distribution's LICENSE.2 file. +# + +# +# This example shows: +# 1. How to build a runtime loadable application using waf and rtems_waf. +# 2. Runtime loading of object files from archives held on the target. +# +# The example's executable is large. +# +# Note: The archives and object files and placed in the root file system so the +# exapmle can run on as many BSPs as possible. A real system with +# non-volatile storage and a supported file system can hold these files +# lowering the executable's memory footprint. +# + +# Waf build script for an RTEMS Hello +import rtems_waf.rtems as rtems +import rtems_waf.rtems_bsd as rtems_bsd +import rtems_waf.rootfs as rtems_rootfs +import rtems_waf.dl as rtems_dl + +def configure(conf): + # + # The path to the following libraries. These are loaded onto the target. + # + rtems.check_lib_path(conf, lib = 'c') + rtems.check_lib_path(conf, lib = 'm') + rtems.check_lib_path(conf, lib = 'bsd', libpath = conf.env.LIBPATH) + +def build(bld): + rtems.build(bld) + + if not rtems_bsd.check_net_config(bld): + bld.fatal('libbsd libdl example needs a network config') + + # + # Build and copy the files to make a target file system. + # + bld.objects(features = 'c', + target = 'dl-objs', + source = ['dl_libbsd.c'], + idx = 101, # hack to find the object file + defines = bld.env.NET_CONFIG_DEFINES.split(',')) + + # + # Strip the object files and archives that are loaded onto the embedded + # target's file system of debug information. + # + rtems_dl.strip_debug_info(bld, + target = 'dl_libbsd.o', + source = 'dl_libbsd.c.101.o') + rtems_dl.strip_debug_info(bld, + target = 'libc.a', + source = bld.env.LIBPATH_libc) + rtems_dl.strip_debug_info(bld, + target = 'libm.a', + source = bld.env.LIBPATH_libm) + rtems_dl.strip_debug_info(bld, + target = 'libbsd.a', + source = bld.env.LIBPATH_libbsd) + + rtems_dl.ranlib(bld, 'libc.a') + rtems_dl.ranlib(bld, 'libm.a') + rtems_dl.ranlib(bld, 'libbsd.a') + + bld.add_group('dl-objs') + + # + # Build the root file system from the list of files. The fields are: + # 1. The build name + # 2. Source file + # 3. Target file in the file system + # + fs_files = [('rootfs-dl_libbsd', + bld.path.find_or_declare('dl_libbsd.o'), + 'dl_libbsd.o'), + ('rootfs-libdl-conf', + 'libdl.conf', + 'etc/libdl.conf'), + ('rootfs-libc', + bld.path.find_or_declare('libc.a'), + 'lib/libc.a'), + ('rootfs-libm', + bld.path.find_or_declare('libm.a'), + 'lib/libm.a'), + ('rootfs-libbsd.a', + bld.path.find_or_declare('libbsd.a'), + 'lib/libbsd.a')] + rtems_rootfs.build(bld, + name = 'libbsd-dl-rootfs', + root = 'rootfs', + files = fs_files) + + # + # Base image application that loads the libbsd initialisation + # + bld.objects(features = 'c', + target = 'exe-objs', + source = ['dl_main.c'], + includes = bld.path.get_bld().abspath()) + + # + # Phase 1 link, this contains the symbols in the base kernel image and is + # used to generate the symbol table. + # + libbsd_libdl_uses = ['exe-objs', 'libbsd-dl-rootfs-obj'] + bld(features = 'c cprogram', + target = 'libbsd-libdl.exe.pre', + use = libbsd_libdl_uses) + + # + # Create a symbol table. This is an object file linked to the base kernel + # imagge. The objects in the phase 1 link must match the objects in the + # phase 2 link. + # + rtems_dl.syms(bld, target = 'dl-syms.o', source = 'libbsd-libdl.exe.pre') + + # + # Phase 2 link, this is the target executable. + # + bld(features = 'c cprogram', + target = 'libbsd-libdl.exe', + use = libbsd_libdl_uses + ['dl-syms.o']) |