summaryrefslogtreecommitdiff
path: root/CC/RULES
diff options
context:
space:
mode:
Diffstat (limited to 'CC/RULES')
-rw-r--r--CC/RULES230
1 files changed, 224 insertions, 6 deletions
diff --git a/CC/RULES b/CC/RULES
index a6c775c..a33e4f2 100644
--- a/CC/RULES
+++ b/CC/RULES
@@ -6,7 +6,7 @@
, "use of this rule. As targets form a different root, the defaults"
, "can be provided without changing this directory."
]
- , "target_fields": ["base", "toolchain", "deps"]
+ , "target_fields": ["base", "toolchain", "deps", "include_scanner"]
, "string_fields":
[ "CC"
, "CXX"
@@ -100,6 +100,16 @@
[ "Path for looking up the compilers. Individual paths are joined"
, "with \":\". Specifying this field extends values from \"base\"."
]
+ , "include_scanner":
+ [ "Specify an include scanner to be run before each compile action, which"
+ , "removes unused headers from the include tree. The given target must"
+ , "contain a single executable artifact, a script or binary. The tool"
+ , "specified must accept as first argument the <out_dir> path and as"
+ , "remaining arguments the argv of the preprocessor command (-E -M)."
+ , "The input headers are located in the local directory \"include\" and"
+ , "the scanner should copy all used headers to \"<out_dir>/include\"."
+ , "Specifying this field overwrites values from \"base\"."
+ ]
}
, "config_doc":
{ "ARCH":
@@ -132,17 +142,22 @@
, "base-provides-++": "defaults-base-provides-++"
, "base-provides-list": "defaults-base-provides-list"
, "artifacts_list": ["./", "..", "field_artifacts_list"]
+ , "artifacts": ["./", "..", "field_artifacts"]
, "compile-deps": "compile-deps"
, "compile-args-deps": "compile-args-deps"
, "link-deps": "link-deps"
, "link-args-deps": "link-args-deps"
+ , "run-libs-deps": "run-libs-deps"
+ , "run-libs-args-deps": "run-libs-args-deps"
, "cflags-files-deps": "cflags-files-deps"
, "ldflags-files-deps": "ldflags-files-deps"
, "for host": ["transitions", "for host"]
, "debug-deps": "debug-deps"
}
, "config_transitions":
- {"toolchain": [{"type": "CALL_EXPRESSION", "name": "for host"}]}
+ { "toolchain": [{"type": "CALL_EXPRESSION", "name": "for host"}]
+ , "include_scanner": [{"type": "CALL_EXPRESSION", "name": "for host"}]
+ }
, "expression":
{ "type": "let*"
, "bindings":
@@ -243,6 +258,25 @@
, ["provider", "ENV"]
, ["default", {"type": "empty_map"}]
, ["ENV", {"type": "CALL_EXPRESSION", "name": "base-provides"}]
+ , ["provider", "INCLUDE_SCANNER"]
+ , ["default", {"type": "empty_map"}]
+ , [ "INCLUDE_SCANNER"
+ , { "type": "if"
+ , "cond": {"type": "FIELD", "name": "include_scanner"}
+ , "then":
+ { "type": "let*"
+ , "bindings":
+ [ ["fieldname", "include_scanner"]
+ , ["transition", {"type": "CALL_EXPRESSION", "name": "for host"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "artifacts"}
+ }
+ , "else":
+ { "type": "disjoint_map_union"
+ , "$1": {"type": "CALL_EXPRESSION", "name": "base-provides-list"}
+ }
+ }
+ ]
, ["provider", "NON_SYSTEM_TOOLS"]
, ["default", {"type": "empty_map"}]
, [ "NON_SYSTEM_TOOLS"
@@ -414,6 +448,10 @@
]
, ["link-deps", {"type": "CALL_EXPRESSION", "name": "link-deps"}]
, ["link-args", {"type": "CALL_EXPRESSION", "name": "link-args-deps"}]
+ , ["run-libs", {"type": "CALL_EXPRESSION", "name": "run-libs-deps"}]
+ , [ "run-libs-args"
+ , {"type": "CALL_EXPRESSION", "name": "run-libs-args-deps"}
+ ]
, [ "cflags-files"
, {"type": "CALL_EXPRESSION", "name": "cflags-files-deps"}
]
@@ -464,12 +502,15 @@
, "ARFLAGS"
, "PATH"
, "ENV"
+ , "INCLUDE_SCANNER"
, "TOOLCHAIN"
, "NON_SYSTEM_TOOLS"
, "compile-deps"
, "compile-args"
, "link-deps"
, "link-args"
+ , "run-libs"
+ , "run-libs-args"
, "package"
, "debug-srcs"
, "debug-hdrs"
@@ -481,7 +522,15 @@
, "library":
{ "doc": ["A C++ library"]
, "target_fields":
- ["srcs", "hdrs", "private-hdrs", "deps", "private-deps", "proto"]
+ [ "srcs"
+ , "hdrs"
+ , "private-hdrs"
+ , "deps"
+ , "private-deps"
+ , "proto"
+ , "private-proto"
+ , "components"
+ ]
, "string_fields":
[ "name"
, "stage"
@@ -490,19 +539,27 @@
, "private-defines"
, "cflags"
, "private-cflags"
+ , "ldflags"
, "private-ldflags"
+ , "soversion"
, "pkg-name"
]
+ , "config_fields": ["shared"]
, "config_vars":
[ "CC"
, "CXX"
, "CFLAGS"
, "CXXFLAGS"
+ , "LDFLAGS"
, "ADD_CFLAGS"
, "ADD_CXXFLAGS"
+ , "ADD_LDFLAGS"
, "AR"
, "DWP"
, "ENV"
+ , "BUILD_POSITION_INDEPENDENT"
+ , "BUILD_OBJECT_ONLY"
+ , "BUILD_OBJECT_ONLY_DROP_OBJECT_LINKING"
, "DEBUG"
, "LINT"
]
@@ -516,6 +573,11 @@
[ "Any header files that only need to be present when compiling the"
, "source files, but are not needed for any consumer of the library."
]
+ , "components":
+ [ "Any other libraries that are considered part of this library;"
+ , "all object files of those are included unconditionally into this"
+ , "library."
+ ]
, "stage":
[ "The logical location of all header and source files, as well as the"
, "resulting library file. Individual directory components are joined"
@@ -538,6 +600,11 @@
["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."]
+ , "ldflags":
+ [ "Additional linker flags for linking external libraries for this"
+ , "target and its consumers (not built by this tool, typically system"
+ , "libraries)."
+ ]
, "private-ldflags":
[ "Additional linker flags for linking external libraries (not built"
, "by this tool, typically system libraries)."
@@ -554,6 +621,18 @@
, "duplicate work will be carried out, even if the same proto library"
, "is used at various places)."
]
+ , "private-proto":
+ [ "Any [\"proto\", \"library\"] this target depends upon privately."
+ , "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)."
+ ]
+ , "shared": ["If non-empty, produce a shared instead of a static library."]
+ , "soversion":
+ [ "The SOVERSION for shared libraries. Individual version components are"
+ , "joined with \".\"."
+ ]
, "pkg-name":
[ "Name to use for pkg-config files. If this field is empty, the field"
, "\"name\" is used instead."
@@ -581,6 +660,12 @@
, "adapting the default target [\"CC\", \"defaults\"] is the better"
, "choice."
]
+ , "LDFLAGS":
+ [ "The linker flags 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"
@@ -593,6 +678,12 @@
, "adapting the default target [\"CC\", \"defaults\"] is the better"
, "choice."
]
+ , "ADD_LDFLAGS":
+ [ "The linker flags to add to 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."
+ ]
, "AR":
[ "The archive tool to used for creating the library"
, "If None, the respective value from [\"CC\", \"defaults\"] will be taken."
@@ -603,6 +694,7 @@
, "If None, the respective value from [\"CC\", \"defaults\"] will be taken."
]
, "ENV": ["The environment for any action generated."]
+ , "BUILD_POSITION_INDEPENDENT": ["Build with -fPIC."]
, "DEBUG":
[ "Map configuring the debug-stage, needed for local debugging."
, "If non-empty, debug mode is enabled."
@@ -622,6 +714,18 @@
, ""
, "If no compile flags are otherwise configured, [\"-g\"] will be taken."
]
+ , "BUILD_OBJECT_ONLY":
+ [ "If true, produce an object library, resulting in object files"
+ , "added to the linker line of all depending targets. If this"
+ , "configuration is set, the \"shared\" option is ignored. This"
+ , "variable is cleared for all dependencies."
+ ]
+ , "BUILD_OBJECT_ONLY_DROP_OBJECT_LINKING":
+ [ "If true, do not include the objects in the provided \"link-args\"."
+ , "This allows consuming libraries that pick on the objects themselves"
+ , "to still forward the \"link-args\" of that library, and thus getting"
+ , "correct linking instructions for the resulting library."
+ ]
, "LINT":
[ "Also provide nodes describing compile actions and header files;"
, "those can be used by lint rules (doing also the config transition)"
@@ -646,6 +750,20 @@
]
, "debug-srcs": ["Map of all sources needed for debugging."]
, "debug-hdrs": ["Map of all additional headers needed for debugging."]
+ , "run-libs":
+ [ "Map of artifacts specifying libraries that have to be present at"
+ , "runtime (as well as during linking)."
+ ]
+ , "run-libs-args":
+ [ "Additional arguments for linking that are related to the run-libs."
+ , "Those are added on the linker command line after the regular link-args."
+ ]
+ , "package":
+ [ "Information related to packaging the library. This provider is a map,"
+ , "specifying \"name\" and \"version\" of the package, as well as"
+ , "additional stages \"cflags-files\" and \"ldflags-files\" for files"
+ , "with compile-flags or link-flags, respctively."
+ ]
}
, "anonymous":
{ "proto-deps":
@@ -656,9 +774,34 @@
, "service library": ["./", "proto", "service library"]
}
}
+ , "private-proto-deps":
+ { "target": "private-proto"
+ , "provider": "proto"
+ , "rule_map":
+ { "library": ["./", "proto", "library"]
+ , "service library": ["./", "proto", "service library"]
+ }
+ }
}
, "imports":
- {"artifacts": ["./", "..", "field_artifacts"], "result": "lib result"}
+ { "artifacts": ["./", "..", "field_artifacts"]
+ , "runfiles": ["./", "..", "field_runfiles"]
+ , "static result": "lib result"
+ , "shared result": "shared result"
+ , "object result": "object result"
+ , "fPIC transition": ["transitions", "with fPIC, not object-only"]
+ , "component transition": ["transitions", "with fPIC, object-only"]
+ }
+ , "config_transitions":
+ { "deps": [{"type": "CALL_EXPRESSION", "name": "fPIC transition"}]
+ , "private-deps": [{"type": "CALL_EXPRESSION", "name": "fPIC transition"}]
+ , "proto-deps": [{"type": "CALL_EXPRESSION", "name": "fPIC transition"}]
+ , "private-proto-deps":
+ [{"type": "CALL_EXPRESSION", "name": "fPIC transition"}]
+ , "defaults": [{"type": "CALL_EXPRESSION", "name": "fPIC transition"}]
+ , "components":
+ [{"type": "CALL_EXPRESSION", "name": "component transition"}]
+ }
, "expression":
{ "type": "let*"
, "bindings":
@@ -716,6 +859,27 @@
}
}
]
+ , [ "component transition"
+ , {"type": "CALL_EXPRESSION", "name": "component transition"}
+ ]
+ , [ "component hdrs"
+ , { "type": "let*"
+ , "bindings":
+ [ ["fieldname", "components"]
+ , ["transition", {"type": "var", "name": "component transition"}]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "runfiles"}
+ }
+ ]
+ , [ "hdrs"
+ , { "type": "disjoint_map_union"
+ , "msg": "Staging conflict between component and own header files"
+ , "$1":
+ [ {"type": "var", "name": "hdrs"}
+ , {"type": "var", "name": "component hdrs"}
+ ]
+ }
+ ]
, [ "private-hdrs"
, { "type": "to_subdir"
, "subdir": {"type": "var", "name": "stage"}
@@ -726,7 +890,9 @@
}
}
]
+ , ["ldflags", {"type": "FIELD", "name": "ldflags"}]
, ["private-ldflags", {"type": "FIELD", "name": "private-ldflags"}]
+ , ["soversion", {"type": "FIELD", "name": "soversion"}]
, [ "pkg-name"
, { "type": "if"
, "cond": {"type": "FIELD", "name": "pkg-name"}
@@ -735,12 +901,52 @@
, "else": {"type": "var", "name": "name"}
}
]
+ , [ "defaults-transition"
+ , {"type": "CALL_EXPRESSION", "name": "fPIC transition"}
+ ]
+ , [ "deps-transition"
+ , {"type": "CALL_EXPRESSION", "name": "fPIC transition"}
+ ]
, ["public-fieldnames", ["deps", "proto-deps", "defaults"]]
, [ "private-fieldnames"
- , ["deps", "private-deps", "proto-deps", "defaults"]
+ , [ "deps"
+ , "private-deps"
+ , "proto-deps"
+ , "private-proto-deps"
+ , "defaults"
+ , "components"
+ ]
+ ]
+ , ["component-fieldnames", ["components"]]
+ , [ "modified-transitions"
+ , { "type": "singleton_map"
+ , "key": "components"
+ , "value": {"type": "var", "name": "component transition"}
+ }
+ ]
+ , [ "shared"
+ , { "type": "and"
+ , "$1":
+ [ {"type": "FIELD", "name": "shared"}
+ , { "type": "not"
+ , "$1": {"type": "var", "name": "BUILD_OBJECT_ONLY"}
+ }
+ ]
+ }
]
]
- , "body": {"type": "CALL_EXPRESSION", "name": "result"}
+ , "body":
+ { "type": "cond"
+ , "cond":
+ [ [ {"type": "var", "name": "shared"}
+ , {"type": "CALL_EXPRESSION", "name": "shared result"}
+ ]
+ , [ {"type": "var", "name": "BUILD_OBJECT_ONLY"}
+ , {"type": "CALL_EXPRESSION", "name": "object result"}
+ ]
+ ]
+ , "default": {"type": "CALL_EXPRESSION", "name": "static result"}
+ }
}
}
, "binary":
@@ -759,10 +965,13 @@
, "CXX"
, "CFLAGS"
, "CXXFLAGS"
+ , "LDFLAGS"
, "ADD_CFLAGS"
, "ADD_CXXFLAGS"
+ , "ADD_LDFLAGS"
, "DWP"
, "ENV"
+ , "BUILD_POSITION_INDEPENDENT"
, "DEBUG"
, "LINT"
]
@@ -813,6 +1022,10 @@
[ "The flags for CXX to be used instead of the default ones"
, "taken from the [\"CC\", \"defaults\"] target"
]
+ , "LDFLAGS":
+ [ "The linker flags do 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"
@@ -821,12 +1034,17 @@
[ "The flags to add to the default ones for CXX"
, "taken from the [\"CC\", \"defaults\"] target"
]
+ , "ADD_LDFLAGS":
+ [ "The linker flags to add to the default ones"
+ , "taken from the [\"CC\", \"defaults\"] target"
+ ]
, "DWP":
[ "The DWARF format packaging tool to use in debug builds that enable"
, "debug fission."
, "If None, the respective value from [\"CC\", \"defaults\"] will be taken."
]
, "ENV": ["The environment for any action generated."]
+ , "BUILD_POSITION_INDEPENDENT": ["Build with -fPIC."]
, "DEBUG":
[ "Map configuring the debug-stage, needed for local debugging."
, "If non-empty, debug mode is enabled."