2
0
Fork 0
mirror of https://github.com/bazel-contrib/rules_foreign_cc synced 2024-11-27 02:43:28 +00:00
Commit graph

91 commits

Author SHA1 Message Date
irengrig 4a6fd7fd62
Add default shell toolchain implementation (#213)
assume Linux as a platform name for CMake
2019-01-31 08:27:34 +01:00
irengrig b0feddbcbb
Remove platform specific variables from generic windows toolchain (#211) 2019-01-30 17:49:37 +01:00
irengrig 216ded8acb
Boost rule to use shell toolchain, fixes #202 (#203) 2019-01-19 17:37:57 +01:00
irengrig 5511d9e1fe
Launch at least some Windows tests on CI (#201)
All custom tools (MS Visual Studio) information goes into
windows_commands.bzl
2019-01-18 18:43:37 +01:00
irengrig c51480261c
Extract shell fragments into a toolchain (#196)
* 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)
2019-01-18 18:06:10 +01:00
irengrig dff9d0a729
More changes because of incompatible flags (#198) 2019-01-10 13:47:45 +01:00
irengrig 7994b96ff6
Remove incorrect load symbol, this failed in incompatible flags build (#197) 2019-01-09 16:41:56 +01:00
Laurent Le Brun dfd1d815f5 Fixes for Bazel --all_incompatible_changes (#194)
Tested:
  `bazel test //... --nobuild --all_incompatible_changes`
2019-01-08 18:25:04 +01:00
irengrig 4dc369a845
Do not support Bazel before 0.20 (#195) 2019-01-08 18:21:22 +01:00
irengrig 99ea1b09fc
Extract cmake and ninja into a toolchain; provide defaults. (#192)
* 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
2019-01-08 12:25:16 +01:00
irengrig ee779e7d9d
Fix create_compilation_context call to match changed Starlark API (#189)
... in Bazel HEAD
2019-01-03 10:21:08 +01:00
irengrig 370a8ff244
Remove unused call of an old Starlark API (#186) 2019-01-02 14:50:20 +01:00
irengrig 82ff0ce803
We need a separate variant for 0.21 and fix for HEAD was in wrong file (#183) 2018-12-20 13:27:52 +01:00
irengrig cec144aef4
Fix a call to cc_common.create_compilation_context for Bazel HEAD (#182) 2018-12-20 13:13:17 +01:00
irengrig b08610b154
Improve the boost rule including user_options attribute. (#177)
* Improve the boost rule including user_options attribute.

Then --with-<library> parameter can be passed to build only that library
Modify examples to demonstrate how to use it.
However, building examples takes too long time, so do not include them into the tests.
2018-12-07 14:30:41 +01:00
irengrig 9a261f7993
Crosstool example + fixes (#174)
* 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
2018-12-06 18:14:00 +01:00
irengrig eb5f16592f
Fix compatibility with Bazel HEAD for a cc_common.create_XXX_variables (#172) 2018-12-05 17:34:00 +01:00
irengrig 8e2cc0f83c
Use shell function for copying directory contents to be multi-platform (#171) 2018-12-05 15:13:03 +01:00
irengrig 87f42c4a5b
Support in-the-middle state of C++ API in Bazel 0.20.0 (#168) 2018-12-04 18:39:08 +01:00
bbarnes52 6caaa8a26b removes strip calls from string concatenation to fix bug where compiler invocation failed due to invalid syntax (#163) 2018-12-04 16:02:00 +01:00
irengrig 7fdfc7cade
When cmake_external script fails, do not delete build directory. (#166)
* When cmake_external script fails, do not delete build directory.

Fixes #162.
2018-12-04 14:32:59 +01:00
irengrig 59bd073a22
In the generated repository, refer to the "parent" as @rules_foreign_cc (#161)
Fixes #160
2018-11-29 21:55:27 +01:00
irengrig d6d2f0761a
Adapt to the new Starlark API. (#157)
The rule supports both old and new API;
however, for switching the implementations, I had to use code generation - copying the actual implementations for different API variants into a generated repository.
I did not invent any other mechanics to deal with non existing top level symbols like CcInfo or CcCompilationInfo.

Design document about the new API: https://github.com/bazelbuild/proposals, Partial C++ Starlark API
Introduced in the commit: eb139371c9
2018-11-27 10:06:23 +01:00
irengrig 13419882d6
Put each of binary files into OutputGroupInfo under its name. (#148)
Add CMake test for building a binary and using that binary in a test.
2018-10-25 16:28:43 +02:00
irengrig d9318f13d3
framework: extract environment variable declaration into separate part (#145) 2018-10-25 12:37:15 +02:00
irengrig dee42b1598
Correct the problem with dependent output files/directories (#138)
* Correct the problem with dependent output files/directories

A rule should not return files and their parent directory;
therefore, create a copy directory for the install directory, which we use in the next-step external builds, and reduce other outputs to the lowest level (library files, binary files, include directories).

* Correct review comments: add documentation, revert not related change.

* Do not pass the rule context as argument into shell utilities functions;

only pass the actions factory and other specific parameters.
(review comments)
2018-10-25 11:53:58 +02:00
bbarnes52 8026d6f5ce minor code cleanup (#144) 2018-10-25 11:30:25 +02:00
bbarnes52 2fc3d7b847 removes directories from output declarations to enable remote execution (#133)
* removes directories from output declarations to enable remote execution

* incorporates @irengrigs feedback
2018-10-25 11:24:44 +02:00
irengrig b3552bfef8
Fix dynamic libraries (#141)
* move cmake_hello example with static library into a subdirectory

* Fix #139; correct arguments to create_library_to_link

However, the test (which should link the externally built shared library to the calling .c file) fails with assertion that the .so file is in a "wrong" directory, so I am providing it here for additional work [possibly] on Bazel side; and I do not include it into the tests list

* As cc_common.create_library_to_link is now broken for shared libraries,
use the "old" variant cc_common.create_symlink_library_to_link.

As it will later be removed (and create_library_to_link fixed),
it is safe to check for the existence of create_symlink_library_to_link and call it.

Now the test with shared library built by CMake runs, so add it ot the [non-Windows, for now] suite.

* Adapt building shared library with cmake test for mac

* increment version

* Add comment on CMAKE_MACOSX_RPATH
2018-10-23 16:49:20 +02:00
bbarnes52 5373e59a65 fixes boost (#136)
* fixes boost rule

* fixes boost

* updates to use configureParameters
2018-10-19 18:49:30 +02:00
irengrig 30ecb0d59e
Fix binary outputs declaration (#131) 2018-10-15 11:05:52 -04:00
irengrig ce306646d0
Improve documentation and naming for the configuration callback (#130)
- create provider for the parameters, passed to the callback
- correct documentation
2018-10-15 11:00:52 -04:00
irengrig 944399982f
Fix getting ForeignCcDeps from deps, it is optional provider (#129) 2018-10-15 07:23:03 -04:00
irengrig 4965090335
External C/C++ libraries rules need to pass transitive info (#112)
* External C/C++ libraries rules need to pass transitive info

- to have the same interface as cc_library to hide the "implementation details",
so that the information about the install directory and its contents of non-direct external dependencies of external library was available for external build
- this is particularly needed for configure-make rule, where we do not control the way needed libraries are found, so we want to provide the install directory and the -L, -I flags (include and library directories to be searched) consistently,
pointing to the directories under $EXT_BUILD_DEPS
- as a side effect, *.la files that contained links to absolute paths of dependencies (pointing somewhere under ...sandbox/bazel-out/...) now will point to directories under $EXT_BUILD_DEPS and so will be replaced correctly/will not point to paths under the previous sandbox

* External C/C++ libraries rules need to pass transitive info [improve]
By review comments;

- rename to do not collate with internally reserved list, dir, provider
- rename providers to use the same "foreign_cc" prefix and be shorter
- improve providers description
- return back output groups to do not reduce the flexibility

* External C/C++ libraries rules need to pass transitive info [improve]
By review comments:

- some more renames

* External C/C++ libraries rules need to pass transitive info: version++

* Correct review comments
2018-10-05 22:04:54 +02:00
irengrig c5cd4bd01f
Remove incorrect merging of the linkopts (#121) 2018-10-04 13:40:30 +02:00
irengrig 0d5f5c2da7
Replace cc_common.create_symlink_library_to_link calls (#117)
... with cc_common.create_library_to_link
2018-10-02 12:39:58 +02:00
irengrig 97d6cfee0c
Print version information by the script (#110) 2018-09-21 11:48:39 +02:00
irengrig 29f66a98cd
Correct bugs and make configure-make work on MacOS (#108)
* correct shell utilities: params differ on mac, remove debug print,

+ correct a bug on windows

* Simplify the example, libz is also needed by libgd

* Framework function: simplify code gathering deps, collect_libs public

* Correct configure-make: get all lib files, also built with bazel

and pass them in LDFLAGS; correct the linking paths (add prefix)

* Make maximum line length for shell = 80

* Improve comments to the _InputFiles provider
2018-09-20 20:19:38 +02:00
irengrig 7d3bdc7e95
Add configure_make rule with zlib, freetype, libpng, libgd examples (#106)
+ fix replacement of the absolute paths in linked directories,
replace only in .pc files for speed
2018-09-18 13:20:58 +02:00
irengrig d4c55bb51e
Refactor framework function: configure_script to be a callback (#104)
reason: configure-make should reuse the linking and compilation structures created by framework function
2018-09-17 14:27:35 +02:00
irengrig 94d95ec85b
Make deps directory be called differently for each library (#100)
otherwise during test execution too much is accumulated in that same directory,
and CMake gives up after searching in some amount of that subdirectories, and tests blink
2018-09-14 11:56:53 +02:00
irengrig af3f3e0618
Mac OS: Pass environment variables to run_shell, not in the script (#99)
for the DEVELOPER_DIRECTORY to be calculated
2018-09-14 11:20:02 +02:00
irengrig fc29335572
Do not convert depset to list for iteration (#98) 2018-09-14 10:40:38 +02:00
irengrig 8dca26ac29
Pass the value of --compilation_mode dbg to the rule and to CMake (#96)
CMAKE_BUILD_TYPE=DEBUG (otherwise RELEASE)
Can be overriden by user passing CMAKE_BUILD_TYPE in cache_entries
2018-09-14 10:18:38 +02:00
irengrig bc43624fc4
Fix the order of libraries in out linking info: first the current (#92)
Otherwise linking error about undefined symbol
2018-09-13 14:25:47 +02:00
irengrig 169cdca87b
More corrections for building on Windows (#89)
* Get cc_toolchain environment variables also for linking

* Correct environment setup

* Add Windows tests for Ninja and NMake generators
2018-09-12 15:20:31 +02:00
irengrig 0aab4e65c5
Win changes (#85)
* Allow execution on Windows, use utils_win.sh, copy instead of symlink

* Prepare for execution on Windows: set up environment, convert path

also rename TMPDIR since it can clash with widely used variable
2018-09-11 11:43:13 +02:00
irengrig b467afc40f
Correct "use default shell environment" action argument (#83)
We should take the default PATH passed by Bazel, not that from cc_toolchain for Windows, because the PATH under msys2 is different and that is which we need for shell commands
2018-09-10 11:34:43 +02:00
irengrig 06970670ae
Correct checking the shared library to also filter out empty values (#82) 2018-09-10 11:22:39 +02:00
bbarnes52 9949b17fe2 implements pcl cmake_external build rule (#68)
* implements pcl cmake_external build rule

* Improve example with building PCL (Point Cloud Library):

- build boost library and use it as dependency
- add/correct some properties

* implements pcl cmake_external build rule

* Improve example with building PCL (Point Cloud Library):

- build boost library and use it as dependency
- add/correct some properties
2018-09-05 22:24:41 +02:00