[5ba6949] | 1 | # |
---|
| 2 | # Copyright (c) 2015 Chris Johns <chrisj@rtems.org>. All rights reserved. |
---|
| 3 | # |
---|
| 4 | # Copyright (c) 2009-2015 embedded brains GmbH. All rights reserved. |
---|
| 5 | # |
---|
| 6 | # embedded brains GmbH |
---|
| 7 | # Dornierstr. 4 |
---|
| 8 | # 82178 Puchheim |
---|
| 9 | # Germany |
---|
| 10 | # <info@embedded-brains.de> |
---|
| 11 | # |
---|
| 12 | # Copyright (c) 2012 OAR Corporation. All rights reserved. |
---|
| 13 | # |
---|
| 14 | # Redistribution and use in source and binary forms, with or without |
---|
| 15 | # modification, are permitted provided that the following conditions |
---|
| 16 | # are met: |
---|
| 17 | # 1. Redistributions of source code must retain the above copyright |
---|
| 18 | # notice, this list of conditions and the following disclaimer. |
---|
| 19 | # 2. Redistributions in binary form must reproduce the above copyright |
---|
| 20 | # notice, this list of conditions and the following disclaimer in the |
---|
| 21 | # documentation and/or other materials provided with the distribution. |
---|
| 22 | # |
---|
| 23 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
---|
| 24 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
---|
| 25 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
---|
| 26 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
---|
| 27 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
---|
| 28 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
---|
| 29 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
---|
| 30 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
---|
| 31 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
---|
| 32 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
---|
| 33 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 34 | |
---|
| 35 | import os |
---|
| 36 | import tempfile |
---|
| 37 | |
---|
| 38 | import builder |
---|
| 39 | |
---|
| 40 | trace = False |
---|
| 41 | |
---|
| 42 | data = { } |
---|
| 43 | |
---|
| 44 | def _add_files(name, files): |
---|
| 45 | if type(files) is not list: |
---|
| 46 | files = [files] |
---|
| 47 | if name not in data: |
---|
| 48 | data[name] = [] |
---|
| 49 | data[name] += files |
---|
| 50 | |
---|
| 51 | class SourceFileFragmentComposer(builder.BuildSystemFragmentComposer): |
---|
| 52 | |
---|
| 53 | def __init__(self, cflags = "default"): |
---|
| 54 | self.cflags = cflags |
---|
| 55 | |
---|
| 56 | def compose(self, path): |
---|
| 57 | return ['sources', self.cflags], [path] |
---|
| 58 | |
---|
| 59 | class TestFragementComposer(builder.BuildSystemFragmentComposer): |
---|
| 60 | |
---|
| 61 | def __init__(self, testName, fileFragments, runTest = True, netTest = False): |
---|
| 62 | self.testName = testName |
---|
| 63 | self.fileFragments = fileFragments |
---|
| 64 | self.runTest = runTest |
---|
| 65 | self.netTest = netTest |
---|
| 66 | |
---|
| 67 | def compose(self, path): |
---|
| 68 | return ['tests', self.testName], { 'files': self.fileFragments, |
---|
| 69 | 'run': self.runTest, |
---|
| 70 | 'net': self.netTest } |
---|
| 71 | |
---|
| 72 | class KVMSymbolsFragmentComposer(builder.BuildSystemFragmentComposer): |
---|
| 73 | |
---|
| 74 | def compose(self, path): |
---|
| 75 | return ['KVMSymbols', 'files'], [path] |
---|
| 76 | |
---|
| 77 | class RPCGENFragmentComposer(builder.BuildSystemFragmentComposer): |
---|
| 78 | |
---|
| 79 | def compose(self, path): |
---|
| 80 | return ['RPCGen', 'files'], [path] |
---|
| 81 | |
---|
| 82 | class RouteKeywordsFragmentComposer(builder.BuildSystemFragmentComposer): |
---|
| 83 | |
---|
| 84 | def compose(self, path): |
---|
| 85 | return ['RouteKeywords', 'files'], [path] |
---|
| 86 | |
---|
| 87 | class LexFragmentComposer(builder.BuildSystemFragmentComposer): |
---|
| 88 | |
---|
| 89 | def __init__(self, sym, dep): |
---|
| 90 | self.sym = sym |
---|
| 91 | self.dep = dep |
---|
| 92 | |
---|
| 93 | def compose(self, path): |
---|
| 94 | return ['lex', path], { 'file': path, |
---|
| 95 | 'sym': self.sym, |
---|
| 96 | 'dep': self.dep } |
---|
| 97 | |
---|
| 98 | class YaccFragmentComposer(builder.BuildSystemFragmentComposer): |
---|
| 99 | |
---|
| 100 | def __init__(self, sym, header): |
---|
| 101 | self.sym = sym |
---|
| 102 | self.header = header |
---|
| 103 | |
---|
| 104 | def compose(self, path): |
---|
| 105 | return ['yacc', path], { 'file': path, |
---|
| 106 | 'sym': self.sym, |
---|
| 107 | 'header': self.header } |
---|
| 108 | |
---|
| 109 | # Module Manager - Collection of Modules |
---|
| 110 | class ModuleManager(builder.ModuleManager): |
---|
| 111 | |
---|
| 112 | def restart(self): |
---|
| 113 | self.script = '' |
---|
| 114 | |
---|
| 115 | def add(self, line = ''): |
---|
| 116 | self.script += line + os.linesep |
---|
| 117 | |
---|
| 118 | def write(self): |
---|
| 119 | try: |
---|
| 120 | out = tempfile.NamedTemporaryFile(delete = False) |
---|
| 121 | out.write(self.script) |
---|
| 122 | out.close() |
---|
| 123 | wscript = builder.RTEMS_DIR + '/wscript' |
---|
| 124 | builder.processIfDifferent(out.name, wscript, "wscript") |
---|
| 125 | finally: |
---|
| 126 | try: |
---|
| 127 | os.remove(out.name) |
---|
| 128 | except: |
---|
| 129 | pass |
---|
| 130 | |
---|
| 131 | def setGenerators(self): |
---|
| 132 | self.generator['convert'] = builder.Converter |
---|
| 133 | self.generator['no-convert'] = builder.NoConverter |
---|
| 134 | |
---|
| 135 | self.generator['file'] = builder.File |
---|
| 136 | |
---|
| 137 | self.generator['path'] = builder.PathComposer |
---|
| 138 | self.generator['freebsd-path'] = builder.FreeBSDPathComposer |
---|
| 139 | self.generator['rtems-path'] = builder.RTEMSPathComposer |
---|
| 140 | self.generator['cpu-path'] = builder.CPUDependentPathComposer |
---|
| 141 | self.generator['target-src-cpu--path'] = builder.TargetSourceCPUDependentPathComposer |
---|
| 142 | |
---|
| 143 | self.generator['source'] = SourceFileFragmentComposer |
---|
| 144 | self.generator['test'] = TestFragementComposer |
---|
| 145 | self.generator['kvm-symbols'] = KVMSymbolsFragmentComposer |
---|
| 146 | self.generator['rpc-gen'] = RPCGENFragmentComposer |
---|
| 147 | self.generator['route-keywords'] = RouteKeywordsFragmentComposer |
---|
| 148 | self.generator['lex'] = LexFragmentComposer |
---|
| 149 | self.generator['yacc'] = YaccFragmentComposer |
---|
| 150 | |
---|
| 151 | def generate(self): |
---|
| 152 | |
---|
| 153 | def _source_list(lhs, files, append = False): |
---|
| 154 | if append: |
---|
| 155 | adder = '+' |
---|
| 156 | adder_space = ' ' |
---|
| 157 | else: |
---|
| 158 | adder = '' |
---|
| 159 | adder_space = '' |
---|
| 160 | ll = len(lhs) |
---|
| 161 | if len(files) == 1: |
---|
| 162 | self.add('%s %s= [%r]' % (lhs, adder, files[0])) |
---|
| 163 | elif len(files) == 2: |
---|
| 164 | self.add('%s %s= [%r,' % (lhs, adder, files[0])) |
---|
| 165 | self.add('%s %s %r]' % (' ' * ll, adder_space, files[-1])) |
---|
| 166 | elif len(files) > 0: |
---|
| 167 | self.add('%s %s= [%r,' % (lhs, adder, files[0])) |
---|
| 168 | for f in files[1:-1]: |
---|
| 169 | self.add('%s %s %r,' % (' ' * ll, adder_space, f)) |
---|
| 170 | self.add('%s %s %r]' % (' ' * ll, adder_space, files[-1])) |
---|
| 171 | |
---|
| 172 | def _data_insert(data, cpu, frag): |
---|
| 173 | # |
---|
| 174 | # The default handler returns an empty string. Skip it. |
---|
| 175 | # |
---|
| 176 | if type(frag) is not str: |
---|
| 177 | d = data |
---|
| 178 | for p in frag[0]: |
---|
| 179 | if p not in d: |
---|
| 180 | d[p] = {} |
---|
| 181 | d = d[p] |
---|
| 182 | if type(frag[1]) is list: |
---|
| 183 | if cpu not in d: |
---|
| 184 | d[cpu] = [] |
---|
| 185 | d[cpu] += frag[1] |
---|
| 186 | else: |
---|
| 187 | d[cpu] = frag[1] |
---|
| 188 | |
---|
| 189 | data = { } |
---|
| 190 | |
---|
| 191 | for mn in self.getModules(): |
---|
| 192 | m = self[mn] |
---|
| 193 | if m.conditionalOn == "none": |
---|
| 194 | for f in m.files: |
---|
| 195 | _data_insert(data, 'all', f.getFragment()) |
---|
| 196 | for cpu, files in sorted(m.cpuDependentSourceFiles.items()): |
---|
| 197 | for f in files: |
---|
| 198 | _data_insert(data, cpu, f.getFragment()) |
---|
| 199 | |
---|
| 200 | if trace: |
---|
| 201 | import pprint |
---|
| 202 | pprint.pprint(data) |
---|
| 203 | |
---|
| 204 | self.restart() |
---|
| 205 | |
---|
| 206 | self.add('#') |
---|
[e9aa9537] | 207 | self.add('# RTEMS Project (https://www.rtems.org)') |
---|
| 208 | self.add('#') |
---|
| 209 | self.add('# Generated waf script. Do not edit, run ./freebsd-to-rtems.py -m') |
---|
| 210 | self.add('#') |
---|
| 211 | self.add('# To use see README.waf shipped with this file.') |
---|
[5ba6949] | 212 | self.add('#') |
---|
| 213 | self.add('') |
---|
[4963785] | 214 | self.add('import os.path') |
---|
| 215 | self.add('') |
---|
[5ba6949] | 216 | self.add('try:') |
---|
| 217 | self.add(' import rtems_waf.rtems as rtems') |
---|
| 218 | self.add('except:') |
---|
| 219 | self.add(' print "error: no rtems_waf git submodule; see README.waf"') |
---|
| 220 | self.add(' import sys') |
---|
| 221 | self.add(' sys.exit(1)') |
---|
| 222 | self.add('') |
---|
| 223 | self.add('def init(ctx):') |
---|
| 224 | self.add(' rtems.init(ctx)') |
---|
| 225 | self.add('') |
---|
| 226 | self.add('def options(opt):') |
---|
| 227 | self.add(' rtems.options(opt)') |
---|
[e9aa9537] | 228 | self.add(' opt.add_option("--enable-auto-regen",') |
---|
| 229 | self.add(' action = "store_true",') |
---|
| 230 | self.add(' default = False,') |
---|
| 231 | self.add(' dest = "auto_regen",') |
---|
| 232 | self.add(' help = "Enable auto-regeneration of LEX, RPC and YACC files.")') |
---|
| 233 | self.add(' opt.add_option("--enable-warnings",') |
---|
| 234 | self.add(' action = "store_true",') |
---|
| 235 | self.add(' default = False,') |
---|
| 236 | self.add(' dest = "warnings",') |
---|
| 237 | self.add(' help = "Enable all warnings. The default is quiet builds.")') |
---|
[4963785] | 238 | self.add(' opt.add_option("--net-test-config",') |
---|
| 239 | self.add(' default = "config.inc",') |
---|
| 240 | self.add(' dest = "net_config",') |
---|
| 241 | self.add(' help = "Network test configuration.")') |
---|
[5ba6949] | 242 | self.add('') |
---|
| 243 | self.add('def configure(conf):') |
---|
[e9aa9537] | 244 | self.add(' if conf.options.auto_regen:') |
---|
| 245 | self.add(' conf.find_program("lex", mandatory = True)') |
---|
| 246 | self.add(' conf.find_program("rpcgen", mandatory = True)') |
---|
| 247 | self.add(' conf.find_program("yacc", mandatory = True)') |
---|
| 248 | self.add(' conf.env.AUTO_REGEN = conf.options.auto_regen') |
---|
| 249 | self.add(' conf.env.WARNINGS = conf.options.warnings') |
---|
[4963785] | 250 | self.add(' conf.env.NET_CONFIG = conf.options.net_config') |
---|
[5ba6949] | 251 | self.add(' rtems.configure(conf)') |
---|
| 252 | self.add(' if rtems.check_networking(conf):') |
---|
| 253 | self.add(' conf.fatal("RTEMS kernel contains the old network support; configure RTEMS with --disable-networking")') |
---|
| 254 | self.add('') |
---|
| 255 | self.add('def build(bld):') |
---|
| 256 | self.add(' rtems.build(bld)') |
---|
| 257 | self.add('') |
---|
| 258 | self.add(' # C/C++ flags') |
---|
| 259 | self.add(' common_flags = []') |
---|
| 260 | for f in builder.common_flags(): |
---|
| 261 | self.add(' common_flags += ["%s"]' % (f)) |
---|
[e9aa9537] | 262 | self.add(' if bld.env.WARNINGS:') |
---|
| 263 | for f in builder.common_warnings(): |
---|
| 264 | self.add(' common_flags += ["%s"]' % (f)) |
---|
| 265 | self.add(' else:') |
---|
[5ba6949] | 266 | for f in builder.common_no_warnings(): |
---|
[e9aa9537] | 267 | self.add(' common_flags += ["%s"]' % (f)) |
---|
[5ba6949] | 268 | self.add(' cflags = %r + common_flags' % (builder.cflags())) |
---|
| 269 | self.add(' cxxflags = %r + common_flags' % (builder.cxxflags())) |
---|
| 270 | self.add('') |
---|
| 271 | self.add(' # Include paths') |
---|
| 272 | self.add(' includes = []') |
---|
| 273 | for i in builder.includes(): |
---|
| 274 | self.add(' includes += ["%s"]' % (i[2:])) |
---|
| 275 | self.add(' for i in %r:' % (builder.cpu_includes())) |
---|
| 276 | self.add(' includes += ["%s" % (i[2:].replace("@CPU@", bld.get_env()["RTEMS_ARCH"]))]') |
---|
| 277 | self.add('') |
---|
| 278 | self.add(' # Support dummy PIC IRQ includes') |
---|
| 279 | self.add(' if bld.get_env()["RTEMS_ARCH"] not in ("arm", "i386", "lm32", "mips", "powerpc", "sparc", "m68k"):') |
---|
| 280 | self.add(' includes += ["rtems-dummy-pic-irq/include"]') |
---|
| 281 | self.add('') |
---|
| 282 | |
---|
| 283 | self.add(' # Collect the libbsd uses') |
---|
| 284 | self.add(' libbsd_use = []') |
---|
| 285 | self.add('') |
---|
| 286 | |
---|
[4963785] | 287 | # |
---|
| 288 | # Support the existing Makefile based network configuration file. |
---|
| 289 | # |
---|
| 290 | self.add(' # Network test configuration') |
---|
| 291 | self.add(' if not os.path.exists(bld.env.NET_CONFIG):') |
---|
| 292 | self.add(' bld.fatal("network configuraiton \'%s\' not found" % (bld.env.NET_CONFIG))') |
---|
| 293 | self.add(' net_cfg_self_ip = None') |
---|
| 294 | self.add(' net_cfg_netmask = None') |
---|
| 295 | self.add(' net_cfg_peer_ip = None') |
---|
| 296 | self.add(' net_cfg_gateway_ip = None') |
---|
| 297 | self.add(' net_tap_interface = None') |
---|
| 298 | self.add(' try:') |
---|
| 299 | self.add(' net_cfg_lines = open(bld.env.NET_CONFIG).readlines()') |
---|
| 300 | self.add(' except:') |
---|
| 301 | self.add(' bld.fatal("network configuraiton \'%s\' read failed" % (bld.env.NET_CONFIG))') |
---|
| 302 | self.add(' lc = 0') |
---|
| 303 | self.add(' for l in net_cfg_lines:') |
---|
| 304 | self.add(' lc += 1') |
---|
| 305 | self.add(' if l.strip().startswith("NET_CFG_"):') |
---|
| 306 | self.add(' ls = l.split("=")') |
---|
| 307 | self.add(' if len(ls) != 2:') |
---|
| 308 | self.add(' bld.fatal("network configuraiton \'%s\' parse error: %d: %s" % ' + \ |
---|
| 309 | '(bld.env.NET_CONFIG, lc, l))') |
---|
| 310 | self.add(' lhs = ls[0].strip()') |
---|
| 311 | self.add(' rhs = ls[1].strip()') |
---|
| 312 | self.add(' if lhs == "NET_CFG_SELF_IP":') |
---|
| 313 | self.add(' net_cfg_self_ip = rhs') |
---|
| 314 | self.add(' if lhs == "NET_CFG_NETMASK":') |
---|
| 315 | self.add(' net_cfg_netmask = rhs') |
---|
| 316 | self.add(' if lhs == "NET_CFG_PEER_IP":') |
---|
| 317 | self.add(' net_cfg_peer_ip = rhs') |
---|
| 318 | self.add(' if lhs == "NET_CFG_GATEWAY_IP_IP":') |
---|
| 319 | self.add(' net_cfg_gateway_ip = rhs') |
---|
| 320 | self.add(' if lhs == "NET_TAP_INTERFACE_IP_IP":') |
---|
| 321 | self.add(' net_tap_interface = rhs') |
---|
| 322 | self.add(' bld(target = "testsuite/include/rtems/bsd/test/network-config.h",') |
---|
| 323 | self.add(' source = "testsuite/include/rtems/bsd/test/network-config.h.in",') |
---|
| 324 | self.add(' rule = "sed -e \'s/@NET_CFG_SELF_IP@/%s/\' ' + \ |
---|
| 325 | '-e \'s/@NET_CFG_NETMASK@/%s/\' ' + \ |
---|
| 326 | '-e \'s/@NET_CFG_PEER_IP@/%s/\' ' + \ |
---|
| 327 | '-e \'s/@NET_CFG_GATEWAY_IP@/%s/\' < ${SRC} > ${TGT}" % ' + \ |
---|
| 328 | '(net_cfg_self_ip, net_cfg_netmask, net_cfg_peer_ip, net_cfg_netmask))') |
---|
| 329 | self.add('') |
---|
| 330 | |
---|
[5ba6949] | 331 | # |
---|
| 332 | # Add the specific rule based builders for generating files. |
---|
| 333 | # |
---|
| 334 | if 'KVMSymbols' in data: |
---|
| 335 | kvmsymbols = data['KVMSymbols'] |
---|
| 336 | self.add(' # KVM Symbols') |
---|
[4963785] | 337 | self.add(' bld(target = "%s",' % (kvmsymbols['files']['all'][0])) |
---|
| 338 | self.add(' source = "rtemsbsd/rtems/generate_kvm_symbols",') |
---|
| 339 | self.add(' rule = "./${SRC} > ${TGT}")') |
---|
[5ba6949] | 340 | self.add(' bld.objects(target = "kvmsymbols",') |
---|
| 341 | self.add(' features = "c",') |
---|
| 342 | self.add(' cflags = cflags,') |
---|
[4963785] | 343 | self.add(' includes = includes + ["rtemsbsd/rtems"],') |
---|
[5ba6949] | 344 | self.add(' source = "%s")' % (kvmsymbols['files']['all'][0])) |
---|
| 345 | self.add(' libbsd_use += ["kvmsymbols"]') |
---|
| 346 | self.add('') |
---|
| 347 | |
---|
| 348 | if 'RPCGen' in data: |
---|
| 349 | rpcgen = data['RPCGen'] |
---|
| 350 | rpcname = rpcgen['files']['all'][0][:-2] |
---|
| 351 | self.add(' # RPC Generation') |
---|
[e9aa9537] | 352 | self.add(' if bld.env.AUTO_REGEN:') |
---|
| 353 | self.add(' bld(target = "%s.h",' % (rpcname)) |
---|
| 354 | self.add(' source = "%s.x",' % (rpcname)) |
---|
| 355 | self.add(' rule = "${RPCGEN} -h -o ${TGT} ${SRC}")') |
---|
[5ba6949] | 356 | self.add('') |
---|
| 357 | |
---|
| 358 | if 'RouteKeywords' in data: |
---|
| 359 | routekw = data['RouteKeywords'] |
---|
| 360 | rkwname = routekw['files']['all'][0] |
---|
| 361 | self.add(' # Route keywords') |
---|
[e9aa9537] | 362 | self.add(' if bld.env.AUTO_REGEN:') |
---|
| 363 | self.add(' rkw_rule = "cat ${SRC} | ' + \ |
---|
[5ba6949] | 364 | 'awk \'BEGIN { r = 0 } { if (NF == 1) ' + \ |
---|
| 365 | 'printf \\"#define\\\\tK_%%s\\\\t%%d\\\\n\\\\t{\\\\\\"%%s\\\\\\", K_%%s},\\\\n\\", ' + \ |
---|
| 366 | 'toupper($1), ++r, $1, toupper($1)}\' > ${TGT}"') |
---|
[e9aa9537] | 367 | self.add(' bld(target = "%s.h",' % (rkwname)) |
---|
| 368 | self.add(' source = "%s",' % (rkwname)) |
---|
| 369 | self.add(' rule = rkw_rule)') |
---|
[5ba6949] | 370 | self.add('') |
---|
| 371 | |
---|
| 372 | if 'lex' in data: |
---|
| 373 | lexes = data['lex'] |
---|
| 374 | self.add(' # Lex') |
---|
| 375 | for l in lexes: |
---|
| 376 | lex = lexes[l]['all'] |
---|
[e9aa9537] | 377 | self.add(' if bld.env.AUTO_REGEN:') |
---|
| 378 | self.add(' bld(target = "%s.c",' % (lex['file'][:-2])) |
---|
| 379 | self.add(' source = "%s",' % (lex['file'])) |
---|
| 380 | self.add(' rule = "${LEX} -P %s -t ${SRC} | ' % (lex['sym']) + \ |
---|
[5ba6949] | 381 | 'sed -e \'/YY_BUF_SIZE/s/16384/1024/\' > ${TGT}")') |
---|
| 382 | self.add(' bld.objects(target = "lex_%s",' % (lex['sym'])) |
---|
| 383 | self.add(' features = "c",') |
---|
| 384 | self.add(' cflags = cflags,') |
---|
| 385 | self.add(' includes = includes,') |
---|
| 386 | self.add(' source = "%s.c")' % (lex['file'][:-2])) |
---|
| 387 | self.add(' libbsd_use += ["lex_%s"]' % (lex['sym'])) |
---|
| 388 | self.add('') |
---|
| 389 | |
---|
| 390 | if 'yacc' in data: |
---|
| 391 | yaccs = data['yacc'] |
---|
| 392 | self.add(' # Yacc') |
---|
| 393 | for y in yaccs: |
---|
| 394 | yacc = yaccs[y]['all'] |
---|
| 395 | yacc_file = yacc['file'] |
---|
| 396 | yacc_sym = yacc['sym'] |
---|
| 397 | yacc_header = '%s/%s' % (os.path.dirname(yacc_file), yacc['header']) |
---|
[e9aa9537] | 398 | self.add(' if bld.env.AUTO_REGEN:') |
---|
| 399 | self.add(' bld(target = "%s.c",' % (yacc_file[:-2])) |
---|
| 400 | self.add(' source = "%s",' % (yacc_file)) |
---|
| 401 | self.add(' rule = "${YACC} -b %s -d -p %s ${SRC} && ' % (yacc_sym, yacc_sym) + \ |
---|
[5ba6949] | 402 | 'sed -e \'/YY_BUF_SIZE/s/16384/1024/\' < %s.tab.c > ${TGT} && ' % (yacc_sym) + \ |
---|
| 403 | 'rm -f %s.tab.c && mv %s.tab.h %s")' % (yacc_sym, yacc_sym, yacc_header)) |
---|
| 404 | self.add(' bld.objects(target = "yacc_%s",' % (yacc_sym)) |
---|
| 405 | self.add(' features = "c",') |
---|
| 406 | self.add(' cflags = cflags,') |
---|
| 407 | self.add(' includes = includes,') |
---|
| 408 | self.add(' source = "%s.c")' % (yacc_file[:-2])) |
---|
| 409 | self.add(' libbsd_use += ["yacc_%s"]' % (yacc_sym)) |
---|
| 410 | self.add('') |
---|
| 411 | |
---|
| 412 | # |
---|
| 413 | # We have 'm' different sets of flags and there can be 'n' cpus |
---|
| 414 | # specific files for those flags. |
---|
| 415 | # |
---|
| 416 | objs = 0 |
---|
| 417 | self.add(' # Objects built with different CFLAGS') |
---|
| 418 | for cflags in sorted(data['sources']): |
---|
| 419 | if cflags is not 'default': |
---|
| 420 | objs += 1 |
---|
| 421 | _source_list(' objs%02d_source' % objs, sorted(data['sources'][cflags]['all'])) |
---|
| 422 | archs = sorted(data['sources'][cflags]) |
---|
| 423 | for arch in archs: |
---|
| 424 | if arch is not 'all': |
---|
| 425 | self.add(' if bld.get_env()["RTEMS_ARCH"] == "%s":' % arch) |
---|
| 426 | _source_list(' objs%02d_source' % objs, |
---|
| 427 | sorted(data['sources'][cflags][arch]), |
---|
| 428 | append = True) |
---|
| 429 | defines = [d[2:] for d in cflags.split(' ')] |
---|
| 430 | self.add(' bld.objects(target = "objs%02d",' % (objs)) |
---|
| 431 | self.add(' features = "c",') |
---|
| 432 | self.add(' cflags = cflags,') |
---|
| 433 | self.add(' includes = includes,') |
---|
| 434 | self.add(' defines = %r,' % (defines)) |
---|
| 435 | self.add(' source = objs%02d_source)' % objs) |
---|
| 436 | self.add(' libbsd_use += ["objs%02d"]' % (objs)) |
---|
| 437 | self.add('') |
---|
| 438 | |
---|
| 439 | # |
---|
| 440 | # We hold the 'default' cflags set of files to the end to create the |
---|
| 441 | # static library with. |
---|
| 442 | # |
---|
| 443 | _source_list(' source', sorted(data['sources']['default']['all'])) |
---|
| 444 | archs = sorted(data['sources']['default']) |
---|
| 445 | for arch in archs: |
---|
| 446 | if arch is not 'all': |
---|
| 447 | self.add(' if bld.get_env()["RTEMS_ARCH"] == "%s":' % arch) |
---|
| 448 | _source_list(' source', |
---|
| 449 | sorted(data['sources']['default'][arch]), |
---|
| 450 | append = True) |
---|
| 451 | self.add(' bld.stlib(target = "bsd",') |
---|
| 452 | self.add(' features = "c cxx",') |
---|
| 453 | self.add(' cflags = cflags,') |
---|
| 454 | self.add(' cxxflags = cxxflags,') |
---|
| 455 | self.add(' includes = includes,') |
---|
| 456 | self.add(' source = source,') |
---|
| 457 | self.add(' use = libbsd_use)') |
---|
| 458 | self.add('') |
---|
| 459 | |
---|
| 460 | self.add(' # Tests') |
---|
| 461 | tests = data['tests'] |
---|
| 462 | for test_name in tests: |
---|
| 463 | files = ['testsuite/%s/%s.c' % (test_name, f) for f in data['tests'][test_name]['all']['files']] |
---|
| 464 | _source_list(' test_%s' % (test_name), sorted(files)) |
---|
| 465 | self.add(' bld.program(target = "%s",' % (test_name)) |
---|
| 466 | self.add(' features = "cprogram",') |
---|
| 467 | self.add(' cflags = cflags,') |
---|
| 468 | self.add(' includes = includes,') |
---|
| 469 | self.add(' source = test_%s,' % (test_name)) |
---|
| 470 | self.add(' use = ["bsd"],') |
---|
| 471 | self.add(' lib = ["m", "z"])') |
---|
| 472 | self.add('') |
---|
| 473 | |
---|
| 474 | self.write() |
---|