Skip to content

Commit 657e41c

Browse files
committed
Readme stuff
1 parent 372a7dc commit 657e41c

File tree

2 files changed

+53
-2
lines changed

2 files changed

+53
-2
lines changed

README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
Ever wanted to build “native” assembly stuff in your cargo build scripts… something gcc crate
2+
cannot quite handle yet? Welcome to llvm_build_utils which provides a convenient API to pack your
3+
.ll or .bc files into a ready to use archive full of machine code! It doesn’t even need LLVM
4+
installation and works on stable Rust¹!
5+
6+
¹: May break between versions or be incompatible with some versions of Rust, though. We’ll try to
7+
document such breakages in the table below.
8+
9+
# Compatibility table
10+
11+
| Rustc version | This Library |
12+
| ------------- | ------------- |
13+
| 1.8-1.11 | 0.1.0 |
14+
15+
# Using llvm_build_utils
16+
17+
First, you'll want to both add a build script for your crate (build.rs) and also add this crate to
18+
your Cargo.toml via:
19+
20+
```toml
21+
[package]
22+
# ...
23+
build = "build.rs"
24+
25+
[build-dependencies]
26+
llvm_build_utils = "0.1"
27+
```
28+
29+
Then write your `build.rs` like this:
30+
31+
```rust
32+
extern crate llvm_build_utils;
33+
use llvm_build_utils::*;
34+
35+
fn main() {
36+
build_archive(&[
37+
("input.ll", BuildOptions {
38+
// customise how the file is built
39+
..BuildOptions::default()
40+
})/*, ("input2.ll", ...
41+
// more .ll files to be built into the archive in same format as first one
42+
*/], "libyourthing.a").expect("error happened");
43+
}
44+
```
45+
46+
Running a `cargo build` should produce `libyourthing.a` which then may be linked to your Rust
47+
executable/library.
48+
49+
# License
50+
51+
llvm_build_utils is distributed under ISC (MIT-like) or Apache (version 2.0) license at your
52+
choice.

build.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
use std::io::Write;
2-
use std::path::{Path, PathBuf};
1+
use std::path::PathBuf;
32
use std::process::Command;
43

54
fn main(){

0 commit comments

Comments
 (0)