From 7f72f33c498ba39f5f4900642b63ec6e89c471e6 Mon Sep 17 00:00:00 2001 From: Oliver Reiche Date: Thu, 16 Nov 2023 16:41:38 +0100 Subject: defaults: Fix flag inheritance ... which should accumulate values from all base targets unless the flag type (CFLAGS, CXXFLAGS, or LDFLAGS) is explicity overwritten by the inheritor. --- CC/EXPRESSIONS | 13 +++++++++++++ CC/RULES | 11 +++++------ CC/foreign/RULES | 5 ++--- CC/proto/RULES | 7 +++---- patch/RULES | 5 ++--- 5 files changed, 25 insertions(+), 16 deletions(-) diff --git a/CC/EXPRESSIONS b/CC/EXPRESSIONS index 1f57fcd..c4a3e34 100644 --- a/CC/EXPRESSIONS +++ b/CC/EXPRESSIONS @@ -153,6 +153,19 @@ , "body": {"type": "CALL_EXPRESSION", "name": "provider_list"} } } +, "defaults-base-provides-++": + { "doc": ["Query flattend list of providers from 'base' targets"] + , "vars": ["provider", "default"] + , "vars_doc": + { "provider": ["The name of the provider in the provides map."] + , "default": ["The default if provider is missing (default: [])."] + } + , "imports": {"base-provides-list": "defaults-base-provides-list"} + , "expression": + { "type": "++" + , "$1": {"type": "CALL_EXPRESSION", "name": "base-provides-list"} + } + } , "defaults-base-provides": { "doc": ["Query provider from 'base' targets (last wins)"] , "vars": ["provider", "default"] diff --git a/CC/RULES b/CC/RULES index c6426b1..230c397 100644 --- a/CC/RULES +++ b/CC/RULES @@ -75,6 +75,7 @@ , "config_vars": ["ARCH", "HOST_ARCH", "TARGET_ARCH"] , "imports": { "base-provides": "defaults-base-provides" + , "base-provides-++": "defaults-base-provides-++" , "base-provides-list": "defaults-base-provides-list" , "artifacts_list": ["./", "..", "field_artifacts_list"] , "nub_left": ["", "nub_left"] @@ -121,7 +122,7 @@ , { "type": "if" , "cond": {"type": "var", "name": "CFLAGS"} , "then": {"type": "var", "name": "CFLAGS"} - , "else": {"type": "CALL_EXPRESSION", "name": "base-provides"} + , "else": {"type": "CALL_EXPRESSION", "name": "base-provides-++"} } ] , ["provider", "CXXFLAGS"] @@ -129,7 +130,7 @@ , { "type": "if" , "cond": {"type": "var", "name": "CXXFLAGS"} , "then": {"type": "var", "name": "CXXFLAGS"} - , "else": {"type": "CALL_EXPRESSION", "name": "base-provides"} + , "else": {"type": "CALL_EXPRESSION", "name": "base-provides-++"} } ] , ["provider", "LDFLAGS"] @@ -137,7 +138,7 @@ , { "type": "if" , "cond": {"type": "var", "name": "LDFLAGS"} , "then": {"type": "var", "name": "LDFLAGS"} - , "else": {"type": "CALL_EXPRESSION", "name": "base-provides"} + , "else": {"type": "CALL_EXPRESSION", "name": "base-provides-++"} } ] , ["provider", "AR"] @@ -153,9 +154,7 @@ , { "type": "++" , "$1": [ {"type": "var", "name": "PATH"} - , { "type": "++" - , "$1": {"type": "CALL_EXPRESSION", "name": "base-provides-list"} - } + , {"type": "CALL_EXPRESSION", "name": "base-provides-++"} ] } ] diff --git a/CC/foreign/RULES b/CC/foreign/RULES index 6a48f1d..935d477 100644 --- a/CC/foreign/RULES +++ b/CC/foreign/RULES @@ -28,6 +28,7 @@ , "config_vars": ["ARCH", "HOST_ARCH"] , "imports": { "base-provides": ["./", "..", "defaults-base-provides"] + , "base-provides-++": ["./", "..", "defaults-base-provides-++"] , "base-provides-list": ["./", "..", "defaults-base-provides-list"] , "artifacts_list": ["./", "../..", "field_artifacts_list"] , "nub_left": ["", "nub_left"] @@ -62,9 +63,7 @@ , { "type": "++" , "$1": [ {"type": "var", "name": "PATH"} - , { "type": "++" - , "$1": {"type": "CALL_EXPRESSION", "name": "base-provides-list"} - } + , {"type": "CALL_EXPRESSION", "name": "base-provides-++"} ] } ] diff --git a/CC/proto/RULES b/CC/proto/RULES index 8108161..65b8a7a 100644 --- a/CC/proto/RULES +++ b/CC/proto/RULES @@ -56,6 +56,7 @@ } , "imports": { "base-provides": ["./", "..", "defaults-base-provides"] + , "base-provides-++": ["./", "..", "defaults-base-provides-++"] , "base-provides-list": ["./", "..", "defaults-base-provides-list"] , "artifacts_list": ["", "field_artifacts_list"] , "nub_left": ["", "nub_left"] @@ -91,7 +92,7 @@ , { "type": "if" , "cond": {"type": "var", "name": "LDFLAGS"} , "then": {"type": "var", "name": "LDFLAGS"} - , "else": {"type": "CALL_EXPRESSION", "name": "base-provides"} + , "else": {"type": "CALL_EXPRESSION", "name": "base-provides-++"} } ] , ["provider", "GRPC_PLUGIN"] @@ -107,9 +108,7 @@ , { "type": "++" , "$1": [ {"type": "var", "name": "PATH"} - , { "type": "++" - , "$1": {"type": "CALL_EXPRESSION", "name": "base-provides-list"} - } + , {"type": "CALL_EXPRESSION", "name": "base-provides-++"} ] } ] diff --git a/patch/RULES b/patch/RULES index f57094a..446f842 100644 --- a/patch/RULES +++ b/patch/RULES @@ -29,6 +29,7 @@ , "config_vars": ["ARCH", "HOST_ARCH"] , "imports": { "base-provides": ["CC", "defaults-base-provides"] + , "base-provides-++": ["CC", "defaults-base-provides-++"] , "base-provides-list": ["CC", "defaults-base-provides-list"] , "artifacts_list": ["", "field_artifacts_list"] , "nub_left": ["", "nub_left"] @@ -54,9 +55,7 @@ , { "type": "++" , "$1": [ {"type": "var", "name": "PATH"} - , { "type": "++" - , "$1": {"type": "CALL_EXPRESSION", "name": "base-provides-list"} - } + , {"type": "CALL_EXPRESSION", "name": "base-provides-++"} ] } ] -- cgit v1.2.3 From 779354b0f9e37c71d4c2b15b62d4d34d1e610a48 Mon Sep 17 00:00:00 2001 From: Oliver Reiche Date: Fri, 17 Nov 2023 19:33:28 +0100 Subject: prebuilt: Consider "deps" for flag reader inputs ... so that if e.g., libfoo depends on libbar via "deps", the flag "-lbar" should be filtered out from the flag file generated via pkg-config from file foo.pc. Omitting these flags is always correct, due to those libraries being part of the explicit link dependencies already. --- CC/prebuilt/EXPRESSIONS | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/CC/prebuilt/EXPRESSIONS b/CC/prebuilt/EXPRESSIONS index 7b35c21..b84e494 100644 --- a/CC/prebuilt/EXPRESSIONS +++ b/CC/prebuilt/EXPRESSIONS @@ -208,18 +208,7 @@ } } ] - , [ "run-libs" - , { "type": "map_union" - , "$1": - [ { "type": "if" - , "cond": {"type": "var", "name": "shared"} - , "then": {"type": "var", "name": "libs"} - , "else": {"type": "empty_map"} - } - , {"type": "CALL_EXPRESSION", "name": "run-libs-deps"} - ] - } - ] + , ["run-libs", {"type": "CALL_EXPRESSION", "name": "run-libs-deps"}] , [ "run-libs-args" , { "type": "nub_right" , "$1": @@ -300,6 +289,8 @@ { "type": "map_union" , "$1": [ {"type": "var", "name": "libs"} + , {"type": "var", "name": "link-deps"} + , {"type": "var", "name": "run-libs"} , { "type": "to_subdir" , "subdir": "pkgconfig" , "flat": true @@ -428,6 +419,18 @@ ] } ] + , [ "run-libs" + , { "type": "map_union" + , "$1": + [ { "type": "if" + , "cond": {"type": "var", "name": "shared"} + , "then": {"type": "var", "name": "libs"} + , "else": {"type": "empty_map"} + } + , {"type": "var", "name": "run-libs"} + ] + } + ] , [ "run-libs-args" , { "type": "++" , "$1": -- cgit v1.2.3 From 4e86f756bddca8db402502be47c0825e1e2aeb0d Mon Sep 17 00:00:00 2001 From: Oliver Reiche Date: Fri, 3 Nov 2023 12:42:16 +0100 Subject: foreign: Do not follow symlinks of tool paths --- CC/foreign/cmake/EXPRESSIONS | 10 +++++----- CC/foreign/make/EXPRESSIONS | 8 ++++---- CC/foreign/shell/EXPRESSIONS | 10 +++++----- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/CC/foreign/cmake/EXPRESSIONS b/CC/foreign/cmake/EXPRESSIONS index a36c706..3d277fe 100644 --- a/CC/foreign/cmake/EXPRESSIONS +++ b/CC/foreign/cmake/EXPRESSIONS @@ -267,11 +267,11 @@ , "export TMPDIR=\"$(pwd)/scratch\"" , "export TOOLCHAIN=\"$(pwd)/toolchain\"" , "export LOCALBASE=\"$(pwd)/localbase\"" - , "export CC=$([ -x \"${CC}\" ] && realpath ${CC} || echo ${CC})" - , "export CXX=$([ -x \"${CXX}\" ] && realpath ${CXX} || echo ${CXX})" - , "export AR=$([ -x \"${AR}\" ] && realpath ${AR} || echo ${AR})" - , "export MAKE=$([ -x \"${MAKE}\" ] && realpath ${MAKE} || echo ${MAKE})" - , "export CMAKE=$([ -x \"${CMAKE}\" ] && realpath ${CMAKE} || echo ${CMAKE})" + , "export CC=$([ -x \"${CC}\" ] && echo $(pwd)/${CC} || echo ${CC})" + , "export CXX=$([ -x \"${CXX}\" ] && echo $(pwd)/${CXX} || echo ${CXX})" + , "export AR=$([ -x \"${AR}\" ] && echo $(pwd)/${AR} || echo ${AR})" + , "export MAKE=$([ -x \"${MAKE}\" ] && echo $(pwd)/${MAKE} || echo ${MAKE})" + , "export CMAKE=$([ -x \"${CMAKE}\" ] && echo $(pwd)/${CMAKE} || echo ${CMAKE})" , { "type": "join" , "$1": [ "export PATH=\"$(./expand_exec TOOLCHAIN -- echo " diff --git a/CC/foreign/make/EXPRESSIONS b/CC/foreign/make/EXPRESSIONS index d31a2bb..6a213a7 100644 --- a/CC/foreign/make/EXPRESSIONS +++ b/CC/foreign/make/EXPRESSIONS @@ -245,10 +245,10 @@ , "export DESTDIR=\"$(pwd)/install\"" , "export TOOLCHAIN=\"$(pwd)/toolchain\"" , "export LOCALBASE=\"$(pwd)/localbase\"" - , "export CC=$([ -x \"${CC}\" ] && realpath ${CC} || echo ${CC})" - , "export CXX=$([ -x \"${CXX}\" ] && realpath ${CXX} || echo ${CXX})" - , "export AR=$([ -x \"${AR}\" ] && realpath ${AR} || echo ${AR})" - , "export MAKE=$([ -x \"${MAKE}\" ] && realpath ${MAKE} || echo ${MAKE})" + , "export CC=$([ -x \"${CC}\" ] && echo $(pwd)/${CC} || echo ${CC})" + , "export CXX=$([ -x \"${CXX}\" ] && echo $(pwd)/${CXX} || echo ${CXX})" + , "export AR=$([ -x \"${AR}\" ] && echo $(pwd)/${AR} || echo ${AR})" + , "export MAKE=$([ -x \"${MAKE}\" ] && echo $(pwd)/${MAKE} || echo ${MAKE})" , { "type": "join" , "$1": [ "export PATH=\"$(./expand_exec TOOLCHAIN -- echo " diff --git a/CC/foreign/shell/EXPRESSIONS b/CC/foreign/shell/EXPRESSIONS index 2f05497..be6f797 100644 --- a/CC/foreign/shell/EXPRESSIONS +++ b/CC/foreign/shell/EXPRESSIONS @@ -269,11 +269,11 @@ , "export TOOLCHAIN=\"$(pwd)/toolchain\"" , "export LOCALBASE=\"$(pwd)/localbase\"" , "export DESTDIR=\"$(pwd)/install\"" - , "export CC=$([ -x \"${CC}\" ] && realpath ${CC} || echo ${CC})" - , "export CXX=$([ -x \"${CXX}\" ] && realpath ${CXX} || echo ${CXX})" - , "export AR=$([ -x \"${AR}\" ] && realpath ${AR} || echo ${AR})" - , "export MAKE=$([ -x \"${MAKE}\" ] && realpath ${MAKE} || echo ${MAKE})" - , "export CMAKE=$([ -x \"${CMAKE}\" ] && realpath ${CMAKE} || echo ${CMAKE})" + , "export CC=$([ -x \"${CC}\" ] && echo $(pwd)/${CC} || echo ${CC})" + , "export CXX=$([ -x \"${CXX}\" ] && echo $(pwd)/${CXX} || echo ${CXX})" + , "export AR=$([ -x \"${AR}\" ] && echo $(pwd)/${AR} || echo ${AR})" + , "export MAKE=$([ -x \"${MAKE}\" ] && echo $(pwd)/${MAKE} || echo ${MAKE})" + , "export CMAKE=$([ -x \"${CMAKE}\" ] && echo $(pwd)/${CMAKE} || echo ${CMAKE})" , { "type": "join" , "$1": [ "export PATH=\"$(./expand_exec TOOLCHAIN -- echo " -- cgit v1.2.3 From 527de836e8b7217145ccbc2bc27c7bc87e3dc7f6 Mon Sep 17 00:00:00 2001 From: Oliver Reiche Date: Fri, 3 Nov 2023 12:49:48 +0100 Subject: foreign: Only resolve symlinks on user request --- CC/foreign/cmake/EXPRESSIONS | 11 ++++++++--- CC/foreign/cmake/RULES | 12 ++++++++++++ CC/foreign/make/EXPRESSIONS | 11 ++++++++--- CC/foreign/make/RULES | 12 ++++++++++++ CC/foreign/shell/EXPRESSIONS | 11 ++++++++--- CC/foreign/shell/RULES | 7 ++++++- 6 files changed, 54 insertions(+), 10 deletions(-) diff --git a/CC/foreign/cmake/EXPRESSIONS b/CC/foreign/cmake/EXPRESSIONS index 3d277fe..b4a9147 100644 --- a/CC/foreign/cmake/EXPRESSIONS +++ b/CC/foreign/cmake/EXPRESSIONS @@ -24,6 +24,7 @@ , "BUILD_POSITION_INDEPENDENT" , "defaults-transition" , "expand_exec" + , "resolve_symlinks" ] , "imports": { "artifacts": ["", "field_artifacts"] @@ -336,9 +337,13 @@ } } } - , [ "mv install install_with_symlinks" - , "cp -rL install_with_symlinks install" - ] + , { "type": "if" + , "cond": {"type": "var", "name": "resolve_symlinks"} + , "then": + [ "mv install install_with_symlinks" + , "cp -rL install_with_symlinks install >copy.log 2>&1 || (echo 'ERROR: symlink resolve failed with:' && cat copy.log && exit 1)" + ] + } , { "type": "if" , "cond": {"type": "var", "name": "post_cmds"} , "then": diff --git a/CC/foreign/cmake/RULES b/CC/foreign/cmake/RULES index b36bc73..166e2d6 100644 --- a/CC/foreign/cmake/RULES +++ b/CC/foreign/cmake/RULES @@ -18,6 +18,7 @@ , "post_cmds" , "out_files" , "out_dirs" + , "resolve_symlinks" ] , "config_vars": [ "ARCH" @@ -78,6 +79,10 @@ , "accessed via \"$CMAKE_SOURCE_DIR\" and \"$CMAKE_BINARY_DIR\"," , "respectively." ] + , "resolve_symlinks": + [ "Resolve all symlinks in the install directory. This operation is" + , "performed immediately after the install, before \"post_cmds\" are run." + ] , "out_files": [ "Paths to the produced output files. The paths are considered relative" , "to the install directory." @@ -204,6 +209,7 @@ , ["cmake_jobs", {"type": "FIELD", "name": "jobs"}] , ["pre_cmds", {"type": "FIELD", "name": "pre_cmds"}] , ["post_cmds", {"type": "FIELD", "name": "post_cmds"}] + , ["resolve_symlinks", {"type": "FIELD", "name": "resolve_symlinks"}] , ["defaults-transition", {"type": "empty_map"}] , [ "expand_exec" , { "type": "let*" @@ -291,6 +297,7 @@ , "hdr_prefix" , "lib_prefix" , "pc_prefix" + , "resolve_symlinks" ] , "config_vars": [ "ARCH" @@ -358,6 +365,10 @@ , "source and build directory can be accessed via \"$CMAKE_SOURCE_DIR\"" , "and \"$CMAKE_BINARY_DIR\", respectively." ] + , "resolve_symlinks": + [ "Resolve all symlinks in the install directory. This operation is" + , "performed immediately after the install, before \"post_cmds\" are run." + ] , "out_hdrs": [ "Paths to produced public header files. The path is considered" , "relative to the include directory, which be set via \"hdr_prefix\"." @@ -607,6 +618,7 @@ , ["cmake_jobs", {"type": "FIELD", "name": "jobs"}] , ["pre_cmds", {"type": "FIELD", "name": "pre_cmds"}] , ["post_cmds", {"type": "FIELD", "name": "post_cmds"}] + , ["resolve_symlinks", {"type": "FIELD", "name": "resolve_symlinks"}] , ["defaults-transition", {"type": "empty_map"}] , [ "expand_exec" , { "type": "let*" diff --git a/CC/foreign/make/EXPRESSIONS b/CC/foreign/make/EXPRESSIONS index 6a213a7..b03e056 100644 --- a/CC/foreign/make/EXPRESSIONS +++ b/CC/foreign/make/EXPRESSIONS @@ -26,6 +26,7 @@ , "TIMEOUT_SCALE" , "defaults-transition" , "expand_exec" + , "resolve_symlinks" ] , "imports": { "artifacts": ["", "field_artifacts"] @@ -304,9 +305,13 @@ ] } } - , [ "mv install install_with_symlinks" - , "cp -rL install_with_symlinks install" - ] + , { "type": "if" + , "cond": {"type": "var", "name": "resolve_symlinks"} + , "then": + [ "mv install install_with_symlinks" + , "cp -rL install_with_symlinks install >copy.log 2>&1 || (echo 'ERROR: symlink resolve failed with:' && cat copy.log && exit 1)" + ] + } , { "type": "if" , "cond": {"type": "var", "name": "post_cmds"} , "then": diff --git a/CC/foreign/make/RULES b/CC/foreign/make/RULES index 76fca18..e3c28db 100644 --- a/CC/foreign/make/RULES +++ b/CC/foreign/make/RULES @@ -20,6 +20,7 @@ , "post_cmds" , "out_files" , "out_dirs" + , "resolve_symlinks" ] , "config_vars": [ "ARCH" @@ -89,6 +90,10 @@ , "\"post_cmds\" can be exchanged via \"$TMPDIR\", which is uniquely" , "reserved for this action." ] + , "resolve_symlinks": + [ "Resolve all symlinks in the install directory. This operation is" + , "performed immediately after the install, before \"post_cmds\" are run." + ] , "out_files": [ "Paths to the produced output files. The paths are considered relative" , "to the install directory." @@ -222,6 +227,7 @@ , ["make_jobs", {"type": "FIELD", "name": "jobs"}] , ["pre_cmds", {"type": "FIELD", "name": "pre_cmds"}] , ["post_cmds", {"type": "FIELD", "name": "post_cmds"}] + , ["resolve_symlinks", {"type": "FIELD", "name": "resolve_symlinks"}] , ["defaults-transition", {"type": "empty_map"}] , [ "expand_exec" , { "type": "let*" @@ -310,6 +316,7 @@ , "hdr_prefix" , "lib_prefix" , "pc_prefix" + , "resolve_symlinks" ] , "config_vars": [ "ARCH" @@ -383,6 +390,10 @@ , "that data between \"pre_cmds\" and \"post_cmds\" can be exchanged via" , "\"$TMPDIR\", which is uniquely reserved for this action." ] + , "resolve_symlinks": + [ "Resolve all symlinks in the install directory. This operation is" + , "performed immediately after the install, before \"post_cmds\" are run." + ] , "out_hdrs": [ "Paths to produced public header files. The path is considered" , "relative to the include directory, which be set via \"hdr_prefix\"." @@ -640,6 +651,7 @@ , ["make_jobs", {"type": "FIELD", "name": "jobs"}] , ["pre_cmds", {"type": "FIELD", "name": "pre_cmds"}] , ["post_cmds", {"type": "FIELD", "name": "post_cmds"}] + , ["resolve_symlinks", {"type": "FIELD", "name": "resolve_symlinks"}] , ["defaults-transition", {"type": "empty_map"}] , [ "expand_exec" , { "type": "let*" diff --git a/CC/foreign/shell/EXPRESSIONS b/CC/foreign/shell/EXPRESSIONS index be6f797..3836388 100644 --- a/CC/foreign/shell/EXPRESSIONS +++ b/CC/foreign/shell/EXPRESSIONS @@ -19,6 +19,7 @@ , "BUILD_POSITION_INDEPENDENT" , "TIMEOUT_SCALE" , "expand_exec" + , "resolve_symlinks" ] , "imports": { "artifacts": ["", "field_artifacts"] @@ -287,9 +288,13 @@ , ["(", "set --", "cd ./work"] , {"type": "var", "name": "cmds"} , [")"] - , [ "mv install install_with_symlinks" - , "cp -rL install_with_symlinks install" - ] + , { "type": "if" + , "cond": {"type": "var", "name": "resolve_symlinks"} + , "then": + [ "mv install install_with_symlinks" + , "cp -rL install_with_symlinks install >copy.log 2>&1 || (echo 'ERROR: symlink resolve failed with:' && cat copy.log && exit 1)" + ] + } ] } } diff --git a/CC/foreign/shell/RULES b/CC/foreign/shell/RULES index ffffc26..82a7d05 100644 --- a/CC/foreign/shell/RULES +++ b/CC/foreign/shell/RULES @@ -10,7 +10,7 @@ , "current action directory, if needed for achieving reproducibility." ] , "target_fields": ["project", "localbase", "deps"] - , "string_fields": ["cmds", "outs", "out_dirs"] + , "string_fields": ["cmds", "outs", "out_dirs", "resolve_symlinks"] , "config_vars": [ "CC" , "CXX" @@ -42,6 +42,10 @@ [ "List of commands to execute by \"sh\". Multiple commands will be" , "joined with the newline character." ] + , "resolve_symlinks": + [ "Resolve all symlinks in the install directory. This operation is" + , "performed immediately after \"cmds\" were executed." + ] , "outs": ["Paths to the produced output files in \"DESTDIR\"."] , "out_dirs": ["Paths to the produced output directories in \"DESTDIR\"."] } @@ -161,6 +165,7 @@ , "body": {"type": "CALL_EXPRESSION", "name": "stage_field"} } ] + , ["resolve_symlinks", {"type": "FIELD", "name": "resolve_symlinks"}] ] , "body": { "type": "RESULT" -- cgit v1.2.3 From a513b2e823dc6a2e37ae1fad6924b3d5c34dabf0 Mon Sep 17 00:00:00 2001 From: Oliver Reiche Date: Thu, 16 Nov 2023 16:41:38 +0100 Subject: rules: Fix flag inheritance ... which should accumulate values from all base targets unless the flag type (CFLAGS, CXXFLAGS, or LDFLAGS) is explicity overwritten by the inheritor. --- CC/EXPRESSIONS | 13 +++++++++++++ CC/RULES | 11 +++++------ CC/proto/RULES | 7 +++---- patch/RULES | 5 ++--- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/CC/EXPRESSIONS b/CC/EXPRESSIONS index 6b7b842..24a2cff 100644 --- a/CC/EXPRESSIONS +++ b/CC/EXPRESSIONS @@ -153,6 +153,19 @@ , "body": {"type": "CALL_EXPRESSION", "name": "provider_list"} } } +, "defaults-base-provides-++": + { "doc": ["Query flattend list of providers from 'base' targets"] + , "vars": ["provider", "default"] + , "vars_doc": + { "provider": ["The name of the provider in the provides map."] + , "default": ["The default if provider is missing (default: [])."] + } + , "imports": {"base-provides-list": "defaults-base-provides-list"} + , "expression": + { "type": "++" + , "$1": {"type": "CALL_EXPRESSION", "name": "base-provides-list"} + } + } , "defaults-base-provides": { "doc": ["Query provider from 'base' targets (last wins)"] , "vars": ["provider", "default"] diff --git a/CC/RULES b/CC/RULES index bea41d2..0c5021c 100644 --- a/CC/RULES +++ b/CC/RULES @@ -75,6 +75,7 @@ , "config_vars": ["ARCH", "HOST_ARCH", "TARGET_ARCH"] , "imports": { "base-provides": "defaults-base-provides" + , "base-provides-++": "defaults-base-provides-++" , "base-provides-list": "defaults-base-provides-list" , "artifacts_list": ["./", "..", "field_artifacts_list"] , "nub_left": ["", "nub_left"] @@ -119,7 +120,7 @@ , { "type": "if" , "cond": {"type": "var", "name": "CFLAGS"} , "then": {"type": "var", "name": "CFLAGS"} - , "else": {"type": "CALL_EXPRESSION", "name": "base-provides"} + , "else": {"type": "CALL_EXPRESSION", "name": "base-provides-++"} } ] , ["provider", "CXXFLAGS"] @@ -127,7 +128,7 @@ , { "type": "if" , "cond": {"type": "var", "name": "CXXFLAGS"} , "then": {"type": "var", "name": "CXXFLAGS"} - , "else": {"type": "CALL_EXPRESSION", "name": "base-provides"} + , "else": {"type": "CALL_EXPRESSION", "name": "base-provides-++"} } ] , ["provider", "LDFLAGS"] @@ -135,7 +136,7 @@ , { "type": "if" , "cond": {"type": "var", "name": "LDFLAGS"} , "then": {"type": "var", "name": "LDFLAGS"} - , "else": {"type": "CALL_EXPRESSION", "name": "base-provides"} + , "else": {"type": "CALL_EXPRESSION", "name": "base-provides-++"} } ] , ["provider", "AR"] @@ -151,9 +152,7 @@ , { "type": "++" , "$1": [ {"type": "var", "name": "PATH"} - , { "type": "++" - , "$1": {"type": "CALL_EXPRESSION", "name": "base-provides-list"} - } + , {"type": "CALL_EXPRESSION", "name": "base-provides-++"} ] } ] diff --git a/CC/proto/RULES b/CC/proto/RULES index 4ffc73b..2fc0346 100644 --- a/CC/proto/RULES +++ b/CC/proto/RULES @@ -56,6 +56,7 @@ } , "imports": { "base-provides": ["./", "..", "defaults-base-provides"] + , "base-provides-++": ["./", "..", "defaults-base-provides-++"] , "base-provides-list": ["./", "..", "defaults-base-provides-list"] , "artifacts_list": ["", "field_artifacts_list"] , "nub_left": ["", "nub_left"] @@ -89,7 +90,7 @@ , { "type": "if" , "cond": {"type": "var", "name": "LDFLAGS"} , "then": {"type": "var", "name": "LDFLAGS"} - , "else": {"type": "CALL_EXPRESSION", "name": "base-provides"} + , "else": {"type": "CALL_EXPRESSION", "name": "base-provides-++"} } ] , ["provider", "GRPC_PLUGIN"] @@ -105,9 +106,7 @@ , { "type": "++" , "$1": [ {"type": "var", "name": "PATH"} - , { "type": "++" - , "$1": {"type": "CALL_EXPRESSION", "name": "base-provides-list"} - } + , {"type": "CALL_EXPRESSION", "name": "base-provides-++"} ] } ] diff --git a/patch/RULES b/patch/RULES index f57094a..446f842 100644 --- a/patch/RULES +++ b/patch/RULES @@ -29,6 +29,7 @@ , "config_vars": ["ARCH", "HOST_ARCH"] , "imports": { "base-provides": ["CC", "defaults-base-provides"] + , "base-provides-++": ["CC", "defaults-base-provides-++"] , "base-provides-list": ["CC", "defaults-base-provides-list"] , "artifacts_list": ["", "field_artifacts_list"] , "nub_left": ["", "nub_left"] @@ -54,9 +55,7 @@ , { "type": "++" , "$1": [ {"type": "var", "name": "PATH"} - , { "type": "++" - , "$1": {"type": "CALL_EXPRESSION", "name": "base-provides-list"} - } + , {"type": "CALL_EXPRESSION", "name": "base-provides-++"} ] } ] -- cgit v1.2.3 From 71628adff7612813c6ab1d21a1540fbd366cd1cf Mon Sep 17 00:00:00 2001 From: Oliver Reiche Date: Fri, 10 Nov 2023 16:09:37 +0100 Subject: foreign: Implement shell library --- CC/foreign/shell/EXPRESSIONS | 58 +----- CC/foreign/shell/RULES | 462 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 466 insertions(+), 54 deletions(-) diff --git a/CC/foreign/shell/EXPRESSIONS b/CC/foreign/shell/EXPRESSIONS index 3836388..1ed7daa 100644 --- a/CC/foreign/shell/EXPRESSIONS +++ b/CC/foreign/shell/EXPRESSIONS @@ -3,8 +3,8 @@ [ "cmds" , "sources" , "localbase" - , "outs" - , "out_dirs" + , "installed_files" + , "installed_dirs" , "CC" , "CXX" , "CFLAGS" @@ -38,7 +38,6 @@ , "foreign-PATH": ["CC/foreign", "default-PATH"] , "foreign-TOOLCHAIN": ["CC/foreign", "default-TOOLCHAIN"] , "foreign-NON_SYSTEM_TOOLS": ["CC/foreign", "default-NON_SYSTEM_TOOLS"] - , "strip-prefix": ["CC/foreign", "strip-prefix"] } , "expression": { "type": "let*" @@ -210,7 +209,6 @@ ] } ] - , ["install_prefix", "install"] , [ "localbase" , { "type": "to_subdir" , "subdir": "localbase" @@ -223,34 +221,6 @@ , "$1": {"type": "var", "name": "sources"} } ] - , [ "installed_out_files" - , { "type": "foreach" - , "var": "file_path" - , "range": {"type": "var", "name": "outs"} - , "body": - { "type": "join" - , "separator": "/" - , "$1": - [ {"type": "var", "name": "install_prefix"} - , {"type": "var", "name": "file_path"} - ] - } - } - ] - , [ "installed_out_dirs" - , { "type": "foreach" - , "var": "dir_path" - , "range": {"type": "var", "name": "out_dirs"} - , "body": - { "type": "join" - , "separator": "/" - , "$1": - [ {"type": "var", "name": "install_prefix"} - , {"type": "var", "name": "dir_path"} - ] - } - } - ] , [ "script" , { "type": "singleton_map" , "key": "run_cmds.sh" @@ -314,33 +284,15 @@ ] } , "cmd": ["sh", "run_cmds.sh"] - , "outs": {"type": "var", "name": "installed_out_files"} - , "out_dirs": {"type": "var", "name": "installed_out_dirs"} + , "outs": {"type": "var", "name": "installed_files"} + , "out_dirs": {"type": "var", "name": "installed_dirs"} , "env": {"type": "var", "name": "ENV"} , "timeout scaling": {"type": "var", "name": "TIMEOUT_SCALE", "default": 10.0} } ] ] - , "body": - { "type": "map_union" - , "$1": - { "type": "let*" - , "bindings": - [ ["artifacts", {"type": "var", "name": "artifacts"}] - , [ "paths" - , { "type": "++" - , "$1": - [ {"type": "var", "name": "outs"} - , {"type": "var", "name": "out_dirs"} - ] - } - ] - , ["prefix", {"type": "var", "name": "install_prefix"}] - ] - , "body": {"type": "CALL_EXPRESSION", "name": "strip-prefix"} - } - } + , "body": {"type": "var", "name": "artifacts"} } } } diff --git a/CC/foreign/shell/RULES b/CC/foreign/shell/RULES index 82a7d05..5c85955 100644 --- a/CC/foreign/shell/RULES +++ b/CC/foreign/shell/RULES @@ -118,6 +118,7 @@ , "stage_field": ["", "stage_singleton_field"] , "shell-build": "shell-build" , "install-deps": ["CC", "install-with-deps stage"] + , "strip-prefix": ["CC/foreign", "strip-prefix"] , "for host": ["transitions", "for host"] } , "config_transitions": @@ -155,6 +156,35 @@ ] , ["outs", {"type": "FIELD", "name": "outs"}] , ["out_dirs", {"type": "FIELD", "name": "out_dirs"}] + , ["install_prefix", "install"] + , [ "installed_files" + , { "type": "foreach" + , "var": "file_path" + , "range": {"type": "var", "name": "outs"} + , "body": + { "type": "join" + , "separator": "/" + , "$1": + [ {"type": "var", "name": "install_prefix"} + , {"type": "var", "name": "file_path"} + ] + } + } + ] + , [ "installed_dirs" + , { "type": "foreach" + , "var": "dir_path" + , "range": {"type": "var", "name": "out_dirs"} + , "body": + { "type": "join" + , "separator": "/" + , "$1": + [ {"type": "var", "name": "install_prefix"} + , {"type": "var", "name": "dir_path"} + ] + } + } + ] , [ "expand_exec" , { "type": "let*" , "bindings": @@ -166,11 +196,441 @@ } ] , ["resolve_symlinks", {"type": "FIELD", "name": "resolve_symlinks"}] + , ["artifacts", {"type": "CALL_EXPRESSION", "name": "shell-build"}] ] , "body": { "type": "RESULT" - , "artifacts": {"type": "CALL_EXPRESSION", "name": "shell-build"} + , "artifacts": + { "type": "map_union" + , "$1": + { "type": "let*" + , "bindings": + [ ["artifacts", {"type": "var", "name": "artifacts"}] + , [ "paths" + , { "type": "++" + , "$1": + [ {"type": "var", "name": "outs"} + , {"type": "var", "name": "out_dirs"} + ] + } + ] + , ["prefix", {"type": "var", "name": "install_prefix"}] + ] + , "body": {"type": "CALL_EXPRESSION", "name": "strip-prefix"} + } + } } } } +, "library": + { "doc": + [ "Library produced by generic shell commands with toolchain support." + , "" + , "All variables accessible to commands and options are: \"TMPDIR\"," + , "\"LOCALBASE\", \"WORKDIR\", \"DESTDIR\", \"CC\", \"CXX\", \"CFLAGS\"," + , "\"CXXFLAGS\", \"LDFLAGS\", and \"AR\". \"LOCALBASE\" contains the path" + , "to the staged artifacts from \"localbase\" and the installed artifacts" + , "from \"deps\". Furthermore, the variable \"ACTION_DIR\" points to the" + , "current action directory, if needed for achieving reproducibility." + ] + , "target_fields": ["project", "localbase", "deps"] + , "string_fields": + [ "name" + , "version" + , "stage" + , "cmds" + , "out_hdrs" + , "out_hdr_dirs" + , "out_libs" + , "cflags" + , "ldflags" + , "pkg-config" + , "hdr_prefix" + , "lib_prefix" + , "pc_prefix" + , "resolve_symlinks" + ] + , "config_vars": + [ "CC" + , "CXX" + , "CFLAGS" + , "CXXFLAGS" + , "LDFLAGS" + , "ADD_CFLAGS" + , "ADD_CXXFLAGS" + , "ADD_LDFLAGS" + , "ENV" + , "AR" + , "PREFIX" + , "BUILD_POSITION_INDEPENDENT" + , "TIMEOUT_SCALE" + ] + , "implicit": + { "defaults": [["CC", "defaults"]] + , "foreign-defaults": [["CC/foreign", "defaults"]] + , "config_reader": [["CC", "prebuilt/read_pkgconfig.py"]] + , "expand_exec": [["./", "..", "expand_exec"]] + } + , "field_doc": + { "project": + [ "The project directory. It should contain a single tree artifact." + , "It's path can be accessed via the \"WORKDIR\" variable." + ] + , "name": + [ "The name of the library (without leading \"lib\" or trailing file name" + , "extension), also used as name for pkg-config files." + ] + , "version": + [ "The library version, used for pkg-config files. Individual version" + , "components are joined with \".\"." + ] + , "localbase": ["Artifacts to stage to \"LOCALBASE\"."] + , "cmds": + [ "List of commands to execute by \"sh\". Multiple commands will be" + , "joined with the newline character." + ] + , "resolve_symlinks": + [ "Resolve all symlinks in the install directory. This operation is" + , "performed immediately after \"cmds\" were executed." + ] + , "out_hdrs": + [ "Paths to produced public header files. The path is considered" + , "relative to the include directory, which be set via \"hdr_prefix\"." + , "Note that \"out_hdrs\" and \"out_hdr_dirs\" may not overlap." + ] + , "out_hdr_dirs": + [ "Paths to produced public header directories. The path is considered" + , "relative to the include directory, which be set via \"hdr_prefix\"." + , "Note that \"out_hdrs\" and \"out_hdr_dirs\" may not overlap." + ] + , "out_libs": + [ "Paths to produced library files. The path is considered relative" + , "to the library directory, which be set via \"lib_prefix\"." + , "Order matters in the case of one library depending on another." + ] + , "cflags": + ["List of compile flags set for this target and its consumers."] + , "ldflags": + [ "Additional linker flags that are required for the consumer of the" + , "produced libraries." + ] + , "stage": + [ "The logical location of the public headers and library files." + , "Individual directory components are joined with \"/\"." + ] + , "deps": ["Public dependency on other CC libraries."] + , "pkg-config": + [ "Pkg-config file for optional infer of public cflags and ldflags. If" + , "multiple files are specified (e.g., one depends on the other), the" + , "first one is used as entry. Note that if this field is non-empty the" + , "tool \"pkg-config\" must be available in \"PATH\", which is taken" + , "from [\"CC\", \"defaults\"] or the \"ENV\" variable." + ] + , "hdr_prefix": + [ "Prefix where headers will be installed by Make. Individual directory" + , "components are joined with \"/\". Defaults to \"include\" if not set." + ] + , "lib_prefix": + [ "Prefix where libraries will be installed by Make. Individual" + , "directory components are joined with \"/\". Defaults to \"lib\" if" + , "not set." + ] + , "pc_prefix": + [ "Prefix where pkg-config files will be installed by Make. Individual" + , "directory components are joined with \"/\". Defaults to" + , "\"lib/pkgconfig\" if not set." + ] + } + , "config_doc": + { "CC": + [ "The name of the C compiler to be used." + , "If null, the respective value from [\"CC\", \"defaults\"] will be taken." + ] + , "CXX": + [ "The name of the C++ compiler to be used." + , "If null, 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." + ] + , "LDFLAGS": + [ "The linker flags to be used instead of the default ones." + , "For libraries that should be linked 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." + ] + , "ADD_LDFLAGS": + [ "The linker flags to add to the default ones." + , "For libraries that should be linked in a non-standard way; usually" + , "adapting the default target [\"CC\", \"defaults\"] is the better" + , "choice." + ] + , "ENV": + [ "The environment for any action generated." + , "If null, the respective value from [\"CC\", \"defaults\"] will be taken." + ] + , "AR": + [ "The archive tool to used for creating the library." + , "If null, the respective value from [\"CC\", \"defaults\"] will be taken." + ] + , "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." + ] + , "BUILD_POSITION_INDEPENDENT": ["Build position independent code."] + , "TIMEOUT_SCALE": + [ "The scaling of the timeout for the invocation of the foreign build." + , "Defaults to 10." + ] + } + , "imports": + { "artifacts": ["", "field_artifacts"] + , "stage_field": ["", "stage_singleton_field"] + , "shell-build": "shell-build" + , "prebuilt result": ["CC/prebuilt", "prebuilt result"] + , "install-deps": ["CC", "install-with-deps stage"] + , "strip-prefix": ["CC/foreign", "strip-prefix"] + , "for host": ["transitions", "for host"] + } + , "config_transitions": + { "defaults": + [{"type": "empty_map"}, {"type": "CALL_EXPRESSION", "name": "for host"}] + , "expand_exec": [{"type": "CALL_EXPRESSION", "name": "for host"}] + } + , "expression": + { "type": "let*" + , "bindings": + [ [ "hdr_prefix" + , { "type": "join" + , "separator": "/" + , "$1": + { "type": "++" + , "$1": + [ ["install"] + , { "type": "if" + , "cond": {"type": "FIELD", "name": "hdr_prefix"} + , "then": {"type": "FIELD", "name": "hdr_prefix"} + , "else": ["include"] + } + ] + } + } + ] + , [ "lib_prefix" + , { "type": "join" + , "separator": "/" + , "$1": + { "type": "++" + , "$1": + [ ["install"] + , { "type": "if" + , "cond": {"type": "FIELD", "name": "lib_prefix"} + , "then": {"type": "FIELD", "name": "lib_prefix"} + , "else": ["lib"] + } + ] + } + } + ] + , [ "pc_prefix" + , { "type": "join" + , "separator": "/" + , "$1": + { "type": "++" + , "$1": + [ ["install"] + , { "type": "if" + , "cond": {"type": "FIELD", "name": "pc_prefix"} + , "then": {"type": "FIELD", "name": "pc_prefix"} + , "else": ["lib", "pkgconfig"] + } + ] + } + } + ] + , [ "sources" + , { "type": "let*" + , "bindings": [["fieldname", "project"]] + , "body": {"type": "CALL_EXPRESSION", "name": "artifacts"} + } + ] + , [ "localbase" + , { "type": "disjoint_map_union" + , "msg": "localbase and installed dependency files may not overlap" + , "$1": + [ { "type": "let*" + , "bindings": + [ ["pc-install-dir", "lib/pkgconfig"] + , ["targets", {"type": "FIELD", "name": "deps"}] + ] + , "body": {"type": "CALL_EXPRESSION", "name": "install-deps"} + } + , { "type": "let*" + , "bindings": [["fieldname", "localbase"]] + , "body": {"type": "CALL_EXPRESSION", "name": "artifacts"} + } + ] + } + ] + , [ "installed_dirs" + , { "type": "foreach" + , "var": "dir_path" + , "range": {"type": "FIELD", "name": "out_hdr_dirs"} + , "body": + { "type": "join" + , "separator": "/" + , "$1": + [ {"type": "var", "name": "hdr_prefix"} + , {"type": "var", "name": "dir_path"} + ] + } + } + ] + , [ "installed_files" + , { "type": "++" + , "$1": + [ { "type": "foreach" + , "var": "lib_path" + , "range": {"type": "FIELD", "name": "out_libs"} + , "body": + { "type": "join" + , "separator": "/" + , "$1": + [ {"type": "var", "name": "lib_prefix"} + , {"type": "var", "name": "lib_path"} + ] + } + } + , { "type": "foreach" + , "var": "hdr_path" + , "range": {"type": "FIELD", "name": "out_hdrs"} + , "body": + { "type": "join" + , "separator": "/" + , "$1": + [ {"type": "var", "name": "hdr_prefix"} + , {"type": "var", "name": "hdr_path"} + ] + } + } + , { "type": "foreach" + , "var": "pc_path" + , "range": {"type": "FIELD", "name": "pkg-config"} + , "body": + { "type": "join" + , "separator": "/" + , "$1": + [ {"type": "var", "name": "pc_prefix"} + , {"type": "var", "name": "pc_path"} + ] + } + } + ] + } + ] + , ["cmds", {"type": "FIELD", "name": "cmds"}] + , ["resolve_symlinks", {"type": "FIELD", "name": "resolve_symlinks"}] + , ["defaults-transition", {"type": "empty_map"}] + , [ "expand_exec" + , { "type": "let*" + , "bindings": + [ ["fieldname", "expand_exec"] + , ["location", "expand_exec"] + , ["transition", {"type": "CALL_EXPRESSION", "name": "for host"}] + ] + , "body": {"type": "CALL_EXPRESSION", "name": "stage_field"} + } + ] + , ["install_dir", {"type": "CALL_EXPRESSION", "name": "shell-build"}] + , [ "hdrs" + , { "type": "++" + , "$1": + [ { "type": "let*" + , "bindings": + [ ["artifacts", {"type": "var", "name": "install_dir"}] + , ["paths", {"type": "FIELD", "name": "out_hdrs"}] + , ["prefix", {"type": "var", "name": "hdr_prefix"}] + ] + , "body": {"type": "CALL_EXPRESSION", "name": "strip-prefix"} + } + , { "type": "let*" + , "bindings": + [ ["artifacts", {"type": "var", "name": "install_dir"}] + , ["paths", {"type": "FIELD", "name": "out_hdr_dirs"}] + , ["prefix", {"type": "var", "name": "hdr_prefix"}] + ] + , "body": {"type": "CALL_EXPRESSION", "name": "strip-prefix"} + } + ] + } + ] + , [ "libs" + , { "type": "let*" + , "bindings": + [ ["artifacts", {"type": "var", "name": "install_dir"}] + , ["paths", {"type": "FIELD", "name": "out_libs"}] + , ["prefix", {"type": "var", "name": "lib_prefix"}] + ] + , "body": {"type": "CALL_EXPRESSION", "name": "strip-prefix"} + } + ] + , [ "config_reader" + , { "type": "let*" + , "bindings": + [["fieldname", "config_reader"], ["location", "config_reader"]] + , "body": {"type": "CALL_EXPRESSION", "name": "stage_field"} + } + ] + , [ "pkg-configs" + , { "type": "let*" + , "bindings": + [ ["artifacts", {"type": "var", "name": "install_dir"}] + , ["paths", {"type": "FIELD", "name": "pkg-config"}] + , ["prefix", {"type": "var", "name": "pc_prefix"}] + ] + , "body": {"type": "CALL_EXPRESSION", "name": "strip-prefix"} + } + ] + , [ "name" + , { "type": "assert_non_empty" + , "msg": "name is required for make library" + , "$1": {"type": "join", "$1": {"type": "FIELD", "name": "name"}} + } + ] + , ["version", {"type": "FIELD", "name": "version"}] + , ["cflags", {"type": "FIELD", "name": "cflags"}] + , ["ldflags", {"type": "FIELD", "name": "ldflags"}] + , [ "stage" + , { "type": "join" + , "separator": "/" + , "$1": {"type": "FIELD", "name": "stage"} + } + ] + , ["deps-fieldnames", ["deps", "defaults"]] + ] + , "body": {"type": "CALL_EXPRESSION", "name": "prebuilt result"} + } + } } -- cgit v1.2.3