Skip to content

Commit

Permalink
Updating bgfx and fixing build.
Browse files Browse the repository at this point in the history
- bgfx and bx updated, bimg added.
- Updated to compile with latest rust.
- rust-bindgen change a lot, which caused a lot of changes.
- Removed beta channels from appveyor, as it fails to link documentation tests for some reason.
  • Loading branch information
rhoot committed May 29, 2017
1 parent b3bb0e8 commit a811a69
Show file tree
Hide file tree
Showing 17 changed files with 5,409 additions and 1,743 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "bgfx-sys/bx"]
path = bgfx-sys/bx
url = https://github.com/bkaradzic/bx.git
[submodule "bgfx-sys/bimg"]
path = bgfx-sys/bimg
url = https://github.com/bkaradzic/bimg.git
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
language: rust
dist: trusty
sudo: false

rust:
- stable
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ path = "bgfx-sys/"

[dev-dependencies]
cgmath = "0.7.0"
glutin = { git = "https://github.com/tomaka/glutin.git", rev = "0297efb" }
glutin = "0.7.1"
time = "0.1.33"
6 changes: 0 additions & 6 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,10 @@ environment:
matrix:
- CHANNEL: stable
TARGET: x86_64-pc-windows-msvc
- CHANNEL: beta
TARGET: x86_64-pc-windows-msvc
- CHANNEL: stable
TARGET: x86_64-pc-windows-gnu
- CHANNEL: beta
TARGET: x86_64-pc-windows-gnu
- CHANNEL: stable
TARGET: i686-pc-windows-gnu
- CHANNEL: beta
TARGET: i686-pc-windows-gnu

install:
- git submodule update --init --recursive
Expand Down
26 changes: 10 additions & 16 deletions bgfx-sys/Makefile
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
rust-bindgen:
git clone https://github.com/crabtw/rust-bindgen
git clone https://github.com/servo/rust-bindgen.git

rust-bindgen/target/release/bindgen: rust-bindgen
cd rust-bindgen && git checkout 6e33fbe74de0c38c68658cc51c6d8fe584691367
cd rust-bindgen && cargo build --release

src/ffi_bgfx.rs: rust-bindgen/target/release/bindgen bgfx/include/bgfx/c99/bgfx.h bgfx/include/bgfx/c99/bgfxplatform.h
src/ffi_bgfx.rs: rust-bindgen/target/release/bindgen bgfx/include/bgfx/c99/bgfx.h bgfx/include/bgfx/c99/platform.h
rust-bindgen/target/release/bindgen \
-match bgfx.h \
-I bgfx/include \
-I bx/include \
--constified-enum bgfx_renderer_type \
--constified-enum bgfx_attrib \
--constified-enum bgfx_render_frame \
-o src/ffi_bgfx.rs \
bgfx/include/bgfx/c99/bgfx.h

src/ffi_bgfxplatform.rs: rust-bindgen/target/release/bindgen bgfx/include/bgfx/c99/bgfx.h bgfx/include/bgfx/c99/bgfxplatform.h
rust-bindgen/target/release/bindgen \
-match bgfxplatform.h \
-I bgfx/include \
-I bx/include \
-include bgfx/c99/bgfx.h \
-o src/ffi_bgfxplatform.rs \
bgfx/include/bgfx/c99/bgfxplatform.h
bgfx/include/bgfx/c99/platform.h \
-- \
-Ibgfx/include \
-Ibx/include \
-include bgfx/c99/bgfx.h
2 changes: 1 addition & 1 deletion bgfx-sys/bgfx
Submodule bgfx updated 2707 files
1 change: 1 addition & 0 deletions bgfx-sys/bimg
Submodule bimg added at 4ec629
25 changes: 23 additions & 2 deletions bgfx-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// License: http://opensource.org/licenses/ISC

use std::env;
use std::io::{Read, Write};
use std::io::Write;
use std::path::PathBuf;
use std::process::{Command, Stdio};

Expand Down Expand Up @@ -33,6 +33,7 @@ fn build_msvc(bitness: u32) {
let vs_release = match vs_version.as_ref() {
"12.0" => "2013",
"14.0" => "2015",
"15.0" => "2017",
_ => panic!(format!("Unknown Visual Studio version: {:?}", vs_version)),
};

Expand All @@ -47,7 +48,7 @@ fn build_msvc(bitness: u32) {
.current_dir("bgfx")
.arg("/p:Configuration=Release")
.arg(format!("/p:Platform={}", platform))
.arg(format!(".build/projects/vs{}/bgfx.vcxproj", vs_release))
.arg(format!(".build/projects/vs{}/bgfx.sln", vs_release))
.status()
.expect("Failed to build bgfx");

Expand All @@ -61,6 +62,8 @@ fn build_msvc(bitness: u32) {
path.push(format!("win{}_vs{}", bitness, vs_release));
path.push("bin");

println!("cargo:rustc-link-lib=static=bxRelease");
println!("cargo:rustc-link-lib=static=bimgRelease");
println!("cargo:rustc-link-lib=static=bgfxRelease");
println!("cargo:rustc-link-lib=gdi32");
println!("cargo:rustc-link-lib=user32");
Expand Down Expand Up @@ -118,6 +121,22 @@ fn build_gmake(bitness: u32, profile: &str, platform: &str) {
panic!("Failed to build bgfx.");
}

// Build bimg
let status = Command::new("make")
.env("CFLAGS", cflags)
.arg("-R")
.arg("-C")
.arg(format!("bgfx/.build/projects/{}", project_name))
.arg(format!("config={}{}", profile, bitness))
.arg("verbose=1")
.arg("bimg")
.status()
.expect("Failed to build bimg");

if status.code().unwrap() != 0 {
panic!("Failed to build bimg.");
}

// Output linker config
let mut path = PathBuf::from(env::current_dir().unwrap());
path.push("bgfx");
Expand All @@ -127,6 +146,8 @@ fn build_gmake(bitness: u32, profile: &str, platform: &str) {

let config = if profile == "debug" { "Debug" } else { "Release" };
println!("cargo:rustc-link-lib=bgfx{}", config);
println!("cargo:rustc-link-lib=bimg{}", config);
println!("cargo:rustc-link-lib=bx{}", config);
println!("cargo:rustc-link-lib=stdc++");
println!("cargo:rustc-link-search=native={}", path.as_os_str().to_str().unwrap());

Expand Down
2 changes: 1 addition & 1 deletion bgfx-sys/bx
Submodule bx updated 227 files
Loading

0 comments on commit a811a69

Please sign in to comment.