* Fix tool_prefix for CMake.
Set the prefix before the first CMake invocation (where all the extra
flags are passed), and don't set the prefix for the `--build` and
`--install` invocations of CMake.
Fixes #685.
* Update test/cmake_text_tests.bzl
Co-authored-by: UebelAndre <github@uebelandre.com>
* Add config for building with spawn_strategy=standalone
* Always build RELEASE configuration to avoid having to select for the output due to change in artifact names for debug builds
* Fix for copy_contents_to_dir and symlink_contents_to_dir on macOS as per #512
* Update name of test files
* Added a new `platform_info` target to the foreign_cc framework
* Update foreign_cc/private/framework/platform.bzl
Co-authored-by: James Sharpe <james.sharpe@zenotech.com>
Co-authored-by: James Sharpe <james.sharpe@zenotech.com>
* Fix string escaping for cmake and configure/make
Use raw strings where possible to make readability slightly less maddening.
* Example usage of __TIME__
* Allow expansion of environment variables in HEREDOC for cmake crosstool
* Add compile check that __TIME__ is correctly redacted
* Ran buildifier
* Remove comment that is now invalid
Co-authored-by: James Sharpe <james.sharpe@zenotech.com>
* Added `targets` API to all existing build rules
* Updated examples
* Restore making the make toolchain always available.
* Add support for generator cmake parsing and setting CMAKE_MAKE_PROGRAM
* Cleaned up duplicate generator arguments
* Fixed cmake tests
* Updated docs
* Addressed PR feedback
* Fixed missing and incorrect generators
* Fixed `generate_args` name
* Attempt to catch shell script errors proactively with 'set -euo pipefail'
* Fix up uninitialised variable use
* Fix osx shell function
* Fix to unbound variable in windows commands
* 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>
handle filename containg space.
cmake prebuilt archive contains such filename in docs etc.
also fix symlink to a directory. [ -L "$1" ] returns success
for it, but it would fail "cp $1 $2" as
cp: -r not specified; omitting directory ...
Fixes: #405, #406
Co-authored-by: UebelAndre <andre.brisco@gmail.com>
Fix shell function symlink_contents_to_dir, add test
- test for the case when we symlink the contents of two directories with the same inner directories (include)
- the test data of the test for shell script helper also changes, as it uses the real shell toolchain implementation text
- Fixes the issue from #330
Fix shell_script_helper.bzl to replace function calls inside function texts.
Add test for shell_script_helper.bzl.
In particular, this fixes the case when some of the shell toolchain functions calls other shell toolchain functions (symlink_contents_to_dir and symlink_to_dir).
* Fix a way of wiping CMake cache entry values defined by toolchain from a command line, in case user specified empty values for these cache entries explicitly in cmake_external target
- it was a problem that we did not check that there was some value in the "toolchain" dict before we pop() - reported in comment in #292
- make code which does wiping empty values more explicit
* Additionally, if non-empty value for CMAKE_RANLIB was not specified by user or Bazel toolchain, put empty value for it to forbid CMake to auto detect it
context: https://github.com/bazelbuild/rules_foreign_cc/issues/252
* Add test for user's redefined value for CMAKE_BUILD_TYPE
* fix(cmake): Use "Debug" and "Release" instead of "DEBUG" and "RELEASE"
These values are case-sensitive in cmake and give this error currently:
```
CMake Error at CMakeLists.txt:23 (message):
CMAKE_BUILD_TYPE must be one of: Debug, Release (current value: 'RELEASE')
```
* update test data
* Windows, tests: fix for native test wrapper
In this PR:
- Update `@bazel_skylib` to 0.8.0, which has a
Windows-compatible unittest.bzl
- Fix unittest-using tests. Correct usage of
`unittest.end(env)` is to return its value.
Result: //test:all now passes with Bazel 0.25.0rc3
and --incompatible_windows_native_test_wrapper
* Register Skylib toolchains
* rules_foreign_cc_dep registers unittest toolchains
* Address review comments
* Add bazel_skylib_workspace to WORKSPACE files
* Remove stale toolchain init code
- explicitly pass the values of these options to corresponding compilation/link flags lists; add them to the end of the lists of they are not already there
- please see the test in test/standard_cxx_flags_test
If the user passes empty string for some cache entry, for instance,
CMAKE_BUILD_TYPE, then the corresponding computed value
(computed from the Bazel's build type or Bazel C/C++ toolchain)
should not be used.
I.e., user passes "CMAKE_BUILD_TYPE": "", and there will be no
-DCMAKE_BUILD_TYPE in the cmake call.
* Extract shell fragments into a toolchain
Construct script in framework.bzl using special notation for calling
shell fragments, defining and referencing environment variables;
have the script converted from this special notation into a real script
(see README.md notes.)
The special notation is used to keep script construction in code still readable.
Tools scripts (cmake, ninja) were also converted.
* Fix reference to environment variables in examples
.. and reference it correctly $$var_name$$ so it is replaced further
* Review comments: documentation, explicitly mark functions from toolchain
- mark functions from shell toolchain as ##funname##, so that they
can not be mixed with usual shell functions
* Fix operating system name for windows in toolchain file
* Additional env vars for windows
* Correct cmake tool build
* Do not build ninja on Windows
* When run on Windows under msys, find utility from Window could "leak"...
into the script. Use heuristics to use /usr/bin/find if it exists.
Also, use pwd -W to get Windows-styled paths (for cmake)
* Extract cmake and ninja into a toolchain; provide defaults.
In the workspace-level rule registration function, default toolchain
implementations are registered for all platforms, which are calling
the cmake and ninja just by name, assuming they are preinstalled.
Also, the user can pass the custom toolchains in the initialization
function, they will be registered before the defaults.
* Do not run ninja build test for now without nested workspaces support
* Corrections after merge
* Always build ninja from sources for tests, correct initialization order
* Add example of using prebuilt artefact in the native tools toolchain.
* Review comments, have native_tool_toolchain#target, not label
+ improve documentation
* Correct ninja toolchain label
* Correct documentation in native_tools_toolchain.bzl
* Add crosstool example; does not work with cmake rule yet
the code is taken from Bazel test data (bazel_toolchain_test_data)
* Make crosstool compilation of cmake_external + cc_binary work
To build example, cd examples/cmake_crosstool bazel build //:libhello_test
Changes:
1) Initially suggested in #124: put $EXT_BUILD_ROOT on path, so that relative paths can be resolved by CMake
2) Toolchain tools are references as relative paths, and they themselves refer to external repository with external/ prefix.
This will not work with CMake, as CMake also perform compiler tests and the build is performed in some temp directory.
We need to convert to absolute paths.
I did a trick with checking of $EXT_BUILD_ROOT is defined and then using it as a prefix.
3) I had to change the visibility of the cc-compiler-k8 toolchain to public
4) For CMake crosstool file, CMAKE_C_COMPILER, CMAKE_CXX_COMPILER, CMAKE_AR need to be absolute, so in cases when they are relative and not under external directory, force paths conversion