mirror of
https://github.com/encounter/rust-sdl2.git
synced 2026-07-10 21:18:41 -07:00
Merge pull request #153 from bvssvni/master
Upgraded to latest Rust-Empty
This commit is contained in:
+27
-61
@@ -1,4 +1,4 @@
|
||||
# Rust-Empty: An Makefile to get started with Rust
|
||||
# Rust-Empty: A Makefile to get started with Rust
|
||||
# https://github.com/bvssvni/rust-empty
|
||||
#
|
||||
# The MIT License (MIT)
|
||||
@@ -45,26 +45,6 @@ COMPILER = rustc
|
||||
# For debugging:
|
||||
# COMPILER_FLAGS = -g
|
||||
|
||||
UNAME=$(shell uname)
|
||||
|
||||
ifeq ($(UNAME),Darwin)
|
||||
# If the user wasn't explicit, see if SDL2 library exists
|
||||
ifeq ("$(strip $(SDL_MODE))","")
|
||||
SDL_CHECK=$(shell pkg-config --exists sdl2 && echo $$?)
|
||||
ifeq ($(SDL_CHECK),0)
|
||||
SDL_MODE = dylib
|
||||
else
|
||||
SDL_MODE = framework
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(SDL_MODE),framework)
|
||||
COMPILER_FLAGS+=--cfg mac_framework
|
||||
else
|
||||
COMPILER_FLAGS+=--cfg mac_dylib
|
||||
endif
|
||||
endif
|
||||
|
||||
RUSTDOC = rustdoc
|
||||
|
||||
# Extracts target from rustc.
|
||||
@@ -83,6 +63,9 @@ 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/$(DYLIB_FILE)
|
||||
|
||||
EXE_FILE = $(shell (rustc --crate-type=bin --print-file-name "$(EXE_ENTRY_FILE)" 2> /dev/null) || (echo "main"))
|
||||
EXE = bin/$(EXE_FILE)
|
||||
|
||||
# Use 'VERBOSE=1' to echo all commands, for example 'make help VERBOSE=1'.
|
||||
ifdef VERBOSE
|
||||
Q :=
|
||||
@@ -93,7 +76,7 @@ endif
|
||||
all: $(DEFAULT)
|
||||
|
||||
help:
|
||||
$(Q)echo "--- rust-empty (0.6 003)"
|
||||
$(Q)echo "--- rust-empty (0.7 000)"
|
||||
$(Q)echo "make run - Runs executable"
|
||||
$(Q)echo "make exe - Builds main executable"
|
||||
$(Q)echo "make lib - Both static and dynamic library"
|
||||
@@ -108,8 +91,6 @@ help:
|
||||
$(Q)echo "make doc - Builds documentation for library"
|
||||
$(Q)echo "make git-ignore - Setup files to be ignored by Git"
|
||||
$(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 - Setup executable package"
|
||||
$(Q)echo "make cargo-lib - Setup library package"
|
||||
$(Q)echo "make rust-ci-lib - Setup Travis CI Rust library"
|
||||
@@ -132,8 +113,6 @@ help:
|
||||
bench-external \
|
||||
cargo-lib \
|
||||
cargo-exe \
|
||||
cargo-lite-lib \
|
||||
cargo-lite-exe \
|
||||
clean \
|
||||
clear-git \
|
||||
clear-project \
|
||||
@@ -178,30 +157,6 @@ nightly-uninstall:
|
||||
fi \
|
||||
)
|
||||
|
||||
cargo-lite-exe: $(EXE_ENTRY_FILE)
|
||||
$(Q)( \
|
||||
test -e cargo-lite.conf \
|
||||
&& echo "--- The file 'cargo-lite.conf' already exists" \
|
||||
) \
|
||||
|| \
|
||||
( \
|
||||
echo -e "deps = [\n]\n\n[build]\ncrate_root = \"$(EXE_ENTRY_FILE)\"\nrustc_args = []\n" > cargo-lite.conf \
|
||||
&& echo "--- Created 'cargo-lite.conf' for executable" \
|
||||
&& cat cargo-lite.conf \
|
||||
)
|
||||
|
||||
cargo-lite-lib: $(LIB_ENTRY_FILE)
|
||||
$(Q)( \
|
||||
test -e cargo-lite.conf \
|
||||
&& echo "--- The file 'cargo-lite.conf' already exists" \
|
||||
) \
|
||||
|| \
|
||||
( \
|
||||
echo -e "deps = [\n]\n\n[build]\ncrate_root = \"$(LIB_ENTRY_FILE)\"\ncrate_type = \"library\"\nrustc_args = []\n" > cargo-lite.conf \
|
||||
&& echo "--- Created 'cargo-lite.conf' for library" \
|
||||
&& cat cargo-lite.conf \
|
||||
)
|
||||
|
||||
cargo-exe: $(EXE_ENTRY_FILE)
|
||||
$(Q)( \
|
||||
test -e Cargo.toml \
|
||||
@@ -226,7 +181,7 @@ cargo-lib: $(LIB_ENTRY_FILE)
|
||||
name=$${PWD##/*/} ; \
|
||||
readme=$$((test -e README.md && echo -e "readme = \"README.md\"") || ("")) ; \
|
||||
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" \
|
||||
&& echo "--- Created 'Cargo.toml' for library" \
|
||||
&& cat Cargo.toml \
|
||||
)
|
||||
|
||||
@@ -260,14 +215,14 @@ doc: $(SOURCE_FILES) | src/
|
||||
|
||||
run: exe
|
||||
$(Q)cd bin/ \
|
||||
&& ./main
|
||||
&& ./$(EXE_FILE)
|
||||
|
||||
target-dir: $(TARGET_LIB_DIR)
|
||||
|
||||
exe: bin/main | $(TARGET_LIB_DIR)
|
||||
exe: $(EXE) | $(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_LIB_DIR)" -L "target" \
|
||||
$(EXE): $(SOURCE_FILES) | bin/ $(EXE_ENTRY_FILE)
|
||||
$(Q)$(COMPILER) --target "$(TARGET)" $(COMPILER_FLAGS) $(EXE_ENTRY_FILE) -o $(EXE) -L "$(TARGET_LIB_DIR)" -L "target" \
|
||||
&& echo "--- Built executable" \
|
||||
&& echo "--- Type 'make run' to run executable"
|
||||
|
||||
@@ -342,7 +297,7 @@ git-ignore:
|
||||
) \
|
||||
|| \
|
||||
( \
|
||||
echo -e ".DS_Store\n*~\n*#\n*.o\n*.so\n*.swp\n*.dylib\n*.dSYM\n*.dll\n*.rlib\n*.dummy\n*.exe\n*-test\n/bin/main\n/bin/test-internal\n/bin/test-external\n/doc/\n/target/\n/build/\n/.rust/\nrusti.sh\nwatch.sh\n/examples/**\n!/examples/*.rs\n!/examples/assets/" > .gitignore \
|
||||
echo -e ".DS_Store\n*~\n*#\n*.o\n*.so\n*.swp\n*.old\n*.bak\n*.kate-swp\n*.dylib\n*.dSYM\n*.dll\n*.rlib\n*.dummy\n*.exe\n*-test\n/$(EXE)\n/bin/test-internal\n/bin/test-external\n/doc/\n/target/\n/build/\n/.rust/\nrusti.sh\nwatch.sh\n/examples/**\n!/examples/*.rs\n!/examples/assets/" > .gitignore \
|
||||
&& echo "--- Created '.gitignore' for git" \
|
||||
&& cat .gitignore \
|
||||
)
|
||||
@@ -371,21 +326,21 @@ $(LIB_ENTRY_FILE): | src/
|
||||
$(Q)test -e $(LIB_ENTRY_FILE) \
|
||||
|| \
|
||||
( \
|
||||
echo -e "#![crate_id = \"\"]\n#![deny(missing_doc)]\n\n//! Documentation goes here.\n" > $(LIB_ENTRY_FILE) \
|
||||
name=$${PWD##/*/} ; \
|
||||
echo -e "#![crate_name = \"$$name\"]\n#![deny(missing_doc)]\n\n//! Documentation goes here.\n" > $(LIB_ENTRY_FILE) \
|
||||
)
|
||||
|
||||
clean:
|
||||
$(Q)rm -f "$(RLIB)"
|
||||
$(Q)rm -f "$(DYLIB)"
|
||||
$(Q)rm -rf "doc/"
|
||||
$(Q)rm -f "bin/main"
|
||||
$(Q)rm -f "$(EXE)"
|
||||
$(Q)rm -f "bin/test-internal"
|
||||
$(Q)rm -f "bin/test-external"
|
||||
$(Q)echo "--- Deleted binaries and documentation"
|
||||
|
||||
clear-project:
|
||||
$(Q)rm -f ".symlink-info"
|
||||
$(Q)rm -f "cargo-lite.conf"
|
||||
$(Q)rm -f "Cargo.toml"
|
||||
$(Q)rm -f ".travis.yml"
|
||||
$(Q)rm -f "rusti.sh"
|
||||
@@ -610,6 +565,8 @@ function build_deps {
|
||||
|
||||
# Visit the symlinks and build the dependencies
|
||||
build_deps
|
||||
|
||||
echo "--- Building $$current_git_dir" \
|
||||
|
||||
# First check for a 'build.sh' script with default settings.
|
||||
# Check for additional 'rust-empty.mk' file. \
|
||||
@@ -627,10 +584,19 @@ function build_deps {
|
||||
) \
|
||||
|| \
|
||||
( \
|
||||
echo "--- Building $$current_git_dir" \
|
||||
test -e Makefile \
|
||||
&& $$MAKE clean \
|
||||
&& $$MAKE \
|
||||
)
|
||||
) \
|
||||
|| \
|
||||
( \
|
||||
test -e Cargo.toml \
|
||||
&& cargo build \
|
||||
) \
|
||||
|| \
|
||||
( \
|
||||
echo "--- ERROR: Missing Makefile in $$current_git_dir" \
|
||||
)
|
||||
done
|
||||
cd $$current
|
||||
}
|
||||
|
||||
+2
-2
@@ -787,7 +787,7 @@ impl Event {
|
||||
Ok(window) => window,
|
||||
};
|
||||
|
||||
let text = str::from_utf8_lossy(event.text.iter().take_while(|&b| (*b) != 0i8).map(|&b| b as u8).collect::<Vec<u8>>().as_slice()).into_string();
|
||||
let text = String::from_utf8_lossy(event.text.iter().take_while(|&b| (*b) != 0i8).map(|&b| b as u8).collect::<Vec<u8>>().as_slice()).into_string();
|
||||
TextEditingEvent(event.timestamp as uint, window, text,
|
||||
event.start as int, event.length as int)
|
||||
}
|
||||
@@ -800,7 +800,7 @@ impl Event {
|
||||
Ok(window) => window,
|
||||
};
|
||||
|
||||
let text = str::from_utf8_lossy(event.text.iter().take_while(|&b| (*b) != 0i8).map(|&b| b as u8).collect::<Vec<u8>>().as_slice()).into_string();
|
||||
let text = String::from_utf8_lossy(event.text.iter().take_while(|&b| (*b) != 0i8).map(|&b| b as u8).collect::<Vec<u8>>().as_slice()).into_string();
|
||||
TextInputEvent(event.timestamp as uint, window, text)
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ pub fn get_keyboard_state() -> HashMap<ScanCode, bool> {
|
||||
let mut current = 0;
|
||||
while current < raw.len() {
|
||||
state.insert(FromPrimitive::from_int(current as int).unwrap(),
|
||||
*raw.get(current) == 1);
|
||||
raw[current] == 1);
|
||||
current += 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -70,6 +70,7 @@ impl<'a> Timer<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
#[unsafe_destructor]
|
||||
impl<'a> Drop for Timer<'a> {
|
||||
fn drop(&mut self) {
|
||||
if self.remove_on_drop {
|
||||
|
||||
Reference in New Issue
Block a user