2
0
Fork 0
mirror of https://github.com/bazel-contrib/rules_foreign_cc synced 2024-12-03 02:52:58 +00:00
Commit graph

154 commits

Author SHA1 Message Date
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
irengrig 6f81b6e39e
fix #75 "trying to mutate a frozen object" (#79) 2018-08-31 20:11:12 +02:00
irengrig 3aecf1c664
update readme file and framework rule comments (#78) 2018-08-31 14:23:16 +02:00
irengrig f06338eafd
correct comment indent (#77) 2018-08-31 10:52:53 +02:00
irengrig bbb4bb8059
Merge CMAKE_PREFIX_PATH, passed by user, with $EXT_BUILD_DEPS (#76)
This allows using locally installed libraries to be found by CMake
+ test
2018-08-31 10:50:38 +02:00
irengrig 1b1de96220
Add comments (#74) 2018-08-30 18:32:03 +02:00
irengrig 8ef43c6f3c
make cmake and ninja build rules be available from util repository (#72) 2018-08-30 17:31:02 +02:00
irengrig 595c9b6d4b
correct CMake script test to use cmake path from workspace definition (#71) 2018-08-30 13:50:12 +02:00
irengrig 515c15a392
Add a feature of generating CMake toolchain file and writing tools and flags information there (#70)
* cmake toolchain files support

* extract cmake script consruction code into a separate file

for further testing

* simplify cmake script creation code

* first four tests for CMake script creation functions

* + move_dict_values_test for CMake script creation functions

* + reverse_descriptor_dict_test for CMake script creation functions

* + toolchain_and_user_values_test for CMake script creation functions

* add create_cmake_script_no_toolchain_file_test for CMake script creation

* do not insert executable linker rule option if it uses cxx compiler

since it would be the same as default
add one more test for command line

* add test for cmake script with toolchain file

* add test for cmake script with toolchain file with user values

* propagate information about target into CMake toolchain file
2018-08-30 13:12:51 +02:00
irengrig 86b28882a2
correct work in osx: take environment from cc_common (#67)
apparently, is it possible to just take the needed environment variables from cc_common, and not do any calls to rules_apple or platform-dependent initialization
2018-08-28 13:36:20 +02:00
irengrig 97b339b91e
escape quotes in toolchain flags and variables (#66) 2018-08-28 11:52:10 +02:00
irengrig a46bef4945
make framework function work on apple: (#63)
- initialize apple tools on workspace level properly using universal install_ws_dependency() function
- pass proper environment variables to the shell script action
- pass proper hidden attributes to framework function rules in case of osx os
- also, clean up WORKSPACE file putting example repositories into a separate file
- correct: repositories needed by framework function itself should be defined in the same single function in workspace_definitions.bzl
- unfortunately, it is not possible to move android initialization anywhere from WORKSPACE file
2018-08-27 14:56:16 +02:00
irengrig d4880f8fac
build cmake if it is missing (should be configurable) (#57) 2018-08-22 22:06:37 +02:00
irengrig 322e81086b
correct linking for osx, use basename (#56) 2018-08-22 16:02:18 +02:00
irengrig 2c46ed501d
correct linking for osx (#55) 2018-08-22 15:31:16 +02:00
irengrig 3983fc9c4b
create non-temporal directory fir build deps (#54)
+ small corrections
2018-08-22 15:15:53 +02:00
irengrig e711ddb2f0
do not follow links when copy ninja sources (#53) 2018-08-22 14:51:27 +02:00
irengrig 600078f283
use different shell utils file depending on the platform (#52) 2018-08-22 14:31:01 +02:00
irengrig cefeeaf82d
add nghttp2 example with test (#51) 2018-08-22 10:22:56 +02:00
irengrig deffd0d10c
correct finding the root of the filegroup/tree artifact, and path (#47) 2018-08-21 14:59:42 +02:00
irengrig 4a391ddbf6
correct replace in files (#46) 2018-08-21 14:45:32 +02:00
irengrig eb8f2a461c
Add ninja tool as the separate rule + version test (#44) 2018-08-20 22:24:42 +02:00
irengrig 3dd96c7a14
Important refactoring of the $EXT_BUILD_DEPS directory structure. (#41)
Some libraries define not only C/C++ libraries and headers, but also
scripts for finding this libraries (pkg_config, CMake find/config scripts).
Another important use case is defining CMake functions to be used in the CMake build of the dependent targets.
As for CMake such scripts are searched for in the number of directory path combinations, relative to CMAKE_INSTALL_PREFIX, including for both Unix and Windows,
<prefix>/<name>*/(lib/<arch>|lib|share)/cmake/<name>*/          (W/U)
<prefix>/<name>*/(lib/<arch>|lib|share)/<name>*/                (W/U)
<prefix>/<name>*/(lib/<arch>|lib|share)/<name>*/(cmake|CMake)/  (W/U)

acceptable solution would be copying the whole CMake install directory under the dependencies root $EXT_BUILD_DEPS, which is passed as CMAKE_INSTALL_PREFIX.

For the libraries, which put their CMake scripts into some other paths, user can add copy command using postfix_script parameter.

To be documented better.
2018-08-20 18:47:49 +02:00
irengrig af3f730c22
allow headers-only libraries (#40) 2018-08-20 17:39:35 +02:00
irengrig 45419956f5
correct utils.sh: in symlinking directory contents check if file passed (#39)
In that case, the file itself should be linked to the target directory
It shows up if we depend on the library, which provides only header files,
and no information on the wrapping directory. Technically it is correct, but
then our linking script should be prepared to link individual files as well as wrapping directories.
Example: cc_import of header-only library.
2018-08-20 17:00:13 +02:00
irengrig 85b4e59103
correct bugs with shared and interface libs in cc_toolchain_util.bzl (#38) 2018-08-20 16:46:24 +02:00
irengrig 840796ef4d
remove debug print (#37) 2018-08-20 16:00:27 +02:00
irengrig 8989362236
install prefix: indicate relative value with "./" (#36)
Unfortunately, the prefix is never relative.
If the relative value is passed, current directory is used as base,
and the real prefix is $(pwd)/<relative-prefix>
However, keep any value, passed by user, as finally outside the build that value can be used.
2018-08-20 15:56:35 +02:00
irengrig 6a0af905db
cmake env vars and cache entries: fix dictionary keys checks (#35) 2018-08-20 15:51:52 +02:00
irengrig 6af670f976
add attribute to append to toolchains env variables (#33)
to be used for flags addition
2018-08-17 23:04:52 +02:00
irengrig 2bfa976185
fix joining cache entries if there is no such toolchain key (#32) 2018-08-17 22:33:48 +02:00
irengrig 4b8af84398
utils.sh: do not copy directories into themselves (#30)
When creating the directory structure for running cmake/configure,
search for underlying items, but exclude self (which used to be returned by find).
For that, use -mindepth option
2018-08-17 17:39:30 +02:00
irengrig df6e76f2cc
add toolchain files to the input files (#29) 2018-08-16 23:22:01 +02:00
irengrig 6ae93cf516
cmake, shell script: pass parameter to find Ubuntu-16 compatible (#28) 2018-08-16 14:00:26 +02:00
irengrig 19ff39c6d8
cmake: add option cache_entries to pass cache initializers (#27)
Have explicit dict option "cache_entries" for passing CMake cache initializer key-values pairs to the rule.
This gives us ability to join user initializers and toolchain initializers. This might be useful with flags option.
2018-08-16 09:53:52 +02:00
irengrig 9f97e440ca
print generated script text as debug information (#26) 2018-08-14 15:54:35 +02:00
irengrig 33ba461485
export rules (#18) 2018-08-13 14:30:15 +02:00
irengrig 30b61168e0
make cmake rule accept install-prefix option (#11)
this way the users can influence which install prefix will appear in the
generated code
install prefix have to be relative - we are doing the hermetic build
modify our shell script to copy the result of the build into the target directory
(we can not leave it in temp directory, it will be deleted)
2018-08-08 16:49:50 +02:00
irengrig 067d4be22e
use tools paths and flags from the toolchain (#7)
* take tools paths and flags from the toolchain

* correct toolchain data extraction, correct cmake flags and environment

* framework script: export variables intended to be used in config script

config script can create child processes which could use this variables

* cmake: prepend relative [to the execroot] paths with "$EXT_BUILD_ROOT/"

unfortunately, CMake does not understand relative paths
(sometimes it runs tests for the passed compiler and for that
concatenates the passed relative path to some tmp directory created for test)

we replace only paths starting with external/ and <top-package-name>/,
so we are quite fine to not make a mistake with replacing some not related to paths text;
the targets for replacement take very different form (judging by examining
toolchain definitions), for instance "-Lexternal/something"

* test data for cross compilation for android and with --crosstool_top

data files taken from bazel examples and bazel test data;

NB one of the interesting things is that we need to specify tools dependency on android sdk and ndk, so that cmake_external shell script have access to these tools

* remove cross compilation example with CROSSTOOL for now

* add very simple CMake library (test data)

* rename target to indicate it is not a test, but example

* adjust android example:

rename the target to indicate it is not a test but example,
add android ndk sources as additional tool for cmake target,
(otherwise it is not available in sandbox)
use more simple cmake-built library

* corrections to the framework & cmake:

- correct search for the root directory of the filegroup (when it is not under external)
- it was a mistake to specify shared library linker, specify CMAKE_AR instead
- unfortunately, I have not discovered how to modify CMake behaviour to pass the custom static flags (rcsD) before "-qc <target>" to the ar linker; option from documentation does not work. To be investigated. For now, do not pass the static cxx linker options, taken from Bazel toolchain.
2018-08-06 15:23:18 +02:00
irengrig 44c0c97846
allow usage of underscore in external libraries rules (#8)
* allow usage of underscore in external libraries rules

* iterate the name string with index (correct review comment)

sorry for autoformatting changes; the real changes are in lines 259, 260

* iterate the name string with index (correct review comment)
2018-08-06 15:20:29 +02:00
irengrig 7792e40fc0
provide several libraries as outputs from external build rules (#6)
i.e. not single libraries, because in general case several build targets
can be created by a single CMake/configure-make build, and several of them linked to the next dependency
2018-07-30 14:59:02 +02:00
irengrig 0fd3a22fbc
external build framework function and cmake_external rule (#4)
* external build framework macro and cmake_external rule

* declare deps headers as inputs as well; correct sed expression

* use symlinking instead of copying, filter duplicates

* correct detect root

* corrections for copying tools and include directories

* correct review comments

* provide a way to pass modified attributes to the framework function

create a function that creates a dict from ctx.attr,
replaces/adds values and creates a resulting struct;
have mandatory attributes as mandatory parameters to this function

* correct review comments

* correct detect_root

* introduce parameter for passing user defined link options

* add documentation, define default static library to be built

* correct/improve documentation

* more correct gathering headers and include directories from dependencies

* correct review comments

* correct passing transitive link options
2018-07-30 12:56:09 +02:00