aboutsummaryrefslogtreecommitdiff
path: root/configuration/bazel
diff options
context:
space:
mode:
authorMarco Poletti <poletti.marco@gmail.com>2020-08-09 21:10:16 -0700
committerMarco Poletti <poletti.marco@gmail.com>2020-08-09 21:10:16 -0700
commitc6d389dab4bcdb61ed1a3d9d0500f8d6feca1ecf (patch)
tree2f65fc3e2f83d33cc18f6fe5cb960dcd46680be3 /configuration/bazel
parent6f3760672a0d2c772306e737d894a2ae2d8c5f58 (diff)
downloadgoogle-fruit-c6d389dab4bcdb61ed1a3d9d0500f8d6feca1ecf.tar.gz
Fix bazel build errors introduced by 94cefefb42f3685c1d64664e6aa9cbaf834b25ee when the Fruit headers are not also installed on the system where bazel runs.
Diffstat (limited to 'configuration/bazel')
-rw-r--r--configuration/bazel/BUILD2
-rw-r--r--configuration/bazel/build_defs.bzl28
2 files changed, 24 insertions, 6 deletions
diff --git a/configuration/bazel/BUILD b/configuration/bazel/BUILD
index 112b732..a207462 100644
--- a/configuration/bazel/BUILD
+++ b/configuration/bazel/BUILD
@@ -3,6 +3,6 @@ load("//third_party/fruit/configuration/bazel:build_defs.bzl", "generate_fruit_c
package(default_visibility = ["//third_party/fruit:__subpackages__"])
generate_fruit_config(
- name = "fruit_config",
+ name = "fruit-config-base",
check_sources = glob(["*.cpp"])
)
diff --git a/configuration/bazel/build_defs.bzl b/configuration/bazel/build_defs.bzl
index 8d683c4..28c3b17 100644
--- a/configuration/bazel/build_defs.bzl
+++ b/configuration/bazel/build_defs.bzl
@@ -17,7 +17,9 @@ def _generate_fruit_config_impl(ctx):
check_output_files = []
for check_source in ctx.files.check_sources:
- output_file = ctx.actions.declare_file(check_source.path + ".o")
+ check_name = check_source.path[:-len(".cpp")].split('/')[-1].split('\\')[-1]
+
+ output_file = ctx.actions.declare_file(check_name + ".o")
c_compile_variables = cc_common.create_compile_variables(
feature_configuration = feature_configuration,
@@ -37,9 +39,8 @@ def _generate_fruit_config_impl(ctx):
variables = c_compile_variables,
)
- check_name = check_source.path.split('/')[-1].split('\\')[-1]
check_define = 'FRUIT_HAS_%s' % check_name.upper()
- check_output_file = ctx.actions.declare_file(check_source.path + ".h")
+ check_output_file = ctx.actions.declare_file(check_name + ".h")
ctx.actions.run_shell(
command = '"$@" &>/dev/null && echo "#define %s 1" >"%s" || echo "#define %s 0" >"%s"; touch "%s"' % (
@@ -55,7 +56,7 @@ def _generate_fruit_config_impl(ctx):
)
check_output_files.append(check_output_file)
- merged_output_file = ctx.actions.declare_file(ctx.label.name + ".h")
+ merged_output_file = ctx.actions.declare_file("fruit/impl/fruit-config-base.h")
ctx.actions.run_shell(
command = '\n'.join([
'(',
@@ -70,8 +71,25 @@ def _generate_fruit_config_impl(ctx):
outputs = [merged_output_file],
)
+ compilation_context, compilation_outputs = cc_common.compile(
+ actions = ctx.actions,
+ feature_configuration = feature_configuration,
+ cc_toolchain = cc_toolchain,
+ public_hdrs = [merged_output_file],
+ name = "%s_link" % ctx.label.name,
+ )
+
+ linking_context, linking_outputs = cc_common.create_linking_context_from_compilation_outputs(
+ actions = ctx.actions,
+ feature_configuration = feature_configuration,
+ compilation_outputs = compilation_outputs,
+ cc_toolchain = cc_toolchain,
+ name = "%s_link" % ctx.label.name,
+ )
+
return [
- DefaultInfo(files = depset([merged_output_file])),
+ DefaultInfo(files = depset([merged_output_file]), runfiles = ctx.runfiles(files = [merged_output_file])),
+ CcInfo(compilation_context=compilation_context, linking_context=linking_context),
]
generate_fruit_config = rule(