commit | 14ad477eda5a99df3bb6575c2b39b00f6a93948c | [log] [tgz] |
---|---|---|
author | Chih-Hung Hsieh <chh@google.com> | Tue Jul 14 01:48:38 2020 +0000 |
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Tue Jul 14 01:48:38 2020 +0000 |
tree | 35d6ecd412a58078813071a196c7745bcc451800 | |
parent | cf8dfc86df6c553baa364f42da35766de4fd03b5 [diff] | |
parent | ce1a38f9d0a9b6ede19d453e50e5637a915c4fd6 [diff] |
Regenerate Android.bp with new cargo2android.py am: 78562bd1ca am: ce1a38f9d0 Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/clang-sys/+/1361325 Change-Id: Ie226dd8ef665fd9e814b8aa1cde0cee0b5299fcc
Rust bindings for libclang
.
If you are interested in a Rust wrapper for these bindings, see clang-rs.
Supported on the stable, beta, and nightly Rust channels.
Minimum supported Rust version: 1.36.0
Released under the Apache License 2.0.
There are two versions of the documentation, one for the API exposed when linking dynamically or statically and one for the API exposed when linking at runtime (see the Dependencies section of the README for more information on the linking options).
The only difference between the APIs exposed is that when linking at runtime a few additional types and functions are exposed to manage the loaded libclang
shared library.
To target a version of libclang
, enable one of the following Cargo features:
clang_3_5
- requires libclang
3.5 or laterclang_3_6
- requires libclang
3.6 or laterclang_3_7
- requires libclang
3.7 or laterclang_3_8
- requires libclang
3.8 or laterclang_3_9
- requires libclang
3.9 or laterclang_4_0
- requires libclang
4.0 or laterclang_5_0
- requires libclang
5.0 or laterclang_6_0
- requires libclang
6.0 or laterclang_7_0
- requires libclang
7.0 or laterclang_8_0
- requires libclang
8.0 or laterclang_9_0
- requires libclang
9.0 or laterIf you do not enable one of these features, the API provided by libclang
3.5 will be available by default.
By default, this crate will attempt to link to libclang
dynamically. In this case, this crate depends on the libclang
shared library (libclang.so
on Linux, libclang.dylib
on macOS, libclang.dll
on Windows). If you want to link to libclang
statically instead, enable the static
Cargo feature. In this case, this crate depends on the LLVM and Clang static libraries. If you don't want to link to libclang
at compiletime but instead want to load it at runtime, enable the runtime
Cargo feature.
These libraries can be either be installed as a part of Clang or downloaded here.
Note: The downloads for LLVM and Clang 3.8 and later do not include the libclang.a
static library. This means you cannot link to any of these versions of libclang
statically unless you build it from source.
This crate supports finding versioned instances of libclang.so
(e.g.,libclang-3.9.so
). In the case where there are multiple instances to choose from, this crate will prefer instances with higher versions. For example, the following instances of libclang.so
are listed in descending order of preference:
libclang-4.0.so
libclang-4.so
libclang-3.9.so
libclang-3.so
libclang.so
Note: On BSD distributions, versioned instances of libclang.so
matching the pattern libclang.so.*
(e.g., libclang.so.7.0
) are also included.
Note: On Linux distributions when the runtime
features is enabled, versioned instances of libclang.so
matching the pattern libclang.so.*
(e.g., libclang.so.1
) are also included.
The following environment variables, if set, are used by this crate to find the required libraries and executables:
LLVM_CONFIG_PATH
(compiletime) - provides a full path to an llvm-config
executable (including the executable itself [i.e., /usr/local/bin/llvm-config-8.0
])LIBCLANG_PATH
(compiletime) - provides a path to a directory containing a libclang
shared library or a full path to a specific libclang
shared libraryLIBCLANG_STATIC_PATH
(compiletime) - provides a path to a directory containing LLVM and Clang static librariesCLANG_PATH
(runtime) - provides a path to a clang
executablelibclang
shared libraries will be searched for in the following directories:
LIBCLANG_PATH
environment variablebin
and lib
directories in the directory provided by llvm-config --libdir
LD_LIBRARY_PATH
environment variable/usr/local/lib
on Linux)xcode-select --print-path
On Linux, running an executable that has been dynamically linked to libclang
may require you to add a path to libclang.so
to the LD_LIBRARY_PATH
environment variable. The same is true on OS X, except the DYLD_LIBRARY_PATH
environment variable is used instead.
On Windows, running an executable that has been dynamically linked to libclang
requires that libclang.dll
can be found by the executable at runtime. See here for more information.
The availability of llvm-config
is not optional for static linking. Ensure that an instance of this executable can be found on your system's path or set the LLVM_CONFIG_PATH
environment variable. The required LLVM and Clang static libraries will be searched for in the same way as shared libraries are searched for, except the LIBCLANG_STATIC_PATH
environment variable is used in place of the LIBCLANG_PATH
environment variable.
The clang_sys::load
function is used to load a libclang
shared library for use in the thread in which it is called. The clang_sys::unload
function will unload the libclang
shared library. clang_sys::load
searches for a libclang
shared library in the same way one is searched for when linking to libclang
dynamically at compiletime.