rules_foreign_cc/toolchains_examples
Attila Oláh 466c32c70f
Build under Bazel sandbox instead of /tmp (#479)
* Build under bazel sandbox instead of /tmp, and remove redundant printf

Build artifacts under /tmp are not cleaned up after a failed build, for
the ease of debugging.  However, this can quickly fill up the /tmp partition
if the build is large.  Build under the sandbox directory instead, and
rely on standard bazel cleanup scheme.

Also remove a print from the cleanup function, which somehow causes empty
newlines to be printed in bazel build output.

* Avoid infinite recursion in symlink_to_dir.

This is a somewhat hackish approach to exclude *.ext_build_deps from
symlinks when creating the symlink forest. This is necessary in cases
where an entire directory is added to the includes, e.g. when setting
includes = ["."] where the directory itself contains a cmake_external()
rule that depends on the very rule containing the includes = ["."].

* Also avoid using a temp directory when bootstrapping make or cmake itself.

* Remove the ##tmpdir## shell toolchain command.

It is no longer necessary now that all its uses are gone.

Co-authored-by: Lauri Peltonen <lape@iki.fi>
2021-02-05 13:29:07 +00:00
..
.bazelrc Register shell toolchain implementations in the correct order and allow customization (#214) 2019-01-31 15:11:28 +01:00
BUILD Replace references to @bazel_tools//platforms with @platforms//. (#427) 2021-01-23 12:28:38 -08:00
README.md Register shell toolchain implementations in the correct order and allow customization (#214) 2019-01-31 15:11:28 +01:00
WORKSPACE Fix typo in macro arguments (#492) 2021-02-03 12:54:23 -08:00
additional_toolchains.bzl Enable Buildifier in CI (#458) 2021-01-25 22:01:43 +00:00
fancy_platform_commands.bzl Build under Bazel sandbox instead of /tmp (#479) 2021-02-05 13:29:07 +00:00
test_platform_name_rule.bzl Enable Buildifier in CI (#458) 2021-01-25 22:01:43 +00:00

README.md

###How to add a shell toolchain implementation for a custom platform: (to modify the fragments of generated shell script)

  • define your own shell toolchain file(s) by copying @rules_foreign_cc//tools/build_defs/shell_toolchain/toolchains/impl:linux_commands.bzl, and modifying the methods.
  • create a mapping: a list of ToolchainMapping with the mappings between created file(s) and execution or/and target platform constraints.
  • in the BUILD file of some package, call "register_mappings" macro from "@rules_foreign_cc//tools/build_defs/shell_toolchain/toolchains:defs.bzl", passing the mappings and toolchain_type_ = "@rules_foreign_cc//tools/build_defs/shell_toolchain/toolchains:shell_commands"
  • in the WORKSPACE file of your main repository, when you initialize rules_foreign_cc, pass the mappings and the package, in which BUILD file you called "register_mappings" macro

Please look how it is done in this example.