Tags down


Isolate Bazel C++ build from system include directories

By : user2174353
Date : October 18 2020, 08:10 AM
it helps some times The solution consists of three parts:
creating a custom C++ toolchain definition convincing Bazel to use that toolchain convincing the compiler to ignore its default system headers and use yours
code :
mkdir /tmp/bar && cd /tmp/bar
echo "cc_binary(name='x',srcs=['x.cc'])" > BUILD
echo -e "#include <stdio.h>\nint main(void) { return 0; }" > x.cc
bazel build //:x
mkdir /tmp/bar/my_toolchain
touch /tmp/bar/my_toolchain/WORKSPACE
cat $(bazel info output_base)/external/local_config_cc/CROSSTOOL > /tmp/bar/my_toolchain/CROSSTOOL
cat $(bazel info output_base)/external/local_config_cc/BUILD > /tmp/bar/my_toolchain/BUILD
echo "local_repository(name='my_toolchain', path='/tmp/bar/my_toolchain')" >> WORKSPACE
bazel build --crosstool_top=@my_toolchain//:toolchain //:x
cxx_builtin_include_directory: "/tmp/bar/my_toolchain"
compiler_flag: "-isystem=/tmp/bar/my_toolchain"
srcs = glob(["**/*.h"]),
touch /tmp/bar/my_toolchain/std-predef.h
$ bazel build --crosstool_top=@my_toolchain//:toolchain //:x
INFO: Build options have changed, discarding analysis cache.
INFO: Analysed target //:x (0 packages loaded, 61 targets configured).
INFO: Found 1 target...
ERROR: /tmp/bar/BUILD:1:1: undeclared inclusion(s) in rule '//:x':
this rule is missing dependency declarations for the following files included by 'x.cc':
Target //:x failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.332s, Critical Path: 0.09s, Remote (0.00% of the time): [queue: 0.00%, setup: 0.00%, process: 0.00%]
INFO: 0 processes.
FAILED: Build did NOT complete successfully
echo 'int foo_func(int x) { return x*2; }' > /tmp/bar/my_toolchain/foo.h
echo -e '#include <foo.h>\nint main(int argc, char**) { return foo_func(argc); }' > x.cc
bazel build --crosstool_top=@my_toolchain//:toolchain //:x
bazel-bin/x hello world ; echo $?

Share : facebook icon twitter icon

How to check whether system has some header file using bazel build?

By : RatteOverlord
Date : March 29 2020, 07:55 AM
Any of those help If you are sure that the header is always present on a particular platform, use select() as elaborated by László.
If you actually need to detect the header at the build time, you will have to implement a custom repository_rule that will query the system and will generate a workspace with a header defining the macro.

CMake: ordering of include directories (How to mix system- and user-based include paths?)

By : Kamil Gregor
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , Here's what CMake says about include_directories():
include_directories([AFTER|BEFORE] [SYSTEM] dir1 [dir2 ...])

Build C++ code with Circular dependency using Bazel Build System

By : Brian James Wolf
Date : March 29 2020, 07:55 AM
Hope that helps In my hunt for a build system that can handle multiple languages and build code in incremental manner, I found Bazel to be a very good solution. However, there is one issue I do not have a solution for. , It depends on how exactly your circular dependency looks like.

C++ / Bazel: How to include angle <> bracket system headers?

By : tsz zhui Chun
Date : March 29 2020, 07:55 AM
This might help you Does the attribute cc_binary.includes help?

read local file content in bazel build system

By : Krish Rao
Date : March 29 2020, 07:55 AM
Any of those help .bzl code cannot read files, and can't make decisions based on contents of files.
You must create actions (e.g. ctx.actions.run), make the file an action input, and have the action read the file.
Related Posts Related Posts :
  • How to slice Torch images as numpy images
  • Understanding purescript-variant
  • Behavior on clustered environment
  • Can I make an area chart which bounds defined between two lines with Google Charts library?
  • Where liquibase stores hash sums?
  • ServiceStack: Getting FileNotFoundException when properties are null?
  • API Automation Testing : Is there any way to automate download scenario with content validation?
  • Howto rotate a Sprite after resizing the Sprite with setBounds ? (LIBGDX)
  • E4 RCP NoClassDefFoundError
  • We used to send parameters to our WMS geoserver SQLViews by the viewparams field. But WMTS doesn't have this field
  • sympy matrix element round?
  • HTTPS Load Balancer to expose a Workload on Google Kubernetes
  • How to connect remote repository in JFrog Artifactory to repo.manento.com?
  • PROMELA: What are interleavings?
  • cppwinrt A subclass of Panel (or other class),What constructors are needed?
  • Should SetCustomStatus() be called when orchestration is replayed?
  • How can I disable right click/context menu for ag-grid?
  • Lucene query syntax in Kibana
  • How do you add the time relation in blender cylces nodes shader?
  • Reference to type 'Assembly' claims it is defined in 'System.Runtime', but it could not be found in Xamarin UWP
  • Class not found in classes/controller/Controller.php in prestashop
  • How should AGI handle a HangupRequest
  • getBinding is not working after the page loads
  • underscore groupBy inner key
  • Unable to get appropriate prediction using statsmodel for HoltWinters
  • building dynamic XSLT in XQuery - using HTML passed into parameter
  • How to iterate through an enmap?
  • Properties, Collections and Permissions information
  • Is there such a thing as a filename that is too long?
  • Karate - [#document: null] in output
  • SAP Introspection: Resolve ForeignKey
  • Flask: Trouble resolving endpoint locations in package
  • Metadata in DynamoDB stream event for delete operation?
  • Create waf size feature
  • Floating decimal point type in Haxe
  • Installing Spyder (updated for 2018)
  • How to use Active Directory Authentication in ASP.NET Core?
  • ABAP: from get_auth_values() result to SQL query
  • AOSP build for Samsung Galaxy Tab A
  • Allow to find only users members of a specific group in 1 query
  • How can I easily label my data in Power BI?
  • Use or not, of lambda to define a function in Racket
  • Can I use GitHub's Linguist as a replacement to Rouge in Jekyll
  • Storing streamed tweets in a list for further analysis
  • Swagger permanent authorization token
  • Output index of ELKI
  • Diverts deleted when restarting ActiveMQ Artemis
  • Sum-up and then calculate vs. calculate and then sum-up (SSAS-MDX)
  • xQuery - fill custom array
  • Issue with javax.mail and attached file
  • How to change the theme colors in Vuetify in standalone/CDN mode?
  • WildFly 10.0 port offset "9" can't connect to CLI at 9999
  • 401 Error when sending data to Stripe `Customers` API
  • When would a linked list be preferred over a circular buffer?
  • How to get Facebook page feed and Filter its fields as Json using Google App script
  • How to delete or set lifespan to zero - Dialogflow Agent Context
  • How to update Mat-Input Place Holder on Focus
  • How to show the Systray Icon and also the corresponding executable in the taskmanager by default when we run the install
  • Google Smart Home Agent responded Empty JSON
  • Using conditionalpanel in shiny where input is a vector
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org