[749ddf1] | 1 | # |
---|
| 2 | # RTEMS Tools Project (http://www.rtems.org/) |
---|
[c5286cd] | 3 | # Copyright 2014-2018 Chris Johns (chrisj@rtems.org) |
---|
[749ddf1] | 4 | # All rights reserved. |
---|
| 5 | # |
---|
| 6 | # This file is part of the RTEMS Tools package in 'rtems-tools'. |
---|
| 7 | # |
---|
| 8 | # Redistribution and use in source and binary forms, with or without |
---|
| 9 | # modification, are permitted provided that the following conditions are met: |
---|
| 10 | # |
---|
| 11 | # 1. Redistributions of source code must retain the above copyright notice, |
---|
| 12 | # this list of conditions and the following disclaimer. |
---|
| 13 | # |
---|
| 14 | # 2. Redistributions in binary form must reproduce the above copyright notice, |
---|
| 15 | # this list of conditions and the following disclaimer in the documentation |
---|
| 16 | # and/or other materials provided with the distribution. |
---|
| 17 | # |
---|
| 18 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
| 19 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
| 20 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
| 21 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
---|
| 22 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
| 23 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
| 24 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
| 25 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
| 26 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
| 27 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
---|
| 28 | # POSSIBILITY OF SUCH DAMAGE. |
---|
| 29 | # |
---|
| 30 | |
---|
[efc4f09] | 31 | import os.path |
---|
| 32 | |
---|
[7148cae] | 33 | import wafwindows |
---|
| 34 | |
---|
[87e0e76] | 35 | subdirs = ['rtemstoolkit', |
---|
[5416cfa] | 36 | 'config', |
---|
[87e0e76] | 37 | 'linkers', |
---|
[1cd75c4] | 38 | 'misc', |
---|
[749ddf1] | 39 | 'tester', |
---|
| 40 | 'tools/gdb/python'] |
---|
| 41 | |
---|
[efc4f09] | 42 | def get_version(ctx): |
---|
[3bd8def] | 43 | from rtemstoolkit import version as rtemsversion |
---|
| 44 | try: |
---|
| 45 | version = rtemsversion.version() |
---|
| 46 | revision = rtemsversion.revision() |
---|
| 47 | except Exception as e: |
---|
| 48 | ctx.fatal('invalid version file: %s' % (e)) |
---|
[8b49f73] | 49 | release = '%s.%s' % (version, revision) |
---|
[3bd8def] | 50 | return version, release |
---|
[efc4f09] | 51 | |
---|
[749ddf1] | 52 | def recurse(ctx): |
---|
| 53 | for sd in subdirs: |
---|
| 54 | ctx.recurse(sd) |
---|
| 55 | |
---|
| 56 | def options(ctx): |
---|
[87e0e76] | 57 | ctx.add_option('--c-opts', |
---|
| 58 | default = '-O2', |
---|
| 59 | dest='c_opts', |
---|
| 60 | help = 'Set build options, default: -O2.') |
---|
[3badbb0] | 61 | ctx.add_option('--host', |
---|
| 62 | default = 'native', |
---|
| 63 | dest='host', |
---|
| 64 | help = 'Set host to build for, default: none.') |
---|
[749ddf1] | 65 | recurse(ctx) |
---|
| 66 | |
---|
[3badbb0] | 67 | def init(ctx): |
---|
[7148cae] | 68 | wafwindows.set_compilers() |
---|
[3badbb0] | 69 | try: |
---|
| 70 | import waflib.Options |
---|
| 71 | import waflib.ConfigSet |
---|
| 72 | env = waflib.ConfigSet.ConfigSet() |
---|
| 73 | env.load(waflib.Options.lockfile) |
---|
| 74 | check_options(ctx, env.options['host']) |
---|
[7148cae] | 75 | recurse(ctx) |
---|
[3badbb0] | 76 | except: |
---|
| 77 | pass |
---|
| 78 | |
---|
[7148cae] | 79 | def shutdown(ctx): |
---|
| 80 | pass |
---|
| 81 | |
---|
[749ddf1] | 82 | def configure(ctx): |
---|
[87e0e76] | 83 | try: |
---|
| 84 | ctx.load("doxygen", tooldir = 'waf-tools') |
---|
| 85 | except: |
---|
| 86 | pass |
---|
[efc4f09] | 87 | ctx.env.RTEMS_VERSION, ctx.env.RTEMS_RELEASE = get_version(ctx) |
---|
[8b49f73] | 88 | ctx.start_msg('Version') |
---|
| 89 | ctx.end_msg('%s (%s)' % (ctx.env.RTEMS_RELEASE, ctx.env.RTEMS_VERSION)) |
---|
[87e0e76] | 90 | ctx.env.C_OPTS = ctx.options.c_opts.split(',') |
---|
[3badbb0] | 91 | check_options(ctx, ctx.options.host) |
---|
[de1beea] | 92 | # |
---|
| 93 | # Common Python check. |
---|
| 94 | # |
---|
| 95 | ctx.load('python') |
---|
| 96 | ctx.check_python_version((2,6,6)) |
---|
| 97 | # |
---|
| 98 | # Installing the PYO,PYC seems broken on 1.8.19. The path is wrong. |
---|
| 99 | # |
---|
| 100 | ctx.env.PYO = 0 |
---|
| 101 | ctx.env.PYC = 0 |
---|
[749ddf1] | 102 | recurse(ctx) |
---|
| 103 | |
---|
| 104 | def build(ctx): |
---|
[efc4f09] | 105 | if os.path.exists('VERSION'): |
---|
| 106 | ctx.install_files('${PREFIX}/share/rtems/rtemstoolkit', ['VERSION']) |
---|
[749ddf1] | 107 | recurse(ctx) |
---|
| 108 | |
---|
| 109 | def install(ctx): |
---|
| 110 | recurse(ctx) |
---|
| 111 | |
---|
| 112 | def clean(ctx): |
---|
| 113 | recurse(ctx) |
---|
[87e0e76] | 114 | |
---|
| 115 | def rebuild(ctx): |
---|
| 116 | import waflib.Options |
---|
| 117 | waflib.Options.commands.extend(['clean', 'build']) |
---|
| 118 | |
---|
[3badbb0] | 119 | def check_options(ctx, host): |
---|
[845054a] | 120 | if host in ['mingw32', 'x86_64-w64-mingw32']: |
---|
[3badbb0] | 121 | ctx.env.HOST = host |
---|
| 122 | ctx.env.CC = '%s-gcc' % (host) |
---|
| 123 | ctx.env.CXX = '%s-g++' % (host) |
---|
| 124 | ctx.env.AR = '%s-ar' % (host) |
---|
| 125 | ctx.env.PYTHON = 'python' |
---|
| 126 | elif host is not 'native': |
---|
| 127 | ctx.fatal('unknown host: %s' % (host)); |
---|
| 128 | |
---|
[87e0e76] | 129 | # |
---|
| 130 | # The doxy command. |
---|
| 131 | # |
---|
| 132 | from waflib import Build |
---|
| 133 | class doxy(Build.BuildContext): |
---|
| 134 | fun = 'build' |
---|
| 135 | cmd = 'doxy' |
---|