diff options
Diffstat (limited to 'wscript')
-rwxr-xr-x | wscript | 181 |
1 files changed, 91 insertions, 90 deletions
@@ -43,7 +43,13 @@ except: from waflib.TaskGen import after, before_method, feature is_windows_host = os.name == "nt" or sys.platform in ["msys", "cygwin"] -default_prefix = "/opt/rtems/6" +version = { + "__RTEMS_MAJOR__": "6", + "__RTEMS_MINOR__": "0", + "__RTEMS_REVISION__": "0", + "RTEMS_VERSION_CONTROL_KEY": "git" +} +default_prefix = "/opt/rtems/" + version["__RTEMS_MAJOR__"] compilers = ["gcc", "clang"] items = {} bsps = {} @@ -62,22 +68,28 @@ class VersionControlKeyHeader: @staticmethod def write(bld, filename): - if VersionControlKeyHeader._content is None: - from waflib.Build import Context - from waflib.Errors import WafError - + content = VersionControlKeyHeader._content + if content is None: content = """/* * Automatically generated. Do not edit. */ #if !defined(_RTEMS_VERSION_VC_KEY_H_) #define _RTEMS_VERSION_VC_KEY_H_ """ - try: - rev = bld.cmd_and_log("git rev-parse HEAD", - quiet=Context.STDOUT).strip() - content += """#define RTEMS_VERSION_VC_KEY "{}" -""".format(rev) - except WafError: + key = bld.env.RTEMS_VERSION_CONTROL_KEY + if key == "git": + from waflib.Build import Context + from waflib.Errors import WafError + + try: + key = bld.cmd_and_log("git rev-parse HEAD", + quiet=Context.STDOUT).strip() + except WafError: + key = "" + if key: + content += """#define RTEMS_VERSION_CONTROL_KEY "{}" +""".format(key) + else: content += """/* No version control key found; release? */ """ content += """#endif @@ -87,9 +99,9 @@ class VersionControlKeyHeader: f.parent.mkdir() try: if content != f.read(): - f.write(VersionControlKeyHeader._content) + f.write(content) except: - f.write(VersionControlKeyHeader._content) + f.write(content) class EnvWrapper(object): @@ -113,7 +125,7 @@ class Template(string.Template): idpattern = "[_A-Za-z][_A-Za-z0-9:#]*" -_VAR_PATTERN = re.compile("\$\{?(" + Template.idpattern + ")\}?$") +_VAR_PATTERN = re.compile("\\$\\{?(" + Template.idpattern + ")\\}?$") def _is_enabled_op_and(enabled, enabled_by): @@ -176,6 +188,15 @@ def process_start_files(self): self.link_task.dep_nodes.extend(self.bld.start_files) +def make_tar_info_reproducible(info): + info.uid = 0 + info.gid = 0 + info.mtime = 0 + info.uname = "root" + info.gname = "root" + return info + + class Item(object): def __init__(self, uid, data): @@ -229,9 +250,8 @@ class Item(object): try: self.do_build(bld, bic) except Exception as e: - raise type(e)( - "Build error related to item spec:{}: {}".format( - self.uid, str(e))) + raise type(e)("Build error related to item spec:{}: {}".format( + self.uid, str(e))) def do_defaults(self, enabled): return @@ -287,7 +307,8 @@ class Item(object): target = os.path.splitext(source)[0] + ".o" bld( asflags=self.substitute(bld, self.data["asflags"]), - cppflags=self.substitute(bld, self.data["cppflags"]), + cppflags=bic.cppflags + + self.substitute(bld, self.data["cppflags"]), features="asm_explicit_target asm c", includes=bic.includes + self.substitute(bld, self.data["includes"]), @@ -300,8 +321,9 @@ class Item(object): if target is None: target = os.path.splitext(source)[0] + ".o" bld( - cflags=self.substitute(bld, self.data["cflags"]), - cppflags=cppflags + self.substitute(bld, self.data["cppflags"]), + cflags=bic.cflags + self.substitute(bld, self.data["cflags"]), + cppflags=bic.cppflags + cppflags + + self.substitute(bld, self.data["cppflags"]), features="c", includes=bic.includes + self.substitute(bld, self.data["includes"]), @@ -316,8 +338,10 @@ class Item(object): if target is None: target = os.path.splitext(source)[0] + ".o" bld( - cppflags=cppflags + self.substitute(bld, self.data["cppflags"]), - cxxflags=self.substitute(bld, self.data["cxxflags"]), + cppflags=bic.cppflags + cppflags + + self.substitute(bld, self.data["cppflags"]), + cxxflags=bic.cxxflags + + self.substitute(bld, self.data["cxxflags"]), features="cxx", includes=bic.includes + self.substitute(bld, self.data["includes"]), @@ -333,10 +357,10 @@ class Item(object): class link(Task): - def __init__(self, item, bic, cmd, env): + def __init__(self, item, bic, cmd, env, ldflags): super(link, self).__init__(self, env=env) self.cmd = cmd - self.ldflags = bic.ldflags + item.data["ldflags"] + self.ldflags = ldflags self.stlib = item.data["stlib"] self.use = (item.data["use-before"] + bic.use + item.data["use-after"]) @@ -362,7 +386,8 @@ class Item(object): [], ) - tsk = link(self, bic, cmd, bld.env) + tsk = link(self, bic, cmd, bld.env, + bic.ldflags + self.substitute(bld, self.data["ldflags"])) tsk.set_inputs([bld.bldnode.make_node(s) for s in source]) tsk.set_outputs(bld.bldnode.make_node(target)) bld.add_to_group(tsk) @@ -445,7 +470,7 @@ class Item(object): def gzip(self, bld, source): target = source + ".gz" - bld(rule="${GZIP} < ${SRC} > ${TGT}", source=source, target=target) + bld(rule="${GZIP} -n < ${SRC} > ${TGT}", source=source, target=target) return target def xz(self, bld, source): @@ -468,7 +493,7 @@ class Item(object): dst = src for r in remove: dst = src.replace(srcpath + r, "").replace(bldpath + r, "") - tar.add(src, dst) + tar.add(src, dst, filter=make_tar_info_reproducible) tar.close() return 0 @@ -825,6 +850,13 @@ class OptionItem(Item): value, self.data["name"], arg)) return value + def _assert_in_set(self, conf, cic, value, arg): + if value is not None and value not in arg: + conf.fatal( + "Value '{}' for option '{}' is not an element of {}" + .format(value, self.data["name"], arg)) + return value + def _assert_in_interval(self, conf, cic, value, arg): if value is not None and (value < arg[0] or value > arg[1]): conf.fatal( @@ -974,8 +1006,8 @@ class OptionItem(Item): cic.add_option(name) except configparser.NoOptionError: value = self.default_value(conf.env.ENABLE) - if value is None: - return value + if not value: + return None try: return eval(value) except Exception as e: @@ -993,18 +1025,15 @@ class OptionItem(Item): value = self.default_value(conf.env.ENABLE) return value - def _get_string_command_line(self, conf, cic, value, arg): - name = self.data["name"] - try: - value = conf.rtems_options[name] - del conf.rtems_options[name] - except KeyError: - value = arg[0] - return value - def _script(self, conf, cic, value, arg): - exec(arg) - return value + local_variables = { + "self": self, + "conf": conf, + "cic": cic, + "value": value + } + exec(arg, None, local_variables) + return local_variables["value"] def _test_state_benchmark(self, conf, name): self._do_append_test_cppflags(conf, name, "-DTEST_STATE_BENCHMARK=1") @@ -1056,6 +1085,7 @@ class OptionItem(Item): "assert-eq": self._assert_eq, "assert-ge": self._assert_ge, "assert-gt": self._assert_gt, + "assert-in-set": self._assert_in_set, "assert-int8": self._assert_int8, "assert-int16": self._assert_int16, "assert-int32": self._assert_int32, @@ -1082,7 +1112,6 @@ class OptionItem(Item): "get-env": self._get_env, "get-integer": self._get_integer, "get-string": self._get_string, - "get-string-command-line": self._get_string_command_line, "script": self._script, "set-test-state": self._set_test_state, "set-value": self._set_value, @@ -1305,21 +1334,6 @@ def options(ctx): help= "the UID of the top-level group [default: '/grp']; it may be used in the bspdefaults and configure commands", ) - rg.add_option( - "--rtems-version", - metavar="VALUE", - help= - "sets the RTEMS major version number; it is intended for RTEMS maintainers and may be used in the bspdefaults and configure commands", - ) - rg.add_option( - "--rtems-option", - metavar="KEY=VALUE", - action="append", - dest="rtems_options", - default=[], - help= - "sets the option identified by KEY to the VALUE in the build specification; it is intended for RTEMS maintainers and may be used in the bspdefaults and configure commands", - ) def check_environment(conf): @@ -1346,6 +1360,21 @@ def check_environment(conf): conf.msg("Environment variable set", ev, color="RED") +def configure_version(conf): + cp = configparser.ConfigParser() + version_file = "VERSION" + if cp.read([version_file]): + conf.msg("Configure RTEMS version from file", + version_file, + color="YELLOW") + for key in version: + try: + value = cp.get("RTEMS_VERSION", key) + version[key] = no_unicode(value) + except configparser.NoOptionError: + pass + + def load_config_files(ctx): cp = configparser.ConfigParser() files = ctx.options.rtems_config @@ -1442,6 +1471,9 @@ def configure_variant(conf, cp, bsp_map, path_list, top_group, variant): arch_bsp = arch + "/" + bsp_base arch_family = arch + "/" + family + for key, value in version.items(): + conf.env[key] = value + conf.env["ARCH"] = arch conf.env["ARCH_BSP"] = arch_bsp conf.env["ARCH_FAMILY"] = arch_family @@ -1463,7 +1495,6 @@ def configure_variant(conf, cp, bsp_map, path_list, top_group, variant): conf.env["TOPGROUP"] = top_group conf.env["VARIANT"] = variant - prepare_rtems_options(conf) cic = ConfigItemContext(cp, path_list) items[conf.env.TOPGROUP].configure(conf, cic) bsp_item.configure(conf, cic) @@ -1471,8 +1502,6 @@ def configure_variant(conf, cp, bsp_map, path_list, top_group, variant): options = set([o[0].upper() for o in cp.items(variant)]) for o in options.difference(cic.options): conf.msg("Unknown configuration option", o.upper(), color="RED") - for key in conf.rtems_options: - conf.msg("Unknown command line RTEMS option", key, color="RED") def check_forbidden_options(ctx, opts): @@ -1505,27 +1534,9 @@ def get_top_group(ctx): return top_group -def prepare_rtems_options(conf): - conf.rtems_options = {} - for x in conf.options.rtems_options: - try: - k, v = x.split("=", 1) - conf.rtems_options[k] = v - except: - conf.fatal( - "The RTEMS option '{}' is not in KEY=VALUE format".format(x)) - version = conf.options.rtems_version - if version is not None: - key = "__RTEMS_MAJOR__" - if conf.rtems_options.get(key, version) != version: - conf.fatal( - "Conflicting RTEMS major versions specified at the command line" - ) - conf.rtems_options[key] = version - - def configure(conf): check_forbidden_options(conf, ["compiler"]) + configure_version(conf) check_environment(conf) conf.env["SPECS"] = load_items_from_options(conf) top_group = get_top_group(conf) @@ -1571,15 +1582,7 @@ def build(bld): if not bld.variant: check_forbidden_options( bld, - [ - "compiler", - "config", - "options", - "specs", - "tools", - "top_group", - "version", - ], + ["compiler", "config", "specs", "tools", "top_group"], ) load_items(bld, bld.env.SPECS) append_variant_builds(bld) @@ -1668,9 +1671,7 @@ COMPILER = {}""".format(variant, compiler)) def bsplist(ctx): """lists base BSP variants""" - check_forbidden_options( - ctx, - ["compiler", "config", "options", "tools", "top_group", "version"]) + check_forbidden_options(ctx, ["compiler", "config", "tools", "top_group"]) add_log_filter(ctx.cmd) load_items_from_options(ctx) white_list = get_white_list(ctx) |