Merge pull request #6 from bvssvni/master

Upgraded to latest Rust + Rust-Empty
This commit is contained in:
ShuYu Wang
2014-06-30 20:57:49 +08:00
3 changed files with 93 additions and 90 deletions
+24 -21
View File
@@ -68,20 +68,20 @@ endif
RUSTDOC = rustdoc
# Extracts target from rustc.
TARGET = $(shell rustc --version 2> /dev/null | awk "/host:/ { print \$$2 }")
TARGET = $(shell rustc --version verbose 2> /dev/null | awk "/host:/ { print \$$2 }")
# TARGET = x86_64-unknown-linux-gnu
# TARGET = x86_64-apple-darwin
TARGET_LIB_DIR = target/$(TARGET)/lib/
TARGET_LIB_DIR = target/deps/
# Ask 'rustc' the file name of the library and use a dummy name if the source has not been created yet.
# The dummy file name is used to trigger the creation of the source first time.
# Next time 'rustc' will return the right file name.
RLIB_FILE = $(shell (rustc --crate-type=rlib --crate-file-name "$(LIB_ENTRY_FILE)" 2> /dev/null) || (echo "dummy.rlib"))
# You can't have quotes around paths because 'make' doesn't see it exists.
RLIB = target/$(TARGET)/lib/$(RLIB_FILE)
RLIB = target/$(RLIB_FILE)
DYLIB_FILE = $(shell (rustc --crate-type=dylib --crate-file-name "$(LIB_ENTRY_FILE)" 2> /dev/null) || (echo "dummy.dylib"))
DYLIB = target/$(TARGET)/lib/$(DYLIB_FILE)
DYLIB = target/$(DYLIB_FILE)
# Use 'VERBOSE=1' to echo all commands, for example 'make help VERBOSE=1'.
ifdef VERBOSE
@@ -93,7 +93,7 @@ endif
all: $(DEFAULT)
help:
$(Q)echo "--- rust-empty (0.5 007)"
$(Q)echo "--- rust-empty (0.6 003)"
$(Q)echo "make run - Runs executable"
$(Q)echo "make exe - Builds main executable"
$(Q)echo "make lib - Both static and dynamic library"
@@ -110,8 +110,8 @@ help:
$(Q)echo "make examples - Builds examples"
$(Q)echo "make cargo-lite-exe - Setup executable package"
$(Q)echo "make cargo-lite-lib - Setup library package"
$(Q)echo "make cargo-exe - EXPERIMENTAL: Setup executable package"
$(Q)echo "make cargo-lib - EXPERIMENTAL: Setup library package"
$(Q)echo "make cargo-exe - Setup executable package"
$(Q)echo "make cargo-lib - Setup library package"
$(Q)echo "make rust-ci-lib - Setup Travis CI Rust library"
$(Q)echo "make rust-ci-exe - Setup Travis CI Rust executable"
$(Q)echo "make rusti - Setup 'rusti.sh' for interactive Rust"
@@ -211,12 +211,12 @@ cargo-exe: $(EXE_ENTRY_FILE)
( \
name=$${PWD##/*/} ; \
readme=$$((test -e README.md && echo -e "readme = \"README.md\"") || ("")) ; \
echo -e "[package]\n\nname = \"$$name\"\nversion = \"0.0\"\n$$readme\nauthors = [\"Your Name <your@email.com>\"]\ntags = []\n\n[[bin]]\n\nname = \"$$name\"\npath = \"$(EXE_ENTRY_FILE)\"\n" > Cargo.toml \
echo -e "[package]\n\nname = \"$$name\"\nversion = \"0.0.0\"\n$$readme\nauthors = [\"Your Name <your@email.com>\"]\ntags = []\n\n[[bin]]\n\nname = \"$$name\"\npath = \"$(EXE_ENTRY_FILE)\"\n" > Cargo.toml \
&& echo "--- Created 'Cargo.toml' for executable" \
&& cat Cargo.toml \
)
cargo-lib: $(EXE_ENTRY_FILE)
cargo-lib: $(LIB_ENTRY_FILE)
$(Q)( \
test -e Cargo.toml \
&& echo "--- The file 'Cargo.toml' already exists" \
@@ -225,7 +225,7 @@ cargo-lib: $(EXE_ENTRY_FILE)
( \
name=$${PWD##/*/} ; \
readme=$$((test -e README.md && echo -e "readme = \"README.md\"") || ("")) ; \
echo -e "[package]\n\nname = \"$$name\"\nversion = \"0.0\"\n$$readme\nauthors = [\"Your Name <your@email.com>\"]\ntags = []\n\n[[lib]]\n\nname = \"$$name\"\npath = \"$(LIB_ENTRY_FILE)\"\n" > Cargo.toml \
echo -e "[package]\n\nname = \"$$name\"\nversion = \"0.0.0\"\n$$readme\nauthors = [\"Your Name <your@email.com>\"]\ntags = []\n\n[[lib]]\n\nname = \"$$name\"\npath = \"$(LIB_ENTRY_FILE)\"\n" > Cargo.toml \
&& echo "--- Created 'Cargo.toml' for executable" \
&& cat Cargo.toml \
)
@@ -255,7 +255,7 @@ rust-ci-exe: $(EXE_ENTRY_FILE)
)
doc: $(SOURCE_FILES) | src/
$(Q)$(RUSTDOC) $(LIB_ENTRY_FILE) -L "target/$(TARGET)/lib" \
$(Q)$(RUSTDOC) $(LIB_ENTRY_FILE) -L "$(TARGET_LIB_DIR)" \
&& echo "--- Built documentation"
run: exe
@@ -267,7 +267,7 @@ target-dir: $(TARGET_LIB_DIR)
exe: bin/main | $(TARGET_LIB_DIR)
bin/main: $(SOURCE_FILES) | bin/ $(EXE_ENTRY_FILE)
$(Q)$(COMPILER) --target "$(TARGET)" $(COMPILER_FLAGS) $(EXE_ENTRY_FILE) -o bin/main -L "target/$(TARGET)/lib" \
$(Q)$(COMPILER) --target "$(TARGET)" $(COMPILER_FLAGS) $(EXE_ENTRY_FILE) -o bin/main -L "$(TARGET_LIB_DIR)" -L "target" \
&& echo "--- Built executable" \
&& echo "--- Type 'make run' to run executable"
@@ -280,7 +280,7 @@ test-external: bin/test-external
&& ./test-external
bin/test-external: $(SOURCE_FILES) | rlib bin/ src/test.rs
$(Q)$(COMPILER) --target "$(TARGET)" $(COMPILER_FLAGS) --test src/test.rs -o bin/test-external -L "target/$(TARGET)/lib" \
$(Q)$(COMPILER) --target "$(TARGET)" $(COMPILER_FLAGS) --test src/test.rs -o bin/test-external -L "$(TARGET_LIB_DIR)" -L "target" \
&& echo "--- Built external test runner"
test-internal: bin/test-internal
@@ -288,7 +288,7 @@ test-internal: bin/test-internal
&& ./test-internal
bin/test-internal: $(SOURCE_FILES) | rlib src/ bin/
$(Q)$(COMPILER) --target "$(TARGET)" $(COMPILER_FLAGS) --test $(LIB_ENTRY_FILE) -o bin/test-internal -L "target/$(TARGET)/lib" \
$(Q)$(COMPILER) --target "$(TARGET)" $(COMPILER_FLAGS) --test $(LIB_ENTRY_FILE) -o bin/test-internal -L "$(TARGET_LIB_DIR)" -L "target" \
&& echo "--- Built internal test runner"
bench: bench-internal bench-external
@@ -305,13 +305,13 @@ lib: rlib dylib
rlib: $(RLIB)
$(RLIB): $(SOURCE_FILES) | $(LIB_ENTRY_FILE) $(TARGET_LIB_DIR)
$(Q)$(COMPILER) --target "$(TARGET)" $(COMPILER_FLAGS) --crate-type=rlib $(LIB_ENTRY_FILE) -L "target/$(TARGET)/lib" --out-dir "target/$(TARGET)/lib/" \
$(Q)$(COMPILER) --target "$(TARGET)" $(COMPILER_FLAGS) --crate-type=rlib $(LIB_ENTRY_FILE) -L "$(TARGET_LIB_DIR)" --out-dir "target" \
&& echo "--- Built rlib"
dylib: $(DYLIB)
$(DYLIB): $(SOURCE_FILES) | $(LIB_ENTRY_FILE) $(TARGET_LIB_DIR)
$(Q)$(COMPILER) --target "$(TARGET)" $(COMPILER_FLAGS) --crate-type=dylib $(LIB_ENTRY_FILE) -L "target/$(TARGET)/lib" --out-dir "target/$(TARGET)/lib/" \
$(Q)$(COMPILER) --target "$(TARGET)" $(COMPILER_FLAGS) --crate-type=dylib $(LIB_ENTRY_FILE) -L "$(TARGET_LIB_DIR)" --out-dir "target/" \
&& echo "--- Built dylib"
bin/:
@@ -350,7 +350,7 @@ git-ignore:
examples: $(EXAMPLE_FILES)
$(EXAMPLE_FILES): lib examples-dir
$(Q)$(COMPILER) --target "$(TARGET)" $(COMPILER_FLAGS) $@ -L "target/$(TARGET)/lib" --out-dir examples/ \
$(Q)$(COMPILER) --target "$(TARGET)" $(COMPILER_FLAGS) $@ -L "$(TARGET_LIB_DIR)" -L "target" --out-dir examples/ \
&& echo "--- Built '$@' (make $@)"
$(EXE_ENTRY_FILE): | src/
@@ -416,7 +416,7 @@ while true; do
echo -n "> "
read line
TMP="`mktemp r.XXXXXX`"
$(COMPILER) - -o $$TMP -L "target/$(TARGET)/lib/" <<EOF
$(COMPILER) - -o $$TMP -L "$(TARGET_LIB_DIR)" <<EOF
#![feature(globs, macro_rules, phase, struct_variant)]
extern crate arena;
extern crate collections;
@@ -585,7 +585,7 @@ function contains() {
i=0
function build_deps {
local current=$$(pwd)
for symlib in $$(find target/*/lib -type l) ; do
for symlib in $$(find $(TARGET_LIB_DIR) -type l) ; do
cd $$current
echo $$symlib
local original_file=$$(readlink $$symlib)
@@ -606,6 +606,7 @@ function build_deps {
# Remember git directory to not build it twice
git_dir[i]=$$current_git_dir
let i+=1
# Visit the symlinks and build the dependencies
build_deps
@@ -630,11 +631,13 @@ function build_deps {
&& $$MAKE clean \
&& $$MAKE \
)
let i+=1
done
cd $$current
}
# Mark main project as visited to avoid infinite loop.
git_dir[i]=$$(pwd)
let i+=1
if [ "$$1" == "deps" ]; then
build_deps
fi
@@ -675,7 +678,7 @@ loc:
# prints the commit hash with remote branches containing that commit.
symlink-info:
$(Q) current=$$(pwd) ; \
for symlib in $$(find target/*/lib -type l) ; do \
for symlib in $$(find $(TARGET_LIB_DIR) -type l) ; do \
cd $$current ; \
echo $$symlib ; \
original_file=$$(readlink $$symlib) ; \
+67 -67
View File
@@ -20,83 +20,83 @@ pub static TTF_HINTING_NONE : c_int = 3;
pub type TTF_Font = c_void;
extern "C" {
pub fn TTF_Linked_Version() -> *SDL_version;
pub fn TTF_Linked_Version() -> *const SDL_version;
pub fn TTF_ByteSwappedUNICODE(swapped: c_int);
pub fn TTF_Init() -> c_int;
pub fn TTF_OpenFont(file: *c_char, ptsize: c_int) -> *TTF_Font;
pub fn TTF_OpenFontIndex(file: *c_char, ptsize: c_int, index: c_long) ->
*TTF_Font;
pub fn TTF_OpenFontRW(src: *SDL_RWops, freesrc: c_int, ptsize: c_int)
-> *TTF_Font;
pub fn TTF_OpenFontIndexRW(src: *SDL_RWops, freesrc: c_int,
ptsize: c_int, index: c_long) -> *TTF_Font;
pub fn TTF_GetFontStyle(font: *TTF_Font) -> c_int;
pub fn TTF_SetFontStyle(font: *TTF_Font, style: c_int);
pub fn TTF_GetFontOutline(font: *TTF_Font) -> c_int;
pub fn TTF_SetFontOutline(font: *TTF_Font, outline: c_int);
pub fn TTF_GetFontHinting(font: *TTF_Font) -> c_int;
pub fn TTF_SetFontHinting(font: *TTF_Font, hinting: c_int);
pub fn TTF_FontHeight(font: *TTF_Font) -> c_int;
pub fn TTF_FontAscent(font: *TTF_Font) -> c_int;
pub fn TTF_FontDescent(font: *TTF_Font) -> c_int;
pub fn TTF_FontLineSkip(font: *TTF_Font) -> c_int;
pub fn TTF_GetFontKerning(font: *TTF_Font) -> c_int;
pub fn TTF_SetFontKerning(font: *TTF_Font, allowed: c_int);
pub fn TTF_FontFaces(font: *TTF_Font) -> c_long;
pub fn TTF_FontFaceIsFixedWidth(font: *TTF_Font) -> c_int;
pub fn TTF_FontFaceFamilyName(font: *TTF_Font) -> *c_char;
pub fn TTF_FontFaceStyleName(font: *TTF_Font) -> *c_char;
pub fn TTF_GlyphIsProvided(font: *TTF_Font, ch: uint16_t) -> c_int;
pub fn TTF_GlyphMetrics(font: *TTF_Font, ch: uint16_t, minx: *c_int,
maxx: *c_int, miny: *c_int,
maxy: *c_int, advance: *c_int) -> c_int;
pub fn TTF_SizeText(font: *TTF_Font, text: *c_char, w: *c_int,
h: *c_int) -> c_int;
pub fn TTF_SizeUTF8(font: *TTF_Font, text: *c_char, w: *c_int,
h: *c_int) -> c_int;
pub fn TTF_SizeUNICODE(font: *TTF_Font, text: *uint16_t, w: *c_int,
h: *c_int) -> c_int;
pub fn TTF_RenderText_Solid(font: *TTF_Font, text: *c_char,
fg: SDL_Color) -> *SDL_Surface;
pub fn TTF_RenderUTF8_Solid(font: *TTF_Font, text: *c_char,
fg: SDL_Color) -> *SDL_Surface;
pub fn TTF_RenderUNICODE_Solid(font: *TTF_Font, text: *uint16_t,
fg: SDL_Color) -> *SDL_Surface;
pub fn TTF_RenderGlyph_Solid(font: *TTF_Font, ch: uint16_t,
fg: SDL_Color) -> *SDL_Surface;
pub fn TTF_RenderText_Shaded(font: *TTF_Font, text: *c_char,
pub fn TTF_OpenFont(file: *const c_char, ptsize: c_int) -> *const TTF_Font;
pub fn TTF_OpenFontIndex(file: *const c_char, ptsize: c_int, index: c_long) ->
*const TTF_Font;
pub fn TTF_OpenFontRW(src: *const SDL_RWops, freesrc: c_int, ptsize: c_int)
-> *const TTF_Font;
pub fn TTF_OpenFontIndexRW(src: *const SDL_RWops, freesrc: c_int,
ptsize: c_int, index: c_long) -> *const TTF_Font;
pub fn TTF_GetFontStyle(font: *const TTF_Font) -> c_int;
pub fn TTF_SetFontStyle(font: *const TTF_Font, style: c_int);
pub fn TTF_GetFontOutline(font: *const TTF_Font) -> c_int;
pub fn TTF_SetFontOutline(font: *const TTF_Font, outline: c_int);
pub fn TTF_GetFontHinting(font: *const TTF_Font) -> c_int;
pub fn TTF_SetFontHinting(font: *const TTF_Font, hinting: c_int);
pub fn TTF_FontHeight(font: *const TTF_Font) -> c_int;
pub fn TTF_FontAscent(font: *const TTF_Font) -> c_int;
pub fn TTF_FontDescent(font: *const TTF_Font) -> c_int;
pub fn TTF_FontLineSkip(font: *const TTF_Font) -> c_int;
pub fn TTF_GetFontKerning(font: *const TTF_Font) -> c_int;
pub fn TTF_SetFontKerning(font: *const TTF_Font, allowed: c_int);
pub fn TTF_FontFaces(font: *const TTF_Font) -> c_long;
pub fn TTF_FontFaceIsFixedWidth(font: *const TTF_Font) -> c_int;
pub fn TTF_FontFaceFamilyName(font: *const TTF_Font) -> *const c_char;
pub fn TTF_FontFaceStyleName(font: *const TTF_Font) -> *const c_char;
pub fn TTF_GlyphIsProvided(font: *const TTF_Font, ch: uint16_t) -> c_int;
pub fn TTF_GlyphMetrics(font: *const TTF_Font, ch: uint16_t, minx: *const c_int,
maxx: *const c_int, miny: *const c_int,
maxy: *const c_int, advance: *const c_int) -> c_int;
pub fn TTF_SizeText(font: *const TTF_Font, text: *const c_char, w: *const c_int,
h: *const c_int) -> c_int;
pub fn TTF_SizeUTF8(font: *const TTF_Font, text: *const c_char, w: *const c_int,
h: *const c_int) -> c_int;
pub fn TTF_SizeUNICODE(font: *const TTF_Font, text: *const uint16_t, w: *const c_int,
h: *const c_int) -> c_int;
pub fn TTF_RenderText_Solid(font: *const TTF_Font, text: *const c_char,
fg: SDL_Color) -> *const SDL_Surface;
pub fn TTF_RenderUTF8_Solid(font: *const TTF_Font, text: *const c_char,
fg: SDL_Color) -> *const SDL_Surface;
pub fn TTF_RenderUNICODE_Solid(font: *const TTF_Font, text: *const uint16_t,
fg: SDL_Color) -> *const SDL_Surface;
pub fn TTF_RenderGlyph_Solid(font: *const TTF_Font, ch: uint16_t,
fg: SDL_Color) -> *const SDL_Surface;
pub fn TTF_RenderText_Shaded(font: *const TTF_Font, text: *const c_char,
fg: SDL_Color, bg: SDL_Color) ->
*SDL_Surface;
pub fn TTF_RenderUTF8_Shaded(font: *TTF_Font, text: *c_char,
*const SDL_Surface;
pub fn TTF_RenderUTF8_Shaded(font: *const TTF_Font, text: *const c_char,
fg: SDL_Color, bg: SDL_Color) ->
*SDL_Surface;
pub fn TTF_RenderUNICODE_Shaded(font: *TTF_Font, text: *uint16_t,
*const SDL_Surface;
pub fn TTF_RenderUNICODE_Shaded(font: *const TTF_Font, text: *const uint16_t,
fg: SDL_Color, bg: SDL_Color) ->
*SDL_Surface;
pub fn TTF_RenderGlyph_Shaded(font: *TTF_Font, ch: uint16_t,
*const SDL_Surface;
pub fn TTF_RenderGlyph_Shaded(font: *const TTF_Font, ch: uint16_t,
fg: SDL_Color, bg: SDL_Color) ->
*SDL_Surface;
pub fn TTF_RenderText_Blended(font: *TTF_Font, text: *c_char,
fg: SDL_Color) -> *SDL_Surface;
pub fn TTF_RenderUTF8_Blended(font: *TTF_Font, text: *c_char,
fg: SDL_Color) -> *SDL_Surface;
pub fn TTF_RenderUNICODE_Blended(font: *TTF_Font, text: *uint16_t,
fg: SDL_Color) -> *SDL_Surface;
pub fn TTF_RenderText_Blended_Wrapped(font: *TTF_Font, text: *c_char,
*const SDL_Surface;
pub fn TTF_RenderText_Blended(font: *const TTF_Font, text: *const c_char,
fg: SDL_Color) -> *const SDL_Surface;
pub fn TTF_RenderUTF8_Blended(font: *const TTF_Font, text: *const c_char,
fg: SDL_Color) -> *const SDL_Surface;
pub fn TTF_RenderUNICODE_Blended(font: *const TTF_Font, text: *const uint16_t,
fg: SDL_Color) -> *const SDL_Surface;
pub fn TTF_RenderText_Blended_Wrapped(font: *const TTF_Font, text: *const c_char,
fg: SDL_Color, wrapLength: uint32_t)
-> *SDL_Surface;
pub fn TTF_RenderUTF8_Blended_Wrapped(font: *TTF_Font, text: *c_char,
-> *const SDL_Surface;
pub fn TTF_RenderUTF8_Blended_Wrapped(font: *const TTF_Font, text: *const c_char,
fg: SDL_Color, wrapLength: uint32_t)
-> *SDL_Surface;
pub fn TTF_RenderUNICODE_Blended_Wrapped(font: *TTF_Font,
text: *uint16_t, fg: SDL_Color,
-> *const SDL_Surface;
pub fn TTF_RenderUNICODE_Blended_Wrapped(font: *const TTF_Font,
text: *const uint16_t, fg: SDL_Color,
wrapLength: uint32_t) ->
*SDL_Surface;
pub fn TTF_RenderGlyph_Blended(font: *TTF_Font, ch: uint16_t,
fg: SDL_Color) -> *SDL_Surface;
pub fn TTF_CloseFont(font: *TTF_Font);
*const SDL_Surface;
pub fn TTF_RenderGlyph_Blended(font: *const TTF_Font, ch: uint16_t,
fg: SDL_Color) -> *const SDL_Surface;
pub fn TTF_CloseFont(font: *const TTF_Font);
pub fn TTF_Quit();
pub fn TTF_WasInit() -> c_int;
pub fn TTF_GetFontKerningSize(font: *TTF_Font, prev_index: c_int,
pub fn TTF_GetFontKerningSize(font: *const TTF_Font, prev_index: c_int,
index: c_int) -> c_int;
}
+2 -2
View File
@@ -117,7 +117,7 @@ pub fn quit() {
#[allow(raw_pointer_deriving)]
#[deriving(PartialEq)]
pub struct Font {
raw: *ffi::TTF_Font,
raw: *const ffi::TTF_Font,
owned: bool
}
@@ -135,7 +135,7 @@ impl Drop for Font {
}
impl Font {
fn from_ll(raw: *ffi::TTF_Font, owned: bool) -> Font {
fn from_ll(raw: *const ffi::TTF_Font, owned: bool) -> Font {
Font { raw: raw, owned: owned }
}