Skip to content

Commit c943fb2

Browse files
committed
Started adding the bare basics in documentation
1 parent aa32769 commit c943fb2

File tree

4 files changed

+110
-4
lines changed

4 files changed

+110
-4
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2013 Tony Aldridge
3+
Copyright (c) 2013 Mozilla Foundation
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of
66
this software and associated documentation files (the "Software"), to deal in

Makefile.in

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
VPATH=%VPATH%
2+
3+
RUSTC ?= rustc
4+
RUSTFLAGS ?= --cfg image --cfg mixer
5+
SDL_PREFIX ?= /usr/local/lib
6+
AR ?= ar
7+
CHMOD ?= chmod
8+
CP ?= cp
9+
LD ?= ld
10+
MV ?= mv
11+
RM ?= rm
12+
13+
RUST_SRC = $(shell find $(VPATH)/src/. -type f -name '*.rs')
14+
15+
.PHONY: all
16+
all: libsdl.dummy
17+
18+
UNAME=$(shell uname)
19+
20+
ifeq ($(UNAME),Darwin)
21+
SDLXMAIN=libSDLXmain.a
22+
23+
ifeq (%SDL_MODE%,framework)
24+
RUSTFLAGS+=--cfg mac_framework
25+
else
26+
RUSTFLAGS+=--cfg mac_dylib
27+
endif
28+
29+
else
30+
SDLXMAIN=
31+
endif
32+
33+
libsdl.dummy: src/sdl.rc $(RUST_SRC) $(SDLXMAIN)
34+
$(RUSTC) $(RUSTFLAGS) $< -o $@
35+
touch $@
36+
37+
demos: demo/demo.rc libsdl.dummy
38+
$(RUSTC) -L . $< -o $@
39+
40+
# Darwin-specific hack to change the name of `main` to `SDLX_main`
41+
$(SDLXMAIN): $(SDL_PREFIX)/libSDLmain.a
42+
$(CP) $< $@
43+
$(AR) -x $@ SDLMain.o || $(RM) -f $@
44+
$(LD) -r SDLMain.o -o SDLXMain.o -alias _main _SDLX_main -unexported_symbol main || $(RM) -f $@
45+
$(MV) SDLXMain.o SDLMain.o || $(RM) -f $@
46+
$(CHMOD) u+w $@ || $(RM) -f $@
47+
$(AR) -r $@ SDLMain.o || $(RM) -f $@
48+
49+
demo: demos
50+
./demos
51+
52+
.PHONY: clean
53+
clean:
54+
rm -f sdl-test *.so *.dylib *.dll *.dummy demos

README.md

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,37 @@
1-
rust-sdl2
2-
=========
1+
# Rust-SDL2
2+
Bindings for SDL2 in Rust
3+
# Overview
34

4-
SDL2 bindings for Rust
5+
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.
6+
7+
In addition, it provides optional APIs to a number of common SDL extension libraries.
8+
9+
Rust-SDL2 uses the MIT license.
10+
11+
If you want a library compatible with earlier versions of SDL, please see https://github.com/brson/rust-sdl
12+
13+
# Requirements
14+
15+
* *Rust* - we currently compile against the *Master* branch. The releases on http://www.rust-lang.org tend to not work.
16+
* *SDL2.0 development libraries* - install through your favourite package management tool, or via http://www.libsdl.org/
17+
18+
# Installation
19+
Clone this repo, run `./configure`, and then `make`. To see an example of the code in use, *make demos*.
20+
21+
# Demo
22+
23+
To compile the demo:
24+
25+
> rustc -L$PWD/src demo/demo.rc
26+
27+
28+
Then run:
29+
30+
> ./demo/demo
31+
32+
Or you could instead just use
33+
34+
> make demo
35+
36+
# When things go wrong
37+
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.

configure

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
SRCDIR="$(cd $(dirname $0) && pwd)"
4+
5+
if test `uname` = 'Darwin'; then
6+
if test "x${SDL_MODE}" == "x"; then
7+
if test -e /usr/local/lib/libSDL.dylib -o -e /usr/lib/libSDL.dylib; then
8+
SDL_MODE=dylib
9+
else
10+
SDL_MODE=framework
11+
fi
12+
fi
13+
PLATFORM_COMMANDS="-e s#%SDL_MODE%#${SDL_MODE}#"
14+
else
15+
PLATFORM_COMMANDS=""
16+
fi
17+
18+
sed -e "s#%VPATH%#${SRCDIR}#" $PLATFORM_COMMANDS ${SRCDIR}/Makefile.in > Makefile
19+

0 commit comments

Comments
 (0)