diff options
Diffstat (limited to 'CC/RULES')
-rw-r--r-- | CC/RULES | 386 |
1 files changed, 380 insertions, 6 deletions
@@ -12,8 +12,10 @@ , "CXX" , "CFLAGS" , "CXXFLAGS" + , "LDFLAGS" , "ADD_CFLAGS" , "ADD_CXXFLAGS" + , "ADD_LDFLAGS" , "AR" , "PATH" ] @@ -25,6 +27,7 @@ , ["CXX", {"type": "FIELD", "name": "CXX"}] , ["CFLAGS", {"type": "FIELD", "name": "CFLAGS"}] , ["CXXFLAGS", {"type": "FIELD", "name": "CXXFLAGS"}] + , ["LDFLAGS", {"type": "FIELD", "name": "LDFLAGS"}] , ["AR", {"type": "FIELD", "name": "AR"}] , ["PATH", {"type": "FIELD", "name": "PATH"}] , ["provider", "CC"] @@ -99,12 +102,20 @@ ] } ] + , [ "LDFLAGS" + , { "type": "++" + , "$1": + [ {"type": "var", "name": "LDFLAGS"} + , {"type": "FIELD", "name": "ADD_LDFLAGS"} + ] + } + ] ] , "body": { "type": "RESULT" , "provides": { "type": "env" - , "vars": ["CC", "CXX", "CFLAGS", "CXXFLAGS", "AR", "ENV"] + , "vars": ["CC", "CXX", "CFLAGS", "CXXFLAGS", "LDFLAGS", "AR", "ENV"] } } } @@ -112,7 +123,14 @@ , "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" + ] , "string_fields": [ "name" , "stage" @@ -121,17 +139,24 @@ , "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" , "ENV" + , "BUILD_POSITION_INDEPENDENT" ] , "implicit": {"defaults": ["defaults"]} , "field_doc": @@ -165,6 +190,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)." @@ -181,6 +211,22 @@ , "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." + ] } , "config_doc": { "CC": @@ -203,6 +249,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" @@ -215,11 +267,18 @@ , "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." ] , "ENV": ["The environment for any action generated."] + , "BUILD_POSITION_INDEPENDENT": ["Build with -fPIC."] } , "artifacts_doc": ["The actual library (libname.a) staged in the specified directory"] @@ -247,9 +306,28 @@ , "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"] + , "static result": "lib result" + , "shared result": "shared result" + , "fPIC transition": ["transitions", "with fPIC"] + } + , "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"}] + } , "expression": { "type": "let*" , "bindings": @@ -317,11 +395,31 @@ } } ] + , ["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"} + , "then": + {"type": "join", "$1": {"type": "FIELD", "name": "pkg-name"}} + , "else": {"type": "var", "name": "name"} + } + ] + , [ "deps-transition" + , {"type": "CALL_EXPRESSION", "name": "fPIC transition"} + ] , ["public-fieldnames", ["deps", "proto-deps"]] - , ["private-fieldnames", ["deps", "private-deps", "proto-deps"]] + , [ "private-fieldnames" + , ["deps", "private-deps", "proto-deps", "private-proto-deps"] + ] ] - , "body": {"type": "CALL_EXPRESSION", "name": "result"} + , "body": + { "type": "if" + , "cond": {"type": "FIELD", "name": "shared"} + , "then": {"type": "CALL_EXPRESSION", "name": "shared result"} + , "else": {"type": "CALL_EXPRESSION", "name": "static result"} + } } } , "binary": @@ -336,7 +434,17 @@ , "private-ldflags" ] , "config_vars": - ["CC", "CXX", "CFLAGS", "CXXFLAGS", "ADD_CFLAGS", "ADD_CXXFLAGS", "ENV"] + [ "CC" + , "CXX" + , "CFLAGS" + , "CXXFLAGS" + , "LDFLAGS" + , "ADD_CFLAGS" + , "ADD_CXXFLAGS" + , "ADD_LDFLAGS" + , "ENV" + , "BUILD_POSITION_INDEPENDENT" + ] , "implicit": {"defaults": ["defaults"]} , "field_doc": { "name": ["The name of the binary"] @@ -383,6 +491,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" @@ -391,7 +503,12 @@ [ "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" + ] , "ENV": ["The environment for any action generated."] + , "BUILD_POSITION_INDEPENDENT": ["Build with -fPIC."] } , "artifacts_doc": ["The final binary, staged to the given directory"] , "runfiles_doc": ["None"] @@ -462,4 +579,261 @@ , "body": {"type": "CALL_EXPRESSION", "name": "bin result"} } } +, "install-with-deps": + { "doc": + [ "Install target's artifacts with transitive dependencies. Depending on" + , "the target, artifacts and dependencies will be installed to" + , "subdirectories \"bin\", \"include\", and \"lib\". For library targets," + , "a pkg-config file is generated and provided in \"share/pkgconfig\"." + ] + , "config_vars": ["PREFIX"] + , "target_fields": ["targets"] + , "string_fields": ["flat-libs", "prefix"] + , "imports": + { "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" + , "pkg-config": "pkg-config" + } + , "field_doc": + { "targets": ["Targets to install artifacts from."] + , "flat-libs": + [ "Install libraries flat to the \"lib\" subdirectory. Be aware that" + , "conflicts may occur if any of the (transitive) libraries happen to" + , "have the same base name." + ] + , "prefix": + [ "The prefix used for pkg-config files. The path will be made absolute" + , "and individual directory components are joined with \"/\". If no" + , "prefix is specified, the value from the config variable \"PREFIX\" is" + , "taken, with the default value being \"/\"." + ] + } + , "config_doc": + { "PREFIX": + [ "The absolute path that is used as prefix inside generated pkg-config" + , "files. The default value for this variable is \"/\". This variable" + , "is ignored if the field \"prefix\" is set." + ] + } + , "artifacts_doc": + ["Installed artifacts in subdirectories (\"bin\"/\"include\"/\"lib\")."] + , "expression": + { "type": "let*" + , "bindings": + [ ["pc-install-dir", "share/pkgconfig"] + , [ "install-stage" + , { "type": "disjoint_map_union" + , "msg": "install stages may not overlap" + , "$1": + { "type": "foreach" + , "var": "target" + , "range": {"type": "FIELD", "name": "targets"} + , "body": + { "type": "let*" + , "bindings": + [ [ "artifacts" + , { "type": "DEP_ARTIFACTS" + , "dep": {"type": "var", "name": "target"} + , "default": {"type": "empty_map"} + } + ] + , [ "runfiles" + , { "type": "DEP_RUNFILES" + , "dep": {"type": "var", "name": "target"} + , "default": {"type": "empty_map"} + } + ] + , [ "compile-deps" + , { "type": "DEP_PROVIDES" + , "dep": {"type": "var", "name": "target"} + , "provider": "compile-deps" + , "default": {"type": "empty_map"} + } + ] + , [ "link-deps" + , { "type": "DEP_PROVIDES" + , "dep": {"type": "var", "name": "target"} + , "provider": "link-deps" + , "default": {"type": "empty_map"} + } + ] + , [ "run-libs" + , { "type": "DEP_PROVIDES" + , "dep": {"type": "var", "name": "target"} + , "provider": "run-libs" + , "default": {"type": "empty_map"} + } + ] + , [ "package" + , { "type": "DEP_PROVIDES" + , "dep": {"type": "var", "name": "target"} + , "provider": "package" + , "default": {"type": "empty_map"} + } + ] + , [ "to_bin" + , { "type": "lookup" + , "key": "to_bin" + , "map": {"type": "var", "name": "package"} + } + ] + , [ "binaries" + , { "type": "if" + , "cond": {"type": "var", "name": "to_bin"} + , "then": {"type": "var", "name": "artifacts"} + , "else": {"type": "empty_map"} + } + ] + , [ "headers" + , { "type": "disjoint_map_union" + , "msg": "headers may not overlap" + , "$1": + [ {"type": "var", "name": "runfiles"} + , {"type": "var", "name": "compile-deps"} + ] + } + ] + , [ "libraries" + , { "type": "disjoint_map_union" + , "msg": "libraries may not overlap" + , "$1": + { "type": "++" + , "$1": + [ { "type": "if" + , "cond": {"type": "var", "name": "to_bin"} + , "then": [] + , "else": [{"type": "var", "name": "artifacts"}] + } + , [{"type": "var", "name": "link-deps"}] + , [{"type": "var", "name": "run-libs"}] + ] + } + } + ] + , [ "pkg-name" + , { "type": "lookup" + , "key": "name" + , "map": {"type": "var", "name": "package"} + } + ] + , [ "pkg-config" + , { "type": "if" + , "cond": {"type": "var", "name": "pkg-name"} + , "then": + { "type": "let*" + , "bindings": + [ [ "pkg-prefix" + , { "type": "if" + , "cond": {"type": "FIELD", "name": "prefix"} + , "then": + { "type": "join" + , "separator": "/" + , "$1": + { "type": "++" + , "$1": + [[""], {"type": "FIELD", "name": "prefix"}] + } + } + , "else": + {"type": "var", "name": "PREFIX", "default": "/"} + } + ] + , [ "pkg-version" + , { "type": "lookup" + , "key": "version" + , "map": {"type": "var", "name": "package"} + } + ] + , [ "pkg-cflags" + , { "type": "DEP_PROVIDES" + , "dep": {"type": "var", "name": "target"} + , "provider": "compile-args" + , "default": [] + } + ] + , [ "pkg-ldflags" + , { "type": "++" + , "$1": + [ { "type": "DEP_PROVIDES" + , "dep": {"type": "var", "name": "target"} + , "provider": "link-args" + , "default": [] + } + , { "type": "DEP_PROVIDES" + , "dep": {"type": "var", "name": "target"} + , "provider": "run-libs-args" + , "default": [] + } + ] + } + ] + , [ "pkg-flag-files" + , { "type": "map_union" + , "$1": + [ { "type": "lookup" + , "key": "cflags-files" + , "map": {"type": "var", "name": "package"} + , "default": {"type": "empty_map"} + } + , { "type": "lookup" + , "key": "ldflags-files" + , "map": {"type": "var", "name": "package"} + , "default": {"type": "empty_map"} + } + ] + } + ] + , ["pkg-libs", {"type": "var", "name": "libraries"}] + , ["flat-libs", {"type": "FIELD", "name": "flat-libs"}] + ] + , "body": + { "type": "map_union" + , "$1": + [ {"type": "CALL_EXPRESSION", "name": "pkg-config"} + , {"type": "var", "name": "pkg-flag-files"} + ] + } + } + , "else": {"type": "empty_map"} + } + ] + ] + , "body": + { "type": "map_union" + , "$1": + [ { "type": "to_subdir" + , "subdir": "bin" + , "flat": true + , "msg": "install binaries may not overlap" + , "$1": {"type": "var", "name": "binaries"} + } + , { "type": "to_subdir" + , "subdir": "include" + , "$1": {"type": "var", "name": "headers"} + } + , { "type": "to_subdir" + , "subdir": "lib" + , "flat": {"type": "FIELD", "name": "flat-libs"} + , "msg": "install libraries may not overlap" + , "$1": {"type": "var", "name": "libraries"} + } + , { "type": "to_subdir" + , "subdir": {"type": "var", "name": "pc-install-dir"} + , "$1": {"type": "var", "name": "pkg-config"} + } + ] + } + } + } + } + ] + ] + , "body": + {"type": "RESULT", "artifacts": {"type": "var", "name": "install-stage"}} + } + } } |