Skip to content

Update README.md to reflect the current situation #366

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 28, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 41 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,42 @@ the [Stylo](https://public.etherpad-mozilla.org/p/stylo) project.

## Requirements

The current generator runs on with clang 3.8, but can also run with clang 3.9
with more features (such as detection of inlined functions).
It is recommended to use clang 3.9 with the current generator. It can run with
clang 3.8 with some features disabled.

### Installing clang 3.8
### Installing Clang 3.9

#### OSX
#### Windows

```
# brew install llvm38
```
Download and install the official pre-built binary from
[LLVM download page](http://releases.llvm.org/download.html).

#### On Debian-based Linuxes
#### OSX

If you use Homebrew:
```
# apt-get install llvm-3.8-dev libclang-3.8-dev
$ brew install llvm
```
Adding the LLVM repos to get version 3.8 may be necessary, see http://apt.llvm.org/.
#### Arch

If you use MacPorts:
```
# pacman -S clang clang-tools-extra
$ port install clang-3.9
```

### Getting clang 3.9
#### Debian-based Linuxes

#### From a package manager
```
# apt-get install llvm-3.9-dev libclang-3.9-dev
```

Clang 3.9 has ben released about a month ago, and some package managers already
provide it.
Ubuntu 16.10 provides the necessary packages directly. If you are using older
version of Ubuntu or other Debian-based distros, you may need to add the LLVM
repos to get version 3.9. See http://apt.llvm.org/.

For example, for MacPorts:
#### Arch

```
$ port install clang-3.9
$ LIBCLANG_PATH=/opt/local/libexec/llvm-3.9/lib \
LD_LIBRARY_PATH=/opt/local/libexec/llvm-3.9/lib \
cargo build
# pacman -S clang
```

#### From source
Expand All @@ -65,29 +64,40 @@ Those instructions list optional steps. For bindgen:
## Building

```
$ cargo build --features llvm_stable
$ cd bindgen
$ cargo build
```

If you want a build with extra features (llvm 3.9) then you can use:
If you installed multiple versions of llvm, it may not be able to locate the
latest version of libclang. In that case, you may want to either uninstall
other versions of llvm, or specify the path of the desired libclang explicitly:
```
$ export LIBCLANG_PATH=path/to/clang-3.9/lib
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure whether leaving LD_LIBRARY_PATH will have an effect (cc @emilio)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, per description in clang-sys's README, it seems we would still need LD_LIBRARY_PATH.

```

On Linux and macOS, you may also need to add a path to `libclang.so` (usually
the same path as above) to library search path. This can be done as below:
```
$ LIBCLANG_PATH=path/to/clang-3.9/build/lib \
LD_LIBRARY_PATH=path/to/clang-3.9/build/lib \
cargo build
$ export LD_LIBRARY_PATH=path/to/clang-3.9/lib # for Linux
$ export DYLD_LIBRARY_PATH=path/to/clang-3.9/lib # for macOS
```

# Library usage with `build.rs`

See [the Stylo build script][stylo-script] to see how it is used inside the
Servo organisation.

[stylo-script]: https://github.com/servo/servo/blob/master/components/style/build_gecko.rs

In `Cargo.toml`:

```toml
[package]
# ...
build = "build.rs"

[build-dependencies.libbindgen]
git = "https://github.com/servo/rust-bindgen"
features = ["llvm_stable"]
[build-dependencies]
libbindgen = "0.1"
```

In `build.rs`:
Expand Down Expand Up @@ -117,11 +127,10 @@ include!(concat!(env!("OUT_DIR"), "/example.rs"));
# Command Line Usage

There are a few options documented when running `./bindgen --help`. Other
options might exist (see [the SpiderMonkey script][sm-script] and [the Stylo
scripts][stylo-scripts] to see how is it used inside the Servo organisation.
options might exist (see [the SpiderMonkey script][sm-script] to see how it
is used inside the Servo organisation.

[sm-script]: https://github.com/servo/rust-mozjs/blob/master/etc/bindings.sh
[stylo-scripts]: https://github.com/servo/servo/tree/master/components/style/binding_tools

## C++ Usage

Expand Down