mirror of
https://github.com/vee1e/tflite-micro.git
synced 2026-09-01 17:57:27 +00:00
build: add means of linking with C libs in Py packages (#1668)
Extend the Python repository_rule used to create external repositories, adding targets for C-language binary libraries shipped inside Python packages; e.g., that shipped in package tensorflow-gpu. These targets are to be used as dependencies by C-language targets. Note: when debugging the build, it can be helpful to examine the repository directory and BUILD file this repository_rule generates in the bazel cache. Begin using a python/ directory at the root of the project for code that is specific to Python. Upgrade to the latest version of rules_python first. Note that the unit test to keep requirements.in and requirements.txt is disabled (specifically with ec6bdc5d4443285d28a44076f06c203d9582e4a1) Add a unit test for this feature. BUG=see description
This commit is contained in:
parent
8065fcdf1f
commit
17aae9e35d
12 changed files with 797 additions and 131 deletions
22
python/tests/BUILD
Normal file
22
python/tests/BUILD
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
cc_test(
|
||||
name = "cc_deps_link_test",
|
||||
size = "small",
|
||||
srcs = [
|
||||
"cc_deps_link_test.cc",
|
||||
],
|
||||
copts = [
|
||||
"-std=c++14",
|
||||
# Compiling against upstream Tensorflow headers requires -std=c++14
|
||||
# due (at least) to its dependency on Eigen, which raises the error
|
||||
# "This compiler appears to be too told to be supported by Eigen"
|
||||
# via the preprocessor, as well as several compilation errors.
|
||||
#
|
||||
# TODO(b/271210933): Harmonize this with a global solution
|
||||
# throughout the repository. Presumably this same issue will be
|
||||
# encountered by other code compiling against upstream Tensorflow,
|
||||
# such as custom operator implementations.
|
||||
],
|
||||
deps = [
|
||||
"@tensorflow_cc_deps//:cc_library",
|
||||
],
|
||||
)
|
||||
12
python/tests/cc_deps_link_test.cc
Normal file
12
python/tests/cc_deps_link_test.cc
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// A simple program to test the py_pkg_cc_deps repository rule by building and
|
||||
// linking against the Tensorflow library shipping in the Tensorflow Python
|
||||
// package.
|
||||
|
||||
#include <tensorflow/core/util/util.h>
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
const char* ptr = "test";
|
||||
const size_t n = 4;
|
||||
tensorflow::PrintMemory(ptr, n);
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue