-
Notifications
You must be signed in to change notification settings - Fork 489
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Started adding the bare basics in documentation
- Loading branch information
1 parent
aa32769
commit c943fb2
Showing
4 changed files
with
110 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
VPATH=%VPATH% | ||
|
||
RUSTC ?= rustc | ||
RUSTFLAGS ?= --cfg image --cfg mixer | ||
SDL_PREFIX ?= /usr/local/lib | ||
AR ?= ar | ||
CHMOD ?= chmod | ||
CP ?= cp | ||
LD ?= ld | ||
MV ?= mv | ||
RM ?= rm | ||
|
||
RUST_SRC = $(shell find $(VPATH)/src/. -type f -name '*.rs') | ||
|
||
.PHONY: all | ||
all: libsdl.dummy | ||
|
||
UNAME=$(shell uname) | ||
|
||
ifeq ($(UNAME),Darwin) | ||
SDLXMAIN=libSDLXmain.a | ||
|
||
ifeq (%SDL_MODE%,framework) | ||
RUSTFLAGS+=--cfg mac_framework | ||
else | ||
RUSTFLAGS+=--cfg mac_dylib | ||
endif | ||
|
||
else | ||
SDLXMAIN= | ||
endif | ||
|
||
libsdl.dummy: src/sdl.rc $(RUST_SRC) $(SDLXMAIN) | ||
$(RUSTC) $(RUSTFLAGS) $< -o $@ | ||
touch $@ | ||
|
||
demos: demo/demo.rc libsdl.dummy | ||
$(RUSTC) -L . $< -o $@ | ||
|
||
# Darwin-specific hack to change the name of `main` to `SDLX_main` | ||
$(SDLXMAIN): $(SDL_PREFIX)/libSDLmain.a | ||
$(CP) $< $@ | ||
$(AR) -x $@ SDLMain.o || $(RM) -f $@ | ||
$(LD) -r SDLMain.o -o SDLXMain.o -alias _main _SDLX_main -unexported_symbol main || $(RM) -f $@ | ||
$(MV) SDLXMain.o SDLMain.o || $(RM) -f $@ | ||
$(CHMOD) u+w $@ || $(RM) -f $@ | ||
$(AR) -r $@ SDLMain.o || $(RM) -f $@ | ||
|
||
demo: demos | ||
./demos | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -f sdl-test *.so *.dylib *.dll *.dummy demos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,37 @@ | ||
rust-sdl2 | ||
========= | ||
# Rust-SDL2 | ||
Bindings for SDL2 in Rust | ||
# Overview | ||
|
||
SDL2 bindings for Rust | ||
Rust-SDL2 is a library for talking to the new SDL2.0 libraries from Rust. Low-level C components are wrapped in Rust code to make them more idiomatic and abstract away inappropriate manual memory management. | ||
|
||
In addition, it provides optional APIs to a number of common SDL extension libraries. | ||
|
||
Rust-SDL2 uses the MIT license. | ||
|
||
If you want a library compatible with earlier versions of SDL, please see https://github.com/brson/rust-sdl | ||
|
||
# Requirements | ||
|
||
* *Rust* - we currently compile against the *Master* branch. The releases on http://www.rust-lang.org tend to not work. | ||
* *SDL2.0 development libraries* - install through your favourite package management tool, or via http://www.libsdl.org/ | ||
|
||
# Installation | ||
Clone this repo, run `./configure`, and then `make`. To see an example of the code in use, *make demos*. | ||
|
||
# Demo | ||
|
||
To compile the demo: | ||
|
||
> rustc -L$PWD/src demo/demo.rc | ||
|
||
Then run: | ||
|
||
> ./demo/demo | ||
Or you could instead just use | ||
|
||
> make demo | ||
# When things go wrong | ||
Rust, and Rust-SDL2, are both still heavily in development, and you may run into teething issues when using this. Before panicking, check that you're using the latest Master branch of Rust, check that you've updated Rust-SDL2 to the latest version, and run `make clean` and `./configure`. If that fails, please let us know on the issue tracker. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
|
||
SRCDIR="$(cd $(dirname $0) && pwd)" | ||
|
||
if test `uname` = 'Darwin'; then | ||
if test "x${SDL_MODE}" == "x"; then | ||
if test -e /usr/local/lib/libSDL.dylib -o -e /usr/lib/libSDL.dylib; then | ||
SDL_MODE=dylib | ||
else | ||
SDL_MODE=framework | ||
fi | ||
fi | ||
PLATFORM_COMMANDS="-e s#%SDL_MODE%#${SDL_MODE}#" | ||
else | ||
PLATFORM_COMMANDS="" | ||
fi | ||
|
||
sed -e "s#%VPATH%#${SRCDIR}#" $PLATFORM_COMMANDS ${SRCDIR}/Makefile.in > Makefile | ||
|