Loading core/product_config.rbc +20 −1 Original line number Diff line number Diff line Loading @@ -62,7 +62,8 @@ def __print_attr(attr, value): elif _options.format == "pretty": print(attr, "=", repr(value)) elif _options.format == "make": print(attr, ":=", value) # Trim all spacing to a single space print(attr, ":=", _mkstrip(value)) else: fail("bad output format", _options.format) Loading Loading @@ -432,6 +433,23 @@ def _mkinfo(file, message = ""): """Prints info.""" print(message) def _mkstrip(s): """Emulates Make's strip. That is, removes string's leading and trailing whitespace characters and replaces any sequence of whitespace characters with with a single space. """ result = "" was_space = False for ch in s.strip().elems(): is_space = ch.isspace() if not is_space: if was_space: result += " " result += ch was_space = is_space return result def __get_options(): """Returns struct containing runtime global settings.""" settings = dict( Loading Loading @@ -479,6 +497,7 @@ rblf = struct( mkinfo = _mkinfo, mkerror = _mkerror, mkwarning = _mkwarning, mkstrip = _mkstrip, printvars = _printvars, product_configuration = _product_configuration, require_artifacts_in_path = _require_artifacts_in_path, Loading tests/run.rbc +3 −1 Original line number Diff line number Diff line # Copyright 2021 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); Loading Loading @@ -28,6 +27,9 @@ def assert_eq(expected, actual): if expected != actual: fail("Expected %s, got %s" % (expected, actual)) # Unit tests for non-trivial runtime functions assert_eq("", rblf.mkstrip(" \n \t ")) assert_eq("a b c", rblf.mkstrip(" a b \n c \t")) globals, config = rblf.product_configuration("test/device", init) assert_eq( Loading Loading
core/product_config.rbc +20 −1 Original line number Diff line number Diff line Loading @@ -62,7 +62,8 @@ def __print_attr(attr, value): elif _options.format == "pretty": print(attr, "=", repr(value)) elif _options.format == "make": print(attr, ":=", value) # Trim all spacing to a single space print(attr, ":=", _mkstrip(value)) else: fail("bad output format", _options.format) Loading Loading @@ -432,6 +433,23 @@ def _mkinfo(file, message = ""): """Prints info.""" print(message) def _mkstrip(s): """Emulates Make's strip. That is, removes string's leading and trailing whitespace characters and replaces any sequence of whitespace characters with with a single space. """ result = "" was_space = False for ch in s.strip().elems(): is_space = ch.isspace() if not is_space: if was_space: result += " " result += ch was_space = is_space return result def __get_options(): """Returns struct containing runtime global settings.""" settings = dict( Loading Loading @@ -479,6 +497,7 @@ rblf = struct( mkinfo = _mkinfo, mkerror = _mkerror, mkwarning = _mkwarning, mkstrip = _mkstrip, printvars = _printvars, product_configuration = _product_configuration, require_artifacts_in_path = _require_artifacts_in_path, Loading
tests/run.rbc +3 −1 Original line number Diff line number Diff line # Copyright 2021 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); Loading Loading @@ -28,6 +27,9 @@ def assert_eq(expected, actual): if expected != actual: fail("Expected %s, got %s" % (expected, actual)) # Unit tests for non-trivial runtime functions assert_eq("", rblf.mkstrip(" \n \t ")) assert_eq("a b c", rblf.mkstrip(" a b \n c \t")) globals, config = rblf.product_configuration("test/device", init) assert_eq( Loading