diff options
Diffstat (limited to 'rules/CC/RULES')
-rw-r--r-- | rules/CC/RULES | 103 |
1 files changed, 101 insertions, 2 deletions
diff --git a/rules/CC/RULES b/rules/CC/RULES index 00f3da6..91fcf3d 100644 --- a/rules/CC/RULES +++ b/rules/CC/RULES @@ -142,6 +142,7 @@ , "ldflags" , "private-ldflags" , "soversion" + , "pkg-name" ] , "config_fields": ["shared"] , "config_vars": @@ -222,6 +223,10 @@ [ "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": @@ -393,6 +398,14 @@ , ["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"} ] @@ -570,10 +583,12 @@ { "doc": [ "Install target's artifacts with transitive dependencies. Depending on" , "the target, artifacts and dependencies will be installed to" - , "subdirectories \"bin\", \"include\", and \"lib\"." + , "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"] + , "string_fields": ["flat-libs", "prefix"] , "imports": { "compile-deps": "compile-deps" , "compile-args-deps": "compile-args-deps" @@ -581,6 +596,7 @@ , "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."] @@ -589,6 +605,19 @@ , "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\")."] @@ -684,6 +713,72 @@ } } ] + , [ "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-libs", {"type": "var", "name": "libraries"}] + , ["flat-libs", {"type": "FIELD", "name": "flat-libs"}] + ] + , "body": + {"type": "CALL_EXPRESSION", "name": "pkg-config"} + } + , "else": {"type": "empty_map"} + } + ] ] , "body": { "type": "map_union" @@ -704,6 +799,10 @@ , "msg": "install libraries may not overlap" , "$1": {"type": "var", "name": "libraries"} } + , { "type": "to_subdir" + , "subdir": "share/pkgconfig" + , "$1": {"type": "var", "name": "pkg-config"} + } ] } } |