[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', |
---|
| 36 | 'linkers', |
---|
[1cd75c4] | 37 | 'misc', |
---|
[749ddf1] | 38 | 'tester', |
---|
| 39 | 'tools/gdb/python'] |
---|
| 40 | |
---|
[efc4f09] | 41 | def get_version(ctx): |
---|
[e5dad3c] | 42 | version = '5' |
---|
[8b49f73] | 43 | revision = 'not_released' |
---|
| 44 | release = '%s.%s' % (version, revision) |
---|
[efc4f09] | 45 | if os.path.exists('VERSION'): |
---|
| 46 | try: |
---|
[3828e50] | 47 | import configparser |
---|
| 48 | except ImportError: |
---|
| 49 | import ConfigParser as configparser |
---|
| 50 | v = configparser.SafeConfigParser() |
---|
| 51 | v.read('VERSION') |
---|
| 52 | release = v.get('version', 'release') |
---|
[8b49f73] | 53 | else: |
---|
[c5286cd] | 54 | # |
---|
| 55 | # waf after 1.9.9 does not place the current directory in Python's |
---|
| 56 | # system path which means importing the RTEMS toolkit |
---|
| 57 | # fails. Temporarily add it so we can import the git module. |
---|
| 58 | # |
---|
| 59 | import sys |
---|
| 60 | current_sys_path = sys.path |
---|
| 61 | try: |
---|
| 62 | sys.path = [os.getcwd()] + sys.path |
---|
| 63 | from rtemstoolkit import git |
---|
| 64 | finally: |
---|
| 65 | sys.path = current_sys_path |
---|
[8b49f73] | 66 | repo = git.repo('.') |
---|
| 67 | if repo.valid(): |
---|
| 68 | head = repo.head() |
---|
| 69 | if repo.dirty(): |
---|
| 70 | modified = '_modified' |
---|
| 71 | else: |
---|
| 72 | modified = '' |
---|
[3828e50] | 73 | release = '%s.%s%s' % (version, head[0:12], modified) |
---|
[efc4f09] | 74 | last_dot = release.rfind('.') |
---|
| 75 | if last_dot == -1: |
---|
| 76 | ctx.fatal('invalid VERSION file') |
---|
| 77 | revision = release[0:last_dot] |
---|
| 78 | return revision, release |
---|
| 79 | |
---|
[749ddf1] | 80 | def recurse(ctx): |
---|
| 81 | for sd in subdirs: |
---|
| 82 | ctx.recurse(sd) |
---|
| 83 | |
---|
| 84 | def options(ctx): |
---|
[87e0e76] | 85 | ctx.add_option('--c-opts', |
---|
| 86 | default = '-O2', |
---|
| 87 | dest='c_opts', |
---|
| 88 | help = 'Set build options, default: -O2.') |
---|
[3badbb0] | 89 | ctx.add_option('--host', |
---|
| 90 | default = 'native', |
---|
| 91 | dest='host', |
---|
| 92 | help = 'Set host to build for, default: none.') |
---|
[749ddf1] | 93 | recurse(ctx) |
---|
| 94 | |
---|
[3badbb0] | 95 | def init(ctx): |
---|
[7148cae] | 96 | wafwindows.set_compilers() |
---|
[3badbb0] | 97 | try: |
---|
| 98 | import waflib.Options |
---|
| 99 | import waflib.ConfigSet |
---|
| 100 | env = waflib.ConfigSet.ConfigSet() |
---|
| 101 | env.load(waflib.Options.lockfile) |
---|
| 102 | check_options(ctx, env.options['host']) |
---|
[7148cae] | 103 | recurse(ctx) |
---|
[3badbb0] | 104 | except: |
---|
| 105 | pass |
---|
| 106 | |
---|
[7148cae] | 107 | def shutdown(ctx): |
---|
| 108 | pass |
---|
| 109 | |
---|
[749ddf1] | 110 | def configure(ctx): |
---|
[87e0e76] | 111 | try: |
---|
| 112 | ctx.load("doxygen", tooldir = 'waf-tools') |
---|
| 113 | except: |
---|
| 114 | pass |
---|
[efc4f09] | 115 | ctx.env.RTEMS_VERSION, ctx.env.RTEMS_RELEASE = get_version(ctx) |
---|
[8b49f73] | 116 | ctx.start_msg('Version') |
---|
| 117 | ctx.end_msg('%s (%s)' % (ctx.env.RTEMS_RELEASE, ctx.env.RTEMS_VERSION)) |
---|
[87e0e76] | 118 | ctx.env.C_OPTS = ctx.options.c_opts.split(',') |
---|
[3badbb0] | 119 | check_options(ctx, ctx.options.host) |
---|
[de1beea] | 120 | # |
---|
| 121 | # Common Python check. |
---|
| 122 | # |
---|
| 123 | ctx.load('python') |
---|
| 124 | ctx.check_python_version((2,6,6)) |
---|
| 125 | # |
---|
| 126 | # Installing the PYO,PYC seems broken on 1.8.19. The path is wrong. |
---|
| 127 | # |
---|
| 128 | ctx.env.PYO = 0 |
---|
| 129 | ctx.env.PYC = 0 |
---|
[749ddf1] | 130 | recurse(ctx) |
---|
| 131 | |
---|
| 132 | def build(ctx): |
---|
[efc4f09] | 133 | if os.path.exists('VERSION'): |
---|
| 134 | ctx.install_files('${PREFIX}/share/rtems/rtemstoolkit', ['VERSION']) |
---|
[749ddf1] | 135 | recurse(ctx) |
---|
| 136 | |
---|
| 137 | def install(ctx): |
---|
| 138 | recurse(ctx) |
---|
| 139 | |
---|
| 140 | def clean(ctx): |
---|
| 141 | recurse(ctx) |
---|
[87e0e76] | 142 | |
---|
| 143 | def rebuild(ctx): |
---|
| 144 | import waflib.Options |
---|
| 145 | waflib.Options.commands.extend(['clean', 'build']) |
---|
| 146 | |
---|
[3badbb0] | 147 | def check_options(ctx, host): |
---|
| 148 | if host in ['mingw32']: |
---|
| 149 | ctx.env.HOST = host |
---|
| 150 | ctx.env.CC = '%s-gcc' % (host) |
---|
| 151 | ctx.env.CXX = '%s-g++' % (host) |
---|
| 152 | ctx.env.AR = '%s-ar' % (host) |
---|
| 153 | ctx.env.PYTHON = 'python' |
---|
| 154 | elif host is not 'native': |
---|
| 155 | ctx.fatal('unknown host: %s' % (host)); |
---|
| 156 | |
---|
[87e0e76] | 157 | # |
---|
| 158 | # The doxy command. |
---|
| 159 | # |
---|
| 160 | from waflib import Build |
---|
| 161 | class doxy(Build.BuildContext): |
---|
| 162 | fun = 'build' |
---|
| 163 | cmd = 'doxy' |
---|