Commit Graph

106 Commits

Author SHA1 Message Date
UebelAndre dc49c3716c
Added architecture documentation (#544) 2021-03-09 10:49:13 -08:00
UebelAndre 175b29c6f7
Renamed BUILD files to BUILD.bazel (#540)
* Renamed BUILD files to BUILD.bazel

* Ran Buildifier
2021-03-03 10:08:03 -08:00
UebelAndre fc8efbdf7d
Added `ninja` rule for building Ninja projects (#527)
* Added `ninja` rule for building Ninja projects

* Third party ninja example
2021-03-01 15:46:25 +00:00
UebelAndre e285764b78
Restructed examples and enabled more testing (#515)
* Reorganized examples

* Documentation

* Third party
2021-02-26 20:21:13 +00:00
James Sharpe 4520018bc2
Make generate_crosstool=True the default for cmake. (#523)
This was previously setting `CMAKE_SYSTEM_NAME` in the generated
toolchain file but setting this explicitly enables `CMAKE_CROSSCOMPILING`
(see https://cmake.org/cmake/help/v3.19/variable/CMAKE_CROSSCOMPILING.html#variable:CMAKE_CROSSCOMPILING)
which breaks projects that use `TRY_RUN`
2021-02-24 14:45:36 -08:00
James Sharpe 9a4435ecab
Attempt to catch shell script errors proactively with 'set -euo pipef… (#500)
* 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
2021-02-16 11:55:48 -08:00
UebelAndre dfccdce2c9
Moved some additional examples into the examples directory (#509) 2021-02-16 08:13:25 -08:00
UebelAndre 689c96aaa7
Fetch prebuilt cmake and ninja binaries as registered default toolchains (#508)
* Added tooling for generating repositories for pre-built cmake and ninja binaries

* Generated toolchains

* Picked up fix

* Removed toolchains from http_archives and updated generator script

* Regenerated toolchains

* Updated cmake version

* Added additional constraints

* Added option for registering preinstalled toolchains

* MacOS uses universal binaries

* Fixed typo

* More constraints
2021-02-16 15:41:58 +00:00
James Sharpe f77a9e12a3
Propagate defines into CFLAGS and CXXFLAGS passed to the framework (#498)
* Propagate defines into CFLAGS and CXXFLAGS passed to the framework

* Fix flags test

* Add example to test propagation of defines
2021-02-09 12:56:20 -08:00
Daniel Wagner-Hall ece188f9ab
Allow setting env vars (#489)
* Allow setting env vars

Also, bring all runfiles of data deps along for execution - currently
data deps which consist of more than one file aren't copied into the
action, which means that they will fail at runtime when they try to use
their runfiles.

* Update docs
2021-02-04 11:59:01 +00:00
UebelAndre 743975a998
Fixed incorrect detection of lib_source root (#488)
* Cleanup

* Fixed incorrect detection of lib_source root

* Updated tests
2021-02-03 20:18:43 +00:00
UebelAndre 14520d220f
Made buildifier checks more aggressive (#485)
* Made buildifier checks more aggressive

* Ran buildifier to fix all warnings

* Added sorting to cmake script generation and updated tests
2021-02-02 20:09:33 +00:00
Yun Peng 8ae4651929
Fix test target on macOS with Bazel@HEAD (#475)
* Fix test target on macOS with Bazel@HEAD

supports_dynamic_linker feature was removed from cc toolchain for macOS,
cc_binary should be used to build shared library.

Context: bazelbuild/bazel#4341 (comment)

* Fix test on Windows
2021-01-26 17:03:09 +00:00
UebelAndre 898bed4efb
Enable Buildifier in CI (#458)
* Added Buildifier check to CI

* Addressed Buildifier lint defects
2021-01-25 22:01:43 +00:00
UebelAndre d85b575a40
Remove deprecated rules_foreign_cc_utils repo (#470)
* Removed foreign_cc_platform_utils

* Removed rules_foreign_cc_bazel_version

* Update workspace_definitions.bzl

Co-authored-by: James Sharpe <james.sharpe@zenotech.com>
2021-01-25 13:42:14 -08:00
UebelAndre 9b6a8f675c
Add tests for checking the minimum supported version to CI (#469) 2021-01-25 19:07:05 +00:00
UebelAndre 08e8c6c93d
Moved example dependencies into loadable bzl files (#467)
* Sorted dependencies

* Added rules_android repository to satisfy buildifier defects

* Added rules_cc repository to satisfy buildifier defects

* Ran Buildifier
2021-01-25 08:04:52 -08:00
UebelAndre 76870e532d
Updated uses of `@bazel_tools//src/conditions` to `@platforms//` (#465)
Co-authored-by: James Sharpe <james.sharpe@zenotech.com>
2021-01-25 08:01:46 -08:00
UebelAndre c18be7037a
Added `data` attr to common framework (#461)
* Added `data` attribute for files needed by the rule at runtime.

* Updated documentation

* Added examples

* Enable runfiles on windows

* Also gather transitive runfiles
2021-01-25 07:44:44 -08:00
UebelAndre 8b8f31dd1b
Created a `./docs` directory to house documentation (#466)
* Added links to docs to top level README

* Updated more docs

* Added generated header
2021-01-24 15:23:19 -08:00
Attila Oláh ec690c5075
Replace references to @bazel_tools//platforms with @platforms//. (#427)
The former has been deprecated and will break by
--incompatible_use_platforms_repo_for_constraints, as announced in
https://github.com/bazelbuild/bazel/issues/8622.

Fixes #354.

Co-authored-by: UebelAndre <andre.brisco@gmail.com>
2021-01-23 12:28:38 -08:00
Attila Oláh b1600aa05a
Update GMP to 6.2.1. Fixes #462. (#463)
Version 6.2.0 is gone from gmplib.org.

Also update extension to `.xz`, apparently `.gz` files are no longer
being distributed.
2021-01-23 15:08:17 +00:00
UebelAndre 2dbd5fc2c2
Moved documenting comments into `doc` fields (#460)
* Moved documentation comments to `doc` fields

* Updated docs example
2021-01-22 14:32:28 +00:00
UebelAndre fafbef3eca
Added bzl_libraries for stardoc support (#453)
There's now a top level bzl_library @rules_foreign_cc//:bzl_srcs that contain the .bzl sources for the build rules defined in this repo.

Stardoc support was also added to ensure the bzl_library structure is correct and usable outside of the repo. In addition to this, new documentation can be generated by running bazel run //docs:generate_docs from the root of rules_foreign_cc/examples to output @rules_foreign_cc_tests//docs:README.md.
2021-01-22 14:25:49 +00:00
Attila Oláh ea571fcdd1
Add a GNU Make toolchain (#379)
* Use `.format()` instead of `%` for constructing `make_commands`.

I'm about to add a third substitution parameter to these lines, and it's
already getting a bit crowded. This is a no-op change, but should make
the follow-up commits more readable.

* Add `make_toolchain` toolchain type.

Add a toolchain that implements it using the pre-installed system
`make`. Make use of this toolchain in the `make()` rule.

* Use the `make` toolchain in configure and cmake scripts as well.

This allows the registered `make` toolchain to be used not just in make,
but also in cmake and configure_make targets. As a result, one can
either ship their own `make`, built for the execution environment, or
use a custom `make`, e.g. one that calls `emmake make`.

To make this backwards compatible with `make_commands`, the substitution
will only replace the leading word `make` from any line in
`make_commands`. Thus, existing rules that specify a `make_commands`
attribute that refers to the binary simply as `make` should still work
with any toolchain implementation that provides the binary.

* Update `README.md`.

Describe the new toolchain type.

* Add `BootstrapMake` to bootstrap a `make` toolchain.

This allows the `make` toolchain to be used even without GNU Make being
pre-installed on the system.

* Add example Gnu Make boostrap target.

Test manually using:

```
$ cd examples
$ bazel build //build_make_itself:maketool
```
2020-09-07 10:48:26 +02:00
c-parsons 9eb30f8c5a
Update mpfr to 4.1.0 (#420)
mpfr no longer supports 4.0.2 on the official site, so BazelCI was failing.
2020-07-13 16:41:03 +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
irengrig c86401f4ea
Use preinstalled CMake in tests on Mac OS (#399)
(merging without review because it only changes how the tests are run)
2020-05-07 20:38:21 +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
irengrig 8b477ca9cb
Fix Visual Studio version used in examples for #368 (#370) 2020-02-13 10:26:42 +01:00
Simon Newton ed3db61a55 Fix the simple_make example so that it works on Mac & Linux (#339)
Fix the simple_make example so that it works on Mac and Debian and add it to Mac tests.
2019-11-26 19:13:54 +01:00
Philipp Wollermann 14b79e5a04 Mirror all http_archives. (#341)
Context: https://github.com/bazelbuild/bazel/issues/10270
2019-11-19 14:50:33 +01:00
irengrig c7fe8ce542
Lua example (#291)
Add an example for building https://github.com/LuaJIT/LuaJIT
2019-10-23 12:17:16 +02: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 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
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
Keith Smiley ec8400cbd0 Switch to rules_jvm_external (#287)
The previous gmaven_rules usage was broken, this is the new supported
way to download these dependencies.
2019-07-10 18:44:57 +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
Michal Rostecki 8ccd83504b Minor fixes in example files (#264)
* examples: cmake_crosstool: Remove executable bit from BUILD

There is no reason for BUILD file to be an executable.

Signed-off-by: Michal Rostecki <mrostecki@opensuse.org>

* examples: Add shebang to the bash script

print_bazel_version.sh is a bash script, but it did not contain a
shebang.

Signed-off-by: Michal Rostecki <mrostecki@opensuse.org>
2019-06-25 18:38:25 +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
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
Yun Peng 0f0c0da3a1 Fix patch file for nghttp2 (#275)
The line number doesn't match the exact location of the position of the content. This is tolerable with patch command line tool, but it won't work with a more strict patch implementation.
Context: https://github.com/bazelbuild/bazel/pulls
2019-06-06 13:25:46 +02:00
László Csomor 9cfeff53b5 Windows: tests now work with native test wrapper (#263)
Windows: tests now work with native test wrapper

See https://github.com/bazelbuild/bazel/issues/6622
2019-05-17 11:52:28 +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
irengrig 6b04da2262
Example with malloc attribute, currently not working (#250) 2019-05-07 18:19:16 +02:00
irengrig 4c59d4d0c5
Correct environment variable references to the platform-independent style (#248)
* working example for #241

* correct variables references
2019-05-06 16:30:21 +02:00
irengrig 15aec187ff
working example for #241 (#247) 2019-05-06 16:04:47 +02:00