From c301e85a61dc6e43b8cc6ce8f44a902c392163a2 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Mon, 24 Jun 2024 16:08:57 +0200 Subject: CC defaults: Provide the debug stage also for implicit deps This ensures that one can inspect, e.g., generated protobuf source files (.pb.cc) or standard library headers while debugging proto libraries or general C++ libraries and binaries, respectively. --- CC/RULES | 42 +++++++++++++++++++++++++++++++++++++++++- CC/proto/RULES | 41 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 81 insertions(+), 2 deletions(-) diff --git a/CC/RULES b/CC/RULES index 05653fa..af9ad92 100644 --- a/CC/RULES +++ b/CC/RULES @@ -21,6 +21,7 @@ , "PATH" , "SYSTEM_TOOLS" ] + , "config_vars": ["ARCH", "HOST_ARCH", "TARGET_ARCH", "DEBUG"] , "field_doc": { "base": ["Other targets (using the same rule) to inherit values from."] , "toolchain": @@ -77,7 +78,16 @@ , "with \":\". Specifying this field extends values from \"base\"." ] } - , "config_vars": ["ARCH", "HOST_ARCH", "TARGET_ARCH"] + , "config_doc": + { "ARCH": + [ "The unqualified architecture. Is taken as a default for \"HOST_ARCH\"" + , "and \"TARGET_ARCH\" if not set." + ] + , "HOST_ARCH": + ["The architecture on which the build actions are carried out."] + , "TARGET_ARCH": ["The architecture for which to build."] + , "DEBUG": ["Compute the debug-stage, needed for local debugging."] + } , "imports": { "base-provides": "defaults-base-provides" , "base-provides-++": "defaults-base-provides-++" @@ -91,6 +101,7 @@ , "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"}]} @@ -300,6 +311,33 @@ , {"type": "CALL_EXPRESSION", "name": "ldflags-files-deps"} ] , ["package", {"type": "env", "vars": ["cflags-files", "ldflags-files"]}] + , [ "debug-srcs" + , { "type": "if" + , "cond": {"type": "var", "name": "DEBUG"} + , "then": + { "type": "let*" + , "bindings": [["deps-provider", "debug-srcs"]] + , "body": {"type": "CALL_EXPRESSION", "name": "debug-deps"} + } + , "else": {"type": "empty_map"} + } + ] + , [ "debug-hdrs" + , { "type": "if" + , "cond": {"type": "var", "name": "DEBUG"} + , "then": + { "type": "map_union" + , "$1": + [ { "type": "let*" + , "bindings": [["deps-provider", "debug-hdrs"]] + , "body": {"type": "CALL_EXPRESSION", "name": "debug-deps"} + } + , {"type": "var", "name": "compile-deps"} + ] + } + , "else": {"type": "empty_map"} + } + ] ] , "body": { "type": "RESULT" @@ -321,6 +359,8 @@ , "link-deps" , "link-args" , "package" + , "debug-srcs" + , "debug-hdrs" ] } } diff --git a/CC/proto/RULES b/CC/proto/RULES index abea997..2e4b1d3 100644 --- a/CC/proto/RULES +++ b/CC/proto/RULES @@ -15,7 +15,7 @@ , "GRPC_PLUGIN" , "PATH" ] - , "config_vars": ["ARCH", "HOST_ARCH"] + , "config_vars": ["ARCH", "HOST_ARCH", "DEBUG"] , "field_doc": { "base": [ "Other targets (using the same rule) to inherit values from. If" @@ -69,6 +69,15 @@ , "with \":\". Specifying this field extends values from \"base\"." ] } + , "config_doc": + { "ARCH": + [ "The unqualified architecture. Is taken as a default for \"HOST_ARCH\"" + , "and \"TARGET_ARCH\" if not set." + ] + , "HOST_ARCH": + ["The architecture on which the build actions are carried out."] + , "DEBUG": ["Compute the debug-stage, needed for local debugging."] + } , "imports": { "base-provides": ["./", "..", "defaults-base-provides"] , "base-provides-++": ["./", "..", "defaults-base-provides-++"] @@ -82,6 +91,7 @@ , "cflags-files-deps": ["CC", "cflags-files-deps"] , "ldflags-files-deps": ["CC", "ldflags-files-deps"] , "for host": ["transitions", "for host"] + , "debug-deps": ["CC", "debug-deps"] } , "config_transitions": {"toolchain": [{"type": "CALL_EXPRESSION", "name": "for host"}]} @@ -240,6 +250,33 @@ , {"type": "CALL_EXPRESSION", "name": "ldflags-files-deps"} ] , ["package", {"type": "env", "vars": ["cflags-files", "ldflags-files"]}] + , [ "debug-srcs" + , { "type": "if" + , "cond": {"type": "var", "name": "DEBUG"} + , "then": + { "type": "let*" + , "bindings": [["deps-provider", "debug-srcs"]] + , "body": {"type": "CALL_EXPRESSION", "name": "debug-deps"} + } + , "else": {"type": "empty_map"} + } + ] + , [ "debug-hdrs" + , { "type": "if" + , "cond": {"type": "var", "name": "DEBUG"} + , "then": + { "type": "map_union" + , "$1": + [ { "type": "let*" + , "bindings": [["deps-provider", "debug-hdrs"]] + , "body": {"type": "CALL_EXPRESSION", "name": "debug-deps"} + } + , {"type": "var", "name": "compile-deps"} + ] + } + , "else": {"type": "empty_map"} + } + ] ] , "body": { "type": "RESULT" @@ -259,6 +296,8 @@ , "link-deps" , "link-args" , "package" + , "debug-srcs" + , "debug-hdrs" ] } } -- cgit v1.2.3