diff options
Diffstat (limited to 'CC')
-rw-r--r-- | CC/EXPRESSIONS | 830 | ||||
-rw-r--r-- | CC/IDE/RULES | 96 | ||||
-rw-r--r-- | CC/RULES | 465 | ||||
-rw-r--r-- | CC/TARGETS | 10 | ||||
-rw-r--r-- | CC/auto/EXPRESSIONS | 32 | ||||
-rw-r--r-- | CC/auto/RULES | 1101 | ||||
-rwxr-xr-x | CC/auto/config_runner.py | 76 | ||||
-rw-r--r-- | CC/proto/EXPRESSIONS | 308 | ||||
-rw-r--r-- | CC/proto/RULES | 94 | ||||
-rw-r--r-- | CC/test/RULES | 311 | ||||
-rw-r--r-- | CC/test/TARGETS | 1 | ||||
-rwxr-xr-x | CC/test/test_runner.py | 69 |
12 files changed, 0 insertions, 3393 deletions
diff --git a/CC/EXPRESSIONS b/CC/EXPRESSIONS deleted file mode 100644 index 7beac0a..0000000 --- a/CC/EXPRESSIONS +++ /dev/null @@ -1,830 +0,0 @@ -{ "default-CC": - { "vars": ["defaults-transition"] - , "imports": {"list_provider": ["./", "..", "field_list_provider"]} - , "expression": - { "type": "join" - , "$1": - { "type": "let*" - , "bindings": - [ ["fieldname", "defaults"] - , ["provider", "CC"] - , [ "transition" - , {"type": "var", "name": "defaults-transition", "default": null} - ] - ] - , "body": {"type": "CALL_EXPRESSION", "name": "list_provider"} - } - } - } -, "default-CXX": - { "vars": ["defaults-transition"] - , "imports": {"list_provider": ["./", "..", "field_list_provider"]} - , "expression": - { "type": "join" - , "$1": - { "type": "let*" - , "bindings": - [ ["fieldname", "defaults"] - , ["provider", "CXX"] - , [ "transition" - , {"type": "var", "name": "defaults-transition", "default": null} - ] - ] - , "body": {"type": "CALL_EXPRESSION", "name": "list_provider"} - } - } - } -, "default-AR": - { "vars": ["defaults-transition"] - , "imports": {"list_provider": ["./", "..", "field_list_provider"]} - , "expression": - { "type": "join" - , "$1": - { "type": "let*" - , "bindings": - [ ["fieldname", "defaults"] - , ["provider", "AR"] - , [ "transition" - , {"type": "var", "name": "defaults-transition", "default": null} - ] - ] - , "body": {"type": "CALL_EXPRESSION", "name": "list_provider"} - } - } - } -, "default-CFLAGS": - { "vars": ["defaults-transition"] - , "imports": {"list_provider": ["./", "..", "field_list_provider"]} - , "expression": - { "type": "let*" - , "bindings": - [ ["fieldname", "defaults"] - , ["provider", "CFLAGS"] - , [ "transition" - , {"type": "var", "name": "defaults-transition", "default": null} - ] - ] - , "body": {"type": "CALL_EXPRESSION", "name": "list_provider"} - } - } -, "default-CXXFLAGS": - { "vars": ["defaults-transition"] - , "imports": {"list_provider": ["./", "..", "field_list_provider"]} - , "expression": - { "type": "let*" - , "bindings": - [ ["fieldname", "defaults"] - , ["provider", "CXXFLAGS"] - , [ "transition" - , {"type": "var", "name": "defaults-transition", "default": null} - ] - ] - , "body": {"type": "CALL_EXPRESSION", "name": "list_provider"} - } - } -, "default-ENV": - { "vars": ["defaults-transition"] - , "imports": {"provider_list": ["./", "..", "field_provider_list"]} - , "expression": - { "type": "let*" - , "bindings": - [ ["fieldname", "defaults"] - , ["provider", "ENV"] - , [ "transition" - , {"type": "var", "name": "defaults-transition", "default": null} - ] - , ["default", {"type": "empty_map"}] - ] - , "body": {"type": "CALL_EXPRESSION", "name": "provider_list"} - } - } -, "defaults-base-provides": - { "doc": ["Query list-provider from 'base' targets (last wins)"] - , "vars": ["provider"] - , "vars_doc": - {"provider": ["The name of the list-provider in the provides map."]} - , "imports": {"provider_list": ["./", "..", "field_provider_list"]} - , "expression": - { "type": "let*" - , "bindings": [["fieldname", "base"]] - , "body": - { "type": "foldl" - , "var": "next" - , "accum_var": "curr" - , "range": {"type": "CALL_EXPRESSION", "name": "provider_list"} - , "body": - { "type": "if" - , "cond": {"type": "var", "name": "next"} - , "then": {"type": "var", "name": "next"} - , "else": {"type": "var", "name": "curr"} - } - } - } - } -, "compile-deps": - { "doc": ["Collect compile dependencies (headers) from given target_fields"] - , "vars": ["deps-fieldnames", "deps-transition"] - , "vars_doc": - { "deps-fieldnames": - ["List of target_field names to collect dependencies from."] - , "deps-transition": - ["The optional configuration transition for the targets."] - } - , "imports": - { "runfiles_list": ["./", "..", "field_runfiles_list"] - , "provider_list": ["./", "..", "field_provider_list"] - } - , "expression": - { "type": "disjoint_map_union" - , "$1": - { "type": "++" - , "$1": - { "type": "foreach" - , "var": "fieldname" - , "range": {"type": "var", "name": "deps-fieldnames"} - , "body": - { "type": "++" - , "$1": - { "type": "let*" - , "bindings": - [ ["provider", "compile-deps"] - , ["transition", {"type": "var", "name": "deps-transition"}] - , ["default", {"type": "empty_map"}] - ] - , "body": - [ {"type": "CALL_EXPRESSION", "name": "provider_list"} - , {"type": "CALL_EXPRESSION", "name": "runfiles_list"} - ] - } - } - } - } - } - } -, "compile-args-deps": - { "doc": ["Collect compile arguments from given target_fields"] - , "vars": ["deps-fieldnames", "deps-transition"] - , "vars_doc": - { "deps-fieldnames": - ["List of target_field names to collect arguments from."] - , "deps-transition": - ["The optional configuration transition for the targets."] - } - , "imports": {"list_provider": ["./", "..", "field_list_provider"]} - , "expression": - { "type": "++" - , "$1": - { "type": "foreach" - , "var": "fieldname" - , "range": {"type": "var", "name": "deps-fieldnames"} - , "body": - { "type": "let*" - , "bindings": - [ ["provider", "compile-args"] - , ["transition", {"type": "var", "name": "deps-transition"}] - ] - , "body": {"type": "CALL_EXPRESSION", "name": "list_provider"} - } - } - } - } -, "link-deps": - { "doc": ["Collect link dependencies (libraries) from given target_fields"] - , "vars": ["deps-fieldnames", "deps-transition"] - , "vars_doc": - { "deps-fieldnames": - ["List of target_field names to collect dependencies from."] - , "deps-transition": - ["The optional configuration transition for the targets."] - } - , "imports": - { "artifacts_list": ["./", "..", "field_artifacts_list"] - , "provider_list": ["./", "..", "field_provider_list"] - } - , "expression": - { "type": "disjoint_map_union" - , "$1": - { "type": "++" - , "$1": - { "type": "foreach" - , "var": "fieldname" - , "range": {"type": "var", "name": "deps-fieldnames"} - , "body": - { "type": "++" - , "$1": - { "type": "let*" - , "bindings": - [ ["provider", "link-deps"] - , ["default", {"type": "empty_map"}] - , ["transition", {"type": "var", "name": "deps-transition"}] - ] - , "body": - [ {"type": "CALL_EXPRESSION", "name": "provider_list"} - , {"type": "CALL_EXPRESSION", "name": "artifacts_list"} - ] - } - } - } - } - } - } -, "link-args-deps": - { "doc": ["Collect linker arguments from given target_fields"] - , "vars": ["deps-fieldnames", "deps-transition"] - , "vars_doc": - { "deps-fieldnames": - ["List of target_field names to collect arguments from."] - , "deps-transition": - ["The optional configuration transition for the targets."] - } - , "imports": {"list_provider": ["./", "..", "field_list_provider"]} - , "expression": - { "type": "++" - , "$1": - { "type": "foreach" - , "var": "fieldname" - , "range": {"type": "var", "name": "deps-fieldnames"} - , "body": - { "type": "let*" - , "bindings": - [ ["provider", "link-args"] - , ["transition", {"type": "var", "name": "deps-transition"}] - ] - , "body": {"type": "CALL_EXPRESSION", "name": "list_provider"} - } - } - } - } -, "objects": - { "vars": - [ "COMPILER" - , "COMPILE_FLAGS" - , "ENV" - , "srcs" - , "hdrs" - , "private-hdrs" - , "compile-deps" - ] - , "expression": - { "type": "let*" - , "bindings": - [ [ "include tree" - , { "type": "singleton_map" - , "key": "include" - , "value": - {"type": "TREE", "$1": {"type": "var", "name": "compile-deps"}} - } - ] - , [ "all hdrs" - , { "type": "map_union" - , "$1": - [ {"type": "var", "name": "include tree"} - , { "type": "to_subdir" - , "subdir": "work" - , "$1": - { "type": "disjoint_map_union" - , "$1": - [ {"type": "var", "name": "hdrs"} - , {"type": "var", "name": "private-hdrs"} - ] - } - } - ] - } - ] - ] - , "body": - { "type": "map_union" - , "$1": - { "type": "foreach_map" - , "var_key": "src_name" - , "var_val": "src_val" - , "range": {"type": "var", "name": "srcs"} - , "body": - { "type": "let*" - , "bindings": - [ [ "work src_name" - , { "type": "join" - , "separator": "/" - , "$1": ["work", {"type": "var", "name": "src_name"}] - } - ] - , [ "inputs" - , { "type": "map_union" - , "$1": - [ {"type": "var", "name": "all hdrs"} - , { "type": "singleton_map" - , "key": {"type": "var", "name": "work src_name"} - , "value": {"type": "var", "name": "src_val"} - } - ] - } - ] - , [ "out" - , { "type": "change_ending" - , "$1": {"type": "var", "name": "src_name"} - , "ending": ".o" - } - ] - , [ "work out" - , { "type": "join" - , "separator": "/" - , "$1": ["work", {"type": "var", "name": "out"}] - } - ] - , [ "action output" - , { "type": "ACTION" - , "outs": [{"type": "var", "name": "work out"}] - , "inputs": {"type": "var", "name": "inputs"} - , "env": - { "type": "var" - , "name": "ENV" - , "default": {"type": "empty_map"} - } - , "cmd": - { "type": "++" - , "$1": - [ [{"type": "var", "name": "COMPILER"}] - , {"type": "var", "name": "COMPILE_FLAGS"} - , ["-I", "work", "-isystem", "include"] - , ["-c", {"type": "var", "name": "work src_name"}] - , ["-o", {"type": "var", "name": "work out"}] - ] - } - } - ] - , [ "staged output artifact" - , { "type": "map_union" - , "$1": - { "type": "foreach_map" - , "range": {"type": "var", "name": "action output"} - , "var_val": "object" - , "body": - { "type": "singleton_map" - , "key": {"type": "var", "name": "out"} - , "value": {"type": "var", "name": "object"} - } - } - } - ] - ] - , "body": {"type": "var", "name": "staged output artifact"} - } - } - } - } - } -, "compiler-cc": - { "vars": ["CC", "defaults-transition"] - , "imports": {"default-CC": "default-CC"} - , "expression": - { "type": "var" - , "name": "CC" - , "default": {"type": "CALL_EXPRESSION", "name": "default-CC"} - } - } -, "compiler-cxx": - { "vars": ["CXX", "defaults-transition"] - , "imports": {"default-CXX": "default-CXX"} - , "expression": - { "type": "var" - , "name": "CXX" - , "default": {"type": "CALL_EXPRESSION", "name": "default-CXX"} - } - } -, "compiler": - { "vars": ["CC", "CXX", "pure C", "defaults-transition"] - , "imports": {"compiler-cc": "compiler-cc", "compiler-cxx": "compiler-cxx"} - , "expression": - { "type": "if" - , "cond": {"type": "var", "name": "pure C"} - , "then": {"type": "CALL_EXPRESSION", "name": "compiler-cc"} - , "else": {"type": "CALL_EXPRESSION", "name": "compiler-cxx"} - } - } -, "flags-cc": - { "vars": ["CFLAGS", "ADD_CFLAGS", "defaults-transition"] - , "imports": {"default-CFLAGS": "default-CFLAGS"} - , "expression": - { "type": "++" - , "$1": - [ { "type": "var" - , "name": "CFLAGS" - , "default": {"type": "CALL_EXPRESSION", "name": "default-CFLAGS"} - } - , {"type": "var", "name": "ADD_CFLAGS", "default": []} - ] - } - } -, "flags-cxx": - { "vars": ["CXXFLAGS", "ADD_CXXFLAGS", "defaults-transition"] - , "imports": {"default-CXXFLAGS": "default-CXXFLAGS"} - , "expression": - { "type": "++" - , "$1": - [ { "type": "var" - , "name": "CXXFLAGS" - , "default": {"type": "CALL_EXPRESSION", "name": "default-CXXFLAGS"} - } - , {"type": "var", "name": "ADD_CXXFLAGS", "default": []} - ] - } - } -, "flags": - { "vars": - [ "CFLAGS" - , "CXXFLAGS" - , "ADD_CFLAGS" - , "ADD_CXXFLAGS" - , "pure C" - , "defaults-transition" - ] - , "imports": {"flags-cc": "flags-cc", "flags-cxx": "flags-cxx"} - , "expression": - { "type": "if" - , "cond": {"type": "var", "name": "pure C"} - , "then": {"type": "CALL_EXPRESSION", "name": "flags-cc"} - , "else": {"type": "CALL_EXPRESSION", "name": "flags-cxx"} - } - } -, "lib artifact": - { "vars": - [ "CC" - , "CXX" - , "CFLAGS" - , "CXXFLAGS" - , "ADD_CFLAGS" - , "ADD_CXXFLAGS" - , "AR" - , "ENV" - , "name" - , "pure C" - , "srcs" - , "hdrs" - , "private-hdrs" - , "stage" - , "compile-deps" - , "compile-args" - , "defaults-transition" - ] - , "imports": - { "compiler": "compiler" - , "flags": "flags" - , "objects": "objects" - , "default-AR": "default-AR" - , "default-ENV": "default-ENV" - } - , "expression": - { "type": "let*" - , "bindings": - [ ["COMPILER", {"type": "CALL_EXPRESSION", "name": "compiler"}] - , [ "COMPILE_FLAGS" - , { "type": "++" - , "$1": - [ {"type": "CALL_EXPRESSION", "name": "flags"} - , {"type": "var", "name": "compile-args"} - ] - } - ] - , [ "AR" - , { "type": "var" - , "name": "AR" - , "default": {"type": "CALL_EXPRESSION", "name": "default-AR"} - } - ] - , [ "ENV" - , { "type": "map_union" - , "$1": - { "type": "++" - , "$1": - [ {"type": "CALL_EXPRESSION", "name": "default-ENV"} - , [ { "type": "var" - , "name": "ENV" - , "default": {"type": "empty_map"} - } - ] - ] - } - } - ] - , ["objects", {"type": "CALL_EXPRESSION", "name": "objects"}] - , [ "base name" - , { "type": "if" - , "cond": {"type": "var", "name": "objects"} - , "then": - { "type": "assert_non_empty" - , "msg": "A name has to be provided for non-header-only libraries" - , "$1": {"type": "var", "name": "name"} - } - , "else": {"type": "var", "name": "name"} - } - ] - , [ "libname" - , { "type": "join" - , "$1": ["lib", {"type": "var", "name": "base name"}, ".a"] - } - ] - , [ "libpath" - , { "type": "if" - , "cond": {"type": "var", "name": "stage"} - , "then": - { "type": "join" - , "separator": "/" - , "$1": - [ {"type": "var", "name": "stage"} - , {"type": "var", "name": "libname"} - ] - } - , "else": {"type": "var", "name": "libname"} - } - ] - , [ "lib" - , { "type": "if" - , "cond": {"type": "var", "name": "objects"} - , "else": {"type": "empty_map"} - , "then": - { "type": "ACTION" - , "outs": [{"type": "var", "name": "libpath"}] - , "inputs": {"type": "var", "name": "objects"} - , "env": - {"type": "var", "name": "ENV", "default": {"type": "empty_map"}} - , "cmd": - { "type": "++" - , "$1": - [ [ {"type": "var", "name": "AR", "default": "ar"} - , "cqs" - , {"type": "var", "name": "libpath"} - ] - , {"type": "keys", "$1": {"type": "var", "name": "objects"}} - ] - } - } - } - ] - ] - , "body": {"type": "var", "name": "lib"} - } - } -, "lib result": - { "vars": - [ "CC" - , "CXX" - , "CFLAGS" - , "CXXFLAGS" - , "ADD_CFLAGS" - , "ADD_CXXFLAGS" - , "AR" - , "ENV" - , "name" - , "pure C" - , "srcs" - , "hdrs" - , "private-hdrs" - , "cflags" - , "private-cflags" - , "private-ldflags" - , "stage" - , "extra-provides" - , "public-fieldnames" - , "private-fieldnames" - ] - , "imports": - { "compile-deps": "compile-deps" - , "compile-args-deps": "compile-args-deps" - , "link-deps": "link-deps" - , "link-args-deps": "link-args-deps" - , "lib artifact": "lib artifact" - } - , "expression": - { "type": "let*" - , "bindings": - [ ["deps-fieldnames", {"type": "var", "name": "private-fieldnames"}] - , ["compile-deps", {"type": "CALL_EXPRESSION", "name": "compile-deps"}] - , [ "compile-args" - , { "type": "nub_right" - , "$1": - { "type": "++" - , "$1": - [ {"type": "var", "name": "cflags"} - , {"type": "var", "name": "private-cflags"} - , {"type": "CALL_EXPRESSION", "name": "compile-args-deps"} - ] - } - } - ] - , ["link-deps", {"type": "CALL_EXPRESSION", "name": "link-deps"}] - , ["lib", {"type": "CALL_EXPRESSION", "name": "lib artifact"}] - , [ "link-args" - , { "type": "nub_right" - , "$1": - { "type": "++" - , "$1": - [ {"type": "keys", "$1": {"type": "var", "name": "lib"}} - , {"type": "var", "name": "private-ldflags", "default": []} - , {"type": "CALL_EXPRESSION", "name": "link-args-deps"} - ] - } - } - ] - , ["deps-fieldnames", {"type": "var", "name": "public-fieldnames"}] - , ["compile-deps", {"type": "CALL_EXPRESSION", "name": "compile-deps"}] - , [ "compile-args" - , { "type": "nub_right" - , "$1": - { "type": "++" - , "$1": - [ {"type": "var", "name": "cflags"} - , {"type": "CALL_EXPRESSION", "name": "compile-args-deps"} - ] - } - } - ] - ] - , "body": - { "type": "RESULT" - , "artifacts": {"type": "var", "name": "lib"} - , "runfiles": {"type": "var", "name": "hdrs"} - , "provides": - { "type": "map_union" - , "$1": - [ { "type": "env" - , "vars": - ["compile-deps", "compile-args", "link-deps", "link-args"] - } - , { "type": "var" - , "name": "extra-provides" - , "default": {"type": "empty_map"} - } - ] - } - } - } - } -, "bin artifact": - { "doc": ["Produces the binary artifact."] - , "vars": - [ "CC" - , "CXX" - , "CFLAGS" - , "CXXFLAGS" - , "ADD_CFLAGS" - , "ADD_CXXFLAGS" - , "ENV" - , "name" - , "pure C" - , "srcs" - , "private-hdrs" - , "stage" - , "compile-deps" - , "compile-args" - , "link-deps" - , "link-args" - , "defaults-transition" - ] - , "imports": - { "compiler": "compiler" - , "flags": "flags" - , "objects": "objects" - , "default-ENV": "default-ENV" - } - , "expression": - { "type": "let*" - , "bindings": - [ ["COMPILER", {"type": "CALL_EXPRESSION", "name": "compiler"}] - , [ "COMPILE_FLAGS" - , { "type": "++" - , "$1": - [ {"type": "CALL_EXPRESSION", "name": "flags"} - , {"type": "var", "name": "compile-args"} - ] - } - ] - , [ "ENV" - , { "type": "map_union" - , "$1": - { "type": "++" - , "$1": - [ {"type": "CALL_EXPRESSION", "name": "default-ENV"} - , [ { "type": "var" - , "name": "ENV" - , "default": {"type": "empty_map"} - } - ] - ] - } - } - ] - , ["hdrs", {"type": "empty_map"}] - , ["objects", {"type": "CALL_EXPRESSION", "name": "objects"}] - , [ "link-args" - , { "type": "nub_right" - , "$1": - { "type": "++" - , "$1": - [ {"type": "keys", "$1": {"type": "var", "name": "objects"}} - , {"type": "var", "name": "link-args"} - ] - } - } - ] - , [ "binpath" - , { "type": "if" - , "cond": {"type": "var", "name": "stage"} - , "then": - { "type": "join" - , "separator": "/" - , "$1": - [ {"type": "var", "name": "stage"} - , {"type": "var", "name": "name"} - ] - } - , "else": {"type": "var", "name": "name"} - } - ] - , [ "binary" - , { "type": "ACTION" - , "outs": [{"type": "var", "name": "binpath"}] - , "inputs": - { "type": "disjoint_map_union" - , "$1": - [ {"type": "var", "name": "objects"} - , {"type": "var", "name": "link-deps"} - ] - } - , "cmd": - { "type": "++" - , "$1": - [ [ {"type": "var", "name": "COMPILER"} - , "-o" - , {"type": "var", "name": "binpath"} - ] - , {"type": "var", "name": "COMPILE_FLAGS"} - , {"type": "var", "name": "link-args"} - ] - } - , "env": {"type": "var", "name": "ENV"} - } - ] - ] - , "body": {"type": "var", "name": "binary"} - } - } -, "bin result": - { "doc": ["Produces the binary target result."] - , "vars": - [ "CC" - , "CXX" - , "CFLAGS" - , "CXXFLAGS" - , "ADD_CFLAGS" - , "ADD_CXXFLAGS" - , "ENV" - , "name" - , "pure C" - , "srcs" - , "private-hdrs" - , "private-cflags" - , "private-ldflags" - , "stage" - , "private-fieldnames" - ] - , "imports": - { "compile-deps": "compile-deps" - , "compile-args-deps": "compile-args-deps" - , "link-deps": "link-deps" - , "link-args-deps": "link-args-deps" - , "binary": "bin artifact" - } - , "expression": - { "type": "let*" - , "bindings": - [ ["deps-fieldnames", {"type": "var", "name": "private-fieldnames"}] - , ["compile-deps", {"type": "CALL_EXPRESSION", "name": "compile-deps"}] - , [ "compile-args" - , { "type": "++" - , "$1": - [ {"type": "CALL_EXPRESSION", "name": "compile-args-deps"} - , {"type": "var", "name": "private-cflags"} - ] - } - ] - , ["link-deps", {"type": "CALL_EXPRESSION", "name": "link-deps"}] - , [ "link-args" - , { "type": "nub_right" - , "$1": - { "type": "++" - , "$1": - [ {"type": "var", "name": "private-ldflags"} - , {"type": "CALL_EXPRESSION", "name": "link-args-deps"} - ] - } - } - ] - ] - , "body": - { "type": "RESULT" - , "artifacts": {"type": "CALL_EXPRESSION", "name": "binary"} - } - } - } -} diff --git a/CC/IDE/RULES b/CC/IDE/RULES deleted file mode 100644 index dc4b607..0000000 --- a/CC/IDE/RULES +++ /dev/null @@ -1,96 +0,0 @@ -{ "headers": - { "doc": ["Transitive public headers of C++ target"] - , "target_fields": ["proto", "deps"] - , "string_fields": ["stage"] - , "field_doc": - { "proto": ["The proto source files for creating cc bindings."] - , "deps": ["The targets to obtain the headers from."] - , "stage": - [ "The logical location of the header files. Individual directory" - , "components are joined with \"/\"." - ] - } - , "anonymous": - { "proto-deps": - { "target": "proto" - , "provider": "proto" - , "rule_map": - { "library": ["./", "../proto", "library"] - , "service library": ["./", "../proto", "service library"] - } - } - } - , "imports": {"runfiles_list": ["./", "../..", "field_runfiles_list"]} - , "expression": - { "type": "let*" - , "bindings": - [ [ "stage" - , { "type": "join" - , "separator": "/" - , "$1": {"type": "FIELD", "name": "stage"} - } - ] - , [ "artifacts" - , { "type": "to_subdir" - , "subdir": {"type": "var", "name": "stage"} - , "$1": - { "type": "map_union" - , "$1": - { "type": "++" - , "$1": - [ { "type": "let*" - , "bindings": [["fieldname", "proto-deps"]] - , "body": - {"type": "CALL_EXPRESSION", "name": "runfiles_list"} - } - , { "type": "foreach" - , "var": "x" - , "range": {"type": "FIELD", "name": "proto-deps"} - , "body": - { "type": "DEP_PROVIDES" - , "provider": "compile-deps" - , "dep": {"type": "var", "name": "x"} - , "default": - { "type": "fail" - , "msg": - [ "Expected a library target, but got:" - , {"type": "var", "name": "x"} - ] - } - } - } - , { "type": "let*" - , "bindings": [["fieldname", "deps"]] - , "body": - {"type": "CALL_EXPRESSION", "name": "runfiles_list"} - } - , { "type": "foreach" - , "var": "x" - , "range": {"type": "FIELD", "name": "deps"} - , "body": - { "type": "DEP_PROVIDES" - , "provider": "compile-deps" - , "dep": {"type": "var", "name": "x"} - , "default": - { "type": "fail" - , "msg": - [ "Expected a library target, but got:" - , {"type": "var", "name": "x"} - ] - } - } - } - ] - } - } - } - ] - ] - , "body": - { "type": "RESULT" - , "artifacts": {"type": "var", "name": "artifacts"} - , "runfiles": {"type": "var", "name": "artifacts"} - } - } - } -} diff --git a/CC/RULES b/CC/RULES deleted file mode 100644 index 2b420fb..0000000 --- a/CC/RULES +++ /dev/null @@ -1,465 +0,0 @@ -{ "defaults": - { "doc": - [ "A rule to provide defaults." - , "All CC targets take their defaults for CC, CXX, flags, etc from" - , "the target [\"CC\", \"defaults\"]. This is probably the only sensible" - , "use of this rule. As targets form a different root, the defaults" - , "can be provided without changing this directory." - ] - , "target_fields": ["base"] - , "string_fields": - [ "CC" - , "CXX" - , "CFLAGS" - , "CXXFLAGS" - , "ADD_CFLAGS" - , "ADD_CXXFLAGS" - , "AR" - , "PATH" - ] - , "imports": {"base-provides": "defaults-base-provides"} - , "expression": - { "type": "let*" - , "bindings": - [ ["CC", {"type": "FIELD", "name": "CC"}] - , ["CXX", {"type": "FIELD", "name": "CXX"}] - , ["CFLAGS", {"type": "FIELD", "name": "CFLAGS"}] - , ["CXXFLAGS", {"type": "FIELD", "name": "CXXFLAGS"}] - , ["AR", {"type": "FIELD", "name": "AR"}] - , ["PATH", {"type": "FIELD", "name": "PATH"}] - , ["provider", "CC"] - , [ "CC" - , { "type": "if" - , "cond": {"type": "var", "name": "CC"} - , "then": {"type": "var", "name": "CC"} - , "else": {"type": "CALL_EXPRESSION", "name": "base-provides"} - } - ] - , ["provider", "CXX"] - , [ "CXX" - , { "type": "if" - , "cond": {"type": "var", "name": "CXX"} - , "then": {"type": "var", "name": "CXX"} - , "else": {"type": "CALL_EXPRESSION", "name": "base-provides"} - } - ] - , ["provider", "CFLAGS"] - , [ "CFLAGS" - , { "type": "if" - , "cond": {"type": "var", "name": "CFLAGS"} - , "then": {"type": "var", "name": "CFLAGS"} - , "else": {"type": "CALL_EXPRESSION", "name": "base-provides"} - } - ] - , ["provider", "CXXFLAGS"] - , [ "CXXFLAGS" - , { "type": "if" - , "cond": {"type": "var", "name": "CXXFLAGS"} - , "then": {"type": "var", "name": "CXXFLAGS"} - , "else": {"type": "CALL_EXPRESSION", "name": "base-provides"} - } - ] - , ["provider", "AR"] - , [ "AR" - , { "type": "if" - , "cond": {"type": "var", "name": "AR"} - , "then": {"type": "var", "name": "AR"} - , "else": {"type": "CALL_EXPRESSION", "name": "base-provides"} - } - ] - , ["provider", "ENV"] - , [ "ENV" - , { "type": "if" - , "cond": {"type": "var", "name": "PATH"} - , "then": - { "type": "singleton_map" - , "key": "PATH" - , "value": - { "type": "join" - , "separator": ":" - , "$1": {"type": "var", "name": "PATH"} - } - } - , "else": {"type": "CALL_EXPRESSION", "name": "base-provides"} - } - ] - , [ "CFLAGS" - , { "type": "++" - , "$1": - [ {"type": "var", "name": "CFLAGS"} - , {"type": "FIELD", "name": "ADD_CFLAGS"} - ] - } - ] - , [ "CXXFLAGS" - , { "type": "++" - , "$1": - [ {"type": "var", "name": "CXXFLAGS"} - , {"type": "FIELD", "name": "ADD_CXXFLAGS"} - ] - } - ] - ] - , "body": - { "type": "RESULT" - , "provides": - { "type": "env" - , "vars": ["CC", "CXX", "CFLAGS", "CXXFLAGS", "AR", "ENV"] - } - } - } - } -, "library": - { "doc": ["A C++ library"] - , "target_fields": - ["srcs", "hdrs", "private-hdrs", "deps", "private-deps", "proto"] - , "string_fields": - [ "name" - , "stage" - , "pure C" - , "defines" - , "private-defines" - , "cflags" - , "private-cflags" - , "private-ldflags" - ] - , "config_vars": - [ "CC" - , "CXX" - , "CFLAGS" - , "CXXFLAGS" - , "ADD_CFLAGS" - , "ADD_CXXFLAGS" - , "AR" - , "ENV" - ] - , "implicit": {"defaults": ["defaults"]} - , "field_doc": - { "name": - ["The name of the library (without leading \"lib\" or trailing \".a\")."] - , "srcs": ["The source files of the library."] - , "hdrs": ["Any public header files of the library."] - , "private-hdrs": - [ "Any header files that only need to be present when compiling the" - , "source files, but are not needed for any consumer of the library." - ] - , "stage": - [ "The logical location of all header and source files, as well as the" - , "resulting library file. Individual directory components are joined" - , "with \"/\"." - ] - , "pure C": - [ "If non-empty, compile as C sources rather than C++ sources." - , "In particular, CC is used to compile rather than CXX (or their" - , "respective defaults)." - ] - , "defines": - [ "List of defines set for this target and its consumers." - , "Each list entry will be prepended by \"-D\"." - ] - , "private-defines": - [ "List of defines set for source files local to this target." - , "Each list entry will be prepended by \"-D\"." - ] - , "cflags": - ["List of compile flags set for this target and its consumers."] - , "private-cflags": - ["List of compile flags set for source files local to this target."] - , "private-ldflags": - [ "Additional linker flags for linking external libraries (not built" - , "by this tool, typically system libraries)." - ] - , "deps": ["Any other libraries this library depends upon."] - , "private-deps": - [ "Any other libraries this library depends upon but does not include" - , "in its public headers." - ] - , "proto": - [ "Any [\"proto\", \"library\"] this target depends upon directly." - , "The creation of C++ bindings for this proto library as well as of" - , "its dependencies will be taken care of (as anonymous targets, so no" - , "duplicate work will be carried out, even if the same proto library" - , "is used at various places)." - ] - } - , "config_doc": - { "CC": - [ "The name of the C compiler to be used (when compiling pure C code)." - , "If None, the respective value from [\"CC\", \"defaults\"] will be taken." - ] - , "CXX": - [ "The name of the C++ compiler to be used." - , "If None, the respective value from [\"CC\", \"defaults\"] will be taken." - ] - , "CFLAGS": - [ "The flags for CC to be used instead of the default ones." - , "For libraries that should be built in a non-standard way; usually" - , "adapting the default target [\"CC\", \"defaults\"] is the better" - , "choice." - ] - , "CXXFLAGS": - [ "The flags for CXX to be used instead of the default ones." - , "For libraries that should be built in a non-standard way; usually" - , "adapting the default target [\"CC\", \"defaults\"] is the better" - , "choice." - ] - , "ADD_CFLAGS": - [ "The flags to add to the default ones for CC." - , "For libraries that should be built in a non-standard way; usually" - , "adapting the default target [\"CC\", \"defaults\"] is the better" - , "choice." - ] - , "ADD_CXXFLAGS": - [ "The flags to add to the default ones for CXX." - , "For libraries that should be built in a non-standard way; usually" - , "adapting the default target [\"CC\", \"defaults\"] is the better" - , "choice." - ] - , "AR": - [ "The archive tool to used for creating the library" - , "If None, the respective value from [\"CC\", \"defaults\"] will be taken." - ] - , "ENV": ["The environment for any action generated."] - } - , "artifacts_doc": - ["The actual library (libname.a) staged in the specified directory"] - , "runfiles_doc": ["The public headers of this library"] - , "provides_doc": - { "compile-deps": - [ "Map of artifacts specifying any additional files that, besides the runfiles," - , "have to be present in compile actions of targets depending on this library" - ] - , "link-deps": - [ "Map of artifacts specifying any additional files that, besides the artifacts," - , "have to be present in a link actions of targets depending on this library" - ] - , "link-args": - [ "List of strings that have to be added to the command line for linking actions" - , "in targets depending on this library" - ] - } - , "anonymous": - { "proto-deps": - { "target": "proto" - , "provider": "proto" - , "rule_map": - { "library": ["./", "proto", "library"] - , "service library": ["./", "proto", "service library"] - } - } - } - , "imports": - {"artifacts": ["./", "..", "field_artifacts"], "result": "lib result"} - , "expression": - { "type": "let*" - , "bindings": - [ ["name", {"type": "join", "$1": {"type": "FIELD", "name": "name"}}] - , ["pure C", {"type": "FIELD", "name": "pure C"}] - , [ "cflags" - , { "type": "++" - , "$1": - [ {"type": "FIELD", "name": "cflags"} - , { "type": "foreach" - , "var": "def" - , "range": {"type": "FIELD", "name": "defines"} - , "body": - {"type": "join", "$1": ["-D", {"type": "var", "name": "def"}]} - } - ] - } - ] - , [ "private-cflags" - , { "type": "++" - , "$1": - [ {"type": "FIELD", "name": "private-cflags"} - , { "type": "foreach" - , "var": "def" - , "range": {"type": "FIELD", "name": "private-defines"} - , "body": - {"type": "join", "$1": ["-D", {"type": "var", "name": "def"}]} - } - ] - } - ] - , [ "stage" - , { "type": "join" - , "separator": "/" - , "$1": {"type": "FIELD", "name": "stage"} - } - ] - , [ "srcs" - , { "type": "to_subdir" - , "subdir": {"type": "var", "name": "stage"} - , "$1": - { "type": "let*" - , "bindings": [["fieldname", "srcs"]] - , "body": {"type": "CALL_EXPRESSION", "name": "artifacts"} - } - } - ] - , [ "hdrs" - , { "type": "to_subdir" - , "subdir": {"type": "var", "name": "stage"} - , "$1": - { "type": "let*" - , "bindings": [["fieldname", "hdrs"]] - , "body": {"type": "CALL_EXPRESSION", "name": "artifacts"} - } - } - ] - , [ "private-hdrs" - , { "type": "to_subdir" - , "subdir": {"type": "var", "name": "stage"} - , "$1": - { "type": "let*" - , "bindings": [["fieldname", "private-hdrs"]] - , "body": {"type": "CALL_EXPRESSION", "name": "artifacts"} - } - } - ] - , ["private-ldflags", {"type": "FIELD", "name": "private-ldflags"}] - , ["public-fieldnames", ["deps", "proto-deps"]] - , ["private-fieldnames", ["deps", "private-deps", "proto-deps"]] - ] - , "body": {"type": "CALL_EXPRESSION", "name": "result"} - } - } -, "binary": - { "doc": ["A binary written in C++"] - , "target_fields": ["srcs", "private-hdrs", "private-deps", "private-proto"] - , "string_fields": - [ "name" - , "stage" - , "pure C" - , "private-defines" - , "private-cflags" - , "private-ldflags" - ] - , "config_vars": - ["CC", "CXX", "CFLAGS", "CXXFLAGS", "ADD_CFLAGS", "ADD_CXXFLAGS", "ENV"] - , "implicit": {"defaults": ["defaults"]} - , "field_doc": - { "name": ["The name of the binary"] - , "srcs": ["The source files of the library."] - , "private-hdrs": - [ "Any header files that need to be present when compiling the" - , "source files." - ] - , "stage": - [ "The logical location of all header and source files, as well as the" - , "resulting binary file. Individual directory components are joined" - , "with \"/\"." - ] - , "pure C": - [ "If non-empty, compile as C sources rathter than C++ sources." - , "In particular, CC is used to compile rather than CXX" - ] - , "private-defines": - [ "List of defines set for source files local to this target." - , "Each list entry will be prepended by \"-D\"." - ] - , "private-cflags": - ["List of compile flags set for source files local to this target."] - , "private-ldflags": - ["Additional linker flags for linking external libraries."] - , "private-deps": ["Any other libraries this binary depends upon."] - , "private-proto": - [ "Any [\"proto\", \"library\"] this target depends upon directly." - , "The creation of C++ bindings for this proto library as well as of" - , "is dependencies will be taken care of (as anonymous targets, so no" - , "duplicate work will be carried out, even if the same proto library" - , "is used at various places)." - ] - } - , "config_doc": - { "CC": - ["The name of the C compiler to be used (when compiling pure C code)"] - , "CXX": ["The name of the C++ compiler to be used."] - , "CFLAGS": - [ "The flags for CXX to be used instead of the default ones" - , "taken from the [\"CC\", \"defaults\"] target" - ] - , "CXXFLAGS": - [ "The flags for CXX to be used instead of the default ones" - , "taken from the [\"CC\", \"defaults\"] target" - ] - , "ADD_CFLAGS": - [ "The flags to add to the default ones for CC" - , "taken from the [\"CC\", \"defaults\"] target" - ] - , "ADD_CXXFLAGS": - [ "The flags to add to the default ones for CXX" - , "taken from the [\"CC\", \"defaults\"] target" - ] - , "ENV": ["The environment for any action generated."] - } - , "artifacts_doc": ["The final binary, staged to the given directory"] - , "runfiles_doc": ["None"] - , "anonymous": - { "private-proto-deps": - { "target": "private-proto" - , "provider": "proto" - , "rule_map": - { "library": ["./", "proto", "library"] - , "service library": ["./", "proto", "service library"] - } - } - } - , "imports": - {"artifacts": ["./", "..", "field_artifacts"], "bin result": "bin result"} - , "expression": - { "type": "let*" - , "bindings": - [ [ "name" - , { "type": "assert_non_empty" - , "msg": "A non-empty name has to be provided for binaries" - , "$1": {"type": "join", "$1": {"type": "FIELD", "name": "name"}} - } - ] - , ["pure C", {"type": "FIELD", "name": "pure C"}] - , [ "stage" - , { "type": "join" - , "separator": "/" - , "$1": {"type": "FIELD", "name": "stage"} - } - ] - , [ "srcs" - , { "type": "to_subdir" - , "subdir": {"type": "var", "name": "stage"} - , "$1": - { "type": "let*" - , "bindings": [["fieldname", "srcs"]] - , "body": {"type": "CALL_EXPRESSION", "name": "artifacts"} - } - } - ] - , [ "private-hdrs" - , { "type": "to_subdir" - , "subdir": {"type": "var", "name": "stage"} - , "$1": - { "type": "let*" - , "bindings": [["fieldname", "private-hdrs"]] - , "body": {"type": "CALL_EXPRESSION", "name": "artifacts"} - } - } - ] - , [ "private-cflags" - , { "type": "++" - , "$1": - [ { "type": "foreach" - , "var": "def" - , "range": {"type": "FIELD", "name": "private-defines"} - , "body": - {"type": "join", "$1": ["-D", {"type": "var", "name": "def"}]} - } - , {"type": "FIELD", "name": "private-cflags"} - ] - } - ] - , ["private-ldflags", {"type": "FIELD", "name": "private-ldflags"}] - , ["private-fieldnames", ["private-deps", "private-proto-deps"]] - ] - , "body": {"type": "CALL_EXPRESSION", "name": "bin result"} - } - } -} diff --git a/CC/TARGETS b/CC/TARGETS deleted file mode 100644 index 2da456b..0000000 --- a/CC/TARGETS +++ /dev/null @@ -1,10 +0,0 @@ -{ "defaults": - { "type": ["CC", "defaults"] - , "CC": ["cc"] - , "CXX": ["c++"] - , "CFLAGS": [] - , "CXXFLAGS": [] - , "AR": ["ar"] - , "PATH": ["/bin", "/usr/bin"] - } -} diff --git a/CC/auto/EXPRESSIONS b/CC/auto/EXPRESSIONS deleted file mode 100644 index ac19f7a..0000000 --- a/CC/auto/EXPRESSIONS +++ /dev/null @@ -1,32 +0,0 @@ -{ "last_list_entry": - { "vars": ["list"] - , "expression": - { "type": "foldl" - , "range": {"type": "var", "name": "list"} - , "start": null - , "body": {"type": "var", "name": "_"} - } - } -, "first_list_entry": - { "vars": ["list"] - , "imports": {"last": "last_list_entry"} - , "expression": - { "type": "let*" - , "bindings": - [ [ "list" - , { "type": "foldl" - , "range": {"type": "var", "name": "list", "default": []} - , "start": null - , "body": - { "type": "if" - , "cond": {"type": "var", "name": "$1"} - , "then": {"type": "var", "name": "$1"} - , "else": [{"type": "var", "name": "_"}] - } - } - ] - ] - , "body": {"type": "CALL_EXPRESSION", "name": "last"} - } - } -} diff --git a/CC/auto/RULES b/CC/auto/RULES deleted file mode 100644 index 7d27ff6..0000000 --- a/CC/auto/RULES +++ /dev/null @@ -1,1101 +0,0 @@ -{ "config": - { "doc": - [ "Generate a C/C++ config header" - , "" - , "Generate a C/C++ configuration header using defines specified via the" - , "target configuration. In the usual case, a target using this rule is" - , "configured by depending on it from a target that uses the built-in" - , "\"configure\" rule." - ] - , "field_doc": - { "name": ["Name of the header file to generate (incl. file name ext)."] - , "guard": ["The include guard. Multiple segments are joined with \"_\"."] - , "stage": - ["The location of the header. Path segments are joined with \"/\"."] - , "hdrs": - [ "Additional header files to be available in the include path. Useful" - , "for providing additional header files to values given in" - , "\"have_{cfile,cxxfile,ctype,cxxtype,csymbol,cxxsymbol}\"." - ] - , "deps": - [ "Additional public header files from targets to be available in the" - , "include path. Useful for providing additional header files to values" - , "given in \"have_{cfile,cxxfile,ctype,cxxtype,csymbol,cxxsymbol}\"." - ] - } - , "config_doc": - { "CC": - [ "The name of the C compiler to be used by checks. If None, the" - , "respective value from [\"CC\", \"defaults\"] will be taken." - ] - , "CXX": - [ "The name of the C++ compiler to be used by checks. If None, the" - , "respective value from [\"CC\", \"defaults\"] will be taken." - ] - , "CFLAGS": - [ "The flags for CXX to be used instead of the default ones" - , "taken from the [\"CC\", \"defaults\"] target" - ] - , "CXXFLAGS": - [ "The flags for CXX to be used instead of the default ones" - , "taken from the [\"CC\", \"defaults\"] target" - ] - , "ADD_CFLAGS": - [ "The flags to add to the default ones for CC" - , "taken from the [\"CC\", \"defaults\"] target" - ] - , "ADD_CXXFLAGS": - [ "The flags to add to the default ones for CXX" - , "taken from the [\"CC\", \"defaults\"] target" - ] - , "ENV": ["The environment for running file/symbol/type/size checks."] - , "defines": - [ "Set a define to a specific value unless its value is \"null\". Must" - , "contain a list of pairs. The first element of each pair is the define" - , "name and the second argument is the value to set. Strings must be" - , "properly escaped. Defines generated from this field are added last," - , "so that they can refer to defines from other \"defines*\", " - , "\"have_*\", and \"size_*\" values." - ] - , "defines1": - [ "Set a define to \"1\" unless its value is untrue. Must contain a list" - , "of pairs. The first element of each pair is the define name and the" - , "second argument is the value." - ] - , "defines01": - [ "Set a define to \"0\" or \"1\" depending on its value being true." - , "Must contain a list of pairs. The first element of each pair is the" - , "define name and the second argument is the value." - ] - , "have_cfile": - [ "Set a define to \"1\" if the specified C header is in the include" - , "path. Must contain a list of pairs. The first element of each pair is" - , "the define name and the second argument is the C header file name." - ] - , "have_cxxfile": - [ "Set a define to \"1\" if the specified C++ header is in the include" - , "path. Must contain a list of pairs. The first element of each pair is" - , "the define name and the second argument is the C++ header file name." - ] - , "have_ctype": - [ "Set a define to \"1\" if the specified C type is defined. Must" - , "contain a list of pairs. The first element of each pair is the define" - , "name and the second argument is name of the C type. If the specified" - , "C type is not a built-in type, additionally the headers" - , "\"sys/types.h\", \"stdint.h\", and \"stddef.h\" are checked as well." - ] - , "have_cxxtype": - [ "Set a define to \"1\" if the specified C++ type is defined. Must" - , "contain a list of pairs. The first element of each pair is the define" - , "name and the second argument is name of the C++ type. If the specified" - , "C++ type is not a built-in type, additionally the headers" - , "\"sys/types.h\", \"stdint.h\", and \"stddef.h\" are checked as well." - ] - , "have_csymbol": - [ "Set a define to \"1\" if the specified C symbol is defined by one of" - , "the specified headers in the include path. Must contain a list of" - , "pairs. The first element of each pair is the define name and the" - , "second argument is another pair. This pair's first value is the C" - , "symbol to search for and the second value is a list with the header" - , "file names to consider for searching." - ] - , "have_cxxsymbol": - [ "Set a define to \"1\" if the specified C++ symbol is defined by one of" - , "the specified headers in the include path. Must contain a list of" - , "pairs. The first element of each pair is the define name and the" - , "second argument is another pair. This pair's first value is the C++" - , "symbol to search for and the second value is a list with the header" - , "file names to consider for searching." - ] - , "size_ctype": - [ "Set a define to size of the specified C type. Must contain a list of" - , "pairs. The first element of each pair is the define name and the" - , "second argument is another pair. This pair's first value is the C" - , "type to check for and the second value is a list with possible sizes" - , "as numbers. If none of the specified sizes matches, the action fails." - ] - , "size_cxxtype": - [ "Set a define to size of the specified C++ type. Must contain a list of" - , "pairs. The first element of each pair is the define name and the" - , "second argument is another pair. This pair's first value is the C++" - , "type to check for and the second value is a list with possible sizes" - , "as numbers. If none of the specified sizes matches, the action fails." - ] - } - , "string_fields": ["name", "stage", "guard"] - , "target_fields": ["hdrs", "deps"] - , "config_vars": - [ "CC" - , "CXX" - , "CFLAGS" - , "CXXFLAGS" - , "ADD_CFLAGS" - , "ADD_CXXFLAGS" - , "ENV" - , "defines" - , "defines1" - , "defines01" - , "have_cfile" - , "have_cxxfile" - , "have_ctype" - , "have_cxxtype" - , "have_csymbol" - , "have_cxxsymbol" - , "size_ctype" - , "size_cxxtype" - ] - , "imports": - { "first": "first_list_entry" - , "last": "last_list_entry" - , "artifacts": ["./", "../..", "field_artifacts"] - , "compile-deps": ["./", "..", "compile-deps"] - , "compiler-cc": ["./", "..", "compiler-cc"] - , "compiler-cxx": ["./", "..", "compiler-cxx"] - , "flags-cc": ["./", "..", "flags-cc"] - , "flags-cxx": ["./", "..", "flags-cxx"] - , "default-ENV": ["./", "..", "default-ENV"] - } - , "implicit": {"defaults": [["./", "..", "defaults"]]} - , "expression": - { "type": "let*" - , "bindings": - [ ["name", {"type": "join", "$1": {"type": "FIELD", "name": "name"}}] - , [ "stage" - , { "type": "join" - , "separator": "/" - , "$1": {"type": "FIELD", "name": "stage"} - } - ] - , [ "guard" - , { "type": "assert_non_empty" - , "msg": "Config header include guard may not be empty" - , "$1": - { "type": "join" - , "separator": "_" - , "$1": {"type": "FIELD", "name": "guard"} - } - } - ] - , [ "includes" - , { "type": "to_subdir" - , "subdir": "include" - , "$1": - { "type": "disjoint_map_union" - , "msg": "Includes may not overlap" - , "$1": - [ { "type": "let*" - , "bindings": [["fieldname", "hdrs"]] - , "body": {"type": "CALL_EXPRESSION", "name": "artifacts"} - } - , { "type": "let*" - , "bindings": [["deps-fieldnames", ["deps"]]] - , "body": {"type": "CALL_EXPRESSION", "name": "compile-deps"} - } - ] - } - } - ] - , ["CC", {"type": "CALL_EXPRESSION", "name": "compiler-cc"}] - , ["CXX", {"type": "CALL_EXPRESSION", "name": "compiler-cxx"}] - , ["CFLAGS", {"type": "CALL_EXPRESSION", "name": "flags-cc"}] - , ["CXXFLAGS", {"type": "CALL_EXPRESSION", "name": "flags-cxx"}] - , [ "ENV" - , { "type": "map_union" - , "$1": - { "type": "++" - , "$1": - [ {"type": "CALL_EXPRESSION", "name": "default-ENV"} - , [ { "type": "var" - , "name": "ENV" - , "default": {"type": "empty_map"} - } - ] - ] - } - } - ] - , [ "c.flags" - , { "type": "BLOB" - , "data": - { "type": "join" - , "separator": "\n" - , "$1": {"type": "var", "name": "CFLAGS"} - } - } - ] - , [ "cxx.flags" - , { "type": "BLOB" - , "data": - { "type": "join" - , "separator": "\n" - , "$1": {"type": "var", "name": "CXXFLAGS"} - } - } - ] - , [ "file_check.sh" - , { "type": "BLOB" - , "data": - { "type": "join" - , "separator": "\n" - , "$1": - [ "set -eu" - , "[ $# -ge 4 ]" - , "CC=$1" - , "LANG=$2" - , "DEF=$3" - , "HDR=$4" - , "DEFINE=\"/* #undef $DEF */\"" - , "echo \"#include \\\"$HDR\\\"\" > test.$LANG" - , "if $CC @$LANG.flags -c test.$LANG -I ./include 2>/dev/null; then DEFINE=\"#define $DEF 1\"; fi" - , "echo \"$DEFINE\n\" > out.def" - ] - } - } - ] - , [ "type_check.sh" - , { "type": "BLOB" - , "data": - { "type": "join" - , "separator": "\n" - , "$1": - [ "set -eu" - , "[ $# -ge 4 ]" - , "CC=$1" - , "LANG=$2" - , "DEF=$3" - , "TYPE=$4" - , "INC=\"\"" - , "DEFINE=\"/* #undef $DEF */\"" - , "for HDR in \"\" \"sys/types.h\" \"stdint.h\" \"stddef.h\"; do" - , " if [ -n \"$HDR\" ]; then INC=\"#include \\\"$HDR\\\"\"; fi" - , " cat > test.$LANG << EOF" - , "$INC" - , "$TYPE* __test;" - , "EOF" - , " if $CC @$LANG.flags -c test.$LANG -I ./include 2>/dev/null; then" - , " DEFINE=\"#define $DEF 1\"" - , " break" - , " fi" - , "done" - , "echo \"$DEFINE\n\" > out.def" - ] - } - } - ] - , [ "symbol_check.sh" - , { "type": "BLOB" - , "data": - { "type": "join" - , "separator": "\n" - , "$1": - [ "set -eu" - , "[ $# -ge 4 ]" - , "CC=$1" - , "shift" - , "LANG=$1" - , "shift" - , "DEF=$1" - , "shift" - , "SYMBOL=$1" - , "shift" - , "DEFINE=\"/* #undef $DEF */\"" - , "for INC in \"$@\"; do" - , " cat > test.$LANG << EOF" - , "#include \"$INC\"" - , "#ifndef $SYMBOL" - , "void* __test = &$SYMBOL;" - , "#endif" - , "EOF" - , " if $CC @$LANG.flags -c test.$LANG -I ./include 2>/dev/null; then" - , " DEFINE=\"#define $DEF 1\"" - , " break" - , " fi" - , "done" - , "echo \"$DEFINE\n\" > out.def" - ] - } - } - ] - , [ "size_check.sh" - , { "type": "BLOB" - , "data": - { "type": "join" - , "separator": "\n" - , "$1": - [ "set -eu" - , "[ $# -ge 4 ]" - , "CC=$1" - , "shift" - , "LANG=$1" - , "shift" - , "DEF=$1" - , "shift" - , "TYPE=$1" - , "shift" - , "INC=\"\"" - , "for HDR in \"\" \"sys/types.h\" \"stdint.h\" \"stddef.h\"; do" - , " if [ -n \"$HDR\" ]; then INC=\"#include \\\"$HDR\\\"\"; fi" - , " for SIZE in \"$@\"; do" - , " SIZE=$(printf %.0f $SIZE)" - , " cat > test.$LANG << EOF" - , "$INC" - , "char __test[(sizeof($TYPE) == $SIZE) ? 1 : -1];" - , "EOF" - , " if $CC @$LANG.flags -c test.$LANG -I ./include 2>/dev/null; then" - , " DEFINE=\"#define $DEF $SIZE\"" - , " echo \"$DEFINE\n\" > out.def" - , " exit 0" - , " fi" - , " done" - , "done" - , "exit 1" - ] - } - } - ] - , [ "guard.def" - , { "type": "BLOB" - , "data": - { "type": "join" - , "separator": "\n" - , "$1": - [ { "type": "join" - , "separator": " " - , "$1": ["#ifndef", {"type": "var", "name": "guard"}] - } - , { "type": "join" - , "separator": " " - , "$1": ["#define", {"type": "var", "name": "guard"}] - } - , "\n\n" - ] - } - } - ] - , [ "plain.def" - , { "type": "BLOB" - , "data": - { "type": "join" - , "$1": - { "type": "foreach" - , "range": {"type": "var", "name": "defines", "default": []} - , "var": "pair" - , "body": - { "type": "let*" - , "bindings": - [ ["list", {"type": "var", "name": "pair"}] - , [ "def" - , { "type": "assert_non_empty" - , "msg": "Define name in 'defines' may not be empty" - , "$1": {"type": "CALL_EXPRESSION", "name": "first"} - } - ] - , ["val", {"type": "CALL_EXPRESSION", "name": "last"}] - ] - , "body": - { "type": "join" - , "separator": " " - , "$1": - { "type": "case*" - , "expr": {"type": "var", "name": "val"} - , "case": - [ [ null - , [ "/* #undef" - , {"type": "var", "name": "def"} - , "*/\n\n" - ] - ] - ] - , "default": - [ "#define" - , {"type": "var", "name": "def"} - , { "type": "join" - , "$1": [{"type": "var", "name": "val"}, "\n\n"] - } - ] - } - } - } - } - } - } - ] - , [ "int1.def" - , { "type": "BLOB" - , "data": - { "type": "join" - , "$1": - { "type": "foreach" - , "range": {"type": "var", "name": "defines1", "default": []} - , "var": "pair" - , "body": - { "type": "let*" - , "bindings": - [ ["list", {"type": "var", "name": "pair"}] - , [ "def" - , { "type": "assert_non_empty" - , "msg": "Define name in 'defines1' may not be empty" - , "$1": {"type": "CALL_EXPRESSION", "name": "first"} - } - ] - , ["val", {"type": "CALL_EXPRESSION", "name": "last"}] - ] - , "body": - { "type": "join" - , "separator": " " - , "$1": - { "type": "if" - , "cond": {"type": "var", "name": "val"} - , "then": - ["#define", {"type": "var", "name": "def"}, "1\n\n"] - , "else": - ["/* #undef", {"type": "var", "name": "def"}, "*/\n\n"] - } - } - } - } - } - } - ] - , [ "int01.def" - , { "type": "BLOB" - , "data": - { "type": "join" - , "$1": - { "type": "foreach" - , "range": {"type": "var", "name": "defines01", "default": []} - , "var": "pair" - , "body": - { "type": "let*" - , "bindings": - [ ["list", {"type": "var", "name": "pair"}] - , [ "def" - , { "type": "assert_non_empty" - , "msg": "Define name in 'defines01' may not be empty" - , "$1": {"type": "CALL_EXPRESSION", "name": "first"} - } - ] - , ["val", {"type": "CALL_EXPRESSION", "name": "last"}] - ] - , "body": - { "type": "join" - , "separator": " " - , "$1": - [ "#define" - , {"type": "var", "name": "def"} - , { "type": "if" - , "cond": {"type": "var", "name": "val"} - , "then": "1\n\n" - , "else": "0\n\n" - } - ] - } - } - } - } - } - ] - , [ "cfile-defs" - , { "type": "foreach" - , "range": {"type": "var", "name": "have_cfile", "default": []} - , "var": "pair" - , "body": - { "type": "let*" - , "bindings": - [ ["list", {"type": "var", "name": "pair"}] - , [ "def" - , { "type": "assert_non_empty" - , "msg": "Define name in 'have_cfile' may not be empty" - , "$1": {"type": "CALL_EXPRESSION", "name": "first"} - } - ] - , ["val", {"type": "CALL_EXPRESSION", "name": "last"}] - ] - , "body": - { "type": "lookup" - , "key": "out.def" - , "map": - { "type": "ACTION" - , "inputs": - { "type": "map_union" - , "$1": - [ {"type": "env", "vars": ["file_check.sh", "c.flags"]} - , {"type": "var", "name": "includes"} - ] - } - , "cmd": - [ "sh" - , "./file_check.sh" - , {"type": "var", "name": "CC"} - , "c" - , {"type": "var", "name": "def"} - , {"type": "var", "name": "val"} - ] - , "env": {"type": "var", "name": "ENV"} - , "outs": ["out.def"] - } - } - } - } - ] - , [ "cxxfile-defs" - , { "type": "foreach" - , "range": {"type": "var", "name": "have_cxxfile", "default": []} - , "var": "pair" - , "body": - { "type": "let*" - , "bindings": - [ ["list", {"type": "var", "name": "pair"}] - , [ "def" - , { "type": "assert_non_empty" - , "msg": "Define name in 'have_cxxfile' may not be empty" - , "$1": {"type": "CALL_EXPRESSION", "name": "first"} - } - ] - , ["val", {"type": "CALL_EXPRESSION", "name": "last"}] - ] - , "body": - { "type": "lookup" - , "key": "out.def" - , "map": - { "type": "ACTION" - , "inputs": - { "type": "map_union" - , "$1": - [ {"type": "env", "vars": ["file_check.sh", "cxx.flags"]} - , {"type": "var", "name": "includes"} - ] - } - , "cmd": - [ "sh" - , "./file_check.sh" - , {"type": "var", "name": "CXX"} - , "cxx" - , {"type": "var", "name": "def"} - , {"type": "var", "name": "val"} - ] - , "env": {"type": "var", "name": "ENV"} - , "outs": ["out.def"] - } - } - } - } - ] - , [ "ctype-defs" - , { "type": "foreach" - , "range": {"type": "var", "name": "have_ctype", "default": []} - , "var": "pair" - , "body": - { "type": "let*" - , "bindings": - [ ["list", {"type": "var", "name": "pair"}] - , [ "def" - , { "type": "assert_non_empty" - , "msg": "Define name in 'have_ctype' may not be empty" - , "$1": {"type": "CALL_EXPRESSION", "name": "first"} - } - ] - , ["type", {"type": "CALL_EXPRESSION", "name": "last"}] - ] - , "body": - { "type": "lookup" - , "key": "out.def" - , "map": - { "type": "ACTION" - , "inputs": - { "type": "map_union" - , "$1": - [ {"type": "env", "vars": ["type_check.sh", "c.flags"]} - , {"type": "var", "name": "includes"} - ] - } - , "cmd": - [ "sh" - , "./type_check.sh" - , {"type": "var", "name": "CC"} - , "c" - , {"type": "var", "name": "def"} - , {"type": "var", "name": "type"} - ] - , "env": {"type": "var", "name": "ENV"} - , "outs": ["out.def"] - } - } - } - } - ] - , [ "cxxtype-defs" - , { "type": "foreach" - , "range": {"type": "var", "name": "have_cxxtype", "default": []} - , "var": "pair" - , "body": - { "type": "let*" - , "bindings": - [ ["list", {"type": "var", "name": "pair"}] - , [ "def" - , { "type": "assert_non_empty" - , "msg": "Define name in 'have_cxxtype' may not be empty" - , "$1": {"type": "CALL_EXPRESSION", "name": "first"} - } - ] - , ["type", {"type": "CALL_EXPRESSION", "name": "last"}] - ] - , "body": - { "type": "lookup" - , "key": "out.def" - , "map": - { "type": "ACTION" - , "inputs": - { "type": "map_union" - , "$1": - [ {"type": "env", "vars": ["type_check.sh", "cxx.flags"]} - , {"type": "var", "name": "includes"} - ] - } - , "cmd": - [ "sh" - , "./type_check.sh" - , {"type": "var", "name": "CXX"} - , "cxx" - , {"type": "var", "name": "def"} - , {"type": "var", "name": "type"} - ] - , "env": {"type": "var", "name": "ENV"} - , "outs": ["out.def"] - } - } - } - } - ] - , [ "csymbol-defs" - , { "type": "foreach" - , "range": {"type": "var", "name": "have_csymbol", "default": []} - , "var": "pair" - , "body": - { "type": "let*" - , "bindings": - [ ["list", {"type": "var", "name": "pair"}] - , [ "def" - , { "type": "assert_non_empty" - , "msg": "Define name in 'have_csymbol' may not be empty" - , "$1": {"type": "CALL_EXPRESSION", "name": "first"} - } - ] - , ["list", {"type": "CALL_EXPRESSION", "name": "last"}] - , ["sym", {"type": "CALL_EXPRESSION", "name": "first"}] - , ["hdrs", {"type": "CALL_EXPRESSION", "name": "last"}] - ] - , "body": - { "type": "lookup" - , "key": "out.def" - , "map": - { "type": "ACTION" - , "inputs": - { "type": "map_union" - , "$1": - [ {"type": "env", "vars": ["symbol_check.sh", "c.flags"]} - , {"type": "var", "name": "includes"} - ] - } - , "cmd": - { "type": "++" - , "$1": - [ [ "sh" - , "./symbol_check.sh" - , {"type": "var", "name": "CC"} - , "c" - , {"type": "var", "name": "def"} - , {"type": "var", "name": "sym"} - ] - , {"type": "var", "name": "hdrs"} - ] - } - , "env": {"type": "var", "name": "ENV"} - , "outs": ["out.def"] - } - } - } - } - ] - , [ "cxxsymbol-defs" - , { "type": "foreach" - , "range": {"type": "var", "name": "have_cxxsymbol", "default": []} - , "var": "pair" - , "body": - { "type": "let*" - , "bindings": - [ ["list", {"type": "var", "name": "pair"}] - , [ "def" - , { "type": "assert_non_empty" - , "msg": "Define name in 'have_cxxsymbol' may not be empty" - , "$1": {"type": "CALL_EXPRESSION", "name": "first"} - } - ] - , ["list", {"type": "CALL_EXPRESSION", "name": "last"}] - , ["sym", {"type": "CALL_EXPRESSION", "name": "first"}] - , ["hdrs", {"type": "CALL_EXPRESSION", "name": "last"}] - ] - , "body": - { "type": "lookup" - , "key": "out.def" - , "map": - { "type": "ACTION" - , "inputs": - { "type": "map_union" - , "$1": - [ {"type": "env", "vars": ["symbol_check.sh", "cxx.flags"]} - , {"type": "var", "name": "includes"} - ] - } - , "cmd": - { "type": "++" - , "$1": - [ [ "sh" - , "./symbol_check.sh" - , {"type": "var", "name": "CXX"} - , "cxx" - , {"type": "var", "name": "def"} - , {"type": "var", "name": "sym"} - ] - , {"type": "var", "name": "hdrs"} - ] - } - , "env": {"type": "var", "name": "ENV"} - , "outs": ["out.def"] - } - } - } - } - ] - , [ "csize-defs" - , { "type": "foreach" - , "range": {"type": "var", "name": "size_ctype", "default": []} - , "var": "pair" - , "body": - { "type": "let*" - , "bindings": - [ ["list", {"type": "var", "name": "pair"}] - , [ "def" - , { "type": "assert_non_empty" - , "msg": "Define name in 'size_ctype' may not be empty" - , "$1": {"type": "CALL_EXPRESSION", "name": "first"} - } - ] - , ["list", {"type": "CALL_EXPRESSION", "name": "last"}] - , ["type", {"type": "CALL_EXPRESSION", "name": "first"}] - , ["sizes", {"type": "CALL_EXPRESSION", "name": "last"}] - ] - , "body": - { "type": "lookup" - , "key": "out.def" - , "map": - { "type": "ACTION" - , "inputs": - { "type": "map_union" - , "$1": - [ {"type": "env", "vars": ["size_check.sh", "c.flags"]} - , {"type": "var", "name": "includes"} - ] - } - , "cmd": - { "type": "++" - , "$1": - [ [ "sh" - , "./size_check.sh" - , {"type": "var", "name": "CC"} - , "c" - , {"type": "var", "name": "def"} - , {"type": "var", "name": "type"} - ] - , { "type": "foreach" - , "var": "size" - , "range": {"type": "var", "name": "sizes"} - , "body": - { "type": "json_encode" - , "$1": {"type": "var", "name": "size"} - } - } - ] - } - , "env": {"type": "var", "name": "ENV"} - , "outs": ["out.def"] - } - } - } - } - ] - , [ "cxxsize-defs" - , { "type": "foreach" - , "range": {"type": "var", "name": "size_cxxtype", "default": []} - , "var": "pair" - , "body": - { "type": "let*" - , "bindings": - [ ["list", {"type": "var", "name": "pair"}] - , [ "def" - , { "type": "assert_non_empty" - , "msg": "Define name in 'size_cxxtype' may not be empty" - , "$1": {"type": "CALL_EXPRESSION", "name": "first"} - } - ] - , ["list", {"type": "CALL_EXPRESSION", "name": "last"}] - , ["type", {"type": "CALL_EXPRESSION", "name": "first"}] - , ["sizes", {"type": "CALL_EXPRESSION", "name": "last"}] - ] - , "body": - { "type": "lookup" - , "key": "out.def" - , "map": - { "type": "ACTION" - , "inputs": - { "type": "map_union" - , "$1": - [ {"type": "env", "vars": ["size_check.sh", "cxx.flags"]} - , {"type": "var", "name": "includes"} - ] - } - , "cmd": - { "type": "++" - , "$1": - [ [ "sh" - , "./size_check.sh" - , {"type": "var", "name": "CXX"} - , "cxx" - , {"type": "var", "name": "def"} - , {"type": "var", "name": "type"} - ] - , { "type": "foreach" - , "var": "size" - , "range": {"type": "var", "name": "sizes"} - , "body": - { "type": "json_encode" - , "$1": {"type": "var", "name": "size"} - } - } - ] - } - , "env": {"type": "var", "name": "ENV"} - , "outs": ["out.def"] - } - } - } - } - ] - , ["end.def", {"type": "BLOB", "data": "\n#endif\n"}] - , [ "definitions" - , { "type": "enumerate" - , "$1": - { "type": "++" - , "$1": - [ [ {"type": "var", "name": "guard.def"} - , {"type": "var", "name": "int1.def"} - , {"type": "var", "name": "int01.def"} - ] - , {"type": "var", "name": "cfile-defs"} - , {"type": "var", "name": "cxxfile-defs"} - , {"type": "var", "name": "ctype-defs"} - , {"type": "var", "name": "cxxtype-defs"} - , {"type": "var", "name": "csymbol-defs"} - , {"type": "var", "name": "cxxsymbol-defs"} - , {"type": "var", "name": "csize-defs"} - , {"type": "var", "name": "cxxsize-defs"} - , [ {"type": "var", "name": "plain.def"} - , {"type": "var", "name": "end.def"} - ] - ] - } - } - ] - , [ "outfile" - , { "type": "ACTION" - , "inputs": {"type": "var", "name": "definitions"} - , "cmd": - [ "sh" - , "-c" - , { "type": "join" - , "separator": " " - , "$1": - [ "cat" - , { "type": "join_cmd" - , "$1": - { "type": "keys" - , "$1": {"type": "var", "name": "definitions"} - } - } - , "> out" - ] - } - ] - , "outs": ["out"] - , "env": {"type": "var", "name": "ENV"} - } - ] - , [ "outfile" - , { "type": "to_subdir" - , "subdir": {"type": "var", "name": "stage"} - , "$1": - { "type": "singleton_map" - , "key": {"type": "var", "name": "name"} - , "value": - { "type": "lookup" - , "key": "out" - , "map": {"type": "var", "name": "outfile"} - } - } - } - ] - ] - , "body": - { "type": "RESULT" - , "artifacts": {"type": "var", "name": "outfile"} - , "runfiles": {"type": "var", "name": "outfile"} - } - } - } -, "config_file": - { "doc": - [ "Generate a C/C++ config header from a given template" - , "" - , "Generate a C/C++ configuration header using defines specified via the" - , "target configuration. In the usual case, a target using this rule is" - , "configured by depending on it from a target that uses the built-in" - , "\"configure\" rule." - ] - , "field_doc": - { "output": - [ "Name of the header file to generate (incl. file name ext). Components are joined with /." - ] - , "input": ["The input configuration file, used as template."] - , "magic_string": - [ "The magic string (e.g., \"cmakedefine\") which identifies in which line" - , "we have to \"#define\" or \"#undef\" variables according to what is" - , "defined in the config field \"defines\"." - ] - , "@only": ["If set, only replace @VAR@ and not ${VAR}"] - } - , "config_doc": - { "defines": - [ "Set a define to a specific value unless its value is \"null\". Must" - , "contain a list of pairs. The first element of each pair is the define" - , "name and the second argument is the value to set. Strings must be" - , "properly escaped. Defines generated from this field are added last," - , "so that they can refer to defines from other \"defines*\" values." - ] - } - , "string_fields": ["magic_string", "@only", "output"] - , "target_fields": ["input"] - , "config_vars": ["defines"] - , "imports": - { "first": "first_list_entry" - , "last": "last_list_entry" - , "stage_singleton_field": ["", "stage_singleton_field"] - } - , "implicit": {"runner": ["config_runner.py"]} - , "expression": - { "type": "let*" - , "bindings": - [ [ "runner" - , { "type": "let*" - , "bindings": [["fieldname", "runner"], ["location", "runner"]] - , "body": - {"type": "CALL_EXPRESSION", "name": "stage_singleton_field"} - } - ] - , [ "dict-defines" - , { "type": "map_union" - , "$1": - { "type": "foreach" - , "range": {"type": "var", "name": "defines", "default": []} - , "var": "pair" - , "body": - { "type": "let*" - , "bindings": - [ ["list", {"type": "var", "name": "pair"}] - , ["key", {"type": "CALL_EXPRESSION", "name": "first"}] - , ["val", {"type": "CALL_EXPRESSION", "name": "last"}] - ] - , "body": - { "type": "singleton_map" - , "key": {"type": "var", "name": "key"} - , "value": {"type": "var", "name": "val"} - } - } - } - } - ] - , [ "magic_string" - , { "type": "assert_non_empty" - , "msg": "A non-empty string has to be provided for magic_string" - , "$1": - {"type": "join", "$1": {"type": "FIELD", "name": "magic_string"}} - } - ] - , [ "@only" - , { "type": "if" - , "cond": {"type": "FIELD", "name": "@only"} - , "then": "true" - , "else": "false" - } - ] - , [ "param-blob" - , { "type": "singleton_map" - , "key": "param-file" - , "value": - { "type": "BLOB" - , "data": - { "type": "json_encode" - , "$1": {"type": "var", "name": "dict-defines"} - } - } - } - ] - , [ "input-blob" - , { "type": "let*" - , "bindings": [["fieldname", "input"], ["location", "input-file"]] - , "body": - {"type": "CALL_EXPRESSION", "name": "stage_singleton_field"} - } - ] - , [ "outfile" - , { "type": "ACTION" - , "inputs": - { "type": "map_union" - , "$1": - [ {"type": "var", "name": "param-blob"} - , {"type": "var", "name": "input-blob"} - , {"type": "var", "name": "runner"} - ] - } - , "cmd": - [ "./runner" - , "input-file" - , "param-file" - , {"type": "var", "name": "magic_string"} - , {"type": "var", "name": "@only"} - ] - , "outs": ["out"] - } - ] - , [ "outfile" - , { "type": "singleton_map" - , "key": - { "type": "join" - , "separator": "/" - , "$1": {"type": "FIELD", "name": "output"} - } - , "value": - { "type": "lookup" - , "key": "out" - , "map": {"type": "var", "name": "outfile"} - } - } - ] - ] - , "body": - { "type": "RESULT" - , "artifacts": {"type": "var", "name": "outfile"} - , "runfiles": {"type": "var", "name": "outfile"} - } - } - } -} diff --git a/CC/auto/config_runner.py b/CC/auto/config_runner.py deleted file mode 100755 index f938c27..0000000 --- a/CC/auto/config_runner.py +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/python3 - -# Copyright 2022 Huawei Cloud Computing Technology Co., Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import json -import re -from sys import argv -from re import sub, match - -input_file = argv[1] -param_file = argv[2] -magic_string = argv[3] -at_only = argv[4] == "true" - - -with open(param_file) as f: - param = json.loads(f.read()) - -# In many cases, CMake simply defines some variables (without any associated -# value). We handle this situation by assigning to the boolean True the empty -# string. Note that no False value should be found, because the right way to set -# a variable to False in the TARGETS file is to *do not mention* that variable -# at all. -for k, v in param.items(): - if isinstance(v, bool): - param[k] = "" - -with open(input_file) as i: - with open("out", "w") as o: - for line in i.readlines(): - if x := re.search( - r"#(.*)(" + magic_string + r" )([ \t]*)([a-zA-Z0-9_]+)", line - ): - # get the VAR - key = x.groups()[-1] - if key in param: - line = sub( - f"{x.group()[1:]}", - f"{x.groups()[0]}define {x.groups()[2]}{key} {param[key]}", - line, - ) - else: - line = f"/* #undef {x.groups()[-1]} */\n" - if x := re.search( - r"#(.*)(" + magic_string + "01 )([ \t]*)([a-zA-Z0-9_]+)", line - ): - # get the VAR - key = x.groups()[-1] - line = sub( - f"{x.group()[1:]}", - f"{x.groups()[0]}define {x.groups()[2]}{key} " - + str(1 if key in param else 0), - line, - ) - if match("#[ \t]*define", line): - if x := re.search(r"@([a-zA-Z0-9-_]+)@", line): - key = x.groups()[0] - line = sub(x.group(), param.get(key, ""), line) - if not at_only: - if x := re.search(r"\${([a-zA-Z0-9-_]+)}", line): - key = x.groups()[0] - line = sub(r"\${" + key + r"}", param.get(key, ""), line) - - print(line, end="", file=o) diff --git a/CC/proto/EXPRESSIONS b/CC/proto/EXPRESSIONS deleted file mode 100644 index 1ab17a5..0000000 --- a/CC/proto/EXPRESSIONS +++ /dev/null @@ -1,308 +0,0 @@ -{ "protoc-deps": - { "imports": {"map_provider": ["./", "../..", "field_map_provider"]} - , "expression": - { "type": "let*" - , "bindings": [["fieldname", "deps"], ["provider", "protoc-deps"]] - , "body": {"type": "CALL_EXPRESSION", "name": "map_provider"} - } - } -, "protoc-compile": - { "vars": - [ "CXX" - , "CXXFLAGS" - , "ADD_CXXFLAGS" - , "AR" - , "ENV" - , "name" - , "stage" - , "service support" - , "deps-transition" - , "public-fieldnames" - , "private-fieldnames" - ] - , "imports": - { "stage": ["", "stage_singleton_field"] - , "result": ["./", "..", "lib result"] - , "artifacts": ["./", "../..", "field_artifacts"] - , "artifacts_list": ["./", "../..", "field_artifacts_list"] - , "protoc-deps": "protoc-deps" - } - , "expression": - { "type": "let*" - , "bindings": - [ ["pure C", false] - , [ "protoc" - , { "type": "let*" - , "bindings": - [ ["fieldname", "protoc"] - , ["transition", {"type": "var", "name": "deps-transition"}] - , ["location", "protoc"] - ] - , "body": {"type": "CALL_EXPRESSION", "name": "stage"} - } - ] - , [ "grpc_cpp_plugin" - , { "type": "if" - , "cond": {"type": "var", "name": "service support"} - , "then": - { "type": "let*" - , "bindings": - [ ["fieldname", "grpc_cpp_plugin"] - , ["transition", {"type": "var", "name": "deps-transition"}] - , ["location", "grpc_cpp_plugin"] - ] - , "body": {"type": "CALL_EXPRESSION", "name": "stage"} - } - , "else": {"type": "empty_map"} - } - ] - , ["protoc-deps", {"type": "CALL_EXPRESSION", "name": "protoc-deps"}] - , [ "proto deps" - , { "type": "to_subdir" - , "subdir": "work" - , "$1": - { "type": "let*" - , "bindings": [["fieldname", "well_known_protos"]] - , "body": {"type": "CALL_EXPRESSION", "name": "artifacts"} - } - } - ] - , [ "proto srcs" - , { "type": "disjoint_map_union" - , "msg": "Sources may not conflict" - , "$1": - { "type": "let*" - , "bindings": [["fieldname", "srcs"]] - , "body": {"type": "CALL_EXPRESSION", "name": "artifacts_list"} - } - } - ] - , [ "all proto srcs" - , { "type": "disjoint_map_union" - , "msg": "Conflict with proto files of dependencies" - , "$1": - [ {"type": "var", "name": "protoc-deps"} - , {"type": "var", "name": "proto srcs"} - ] - } - ] - , [ "staged srcs" - , { "type": "to_subdir" - , "subdir": "work" - , "$1": {"type": "var", "name": "proto srcs"} - } - ] - , [ "staged all proto srcs" - , { "type": "to_subdir" - , "subdir": "work" - , "$1": {"type": "var", "name": "all proto srcs"} - } - ] - , [ "outs" - , { "type": "++" - , "$1": - { "type": "foreach" - , "var": "f" - , "range": - {"type": "keys", "$1": {"type": "var", "name": "staged srcs"}} - , "body": - { "type": "++" - , "$1": - [ [ { "type": "change_ending" - , "$1": {"type": "var", "name": "f"} - , "ending": ".pb.h" - } - , { "type": "change_ending" - , "$1": {"type": "var", "name": "f"} - , "ending": ".pb.cc" - } - ] - , { "type": "if" - , "cond": {"type": "var", "name": "service support"} - , "then": - [ { "type": "change_ending" - , "$1": {"type": "var", "name": "f"} - , "ending": ".grpc.pb.h" - } - , { "type": "change_ending" - , "$1": {"type": "var", "name": "f"} - , "ending": ".grpc.pb.cc" - } - ] - , "else": [] - } - ] - } - } - } - ] - , [ "cmd" - , { "type": "++" - , "$1": - [ ["./protoc", "--proto_path=work", "--cpp_out=work"] - , { "type": "if" - , "cond": {"type": "var", "name": "service support"} - , "then": - [ "--grpc_out=work" - , "--plugin=protoc-gen-grpc=./grpc_cpp_plugin" - ] - , "else": [] - } - , {"type": "keys", "$1": {"type": "var", "name": "staged srcs"}} - ] - } - ] - , [ "generated" - , { "type": "ACTION" - , "inputs": - { "type": "map_union" - , "$1": - [ {"type": "var", "name": "staged all proto srcs"} - , {"type": "var", "name": "protoc"} - , {"type": "var", "name": "grpc_cpp_plugin"} - , {"type": "var", "name": "proto deps"} - ] - } - , "outs": {"type": "var", "name": "outs"} - , "cmd": {"type": "var", "name": "cmd"} - } - ] - , [ "srcs" - , { "type": "map_union" - , "$1": - { "type": "foreach" - , "var": "name" - , "range": - {"type": "keys", "$1": {"type": "var", "name": "proto srcs"}} - , "body": - { "type": "map_union" - , "$1": - [ { "type": "singleton_map" - , "key": - { "type": "change_ending" - , "$1": {"type": "var", "name": "name"} - , "ending": ".pb.cc" - } - , "value": - { "type": "lookup" - , "map": {"type": "var", "name": "generated"} - , "key": - { "type": "join" - , "$1": - [ "work/" - , { "type": "change_ending" - , "$1": {"type": "var", "name": "name"} - , "ending": ".pb.cc" - } - ] - } - } - } - , { "type": "if" - , "cond": {"type": "var", "name": "service support"} - , "then": - { "type": "singleton_map" - , "key": - { "type": "change_ending" - , "$1": {"type": "var", "name": "name"} - , "ending": ".grpc.pb.cc" - } - , "value": - { "type": "lookup" - , "map": {"type": "var", "name": "generated"} - , "key": - { "type": "join" - , "$1": - [ "work/" - , { "type": "change_ending" - , "$1": {"type": "var", "name": "name"} - , "ending": ".grpc.pb.cc" - } - ] - } - } - } - , "else": {"type": "empty_map"} - } - ] - } - } - } - ] - , [ "hdrs" - , { "type": "map_union" - , "$1": - { "type": "foreach" - , "var": "name" - , "range": - {"type": "keys", "$1": {"type": "var", "name": "proto srcs"}} - , "body": - { "type": "map_union" - , "$1": - [ { "type": "singleton_map" - , "key": - { "type": "change_ending" - , "$1": {"type": "var", "name": "name"} - , "ending": ".pb.h" - } - , "value": - { "type": "lookup" - , "map": {"type": "var", "name": "generated"} - , "key": - { "type": "join" - , "$1": - [ "work/" - , { "type": "change_ending" - , "$1": {"type": "var", "name": "name"} - , "ending": ".pb.h" - } - ] - } - } - } - , { "type": "if" - , "cond": {"type": "var", "name": "service support"} - , "then": - { "type": "singleton_map" - , "key": - { "type": "change_ending" - , "$1": {"type": "var", "name": "name"} - , "ending": ".grpc.pb.h" - } - , "value": - { "type": "lookup" - , "map": {"type": "var", "name": "generated"} - , "key": - { "type": "join" - , "$1": - [ "work/" - , { "type": "change_ending" - , "$1": {"type": "var", "name": "name"} - , "ending": ".grpc.pb.h" - } - ] - } - } - } - , "else": {"type": "empty_map"} - } - ] - } - } - } - ] - , ["private-hdrs", {"type": "empty_map"}] - , [ "extra-provides" - , { "type": "singleton_map" - , "key": "protoc-deps" - , "value": {"type": "var", "name": "all proto srcs"} - } - ] - , ["cflags", []] - , ["private-cflags", ["-Wno-sign-conversion", "-Wno-unused-function"]] - , ["private-ldflags", []] - ] - , "body": {"type": "CALL_EXPRESSION", "name": "result"} - } - } -} diff --git a/CC/proto/RULES b/CC/proto/RULES deleted file mode 100644 index af484b0..0000000 --- a/CC/proto/RULES +++ /dev/null @@ -1,94 +0,0 @@ -{ "library": - { "doc": - [ "A library C++ library, generated from proto files." - , "" - , "This rule usually is used to bind anonymous targets generated from" - , "proto libraries." - ] - , "string_fields": ["name", "stage"] - , "target_fields": ["srcs", "deps"] - , "config_vars": - ["OS", "ARCH", "HOST_ARCH", "CXX", "CFLAGS", "ADD_CFLAGS", "AR", "ENV"] - , "implicit": - { "protoc": [["@", "protoc", "", "protoc"]] - , "defaults": [["./", "..", "defaults"]] - , "proto-deps": [["@", "protoc", "", "C++ runtime"]] - , "well_known_protos": [["@", "protoc", "", "well_known_protos"]] - } - , "imports": - { "protoc-compile": "protoc-compile" - , "host transition": ["transitions", "for host"] - } - , "config_transitions": - {"protoc": [{"type": "CALL_EXPRESSION", "name": "host transition"}]} - , "expression": - { "type": "let*" - , "bindings": - [ ["name", {"type": "join", "$1": {"type": "FIELD", "name": "name"}}] - , [ "stage" - , { "type": "join" - , "separator": "/" - , "$1": {"type": "FIELD", "name": "stage"} - } - ] - , [ "deps-transition" - , {"type": "CALL_EXPRESSION", "name": "host transition"} - ] - , ["public-fieldnames", ["deps", "proto-deps"]] - , ["private-fieldnames", ["deps", "proto-deps"]] - ] - , "body": {"type": "CALL_EXPRESSION", "name": "protoc-compile"} - } - } -, "service library": - { "doc": - [ "A service library C++ library, generated from proto files." - , "" - , "Calls protoc with gRPC plugin to additionally generate gRPC services" - , "from proto libraries." - ] - , "string_fields": ["name", "stage"] - , "target_fields": ["srcs", "deps"] - , "config_vars": - ["OS", "ARCH", "HOST_ARCH", "CXX", "CXXFLAGS", "ADD_CXXFLAGS", "AR", "ENV"] - , "implicit": - { "protoc": [["@", "protoc", "", "protoc"]] - , "grpc_cpp_plugin": [["@", "grpc", "src/compiler", "grpc_cpp_plugin"]] - , "defaults": [["./", "..", "defaults"]] - , "proto-deps": - [ ["@", "grpc", "", "grpc++_codegen_proto"] - , ["@", "grpc", "", "grpc++_codegen_base_src"] - , ["@", "protoc", "", "C++ runtime"] - ] - , "well_known_protos": [["@", "protoc", "", "well_known_protos"]] - } - , "imports": - { "protoc-compile": "protoc-compile" - , "host transition": ["transitions", "for host"] - } - , "config_transitions": - { "protoc": [{"type": "CALL_EXPRESSION", "name": "host transition"}] - , "grpc_cpp_plugin": - [{"type": "CALL_EXPRESSION", "name": "host transition"}] - } - , "expression": - { "type": "let*" - , "bindings": - [ ["service support", true] - , ["name", {"type": "join", "$1": {"type": "FIELD", "name": "name"}}] - , [ "stage" - , { "type": "join" - , "separator": "/" - , "$1": {"type": "FIELD", "name": "stage"} - } - ] - , [ "deps-transition" - , {"type": "CALL_EXPRESSION", "name": "host transition"} - ] - , ["public-fieldnames", ["deps", "proto-deps"]] - , ["private-fieldnames", ["deps", "proto-deps"]] - ] - , "body": {"type": "CALL_EXPRESSION", "name": "protoc-compile"} - } - } -} diff --git a/CC/test/RULES b/CC/test/RULES deleted file mode 100644 index 3821339..0000000 --- a/CC/test/RULES +++ /dev/null @@ -1,311 +0,0 @@ -{ "test": - { "doc": ["A test written in C++"] - , "tainted": ["test"] - , "target_fields": ["srcs", "private-hdrs", "private-deps", "data"] - , "string_fields": - [ "name" - , "args" - , "stage" - , "pure C" - , "private-defines" - , "private-cflags" - , "private-ldflags" - ] - , "config_vars": - [ "ARCH" - , "HOST_ARCH" - , "CC" - , "CXX" - , "CFLAGS" - , "CXXFLAGS" - , "ADD_CFLAGS" - , "ADD_CXXFLAGS" - , "ENV" - , "TEST_ENV" - , "CC_TEST_LAUNCHER" - ] - , "implicit": - {"defaults": [["./", "..", "defaults"]], "runner": ["test_runner.py"]} - , "field_doc": - { "name": - [ "The name of the test" - , "" - , "Used to name the test binary as well as for staging the test result" - ] - , "args": ["Command line arguments for the test binary"] - , "srcs": ["The sources of the test binary"] - , "private-hdrs": - [ "Any additional header files that need to be present when compiling" - , "the test binary." - ] - , "private-defines": - [ "List of defines set for source files local to this target." - , "Each list entry will be prepended by \"-D\"." - ] - , "private-cflags": - ["List of compile flags set for source files local to this target."] - , "private-ldflags": - [ "Additional linker flags for linking external libraries (not built" - , "by this tool, typically system libraries)." - ] - , "stage": - [ "The logical location of all header and source files." - , "Individual directory components are joined with \"/\"." - ] - , "data": ["Any files the test binary needs access to when running"] - } - , "config_doc": - { "CC": ["The name of the C compiler to be used."] - , "CXX": ["The name of the C++ compiler to be used."] - , "CFLAGS": - [ "The flags for CC to be used instead of the default ones" - , "taken from the [\"CC\", \"defaults\"] target" - ] - , "CXXFLAGS": - [ "The flags for CXX to be used instead of the default ones" - , "taken from the [\"CC\", \"defaults\"] target" - ] - , "ADD_CFLAGS": - [ "The flags to add to the default ones for CC" - , "taken from the [\"CC\", \"defaults\"] target" - ] - , "ADD_CXXFLAGS": - [ "The flags to add to the default ones for CXX" - , "taken from the [\"CC\", \"defaults\"] target" - ] - , "ENV": ["The environment for any action generated."] - , "TEST_ENV": ["The environment for executing the test runner."] - , "CC_TEST_LAUNCHER": - [ "List of strings representing the launcher that is prepend to the" - , "command line for running the test binary." - ] - } - , "artifacts_doc": - [ "result: the result of this test (\"PASS\" or \"FAIL\"); useful for" - , " generating test reports." - , "stdout/stderr: Any output the invocation of the test binary produced on" - , " the respective file descriptor" - , "time-start/time-stop: The time (decimally coded) in seconds since the" - , " epoch when the test invocation started and ended." - ] - , "runfiles_doc": - [ "A tree consisting of the artifacts staged at the name of the test." - , "As the built-in \"install\" rule only takes the runfiles of its" - , "\"private-deps\" argument, this gives an easy way of defining test" - , "suites." - ] - , "imports": - { "artifacts": ["./", "../..", "field_artifacts"] - , "runfiles": ["./", "../..", "field_runfiles"] - , "compile-deps": ["./", "..", "compile-deps"] - , "compile-args-deps": ["./", "..", "compile-args-deps"] - , "link-deps": ["./", "..", "link-deps"] - , "link-args-deps": ["./", "..", "link-args-deps"] - , "binary": ["./", "..", "bin artifact"] - , "host transition": ["transitions", "for host"] - } - , "config_transitions": - { "defaults": [{"type": "CALL_EXPRESSION", "name": "host transition"}] - , "private-deps": [{"type": "CALL_EXPRESSION", "name": "host transition"}] - , "data": [{"type": "CALL_EXPRESSION", "name": "host transition"}] - } - , "expression": - { "type": "let*" - , "bindings": - [ [ "name" - , { "type": "assert_non_empty" - , "msg": "A non-empty name has to be provided for binaries" - , "$1": {"type": "join", "$1": {"type": "FIELD", "name": "name"}} - } - ] - , ["pure C", {"type": "FIELD", "name": "pure C"}] - , [ "stage" - , { "type": "join" - , "separator": "/" - , "$1": {"type": "FIELD", "name": "stage"} - } - ] - , [ "srcs" - , { "type": "to_subdir" - , "subdir": {"type": "var", "name": "stage"} - , "$1": - { "type": "let*" - , "bindings": [["fieldname", "srcs"]] - , "body": {"type": "CALL_EXPRESSION", "name": "artifacts"} - } - } - ] - , [ "private-hdrs" - , { "type": "to_subdir" - , "subdir": {"type": "var", "name": "stage"} - , "$1": - { "type": "let*" - , "bindings": [["fieldname", "private-hdrs"]] - , "body": {"type": "CALL_EXPRESSION", "name": "artifacts"} - } - } - ] - , ["host-trans", {"type": "CALL_EXPRESSION", "name": "host transition"}] - , ["defaults-transition", {"type": "var", "name": "host-trans"}] - , ["deps-transition", {"type": "var", "name": "host-trans"}] - , ["deps-fieldnames", ["private-deps"]] - , ["compile-deps", {"type": "CALL_EXPRESSION", "name": "compile-deps"}] - , [ "compile-args" - , { "type": "++" - , "$1": - [ { "type": "foreach" - , "var": "def" - , "range": {"type": "FIELD", "name": "private-defines"} - , "body": - {"type": "join", "$1": ["-D", {"type": "var", "name": "def"}]} - } - , {"type": "FIELD", "name": "private-cflags"} - , {"type": "CALL_EXPRESSION", "name": "compile-args-deps"} - ] - } - ] - , ["link-deps", {"type": "CALL_EXPRESSION", "name": "link-deps"}] - , [ "link-args" - , { "type": "++" - , "$1": - [ {"type": "CALL_EXPRESSION", "name": "link-args-deps"} - , {"type": "FIELD", "name": "private-ldflags"} - ] - } - ] - , ["binary", {"type": "CALL_EXPRESSION", "name": "binary"}] - , [ "staged test binary" - , { "type": "map_union" - , "$1": - { "type": "foreach_map" - , "range": {"type": "var", "name": "binary"} - , "var_val": "binary" - , "body": - { "type": "singleton_map" - , "key": "test" - , "value": {"type": "var", "name": "binary"} - } - } - } - ] - , [ "runner" - , { "type": "map_union" - , "$1": - { "type": "foreach" - , "var": "runner" - , "range": {"type": "FIELD", "name": "runner"} - , "body": - { "type": "map_union" - , "$1": - { "type": "foreach" - , "var": "runner" - , "range": - { "type": "values" - , "$1": - { "type": "DEP_ARTIFACTS" - , "dep": {"type": "var", "name": "runner"} - } - } - , "body": - { "type": "singleton_map" - , "key": "runner" - , "value": {"type": "var", "name": "runner"} - } - } - } - } - } - ] - , [ "test-args" - , { "type": "singleton_map" - , "key": "test-args.json" - , "value": - { "type": "BLOB" - , "data": - { "type": "json_encode" - , "$1": {"type": "FIELD", "name": "args", "default": []} - } - } - } - ] - , [ "test-launcher" - , { "type": "singleton_map" - , "key": "test-launcher.json" - , "value": - { "type": "BLOB" - , "data": - { "type": "json_encode" - , "$1": - {"type": "var", "name": "CC_TEST_LAUNCHER", "default": []} - } - } - } - ] - , [ "data" - , { "type": "let*" - , "bindings": - [ ["fieldname", "data"] - , ["transition", {"type": "var", "name": "deps-transition"}] - ] - , "body": - { "type": "map_union" - , "$1": - [ {"type": "CALL_EXPRESSION", "name": "runfiles"} - , {"type": "CALL_EXPRESSION", "name": "artifacts"} - ] - } - } - ] - , [ "test-name" - , { "type": "join" - , "separator": "/" - , "$1": - [{"type": "var", "name": "stage"}, {"type": "var", "name": "name"}] - } - ] - , [ "test-results" - , { "type": "ACTION" - , "outs": ["result", "stdout", "stderr", "time-start", "time-stop"] - , "inputs": - { "type": "map_union" - , "$1": - [ { "type": "to_subdir" - , "subdir": "work" - , "$1": {"type": "var", "name": "data"} - } - , {"type": "var", "name": "runner"} - , {"type": "var", "name": "test-args"} - , {"type": "var", "name": "test-launcher"} - , {"type": "var", "name": "staged test binary"} - ] - } - , "cmd": ["./runner"] - , "env": - { "type": "var" - , "name": "TEST_ENV" - , "default": {"type": "empty_map"} - } - , "may_fail": ["test"] - , "fail_message": - { "type": "join" - , "$1": - ["CC test ", {"type": "var", "name": "test-name"}, " failed"] - } - } - ] - , [ "runfiles" - , { "type": "singleton_map" - , "key": {"type": "var", "name": "name"} - , "value": - {"type": "TREE", "$1": {"type": "var", "name": "test-results"}} - } - ] - ] - , "body": - { "type": "RESULT" - , "artifacts": {"type": "var", "name": "test-results"} - , "runfiles": {"type": "var", "name": "runfiles"} - } - } - } -} diff --git a/CC/test/TARGETS b/CC/test/TARGETS deleted file mode 100644 index 0967ef4..0000000 --- a/CC/test/TARGETS +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/CC/test/test_runner.py b/CC/test/test_runner.py deleted file mode 100755 index 0647621..0000000 --- a/CC/test/test_runner.py +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/env python3 -# Copyright 2022 Huawei Cloud Computing Technology Co., Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import json -import os -import subprocess -import time - -time_start = time.time() -time_stop = 0 -result = "UNKNOWN" -stderr = "" -stdout = "" - - -def dump_results(): - with open("result", "w") as f: - f.write("%s\n" % (result, )) - with open("time-start", "w") as f: - f.write("%d\n" % (time_start, )) - with open("time-stop", "w") as f: - f.write("%d\n" % (time_stop, )) - with open("stdout", "w") as f: - f.write("%s\n" % (stdout, )) - with open("stderr", "w") as f: - f.write("%s\n" % (stderr, )) - - -dump_results() - -TEMP_DIR = os.path.realpath("scratch") -os.makedirs(TEMP_DIR, exist_ok=True) - -WORK_DIR = os.path.realpath("work") -os.makedirs(WORK_DIR, exist_ok=True) - -ENV = dict(os.environ, TEST_TMPDIR=TEMP_DIR) - -with open('test-launcher.json') as f: - test_launcher = json.load(f) - -with open('test-args.json') as f: - test_args = json.load(f) - -ret = subprocess.run(test_launcher + ["../test"] + test_args, - cwd=WORK_DIR, - env=ENV, - capture_output=True) - -time_stop = time.time() -result = "PASS" if ret.returncode == 0 else "FAIL" -stdout = ret.stdout.decode("utf-8") -stderr = ret.stderr.decode("utf-8") - -dump_results() - -if result != "PASS": exit(1) |