Started adding the bare basics in documentation

This commit is contained in:
Tony Aldridge
2013-08-17 10:43:55 +01:00
parent aa327699c1
commit c943fb2a02
4 changed files with 110 additions and 4 deletions

View File

@@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2013 Tony Aldridge
Copyright (c) 2013 Mozilla Foundation
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in

54
Makefile.in Normal file
View File

@@ -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

View File

@@ -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.

19
configure vendored Executable file
View File

@@ -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