You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 2, 2025. It is now read-only.
Merge pull request #51 from tomassedovic/build-script
Convert to the supported Cargo build script
This should make it more consistent to build & use the native libtcod bindings for everyone. We've moved from the old anything-goes build scripts to the new ones that only allow Rust code.
Based on the conventions in the build-script guide[1], this introduces a new crate called `tcod-sys`. That crate defines all the function signatures and type definitions in `libtcod` and so replaces what was previously in `tcod-rs/src/ffi.rs`. It also bundles a libtcod snapshot source known to work (the latest checkout of the `1.5.x` branch) plus fixes to make it compile on Mac OS X. And a build script that knows how to build it and where to put the artifacts.
This should hopefully make building tcod-rs more repeatable for everyone.
This is a breaking change.
To migrate, just make sure you have the right dependencies to build libtcod installed (see readme) and remove any `build = ...` section from your game's `Cargo.toml`. When you run `cargo build`, libtcod will be built as part that build process.
If you want to avoid building libtcod and provide your own pre-built `libtcod.{so,dll,dylib}`, you can use Cargo's build override mechanism[2]. See `tcod-rs/.cargo/config` for an example. You probably want to put the `.cargo/config` file in the root of your game, but it can be in any directory above that, too (such as your `$HOME`).
I have tested this on my 64bit Linux Mint 17 machine and a 32bit Windows 7 box with MinGW. @pmsanford tested this on OSX.
[1]: http://doc.crates.io/build-script.html
[2]: http://doc.crates.io/build-script.html#overriding-build-scriptsCloses#32.
Copy file name to clipboardExpand all lines: README.md
+72-64Lines changed: 72 additions & 64 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,17 +1,17 @@
1
1
libtcod bindings for Rust
2
2
-------------------------
3
3
4
-
[libtcod a.k.a. "The Doryen Library"](http://doryen.eptalys.net/libtcod/) is a
5
-
smallish library designed for writing roguelikes. It provides a bunch of useful
6
-
functionality such as:
4
+
[libtcod a.k.a. "The Doryen Library"](http://roguecentral.org/doryen/libtcod/)
5
+
is a smallish library designed for writing roguelikes. It provides a bunch of
6
+
useful functionality such as:
7
7
8
8
* Text-based graphics API that doesn't suck as much as curses or OpenGL
9
9
* Colours! (like, more than 16)
10
10
* Keyboard and mouse input
11
11
* Path finding
12
12
* Field of view
13
13
* Portable (works on linux and windows; mac too but requires some effort)
14
-
*[lots of other stuff](http://doryen.eptalys.net/libtcod/features/)
14
+
*[lots of other stuff](http://roguecentral.org/doryen/libtcod/features/)
15
15
16
16
17
17
This project provides [Rust](http://www.rust-lang.org/) bindings for libtcod
@@ -49,7 +49,7 @@ complete however.
49
49
* Most of the _Console_ features (new, init_root, blit, putting text on the
50
50
screen, reading key presses, etc.)
51
51
* Most of _Map_ (new, size, set, is_walkable)
52
-
*Most of the A*_Path_ features (no Dijkstra yet)
52
+
* A*and Dijkstra _Path_ finding
53
53
* Some of the _System_ layer (get/set FPS, last frame length)
54
54
55
55
### Probably Won't Ever Be Implemented Because Rust Provides This Already
@@ -66,88 +66,91 @@ complete however.
66
66
How to use this
67
67
---------------
68
68
69
-
You can build this library by cloning the repository and typing `cargo build`. You need to have `libtcod` in your library path, you can
70
-
download it from the [libtcod download page](http://doryen.eptalys.net/libtcod/download/), or install it using some package manager. See below for Mac OS X specific install instructions.
69
+
`tcod-rs` depends on `libtcod` so you need to build or download the official
70
+
version. The `libtcod` version known to work is bundled with `tcod-sys` and
71
+
Cargo will build it for you, but you need the build dependencies installed.
71
72
72
-
This will compile and link the library and a simple example in `target`
73
+
Alternatively, you can provide the precompiled libtcod library to override the
74
+
building process. [See below](#using-existing-binary-distribution).
The Windows version of `libtcod` relies on MinGW and MSYS so you have to install
101
+
them:
115
102
116
-
If this seems a bit convoluted that's because it is. I managed to find instructions [here](http://zackhovatter.com/gamedev/2013/11/26/building-libtcod-on-os-x-mavericks.html) but at the time of writing that link was broken. I grabbed a screenshot from Google Cache and put together my own packages of OS X specific materials. In step two above you're getting an OS X specific makefile and in step three you're getting some OS X specific headers.
103
+
1.[Download and run MinGW][mingw]
104
+
2. In the MinGW installer, mark the following sections for installation:
That copies the required `.dyblib` files from where you built `libtcod` to your project's target directory, and the `terminal.png` that `sdl` requires to your projects root directory.
136
+
---
137
+
138
+
To test this, you can clone this repository directly and run the one of the
0 commit comments