Skip to content
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

Upgrade libtcod to 1.12.3 #290

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions .idea/tcod-rs.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

423 changes: 423 additions & 0 deletions .idea/workspace.xml

Large diffs are not rendered by default.

22 changes: 20 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,26 @@ matrix:
rust: nightly
- os: osx
rust: nightly
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-8
- libsdl2-dev
- libegl1-mesa-dev
- libgles2-mesa-dev
before_install:
- '[ "$TRAVIS_OS_NAME" = linux ] && sudo apt-get update -qq || brew update'
- 'if [[ "$TRAVIS_OS_NAME" != linux ]]; then brew update; fi'
install:
- '[ "$TRAVIS_OS_NAME" = linux ] && sudo apt-get install -y libsdl2-dev libegl1-mesa-dev libgles2-mesa-dev || brew install sdl2'
- 'if [[ "$TRAVIS_OS_NAME" != linux ]]; then brew install sdl2; fi'
# Upgrade SDL. Copy-paste from https://github.com/libtcod/libtcod/blob/master/.ci/travis_before_install.sh @ ce85b9f0245ece439e509fc38667aa59c440d391
- 'if [[ "$TRAVIS_OS_NAME" == linux ]]; then wget -O - https://www.libsdl.org/release/SDL2-2.0.8.tar.gz | tar xz; fi'
- 'if [[ "$TRAVIS_OS_NAME" == linux ]]; then (cd SDL2-* && ./configure --prefix=$HOME/.local && make -j 3 install); fi'
- 'if [[ "$TRAVIS_OS_NAME" == linux ]]; then PATH=~/.local/bin:$PATH; export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$HOME/.local/lib/pkgconfig"; fi'
# Debugging, feel free to remove this
- 'if [[ "$TRAVIS_OS_NAME" == linux ]]; then pkg-config sdl2 --cflags; fi'

script:
- cargo build --verbose
- cargo test --verbose
Expand Down Expand Up @@ -45,3 +61,5 @@ after_success: ! '[ $TRAVIS_BRANCH = master ] &&
env:
global:
- secure: h21kqC5s6iVs4p5n9KFZ5ZTWtPF8nGVFpaPP6t/1Sg+xMaHMDyr/sBYI1gsNGTXrVsiP2Zs6cRTBEbX12PVL6MXFgKpdhKG1+lBCMk6HxU8/W2UHCh6Y38+W4Ybyv5fuoWqkUOX3yODNkRZWrqNhdm8lCdE2uGczkIKPi7hDYMM=
- CC=gcc-8
- CXX=g++-8
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ serialization = ["serde", "serde_derive"]

[dependencies.tcod-sys]
path = "tcod_sys"
version = "5.0.0"
version = "5.3.0"

[dev-dependencies]
rand = "0.3"
Expand Down
2 changes: 1 addition & 1 deletion tcod_sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "tcod-sys"
description = "Raw FFI bindings & build script to link against libtcod."
version = "5.0.1"
version = "5.3.0"
license = "WTFPL"
homepage = "https://github.com/tomassedovic/tcod-rs"
repository = "https://github.com/tomassedovic/tcod-rs/tree/master/tcod-sys"
Expand Down
191 changes: 133 additions & 58 deletions tcod_sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,23 @@ fn build_libz(libz_sources: &[&str]) {
config.compile("libz.a");
}

fn add_includes(config: &mut cc::Build) {
config.include(Path::new("libtcod").join("src").join("vendor"));
config.include(Path::new("libtcod").join("src").join("vendor").join("utf8proc"));
config.include(Path::new("libtcod").join("src").join("vendor").join("zlib"));
config.include(Path::new("libtcod").join("src").join("libtcod").join("color"));
config.include(Path::new("libtcod").join("src").join("libtcod").join("console"));
config.include(Path::new("libtcod").join("src").join("libtcod").join("engine"));
config.include(Path::new("libtcod").join("src").join("libtcod").join("gui"));
config.include(Path::new("libtcod").join("src").join("libtcod").join("sdl2"));
config.include(Path::new("libtcod").join("src").join("libtcod").join("pathfinding"));
config.include(Path::new("libtcod").join("src").join("libtcod").join("tileset"));
config.include(Path::new("libtcod").join("src").join("libtcod").join("utility"));
config.include(Path::new("libtcod").join("src").join("libtcod"));
}

fn build_libtcod_objects(mut config: cc::Build, sources: &[&str]) {
config.include("libtcod/include");
config.include("libtcod/src/zlib");
add_includes(&mut config);
for c_file in sources {
config.file(c_file);
}
Expand Down Expand Up @@ -62,7 +76,7 @@ fn build_linux_static(_dst: &Path, libtcod_sources: &[& 'static str]) {
config.define("NO_OPENGL", None);
config.define("NDEBUG", None);
config.flag("-fno-strict-aliasing");
config.flag("-ansi");
config.flag("-std=c++14");
build_libtcod_objects(config, libtcod_sources);
}

Expand All @@ -80,7 +94,7 @@ fn build_linux_dynamic(dst: &Path, libtcod_sources: &[& 'static str]) {
config.define("NO_OPENGL", None);
config.define("NDEBUG", None);
config.flag("-fno-strict-aliasing");
config.flag("-ansi");
config.flag("-std=c++14");
build_libtcod_objects(config, libtcod_sources);
}

Expand Down Expand Up @@ -127,54 +141,115 @@ fn main() {
let sdl_include_dir = src.join("libtcod").join("dependencies").join("SDL2-2.0.7").join("include");

let libz_sources = &[
"libtcod/src/zlib/adler32.c",
"libtcod/src/zlib/crc32.c",
"libtcod/src/zlib/deflate.c",
"libtcod/src/zlib/infback.c",
"libtcod/src/zlib/inffast.c",
"libtcod/src/zlib/inflate.c",
"libtcod/src/zlib/inftrees.c",
"libtcod/src/zlib/trees.c",
"libtcod/src/zlib/zutil.c",
"libtcod/src/zlib/compress.c",
"libtcod/src/zlib/uncompr.c",
"libtcod/src/zlib/gzclose.c",
"libtcod/src/zlib/gzlib.c",
"libtcod/src/zlib/gzread.c",
"libtcod/src/zlib/gzwrite.c",
"libtcod/src/vendor/zlib/adler32.c",
"libtcod/src/vendor/zlib/crc32.c",
"libtcod/src/vendor/zlib/deflate.c",
"libtcod/src/vendor/zlib/infback.c",
"libtcod/src/vendor/zlib/inffast.c",
"libtcod/src/vendor/zlib/inflate.c",
"libtcod/src/vendor/zlib/inftrees.c",
"libtcod/src/vendor/zlib/trees.c",
"libtcod/src/vendor/zlib/zutil.c",
"libtcod/src/vendor/zlib/compress.c",
"libtcod/src/vendor/zlib/uncompr.c",
"libtcod/src/vendor/zlib/gzclose.c",
"libtcod/src/vendor/zlib/gzlib.c",
"libtcod/src/vendor/zlib/gzread.c",
"libtcod/src/vendor/zlib/gzwrite.c",
];

let vendor_sources = &[
"libtcod/src/vendor/glad.c",
"libtcod/src/vendor/stb.c",
"libtcod/src/vendor/lodepng.cpp",
"libtcod/src/vendor/utf8proc/utf8proc.c",
];

let libtcod_sources = &[
"libtcod/src/bresenham_c.c",
"libtcod/src/bsp_c.c",
"libtcod/src/color_c.c",
"libtcod/src/console_c.c",
"libtcod/src/console_rexpaint.c",
"libtcod/src/fov_c.c",
"libtcod/src/fov_circular_raycasting.c",
"libtcod/src/fov_diamond_raycasting.c",
"libtcod/src/fov_permissive2.c",
"libtcod/src/fov_recursive_shadowcasting.c",
"libtcod/src/fov_restrictive.c",
"libtcod/src/heightmap_c.c",
"libtcod/src/image_c.c",
"libtcod/src/lex_c.c",
"libtcod/src/list_c.c",
"libtcod/src/mersenne_c.c",
"libtcod/src/namegen_c.c",
"libtcod/src/noise_c.c",
"libtcod/src/parser_c.c",
"libtcod/src/path_c.c",
"libtcod/src/sys_c.c",
"libtcod/src/sys_sdl2_c.c",
"libtcod/src/sys_sdl_c.c",
"libtcod/src/sys_sdl_img_bmp.c",
"libtcod/src/sys_sdl_img_png.c",
"libtcod/src/tree_c.c",
"libtcod/src/txtfield_c.c",
"libtcod/src/wrappers.c",
"libtcod/src/zip_c.c",
"libtcod/src/png/lodepng.c",
"libtcod/src/libtcod/bresenham_c.c",
"libtcod/src/libtcod/bsp_c.c",
"libtcod/src/libtcod/color_c.c",
"libtcod/src/libtcod/console.cpp",
"libtcod/src/libtcod/console_c.cpp",
"libtcod/src/libtcod/deprecated.cpp",
"libtcod/src/libtcod/fov_c.c",
"libtcod/src/libtcod/fov_circular_raycasting.c",
"libtcod/src/libtcod/fov_diamond_raycasting.c",
"libtcod/src/libtcod/fov_permissive2.c",
"libtcod/src/libtcod/fov_recursive_shadowcasting.c",
"libtcod/src/libtcod/fov_restrictive.c",
"libtcod/src/libtcod/heightmap_c.c",
"libtcod/src/libtcod/image.cpp",
"libtcod/src/libtcod/image_c.cpp",
"libtcod/src/libtcod/lex_c.c",
"libtcod/src/libtcod/list_c.c",
"libtcod/src/libtcod/mersenne_c.c",
"libtcod/src/libtcod/namegen_c.c",
"libtcod/src/libtcod/noise_c.c",
"libtcod/src/libtcod/parser_c.c",
"libtcod/src/libtcod/path_c.c",
"libtcod/src/libtcod/sys_c.cpp",
"libtcod/src/libtcod/sys_opengl_c.cpp",
"libtcod/src/libtcod/sys_sdl2_c.cpp",
"libtcod/src/libtcod/sys_sdl_c.cpp",
"libtcod/src/libtcod/sys_sdl_img_bmp.cpp",
"libtcod/src/libtcod/sys_sdl_img_png.cpp",
"libtcod/src/libtcod/tree_c.c",
"libtcod/src/libtcod/txtfield_c.c",
"libtcod/src/libtcod/wrappers.cpp",
"libtcod/src/libtcod/zip_c.c",
// color
"libtcod/src/libtcod/color/canvas.cpp",
// console
// Note that console/console.cpp here was renamed because MSVC can't deal with source
// files with the same name in different dirs (output is the same .obj file for each).
// I failed to make this go away with /Fo.
// See https://stackoverflow.com/questions/3729515/visual-studio-2010-2008-cant-handle-source-files-with-identical-names-in-diff/
"libtcod/src/libtcod/console/console_clobbered.cpp",
"libtcod/src/libtcod/console/drawing.cpp",
"libtcod/src/libtcod/console/printing.cpp",
"libtcod/src/libtcod/console/rexpaint.cpp",
// engine
"libtcod/src/libtcod/engine/backend.cpp",
"libtcod/src/libtcod/engine/display.cpp",
"libtcod/src/libtcod/engine/error.cpp",
"libtcod/src/libtcod/engine/globals.cpp",
// gui
// "libtcod/src/libtcod/gui/button.cpp",
// "libtcod/src/libtcod/gui/container.cpp",
// "libtcod/src/libtcod/gui/flatlist.cpp",
// "libtcod/src/libtcod/gui/hbox.cpp",
// "libtcod/src/libtcod/gui/image.cpp",
// "libtcod/src/libtcod/gui/label.cpp",
// "libtcod/src/libtcod/gui/radiobutton.cpp",
// "libtcod/src/libtcod/gui/slider.cpp",
// "libtcod/src/libtcod/gui/statusbar.cpp",
// "libtcod/src/libtcod/gui/textbox.cpp",
// "libtcod/src/libtcod/gui/togglebutton.cpp",
// "libtcod/src/libtcod/gui/toolbar.cpp",
// "libtcod/src/libtcod/gui/vbox.cpp",
// "libtcod/src/libtcod/gui/widget.cpp",
// pathfinding
"libtcod/src/libtcod/pathfinding/astar.cpp",
"libtcod/src/libtcod/pathfinding/dijkstra.cpp",
"libtcod/src/libtcod/pathfinding/generic.cpp",
// sdl2
"libtcod/src/libtcod/sdl2/event.cpp",
"libtcod/src/libtcod/sdl2/gl2_display.cpp",
"libtcod/src/libtcod/sdl2/gl2_raii.cpp",
"libtcod/src/libtcod/sdl2/gl2_renderer.cpp",
"libtcod/src/libtcod/sdl2/gl_alias.cpp",
"libtcod/src/libtcod/sdl2/legacy_backend.cpp",
"libtcod/src/libtcod/sdl2/sdl2_alias.cpp",
"libtcod/src/libtcod/sdl2/sdl2_display.cpp",
"libtcod/src/libtcod/sdl2/sdl2_renderer.cpp",
// tileset
"libtcod/src/libtcod/tileset/fallback.cpp",
"libtcod/src/libtcod/tileset/observer.cpp",
"libtcod/src/libtcod/tileset/tile.cpp",
"libtcod/src/libtcod/tileset/tileset.cpp",
"libtcod/src/libtcod/tileset/tilesheet.cpp",
"libtcod/src/libtcod/tileset/truetype.cpp",
];

if target.contains("linux") {
Expand All @@ -198,7 +273,7 @@ fn main() {
config.define("NO_OPENGL", None);
config.define("NDEBUG", None);
config.flag("-fno-strict-aliasing");
config.flag("-ansi");
config.flag("-std=c++14");
build_libtcod_objects(config, libtcod_sources);
}

Expand All @@ -210,7 +285,7 @@ fn main() {
config.flag("-shared");
config.flag("-o");
config.flag(dst.join("libtcod.dylib").to_str().unwrap());
for c_file in libtcod_sources {
for c_file in libtcod_sources.iter() {
config.flag(dst.join(c_file).with_extension("o").to_str().unwrap());
}
config.flag(dst.join("libz.a").to_str().unwrap());
Expand Down Expand Up @@ -238,7 +313,7 @@ fn main() {
// Build the DLL
let mut config = cc::Build::new();
config.flag("-fno-strict-aliasing");
config.flag("-ansi");
config.flag("-std=c++14");
config.define("TCOD_SDL2", None);
config.define("NO_OPENGL", None);
config.define("NDEBUG", None);
Expand All @@ -248,13 +323,13 @@ fn main() {
config.flag("-shared");
fs::create_dir(dst.join("lib")).unwrap();
config.flag(&format!("-Wl,--out-implib,{}", dst.join("lib/libtcod.a").display()));
config.include(Path::new("libtcod").join("src").join("zlib"));
config.include(Path::new("libtcod").join("include"));
for c_file in libz_sources.iter().chain(libtcod_sources) {
add_includes(&mut config);
for c_file in libz_sources.iter().chain(libtcod_sources.iter()).chain(vendor_sources) {
let path = c_file.split('/').fold(PathBuf::new(), |path, segment| path.join(segment));
config.flag(src.join(path).to_str().unwrap());
}
config.flag("-mwindows");
config.flag("-EHsc");
config.flag("-L");
config.flag(sdl_lib_dir.to_str().unwrap());
config.flag("-lSDL2");
Expand Down Expand Up @@ -283,11 +358,11 @@ fn main() {
config.flag("/DNO_OPENGL");
config.flag("/DNDEBUG");
config.flag("/DLIBTCOD_EXPORTS");
config.flag("/EHsc");
config.flag(&format!("/Fo:{}\\", dst.to_str().unwrap()));
config.include(sdl_include_dir.to_str().unwrap());
config.include(Path::new("libtcod").join("src").join("zlib"));
config.include(Path::new("libtcod").join("include"));
for c_file in libz_sources.iter().chain(libtcod_sources) {
add_includes(&mut config);
for c_file in libz_sources.iter().chain(vendor_sources).chain(libtcod_sources.iter()) {
// Make sure the path is in the Windows format. This
// shouldn't matter but it's distracting when debugging
// build script issues.
Expand Down
Loading