2
0
Fork 0
mirror of https://github.com/bazel-contrib/rules_foreign_cc synced 2024-11-25 17:31:25 +00:00
Commit graph

141 commits

Author SHA1 Message Date
Philip Shao b3caa87950 Fix extension-stripping logic.
Trivial manual test case:
   libpython3.8.a <-> libpython3.8m.a

Existing logic erroneously reports collision on "libpython3" token.
2020-08-21 13:52:49 +02:00
irengrig f54b7ae56d
Add "#!/usr/bin/env bash" prefix to the scripts (#410) 2020-06-09 17:39:51 +02:00
Ilya Dmitrichenko d02a56d0c3
Handle case where LDFLAGS is undefined (#407)
Co-authored-by: irengrig <ichern@google.com>
2020-06-08 19:05:29 +02:00
Justin King aeb5a4e35d
Support running autogen.sh and autoreconf (#403)
Co-authored-by: Justin King <jcking@google.com>
2020-06-08 19:01:21 +02:00
irengrig 74b146dc87
Fix shell function symlink_contents_to_dir, add test (#377)
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
2020-05-08 11:43:40 +02:00
Laurent Le Brun c292369597
Fix Buildifier warnings (#395)
* Run buildifier formatter

* Fix buildifier warnings

Ran: `buildifier --lint=fix -r .`
2020-05-04 19:50:45 +02:00
irengrig 3515b20a24
Fix shell_script_helper.bzl to replace function calls inside function… (#375)
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).
2020-04-30 11:24:25 +02:00
irengrig 8372f383cf
Allow to specify working directory for cmake_external (#390)
Allow to specify working directory for cmake_external
For LLVM case, when main CMakeLists.txt is in the /llvm subdirectory in the source tree

Co-authored-by: Andy Yankovsky <weratt@gmail.com>
2020-04-24 09:16:21 +02:00
bcsgh bafdc9d274
Add some newlines to make the logging print correctly (#364) 2020-02-12 21:56:00 +01:00
irengrig 10daf29cae
For consuming Bazel-built targets as dependencies, do not use quote_includes from CcInfo, as they are not used for anything related to the particular library, but contain references to the gendir and bin directories, which seems hardly useful. (We expect Bazel targets to describe their include directories and headers explicitly). (#322)
Rules_foreign_cc also currently is not using CcInfo.quote_includes.
Having them leads to symlinking directory trees without any reason.
Tests: we already have tests for transitive Bazel dependencies (//cmake_synthetic:test_bazel_transitive_deps, //cmake_with_bazel_transitive:test, //configure_with_bazel_transitive:test)
2019-10-23 16:00:39 +02:00
Dig-Doug 83e79ef83b Prefixes bazel_version so that it doesn't conflict with other libraries. (#328) 2019-10-23 11:40:33 +02:00
irengrig e6ca4d2cd1
Fix permission problem with replacing absolute path with sed, #306 (#324)
* Fix permission problem with replacing absolute path with sed, #306

- we can not modify files under Bazel's output directory
- so we can not modify pkg_config files, written there, for instance
- solution: only replace absolute paths in the files being created by the current target,
using the environment variable as the replacement value ($EXT_BUILD_DEPS)

* Wrap environment variable in ${} in replace string
2019-10-02 10:49:37 +01:00
Niklas Salmoukas 14a9f35611 Improve cygwin compatibility (#323) 2019-09-27 06:39:11 -04:00
irengrig 7bc4be735b
When executed without sandbox, target- and host- configured targets are created in the same execution root with the same names. (#321)
Apparently, it is not the problem for build outputs, but deps directory that is created by script.
What is even more problematic is that this directory can be accessed while building this target in parallel for different configurations. So even if we clean it before using, we might break the build of the parallel target.

Solution: create temp directory to be used as deps directory.
(Additionally, this demonstrates the benefits of sandboxed execution.)
2019-09-26 13:28:21 -04:00
irengrig 16ddc00bd4
Be resilient with Bazel-built transitive dependencies duplicates (#318)
Be resilient with Bazel-built transitive dependencies duplicates

- it is possible that some duplicate libraries, built with Bazel, will be passed as inputs to cmake_external or configure_make. rules_foreign_cc should filter duplicates out rather then fail.
- add a test (which just builds the target) //cmake_synthetic:lib_with_duplicate_transitive_bazel_deps
2019-09-17 14:34:20 -04:00
irengrig 2565832da9
Fix make() rule to run make commands sequentially and not in parallel. (#317)
Fixes #313.
2019-09-16 13:43:41 -04:00
irengrig 6ad84f7739
Adapt rules_foreign_cc for working with libtool instead of ar. (#315)
Adapt rules_foreign_cc for working with libtool instead of ar.

- for CMake, pass "<TARGET>" as the output file when forming linker flags with cc_common. CMake will later replace <TARGET> with the actual output file. Fill CMAKE_C_CREATE_ARCHIVE and CMAKE_CXX_CREATE_ARCHIVE CMake variables with 'CMAKE_AR %Bazel-link-flags% <OBJECTS>' call, where CMAKE_AR will take the path to libtool.
Related documentation: https://cmake.org/cmake/help/v3.15/variable/CMAKE_LANG_ARCHIVE_CREATE.html?highlight=cmake_%20lang%20_archive_create

- for configure_make, for the libevent example, we need to skip specifying the libtool from Bazel's toolchain as a linker, because libevent script uses it's own libtool and manages to pass the output file to it, but not to the libtool we are passing. Let it do so as it is a customized script.
Do it with specifying empty string for the $AR environment variable.
Other examples with configure_make work fine.

This fixes https://github.com/bazelbuild/bazel/issues/9258
2019-09-09 18:20:42 +02:00
Sahn Lam c3d5405cbc Add -H to find in symlink_contents_to_dir (#303)
This fixes #302
2019-08-07 10:55:52 +02:00
irengrig a209b642c7
Remove unnecessary restrictions on the library filename - fixes #276 (#294)
* Remove unnecessary restrictions on the library filename - fixes #276

* Fix review comments, remove unnecessary parameter
2019-07-17 14:05:03 +02:00
irengrig 30f398dc40
Fix a way of wiping CMake cache entry values defined by toolchain fro… (#293)
* 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
2019-07-17 13:51:21 +02:00
Sahn Lam 64e2cda959 Add -L to cp (#266)
This fixes #265. See the issue for details.
2019-07-10 18:54:49 +02:00
irengrig 540253c265
Implement support for "pure" GNU Make in make.bzl (#285)
* Implement support for "pure" GNU Make in make.bzl

Usage: load("@rules_foreign_cc//tools/build_defs:make.bzl", "make")
make(name = <name>, lib_source = <source>), please see more arguments
in make.bzl

Add test in examples/simple_make (runs only on Linux because of Makefile contents)
2019-07-10 18:05:24 +02:00
irengrig 0b8356f199
Fix replace_in_files function in windows_commands.bzl (#280)
* Fix replace_in_files function in windows_commands.bzl

Filter files by types, where the absolute paths need to be replaced.

* Add one more hello world example

* Include test into windows list, remove from Mac OS list
2019-06-25 18:31:21 +02:00
Justin Buchanan d084070466 fix(cmake): Use "Debug" and "Release" instead of "DEBUG" and "RELEASE" (#277)
* 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
2019-06-21 10:40:01 +02:00
irengrig dea1437d92
Fix #123 Improve code readability for collecting input dependencies (#257)
* Fix #123 Improve code readability for collecting input dependencies

* Fix line endings
2019-06-19 15:50:58 +02:00
irengrig a0dc109915
Fix the code to work with Bazel HEAD: (#274)
Fix the code to work with Bazel HEAD:

- convert depset to list for iteration (libraries to link)
- _build_tools() are just creating the file, not contributing anything to the text of constructed BUILD file, so make a call to this method separately.
2019-06-04 11:11:46 +02:00
Marcel Hlopko 6b2f454a41 Use forward compatible version of _configure_features (#271)
This PR fixes the bug introduced in https://github.com/bazelbuild/rules_foreign_cc/pull/270.

hlopko@ should not be allowed to code undercaffeinated.
2019-05-28 10:55:13 +02:00
Laurent Le Brun 3990f265ee Migrate for --incompatible_depset_is_not_iterable (#267) 2019-05-28 10:47:28 +02:00
Marcel Hlopko 604f1e1c9f Guard cc_common.configure_features with a version check (#270)
This PR adds @bazel_version repository which contains single def.bzl
file which contains a BAZEL_VERSION constant that can be used to perform
conditional logic bazed on the Bazel version.

As a result, rules_foreing_cc are now compatible with Bazel 0.24 - 0.27
(at least regarding configure_features :)
2019-05-28 10:31:58 +02:00
Marcel Hlopko 50e2679dee Migrate for --incompatible_enable_cc_toolchain_resolution (#262)
https://github.com/bazelbuild/bazel/issues/7260
2019-05-15 14:43:13 +02:00
Marcel Hlopko 9c6480858a Migrate for incompatible_require_ctx_in_configure_features (#260)
This PR migrates rules_foreign_cc for bazelbuild/bazel#7793
2019-05-10 15:51:44 +02:00
irengrig bf99a0bf00
Fix #254 (Linker flags passed to ar). (#256)
Fix #254 (Linker flags passed to ar).
2019-05-10 15:49:21 +02:00
irengrig 3831409fd5
For cmake_external and configure_make, do not prepend relative instal… (#258)
For cmake_external and configure_make, do not prepend relative install prefix path with "./", as it is recognized as relative and gets appended to the current build directory anyway, forming the path /tmp/something/./install_prefix - which does not make much sense.
2019-05-09 14:11:03 +02:00
Keith Smiley 2b40a0098d Allow ranlib to be overridden (#253)
This allows users to set this to an empty string if they want to disable
it. Related https://github.com/bazelbuild/rules_foreign_cc/issues/252
2019-05-09 10:56:11 +02:00
irengrig e36f3cee8c
Fix using Bazel-built libraries by cmake_external and configure_make (#249)
Fix #232 - enable usage of Bazel-built libraries as dependencies of cmake_external and configure_make.

- fix logic of reading library data described by C/C++ Bazel interface (as CcInfo.linking_context appeared)
- symlink transitive include directories under $EXT_BUILD_DEPS
- gather all possible transitive include directories to pass to CMake, pass transitive include directories to CMAKE_PREFIX_PATH so that the transitive include directories were scanned by CMake
- fix logic of passing transitive libraries into CPPFLAGS (configure_make)
- add test with the chain: Bazel lib -> CMake lib -> Bazel cc_test
- add synthetic configure-make test with the chain: Bazel lib -> configure_make lib -> Bazel cc_test
- also notice, that passed include directories from Bazel C/C++ Sandwich interface are not always existing; for now, make symlinking code resistant to that

see https://www.gnu.org/software/autoconf/manual/autoconf-2.63/html_node/Preset-Output-Variables.html
2019-05-09 10:35:00 +02:00
Dig-Doug e43f5f275a - Fixes a bug where bootstrap options weren't being passed (#245) 2019-05-06 10:30:14 +02:00
irengrig e3f4b5e0bc
remove unneeded -print option from find command (#242) 2019-04-04 13:39:40 +02:00
irengrig f00cd27f06
Pass --copt, --cxxopt, --conlyopt, --linkopt to cmake_external/configure_make rules (#235)
- 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
2019-03-11 16:50:39 +01:00
irengrig bcb7a345f7
Remove support for the versions of Bazel before 0.22 (#234)
- as 0.23 is already released
- to have only one variant of framework code
2019-03-11 16:34:56 +01:00
irengrig bb9d86c1f2
Fix generated code to have load statements strictly in the beginning (#231)
make code compatible with --incompatible_bzl_disallow_load_after_statement
2019-03-07 13:35:13 +01:00
irengrig 8648b04460
Correct check for shared library requiring also interface library on win (#226)
originally suggested in #184
2019-02-14 11:18:47 +01:00
bbarnes52 514cb4e0a1 adds bootstrap_options to attribute to allow user to pass command line args to bootstrap.sh (#181) 2019-02-14 11:05:10 +01:00
bbarnes52 02e808a885 removes unused reference (#180) 2019-02-14 10:50:44 +01:00
irengrig 4d73887da8
Improve outputs handling: wrapper script in shell-abstract manner (#223)
* Improve outputs handling: wrapper script in shell-abstract manner

- extract wrapper script creation into a separate function,
- simplify the script and log names, also output the wrapper script text,
- introduce more shell primitives

related to #204

* Correct review comments
2019-02-14 10:00:19 +01:00
irengrig d8e78e4cf0
cmake_external: allow user to suppress computed cache entries (#224)
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.
2019-02-07 17:11:23 +01:00
irengrig d334e2eec6
For configure_make, allow to run configure in place (#221)
Some configure scripts rely on being called from their parent directory (they call other files as if they are in the same directory). For this case, we should copy/symlink the contents of the directory under our build root, and run configure from there.

New attribute in configure_make rule: "configure_in_place".

Also, add documentation for configure_make.
2019-02-04 20:10:40 +01:00
irengrig 4999ececdb
Fix shell script conversion bug + test (#220) 2019-02-04 19:53:44 +01:00
Dig-Doug fa183dcc1f Hide build output from console (#204)
* Implements redirecting the build command output to a log file and printing it when the build fails.

* - Removed gitignore
2019-02-01 17:39:07 +01:00
irengrig b2ac19e790
Pass through the os_name() from a custom shell toolchain to CMake (#215) 2019-01-31 15:42:37 +01:00
irengrig 91ba4441d2
Register shell toolchain implementations in the correct order and allow customization (#214)
* Register shell toolchain implementations in the correct order

so that the default implementation is the last

* Refactor shell toolchain to allow users register custom shell toolchains.

- 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

* Correct typo
2019-01-31 15:11:28 +01:00