Skip to content

Commit

Permalink
- Fix cgo directives (includes) for Win32 platform builds
Browse files Browse the repository at this point in the history
- Add SDL_GetPlatform() test
  • Loading branch information
marcusva committed Apr 27, 2014
1 parent 08b3e48 commit 7416622
Show file tree
Hide file tree
Showing 33 changed files with 50 additions and 48 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.swp
*~
go-sdl2
4 changes: 0 additions & 4 deletions sdl/misc.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#include "misc.h"

#if (SDL_MAJOR_VERSION >= 2 && SDL_MINOR_VERSION >= 0 && SDL_PATCHLEVEL >= 1)
#include <SDL2/SDL_filesystem.h>
#endif

int _SDL_GetSystemRAM()
{
#if (SDL_MAJOR_VERSION >= 2 && SDL_MINOR_VERSION >= 0 && SDL_PATCHLEVEL >= 1)
Expand Down
4 changes: 2 additions & 2 deletions sdl/sdl.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package sdl

// #cgo !linux,freebsd LDFLAGS: -lSDL2
// #cgo !windows pkg-config: sdl2
// #cgo windows LDFLAGS: -lSDL2
// #cgo linux freebsd pkg-config: sdl2
// #include <SDL2/SDL.h>
import "C"

Expand Down
4 changes: 1 addition & 3 deletions sdl/sdl_audio.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package sdl

/*
#include <SDL2/SDL_audio.h>
*/
// #include <SDL2/SDL.h>
import "C"
import "unsafe"

Expand Down
2 changes: 1 addition & 1 deletion sdl/sdl_blendmode.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package sdl

// #include <SDL2/SDL_blendmode.h>
// #include <SDL2/SDL.h>
import "C"

type BlendMode C.SDL_BlendMode
Expand Down
3 changes: 1 addition & 2 deletions sdl/sdl_clipboard.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package sdl

// #include <SDL2/SDL_stdinc.h>
// #include <SDL2/SDL_clipboard.h>
// #include <SDL2/SDL.h>
import "C"
import "unsafe"

Expand Down
2 changes: 1 addition & 1 deletion sdl/sdl_cpuinfo.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package sdl

// #include <SDL2/SDL_cpuinfo.h>
// #include <SDL2/SDL.h>
// #include "misc.h"
import "C"

Expand Down
2 changes: 1 addition & 1 deletion sdl/sdl_error.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package sdl

// #include <SDL2/SDL_error.h>
// #include <SDL2/SDL.h>
import "C"
import "errors"

Expand Down
2 changes: 1 addition & 1 deletion sdl/sdl_events.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package sdl

// #include <SDL2/SDL_events.h>
// #include <SDL2/SDL.h>
import "C"
import "unsafe"
import "reflect"
Expand Down
2 changes: 1 addition & 1 deletion sdl/sdl_gesture.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package sdl

// #include <SDL2/SDL_gesture.h>
// #include <SDL2/SDL.h>
import "C"
import "unsafe"

Expand Down
2 changes: 1 addition & 1 deletion sdl/sdl_haptic.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package sdl

// #include <SDL2/SDL_haptic.h>
// #include <SDL2/SDL.h>
import "C"
import "unsafe"

Expand Down
2 changes: 1 addition & 1 deletion sdl/sdl_hints.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package sdl

// #include <SDL2/SDL_hints.h>
// #include <SDL2/SDL.h>
import "C"
import "unsafe"

Expand Down
2 changes: 1 addition & 1 deletion sdl/sdl_joystick.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package sdl

// #include <SDL2/SDL_joystick.h>
// #include <SDL2/SDL.h>
import "C"
import "unsafe"

Expand Down
2 changes: 1 addition & 1 deletion sdl/sdl_keyboard.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package sdl

// #include <SDL2/SDL_keyboard.h>
// #include <SDL2/SDL.h>
import "C"
import "unsafe"
import "reflect"
Expand Down
2 changes: 1 addition & 1 deletion sdl/sdl_keycode.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package sdl

// #include <SDL2/SDL_keycode.h>
// #include <SDL2/SDL.h>
import "C"

const K_SCANCODE_MASK = 1 << 30
Expand Down
2 changes: 1 addition & 1 deletion sdl/sdl_loadso.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package sdl

// #include <SDL2/SDL_loadso.h>
// #include <SDL2/SDL.h>
import "C"
import "unsafe"

Expand Down
2 changes: 1 addition & 1 deletion sdl/sdl_log.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package sdl

// #include <SDL2/SDL_log.h>
// #include <SDL2/SDL.h>
import "C"
// import "unsafe"

Expand Down
4 changes: 1 addition & 3 deletions sdl/sdl_mouse.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package sdl

/*
#include <SDL2/SDL_mouse.h>
*/
// #include <SDL2/SDL.h>
import "C"
import "unsafe"

Expand Down
1 change: 0 additions & 1 deletion sdl/sdl_pixels.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package sdl

// #cgo LDFLAGS: -lSDL2
// #include <SDL2/SDL.h>
import "C"

Expand Down
2 changes: 1 addition & 1 deletion sdl/sdl_rect.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package sdl

// #include <SDL2/SDL_rect.h>
// #include <SDL2/SDL.h>
import "C"
import "unsafe"

Expand Down
2 changes: 1 addition & 1 deletion sdl/sdl_render.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package sdl

// #include <SDL2/SDL_render.h>
// #include <SDL2/SDL.h>
import "C"
import "unsafe"

Expand Down
2 changes: 1 addition & 1 deletion sdl/sdl_rwops.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package sdl

/*
#include <SDL2/SDL_rwops.h>
#include <SDL2/SDL.h>
static Sint64 RWsize(SDL_RWops *ctx)
{
return ctx->size(ctx);
Expand Down
2 changes: 1 addition & 1 deletion sdl/sdl_scancode.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package sdl

// #include <SDL2/SDL_scancode.h>
// #include <SDL2/SDL.h>
import "C"

const (
Expand Down
2 changes: 1 addition & 1 deletion sdl/sdl_surface.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package sdl

/*
#include <SDL2/SDL_surface.h>
#include <SDL2/SDL.h>
*/
import "C"
import "unsafe"
Expand Down
1 change: 0 additions & 1 deletion sdl/sdl_syswm.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package sdl

// #cgo LDFLAGS: -lSDL2
// #include <SDL2/SDL.h>
// #include <SDL2/SDL_syswm.h>
import "C"
Expand Down
11 changes: 11 additions & 0 deletions sdl/sdl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,14 @@ func TestInitQuit(t *testing.T) {
}
Quit()
}

func TestGetPlatform(t *testing.T) {
goos := runtime.GOOS
value := GetPlatform()
if ((goos == "linux" && value != "Linux") ||
(goos == "freebsd" && value != "FreeBSD") ||
(goos == "windows" && value != "Windows") ||
(goos == "darwin" && value != "Mac OS X")) {
t.Errorf("platform mismatch: '%s' != '%s'", goos, value)
}
}
2 changes: 1 addition & 1 deletion sdl/sdl_timer.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package sdl

// #include <SDL2/SDL_timer.h>
// #include <SDL2/SDL.h>
import "C"

func GetTicks() uint32 {
Expand Down
2 changes: 1 addition & 1 deletion sdl/sdl_touch.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package sdl

// #include <SDL2/SDL_touch.h>
// #include <SDL2/SDL.h>
import "C"
import "unsafe"

Expand Down
4 changes: 1 addition & 3 deletions sdl/sdl_version.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package sdl

/*
#include <SDL2/SDL_version.h>
*/
// #include <SDL2/SDL.h>
import "C"
import "unsafe"

Expand Down
2 changes: 1 addition & 1 deletion sdl/sdl_video.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package sdl

// #include <SDL2/SDL_video.h>
// #include <SDL2/SDL.h>
import "C"
import "unsafe"

Expand Down
7 changes: 4 additions & 3 deletions sdl_image/sdl_image.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package img

//#cgo !linux,freebsd LDFLAGS: -lSDL2 -lSDL2_image
//#cgo !windows pkg-config: sdl2
//#cgo !windows LDFLAGS: -lSDL2_image
//#cgo linux freebsd pkg-config: sdl2
//#cgo linux freebsd LDFLAGS: -lSDL2_image
//#cgo windows LDFLAGS: -lSDL2 -lSDL2_image
//#include <stdlib.h>
//#include <SDL2/SDL_image.h>
import "C"
import "unsafe"
Expand Down
7 changes: 4 additions & 3 deletions sdl_mixer/sdl_mixer.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package mix

//#cgo !linux,freebsd LDFLAGS: -lSDL2 -lSDL2_mixer
//#cgo !windows pkg-config: sdl2
//#cgo !windows LDFLAGS: -lSDL2_mixer
//#cgo windows LDFLAGS: -lSDL2 -lSDL2_mixer
//#cgo linux freebsd pkg-config: sdl2
//#cgo linux freebsd LDFLAGS: -lSDL2_mixer
//#include <stdlib.h>
//#include <SDL2/SDL_mixer.h>
//
//extern void callPostMixFunction(void *udata, Uint8* stream, int length);
Expand Down
7 changes: 4 additions & 3 deletions sdl_ttf/sdl_ttf.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package ttf

//#cgo !linux,freebsd LDFLAGS: -lSDL2 -lSDL2_ttf
//#cgo !windows pkg-config: sdl2
//#cgo !windows LDFLAGS: -lSDL2_ttf
//#cgo windows LDFLAGS: -lSDL2 -lSDL2_ttf
//#cgo linux freebsd pkg-config: sdl2
//#cgo linux freebsd LDFLAGS: -lSDL2_ttf
//#include <stdlib.h>
//#include <SDL2/SDL_ttf.h>
//void Do_TTF_SetError(const char *str) {
// TTF_SetError(str);
Expand Down

0 comments on commit 7416622

Please sign in to comment.