2018-07-30 10:56:09 +00:00
|
|
|
""" Contains definitions for creation of external C/C++ build rules (for building external libraries
|
|
|
|
with CMake, configure/make, autotools)
|
|
|
|
"""
|
|
|
|
|
|
|
|
load("@bazel_skylib//lib:collections.bzl", "collections")
|
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 13:23:18 +00:00
|
|
|
load(
|
|
|
|
"//tools/build_defs:cc_toolchain_util.bzl",
|
|
|
|
"LibrariesToLinkInfo",
|
|
|
|
"create_linking_info",
|
|
|
|
"targets_windows",
|
|
|
|
)
|
2018-07-30 10:56:09 +00:00
|
|
|
|
|
|
|
""" Dict with definitions of the context attributes, that customize cc_external_rule_impl function.
|
|
|
|
Many of the attributes have default values.
|
|
|
|
|
|
|
|
Typically, the concrete external library rule will use this structure to create the attributes
|
|
|
|
description dict. See cmake.bzl as an example.
|
|
|
|
"""
|
|
|
|
CC_EXTERNAL_RULE_ATTRIBUTES = {
|
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 13:23:18 +00:00
|
|
|
# Library name. Defines the name of the install directory and the name of the static library,
|
|
|
|
# if no output files parameters are defined (any of static_libraries, shared_libraries,
|
|
|
|
# interface_libraries, binaries_names)
|
|
|
|
# Optional. If not defined, defaults to the target's name.
|
|
|
|
"lib_name": attr.string(mandatory = False),
|
|
|
|
# Label with source code to build. Typically a filegroup for the source of remote repository.
|
|
|
|
# Mandatory.
|
|
|
|
"lib_source": attr.label(mandatory = True, allow_files = True),
|
|
|
|
# Optional compilation definitions to be passed to the dependencies of this library.
|
|
|
|
# They are NOT passed to the compiler, you should duplicate them in the configuration options.
|
|
|
|
"defines": attr.string_list(mandatory = False, default = []),
|
|
|
|
#
|
|
|
|
# Optional additional inputs to be declared as needed for the shell script action.
|
|
|
|
# Not used by the shell script part in cc_external_rule_impl.
|
|
|
|
"additional_inputs": attr.label_list(mandatory = False, allow_files = True, default = []),
|
|
|
|
# Optional additional tools needed for the building.
|
|
|
|
# Not used by the shell script part in cc_external_rule_impl.
|
|
|
|
"additional_tools": attr.label_list(mandatory = False, allow_files = True, default = []),
|
|
|
|
#
|
|
|
|
# Optional part of the shell script to be added after the make commands
|
|
|
|
"postfix_script": attr.string(mandatory = False),
|
|
|
|
# Optinal make commands, defaults to ["make", "make install"]
|
|
|
|
"make_commands": attr.string_list(mandatory = False, default = ["make", "make install"]),
|
|
|
|
#
|
|
|
|
# Optional dependencies to be copied into the directory structure.
|
|
|
|
# Typically those directly required for the external building of the library/binaries.
|
|
|
|
# (i.e. those that the external buidl system will be looking for and paths to which are
|
|
|
|
# provided by the calling rule)
|
|
|
|
"deps": attr.label_list(mandatory = False, allow_files = True, default = []),
|
|
|
|
# Optional tools to be copied into the directory structure.
|
|
|
|
# Similar to deps, those directly required for the external building of the library/binaries.
|
|
|
|
"tools_deps": attr.label_list(mandatory = False, allow_files = True, default = []),
|
|
|
|
#
|
|
|
|
# Optional name of the output subdirectory with the header files, defaults to 'include'.
|
|
|
|
"out_include_dir": attr.string(mandatory = False, default = "include"),
|
|
|
|
# Optional name of the output subdirectory with the library files, defaults to 'lib'.
|
|
|
|
"out_lib_dir": attr.string(mandatory = False, default = "lib"),
|
|
|
|
# Optional name of the output subdirectory with the binary files, defaults to 'bin'.
|
|
|
|
"out_bin_dir": attr.string(mandatory = False, default = "bin"),
|
|
|
|
#
|
|
|
|
# Optional. if true, link all the object files from the static library,
|
|
|
|
# even if they are not used.
|
|
|
|
"alwayslink": attr.bool(mandatory = False, default = False),
|
|
|
|
# Optional link options to be passed up to the dependencies of this library
|
|
|
|
"linkopts": attr.string_list(mandatory = False, default = []),
|
|
|
|
#
|
|
|
|
# Output files names parameters. If any of them is defined, only these files are passed to
|
|
|
|
# Bazel providers.
|
|
|
|
# if no of them is defined, default lib_name.a/lib_name.lib static library is assumed.
|
|
|
|
#
|
|
|
|
# Optional names of the resulting static libraries.
|
|
|
|
"static_libraries": attr.string_list(mandatory = False),
|
|
|
|
# Optional names of the resulting shared libraries.
|
|
|
|
"shared_libraries": attr.string_list(mandatory = False),
|
|
|
|
# Optional names of the resulting interface libraries.
|
|
|
|
"interface_libraries": attr.string_list(mandatory = False),
|
|
|
|
# Optional names of the resulting binaries.
|
|
|
|
"binaries": attr.string_list(mandatory = False),
|
2018-08-20 15:39:35 +00:00
|
|
|
# Flag variable to indicate that the library produces only headers
|
|
|
|
"headers_only": attr.bool(mandatory = False, default = False),
|
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 13:23:18 +00:00
|
|
|
#
|
|
|
|
# link to the shell utilities used by the shell script in cc_external_rule_impl.
|
|
|
|
"_utils": attr.label(
|
2018-08-22 12:31:01 +00:00
|
|
|
default = "@foreign_cc_platform_utils//:shell_utils",
|
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 13:23:18 +00:00
|
|
|
allow_single_file = True,
|
|
|
|
cfg = "target",
|
|
|
|
),
|
|
|
|
# we need to declare this attribute to access cc_toolchain
|
|
|
|
"_cc_toolchain": attr.label(default = Label("@bazel_tools//tools/cpp:current_cc_toolchain")),
|
2018-07-30 10:56:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
def create_attrs(attr_struct, configure_name, configure_script, **kwargs):
|
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 13:23:18 +00:00
|
|
|
""" Function for adding/modifying context attributes struct (originally from ctx.attr),
|
|
|
|
provided by user, to be passed to the cc_external_rule_impl function as a struct.
|
2018-07-30 10:56:09 +00:00
|
|
|
|
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 13:23:18 +00:00
|
|
|
Copies a struct 'attr_struct' values (with attributes from CC_EXTERNAL_RULE_ATTRIBUTES)
|
|
|
|
to the resulting struct, adding or replacing attributes passed in 'configure_name',
|
|
|
|
'configure_script', and '**kwargs' parameters.
|
|
|
|
"""
|
|
|
|
dict = {}
|
|
|
|
for key in CC_EXTERNAL_RULE_ATTRIBUTES:
|
|
|
|
if not key.startswith("_") and hasattr(attr_struct, key):
|
|
|
|
dict[key] = getattr(attr_struct, key)
|
2018-07-30 10:56:09 +00:00
|
|
|
|
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 13:23:18 +00:00
|
|
|
dict["configure_name"] = configure_name
|
|
|
|
dict["configure_script"] = configure_script
|
2018-07-30 10:56:09 +00:00
|
|
|
|
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 13:23:18 +00:00
|
|
|
for arg in kwargs:
|
|
|
|
dict[arg] = kwargs[arg]
|
|
|
|
return struct(**dict)
|
2018-07-30 10:56:09 +00:00
|
|
|
|
|
|
|
def cc_external_rule_impl(ctx, attrs):
|
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 13:23:18 +00:00
|
|
|
""" Framework function for performing external C/C++ building.
|
|
|
|
|
|
|
|
To be used to build external libraries or/and binaries with CMake, configure/make, autotools etc.,
|
|
|
|
and use results in Bazel.
|
|
|
|
It is possible to use it to build a group of external libraries, that depend on each other or on
|
|
|
|
Bazel library, and pass nessesary tools.
|
|
|
|
|
|
|
|
Accepts the actual commands for build configuration/execution in attrs.
|
|
|
|
|
|
|
|
Creates and runs a shell script, which:
|
|
|
|
|
|
|
|
1) prepares directory structure with sources, dependencies, and tools symlinked into subdirectories
|
|
|
|
of the execroot directory. Adds tools into PATH.
|
|
|
|
2) defines the correct absolute paths in tools with the script paths, see 7
|
|
|
|
3) defines the following environment variables:
|
|
|
|
EXT_BUILD_ROOT: execroot directory
|
|
|
|
EXT_BUILD_DEPS: subdirectory of execroot, which contains the following subdirectories:
|
|
|
|
include - here the include directories are symlinked
|
|
|
|
lib - here the library files are symlinked
|
|
|
|
lib/pkgconfig - here the pkgconfig files are symlinked
|
|
|
|
bin - here the tools are copied
|
|
|
|
INSTALLDIR: subdirectory of the execroot (named by the lib_name), where the library/binary
|
|
|
|
will be installed
|
|
|
|
|
|
|
|
These variables should be used by the calling rule to refer to the created directory structure.
|
|
|
|
4) calls 'attrs.configure_script'
|
|
|
|
5) calls 'attrs.make_commands'
|
|
|
|
6) calls 'attrs.postfix_script'
|
|
|
|
7) replaces absolute paths in possibly created scripts with a placeholder value
|
|
|
|
|
|
|
|
Please see cmake.bzl for example usage.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
ctx: calling rule context
|
|
|
|
attrs: struct with fields from CC_EXTERNAL_RULE_ATTRIBUTES (see descriptions there), and
|
|
|
|
two mandatory fields:
|
|
|
|
configure_name: name of the configuration tool, to be used in action mnemonic
|
|
|
|
configure_script: actual configuration script
|
|
|
|
All other fields are ignored.
|
|
|
|
"""
|
|
|
|
lib_name = _value(attrs.lib_name, ctx.attr.name)
|
|
|
|
|
|
|
|
inputs = _define_inputs(attrs)
|
|
|
|
outputs = _define_outputs(ctx, attrs, lib_name)
|
|
|
|
out_cc_info = _define_out_cc_info(ctx, attrs, inputs, outputs)
|
|
|
|
|
|
|
|
shell_utils = ctx.attr._utils.files.to_list()[0].path
|
|
|
|
|
|
|
|
script_lines = [
|
|
|
|
"set -e",
|
|
|
|
"export EXT_BUILD_ROOT=$(pwd)",
|
|
|
|
"source " + shell_utils,
|
|
|
|
"echo \"Building external library '{}'\"".format(lib_name),
|
2018-08-08 14:49:50 +00:00
|
|
|
"export TMPDIR=$(mktemp -d)",
|
2018-08-22 13:15:53 +00:00
|
|
|
"trap \"{ rm -rf $TMPDIR $EXT_BUILD_ROOT/bazel_foreign_cc_deps; }\" EXIT",
|
|
|
|
"export EXT_BUILD_DEPS=$EXT_BUILD_ROOT/bazel_foreign_cc_deps",
|
|
|
|
"mkdir -p $EXT_BUILD_DEPS",
|
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 13:23:18 +00:00
|
|
|
"\n".join(_copy_deps_and_tools(inputs)),
|
|
|
|
"define_absolute_paths $EXT_BUILD_ROOT/bin $EXT_BUILD_ROOT/bin",
|
|
|
|
"export INSTALLDIR=$EXT_BUILD_ROOT/" + outputs.installdir.path,
|
|
|
|
"mkdir -p $INSTALLDIR",
|
|
|
|
"echo_vars INSTALLDIR EXT_BUILD_DEPS EXT_BUILD_ROOT PATH",
|
|
|
|
"pushd $TMPDIR",
|
|
|
|
attrs.configure_script,
|
|
|
|
"\n".join(attrs.make_commands),
|
|
|
|
_value(attrs.postfix_script, ""),
|
|
|
|
"replace_absolute_paths $INSTALLDIR $INSTALLDIR",
|
|
|
|
"popd",
|
|
|
|
]
|
|
|
|
|
|
|
|
script_text = "\n".join(script_lines)
|
2018-08-14 13:54:35 +00:00
|
|
|
print("script text: " + script_text)
|
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 13:23:18 +00:00
|
|
|
|
|
|
|
ctx.actions.run_shell(
|
|
|
|
mnemonic = "Cc" + attrs.configure_name.capitalize() + "MakeRule",
|
2018-08-16 21:22:01 +00:00
|
|
|
inputs = depset(inputs.declared_inputs) + ctx.attr._cc_toolchain.files,
|
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 13:23:18 +00:00
|
|
|
outputs = outputs.declared_outputs,
|
|
|
|
tools = ctx.attr._utils.files,
|
|
|
|
use_default_shell_env = True,
|
|
|
|
command = script_text,
|
|
|
|
execution_requirements = {"block-network": ""},
|
|
|
|
)
|
|
|
|
|
|
|
|
return [
|
|
|
|
DefaultInfo(files = depset(direct = outputs.declared_outputs)),
|
|
|
|
OutputGroupInfo(
|
|
|
|
gen_dir = depset([outputs.installdir]),
|
|
|
|
bin_dir = depset([outputs.out_bin_dir]),
|
|
|
|
out_binary_files = depset(outputs.out_binary_files),
|
|
|
|
),
|
|
|
|
cc_common.create_cc_skylark_info(ctx = ctx),
|
|
|
|
out_cc_info.compilation_info,
|
|
|
|
out_cc_info.linking_info,
|
|
|
|
]
|
2018-07-30 10:56:09 +00:00
|
|
|
|
|
|
|
def _value(value, default_value):
|
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 13:23:18 +00:00
|
|
|
if (value):
|
|
|
|
return value
|
|
|
|
return default_value
|
2018-07-30 10:56:09 +00:00
|
|
|
|
|
|
|
def _depset(item):
|
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 13:23:18 +00:00
|
|
|
if item == None:
|
|
|
|
return depset()
|
|
|
|
return depset([item])
|
2018-07-30 10:56:09 +00:00
|
|
|
|
|
|
|
def _list(item):
|
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 13:23:18 +00:00
|
|
|
if item:
|
|
|
|
return [item]
|
|
|
|
return []
|
2018-07-30 10:56:09 +00:00
|
|
|
|
|
|
|
def _copy_deps_and_tools(files):
|
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 13:23:18 +00:00
|
|
|
list = []
|
|
|
|
list += _symlink_to_dir("lib", files.libs, False)
|
|
|
|
list += _symlink_to_dir("include", files.headers, True)
|
2018-08-21 12:59:42 +00:00
|
|
|
|
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 13:23:18 +00:00
|
|
|
list += _symlink_to_dir("bin", files.tools_files, False)
|
2018-07-30 10:56:09 +00:00
|
|
|
|
2018-08-20 16:47:49 +00:00
|
|
|
for ext_dir in files.ext_build_dirs:
|
|
|
|
list += ["symlink_to_dir $EXT_BUILD_ROOT/{} $EXT_BUILD_DEPS".format(_file_path(ext_dir))]
|
|
|
|
|
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 13:23:18 +00:00
|
|
|
list += ["if [ -d $EXT_BUILD_DEPS/bin ]; then"]
|
2018-08-21 12:59:42 +00:00
|
|
|
|
|
|
|
list += [" tools=$(find $EXT_BUILD_DEPS/bin -maxdepth 1 -mindepth 1)"]
|
|
|
|
list += [" for tool in $tools;"]
|
|
|
|
list += [" do"]
|
|
|
|
list += [" if [[ -d \"$tool\" ]] || [[ -L \"$tool\" ]]; then"]
|
|
|
|
list += [" export PATH=$PATH:$tool"]
|
|
|
|
list += [" fi"]
|
|
|
|
list += [" done"]
|
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 13:23:18 +00:00
|
|
|
list += ["fi"]
|
|
|
|
list += ["path $EXT_BUILD_DEPS/bin"]
|
2018-07-30 10:56:09 +00:00
|
|
|
|
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 13:23:18 +00:00
|
|
|
return list
|
2018-07-30 10:56:09 +00:00
|
|
|
|
|
|
|
def _symlink_to_dir(dir_name, files_list, link_children):
|
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 13:23:18 +00:00
|
|
|
if len(files_list) == 0:
|
|
|
|
return []
|
|
|
|
list = ["mkdir -p $EXT_BUILD_DEPS/" + dir_name]
|
2018-07-30 10:56:09 +00:00
|
|
|
|
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 13:23:18 +00:00
|
|
|
paths_list = []
|
|
|
|
for file in files_list:
|
2018-08-20 16:47:49 +00:00
|
|
|
paths_list += [_file_path(file)]
|
2018-07-30 10:56:09 +00:00
|
|
|
|
2018-08-20 15:00:13 +00:00
|
|
|
link_function = "symlink_contents_to_dir" if link_children else "symlink_to_dir"
|
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 13:23:18 +00:00
|
|
|
for path in paths_list:
|
|
|
|
list += ["{} $EXT_BUILD_ROOT/{} $EXT_BUILD_DEPS/{}".format(link_function, path, dir_name)]
|
2018-07-30 10:56:09 +00:00
|
|
|
|
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 13:23:18 +00:00
|
|
|
return list
|
2018-07-30 10:56:09 +00:00
|
|
|
|
2018-08-20 16:47:49 +00:00
|
|
|
def _file_path(file):
|
|
|
|
return file if type(file) == "string" else file.path
|
|
|
|
|
2018-07-30 10:56:09 +00:00
|
|
|
def _check_file_name(var, name):
|
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 13:23:18 +00:00
|
|
|
if (len(var) == 0):
|
|
|
|
fail("{} can not be empty string.".format(name.capitalize()))
|
2018-07-30 10:56:09 +00:00
|
|
|
|
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 13:23:18 +00:00
|
|
|
if (not var[0:1].isalpha()):
|
2018-08-14 13:54:35 +00:00
|
|
|
fail("{} should start with a letter.".format(name.capitalize()))
|
2018-08-06 13:20:29 +00:00
|
|
|
for index in range(1, len(var) - 1):
|
2018-08-14 13:54:35 +00:00
|
|
|
letter = var[index]
|
|
|
|
if not letter.isalnum() and letter != "_":
|
|
|
|
fail("{} should be alphanumeric or '_'.".format(name.capitalize()))
|
2018-07-30 10:56:09 +00:00
|
|
|
|
|
|
|
_Outputs = provider(
|
|
|
|
doc = "Provider to keep different kinds of the external build output files and directories",
|
|
|
|
fields = dict(
|
|
|
|
installdir = "Directory, where the library or binary is installed",
|
|
|
|
out_include_dir = "Directory with header files (relative to install directory)",
|
|
|
|
out_bin_dir = "Directory with binary files (relative to install directory)",
|
|
|
|
out_lib_dir = "Directory with library files (relative to install directory)",
|
|
|
|
out_binary_files = "Binary files, which will be created by the action",
|
|
|
|
libraries = "Library files, which will be created by the action",
|
|
|
|
declared_outputs = "All output files and directories of the action",
|
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 13:23:18 +00:00
|
|
|
),
|
2018-07-30 10:56:09 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
def _define_outputs(ctx, attrs, lib_name):
|
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 13:23:18 +00:00
|
|
|
static_libraries = []
|
2018-08-20 15:39:35 +00:00
|
|
|
if not hasattr(attrs, "headers_only") or not attrs.headers_only:
|
|
|
|
if (not (hasattr(attrs, "static_libraries") and len(attrs.static_libraries) > 0) and
|
|
|
|
not (hasattr(attrs, "shared_libraries") and len(attrs.shared_libraries) > 0) and
|
|
|
|
not (hasattr(attrs, "interface_libraries") and len(attrs.interface_libraries) > 0) and
|
|
|
|
not (hasattr(attrs, "binaries") and len(attrs.binaries) > 0)):
|
|
|
|
static_libraries = [lib_name + (".lib" if targets_windows(ctx, None) else ".a")]
|
|
|
|
else:
|
|
|
|
static_libraries = attrs.static_libraries
|
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 13:23:18 +00:00
|
|
|
|
|
|
|
_check_file_name(lib_name, "Library name")
|
|
|
|
|
|
|
|
out_binary_files = []
|
|
|
|
for file in attrs.binaries:
|
|
|
|
out_binary_files += [_declare_out(ctx, lib_name, attrs.out_bin_dir, file)]
|
|
|
|
|
|
|
|
installdir = ctx.actions.declare_directory(lib_name)
|
|
|
|
out_include_dir = ctx.actions.declare_directory(lib_name + "/" + attrs.out_include_dir)
|
|
|
|
out_bin_dir = ctx.actions.declare_directory(lib_name + "/" + attrs.out_bin_dir)
|
|
|
|
out_lib_dir = ctx.actions.declare_directory(lib_name + "/" + attrs.out_lib_dir)
|
|
|
|
|
|
|
|
libraries = LibrariesToLinkInfo(
|
|
|
|
static_libraries = _declare_out(ctx, lib_name, out_lib_dir, static_libraries),
|
|
|
|
shared_libraries = _declare_out(ctx, lib_name, out_lib_dir, attrs.shared_libraries),
|
|
|
|
interface_libraries = _declare_out(ctx, lib_name, out_lib_dir, attrs.interface_libraries),
|
|
|
|
)
|
|
|
|
declared_outputs = [installdir, out_include_dir, out_bin_dir, out_lib_dir] + out_binary_files
|
2018-08-20 16:47:49 +00:00
|
|
|
declared_outputs += libraries.static_libraries
|
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 13:23:18 +00:00
|
|
|
declared_outputs += libraries.shared_libraries + libraries.interface_libraries
|
|
|
|
|
|
|
|
return _Outputs(
|
|
|
|
installdir = installdir,
|
|
|
|
out_include_dir = out_include_dir,
|
|
|
|
out_bin_dir = out_bin_dir,
|
|
|
|
out_lib_dir = out_lib_dir,
|
|
|
|
out_binary_files = out_binary_files,
|
|
|
|
libraries = libraries,
|
|
|
|
declared_outputs = declared_outputs,
|
|
|
|
)
|
2018-07-30 10:56:09 +00:00
|
|
|
|
2018-07-30 12:59:02 +00:00
|
|
|
def _declare_out(ctx, lib_name, dir, files):
|
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 13:23:18 +00:00
|
|
|
if files and len(files) > 0:
|
|
|
|
return [ctx.actions.declare_file("/".join([lib_name, dir.basename, file])) for file in files]
|
|
|
|
return []
|
2018-07-30 10:56:09 +00:00
|
|
|
|
|
|
|
_InputFiles = provider(
|
|
|
|
doc = """Provider to keep different kinds of input files, directories,
|
|
|
|
and C/C++ compilation and linking info from dependencies""",
|
|
|
|
fields = dict(
|
2018-08-20 16:47:49 +00:00
|
|
|
headers = """Include directories to be used for compilation.
|
|
|
|
Will be copied into $EXT_BUILD_DEPS/include.""",
|
|
|
|
libs = "Library files to be used for building. Will be copied into $EXT_BUILD_DEPS/lib.",
|
2018-07-30 10:56:09 +00:00
|
|
|
deps_linkopts = "Link options from deps to be passed to resulting CcLinkingInfo",
|
|
|
|
tools_files = """Files and directories with tools needed for configuration/building
|
|
|
|
to be copied into the bin folder, which is added to the PATH""",
|
2018-08-20 16:47:49 +00:00
|
|
|
ext_build_dirs = """Directories with libraries, built by framework function.
|
|
|
|
This directories should be copied into $EXT_BUILD_DEPS/lib-name as is, with all contents.""",
|
2018-07-30 10:56:09 +00:00
|
|
|
deps_compilation_info = "Merged CcCompilationInfo from deps attribute",
|
|
|
|
deps_linking_info = "Merged CcLinkingInfo from deps attribute",
|
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 13:23:18 +00:00
|
|
|
declared_inputs = "All files and directories that must be declared as action inputs",
|
|
|
|
),
|
2018-07-30 10:56:09 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
def _define_inputs(attrs):
|
2018-08-20 16:47:49 +00:00
|
|
|
compilation_infos_ext = []
|
|
|
|
linking_infos_ext = []
|
|
|
|
compilation_infos_bazel = []
|
|
|
|
linking_infos_bazel = []
|
2018-08-21 12:59:42 +00:00
|
|
|
|
2018-08-20 16:47:49 +00:00
|
|
|
# This framework function-built libraries: copy result directories under
|
|
|
|
# $EXT_BUILD_DEPS/lib-name
|
|
|
|
ext_build_dirs = []
|
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 13:23:18 +00:00
|
|
|
|
|
|
|
for dep in attrs.deps:
|
|
|
|
provider = dep[OutputGroupInfo]
|
2018-08-20 16:47:49 +00:00
|
|
|
ext_built = provider and hasattr(provider, "gen_dir")
|
|
|
|
|
|
|
|
if ext_built:
|
|
|
|
ext_build_dirs += provider.gen_dir.to_list()
|
|
|
|
compilation_infos_ext += [dep[CcCompilationInfo]]
|
|
|
|
linking_infos_ext += [dep[CcLinkingInfo]]
|
|
|
|
else:
|
|
|
|
compilation_infos_bazel += [dep[CcCompilationInfo]]
|
|
|
|
linking_infos_bazel += [dep[CcLinkingInfo]]
|
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 13:23:18 +00:00
|
|
|
|
|
|
|
tools_roots = []
|
|
|
|
tools_files = []
|
|
|
|
for tool in attrs.tools_deps:
|
|
|
|
tool_root = detect_root(tool)
|
|
|
|
tools_roots += [tool_root]
|
|
|
|
for file_list in tool.files.to_list():
|
|
|
|
tools_files += _list(file_list)
|
|
|
|
|
|
|
|
for tool in attrs.additional_tools:
|
|
|
|
for file_list in tool.files.to_list():
|
|
|
|
tools_files += _list(file_list)
|
|
|
|
|
2018-08-20 16:47:49 +00:00
|
|
|
# For Bazel-built libraries: copy headers and libs.
|
|
|
|
headers = [_get_headers(cc_info) for cc_info in compilation_infos_bazel]
|
|
|
|
deps_linking_bazel = cc_common.merge_cc_linking_infos(cc_linking_infos = linking_infos_bazel)
|
|
|
|
libs = _collect_libs(deps_linking_bazel)
|
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 13:23:18 +00:00
|
|
|
|
2018-08-20 16:47:49 +00:00
|
|
|
# These variables are needed for correct C/C++ providers constraction,
|
|
|
|
# they should contain all libraries and include directories.
|
|
|
|
deps_compilation = cc_common.merge_cc_compilation_infos(cc_compilation_infos = compilation_infos_ext + compilation_infos_bazel)
|
|
|
|
deps_linking = cc_common.merge_cc_linking_infos(cc_linking_infos = linking_infos_ext + [deps_linking_bazel])
|
|
|
|
|
|
|
|
# Pass flags up the dependency chain for all types of libraries;
|
|
|
|
# flags are passed uniformly for Bazel-built and external libraries
|
|
|
|
linkopts = _collect_flags(deps_linking)
|
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 13:23:18 +00:00
|
|
|
|
|
|
|
return _InputFiles(
|
2018-07-30 10:56:09 +00:00
|
|
|
headers = headers,
|
|
|
|
libs = libs,
|
|
|
|
deps_linkopts = linkopts,
|
|
|
|
tools_files = tools_roots,
|
|
|
|
deps_compilation_info = deps_compilation,
|
|
|
|
deps_linking_info = deps_linking,
|
2018-08-20 16:47:49 +00:00
|
|
|
ext_build_dirs = ext_build_dirs,
|
|
|
|
declared_inputs = depset(attrs.lib_source.files) + libs + tools_files +
|
|
|
|
attrs.additional_inputs + deps_compilation.headers + ext_build_dirs,
|
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 13:23:18 +00:00
|
|
|
)
|
2018-07-30 10:56:09 +00:00
|
|
|
|
|
|
|
def _get_headers(compilation_info):
|
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 13:23:18 +00:00
|
|
|
include_dirs = collections.uniq(compilation_info.system_includes.to_list())
|
|
|
|
headers = []
|
|
|
|
for header in compilation_info.headers:
|
|
|
|
path = header.path
|
|
|
|
included = False
|
|
|
|
for dir in include_dirs:
|
|
|
|
if path.startswith(dir):
|
|
|
|
included = True
|
|
|
|
break
|
|
|
|
if not included:
|
|
|
|
headers += [header]
|
|
|
|
return headers + include_dirs
|
2018-07-30 10:56:09 +00:00
|
|
|
|
|
|
|
def _define_out_cc_info(ctx, attrs, inputs, outputs):
|
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 13:23:18 +00:00
|
|
|
compilation_info = CcCompilationInfo(
|
|
|
|
headers = depset([outputs.out_include_dir]),
|
|
|
|
system_includes = depset([outputs.out_include_dir.path]),
|
|
|
|
defines = depset(attrs.defines),
|
|
|
|
)
|
|
|
|
out_compilation_info = cc_common.merge_cc_compilation_infos(
|
|
|
|
cc_compilation_infos = [inputs.deps_compilation_info, compilation_info],
|
|
|
|
)
|
|
|
|
|
|
|
|
linkopts = depset(direct = attrs.linkopts, transitive = [depset(inputs.deps_linkopts)])
|
|
|
|
linking_info = create_linking_info(ctx, linkopts, outputs.libraries)
|
|
|
|
out_linking_info = cc_common.merge_cc_linking_infos(
|
|
|
|
cc_linking_infos = [inputs.deps_linking_info, linking_info],
|
|
|
|
)
|
|
|
|
|
|
|
|
return struct(
|
|
|
|
compilation_info = out_compilation_info,
|
|
|
|
linking_info = out_linking_info,
|
|
|
|
)
|
2018-07-30 10:56:09 +00:00
|
|
|
|
2018-08-20 16:47:49 +00:00
|
|
|
def _extract_link_params(cc_linking):
|
|
|
|
return [
|
2018-08-21 12:59:42 +00:00
|
|
|
cc_linking.static_mode_params_for_dynamic_library,
|
|
|
|
cc_linking.static_mode_params_for_executable,
|
|
|
|
cc_linking.dynamic_mode_params_for_dynamic_library,
|
|
|
|
cc_linking.dynamic_mode_params_for_executable,
|
2018-08-20 16:47:49 +00:00
|
|
|
]
|
2018-07-30 10:56:09 +00:00
|
|
|
|
2018-08-20 16:47:49 +00:00
|
|
|
def _collect_libs(cc_linking):
|
|
|
|
libs = []
|
|
|
|
for params in _extract_link_params(cc_linking):
|
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 13:23:18 +00:00
|
|
|
libs += [lib.artifact() for lib in params.libraries_to_link.to_list()]
|
|
|
|
libs += params.dynamic_libraries_for_runtime.to_list()
|
2018-08-20 16:47:49 +00:00
|
|
|
return collections.uniq(libs)
|
2018-07-30 10:56:09 +00:00
|
|
|
|
2018-08-20 16:47:49 +00:00
|
|
|
def _collect_flags(cc_linking):
|
|
|
|
linkopts = []
|
|
|
|
for params in _extract_link_params(cc_linking):
|
|
|
|
linkopts = params.linkopts.to_list()
|
|
|
|
return collections.uniq(linkopts)
|
2018-07-30 10:56:09 +00:00
|
|
|
|
|
|
|
def detect_root(source):
|
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 13:23:18 +00:00
|
|
|
"""Detects the path to the topmost directory of the 'source' outputs.
|
|
|
|
To be used with external build systems to point to the source code/tools directories.
|
|
|
|
|
|
|
|
If the target groups the sources of the external dependency, the workspace root is used,
|
|
|
|
and no other checks are performed (i.e. it is assumed that the whole contents of the external
|
|
|
|
dependency is used).
|
|
|
|
Otherwise, for the "usual" targets, target's files are iterated and the path with the least length
|
|
|
|
is selected.
|
|
|
|
"""
|
|
|
|
root = source.label.workspace_root
|
|
|
|
sources = source.files
|
2018-08-21 12:59:42 +00:00
|
|
|
if (root and len(root) > 0) or len(sources) == 0:
|
|
|
|
return root
|
|
|
|
|
|
|
|
root = ""
|
|
|
|
level = -1
|
|
|
|
num_at_level = 0
|
|
|
|
|
|
|
|
# find topmost directory
|
|
|
|
for file in sources:
|
|
|
|
file_level = _get_level(file.path)
|
|
|
|
if level == -1 or level > file_level:
|
|
|
|
root = file.path
|
|
|
|
level = file_level
|
|
|
|
num_at_level = 1
|
|
|
|
elif level == file_level:
|
|
|
|
num_at_level += 1
|
|
|
|
|
|
|
|
if num_at_level == 1:
|
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 13:23:18 +00:00
|
|
|
return root
|
|
|
|
|
|
|
|
(before, sep, after) = root.rpartition("/")
|
|
|
|
if before and sep and after:
|
|
|
|
return before
|
|
|
|
return root
|
2018-08-21 12:59:42 +00:00
|
|
|
|
|
|
|
def _get_level(path):
|
|
|
|
normalized = path
|
|
|
|
for i in range(len(path)):
|
|
|
|
new_normalized = normalized.replace("//", "/")
|
|
|
|
if len(new_normalized) == len(normalized):
|
|
|
|
break
|
|
|
|
normalized = new_normalized
|
|
|
|
|
|
|
|
return normalized.count("/")
|