Skip to content

Commit

Permalink
premake: build SDL2 as subproject for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
JaCzekanski committed May 24, 2020
1 parent f21c12c commit a516535
Show file tree
Hide file tree
Showing 5 changed files with 218 additions and 59 deletions.
12 changes: 1 addition & 11 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,6 @@ before_build:
- ps: Start-FileDownload "https://github.com/premake/premake-core/releases/download/v$($env:PREMAKE_VERSION)/premake-$($env:PREMAKE_VERSION)-windows.zip" "premake.zip"
- 7z x premake.zip

# SDL
- cd externals
- rmdir /Q /S SDL2
- ps: Start-FileDownload "https://www.libsdl.org/release/SDL2-devel-$($env:SDL_VERSION)-VC.zip" "SDL.zip"
- 7z x SDL.zip
- ren SDL2-%SDL_VERSION% SDL2
- cd ..

# generate solution
- premake5.exe %TOOLSET%

Expand All @@ -59,12 +51,10 @@ after_build:
# Premake renames x86 to Win32 - undo that
- ps: if ($env:platform -eq "Win32") { $env:platform = "x86" }

# copy avocado.exe, SDL2.dll and data directory
# copy avocado.exe and data directory
- ps: $env:TARGETDIR = "build\$($env:CONFIGURATION)"
- ps: if ($env:platform -ne "x86") { $env:TARGETDIR = $env:TARGETDIR + "_" + $env:platform }
- ps: Copy-Item $env:TARGETDIR\avocado.exe artifact\avocado.exe
# - ps: Copy-Item $env:TARGETDIR\avocado.pdb artifact\avocado.pdb
- ps: Copy-Item externals\SDL2\lib\$env:platform\SDL2.dll artifact\SDL2.dll
- ps: Copy-Item data artifact\ -recurse

# remove .gitignore
Expand Down
65 changes: 32 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Despite this emulator being in early development, some 3D games can run. [Game c
Currently audio is hard synced to NTSC (60Hz) (**running PAL games will make audio stutter**). The timer implementation does not function properly (**games fail to boot** or run at wrong speed). Many games won't boot or crash shortly after booting.

## Requirements
- OS: Windows 7 or later, macOS 10.13 or later, Linux
- OS: Windows 7 or later, macOS 10.13 or later, Linux (Ubuntu 16.04 or later)
- GPU: Graphics card supporting **OpenGL 3.2**
- CPU: [SSE3 compatible (CPUs after 2004)](https://en.wikipedia.org/wiki/SSE3#CPUs_with_SSE3) x64 or x86 processor

Expand Down Expand Up @@ -102,28 +102,27 @@ Configure controls under Options->Controller menu.

### Windows
Requirements:
- Visual Studio 2017
- Visual Studio 2019 (2017 should work as well)
- [Premake5](https://premake.github.io/download.html)
- [SDL2 dev library](https://www.libsdl.org/download-2.0.php)

First build:
```
> git clone https://github.com/JaCzekanski/Avocado.git
> cd Avocado
> git submodule update --init --recursive
> premake5 vs2017
git clone https://github.com/JaCzekanski/Avocado.git
cd Avocado
git submodule update --init --recursive
premake5 vs2019
# Open Visual Studio solution and build it
# Open avocado.sln with Visual Studio, make sure that Release build is selected, build it
```

See appveyor.yml in case of problems.

Update:
```
> git pull && git submodule update --init --recursive
> premake5 vs2017
git pull && git submodule update --init --recursive
premake5 vs2019
# Open Visual Studio solution and build it
# Open avocado.sln, build it
```

### Linux
Expand All @@ -133,25 +132,25 @@ Requirements:

First build:
```
> sudo apt update
> sudo apt install libsdl2-dev
> git clone https://github.com/JaCzekanski/Avocado.git
> cd Avocado
> git submodule update --init --recursive
> premake5 gmake
> make config=release_x64 -j4
sudo apt update
sudo apt install libsdl2-dev
git clone https://github.com/JaCzekanski/Avocado.git
cd Avocado
git submodule update --init --recursive
premake5 gmake
make config=release_x64 -j4
# Running
> ./build/release_x64/avocado
./build/release_x64/avocado
```

See .travis/linux/build.sh in case of problems.

Update:
```
> git pull && git submodule update --init --recursive
> premake5 gmake
> make config=release_x64 -j4
git pull && git submodule update --init --recursive
premake5 gmake
make config=release_x64 -j4
```

### macOS
Expand All @@ -162,25 +161,25 @@ Requirements:

First build:
```
> brew update
> brew install sdl2
> git clone https://github.com/JaCzekanski/Avocado.git
> cd Avocado
> git submodule update --init --recursive
> premake5 gmake
> make config=release_x64 -j4
brew update
brew install sdl2
git clone https://github.com/JaCzekanski/Avocado.git
cd Avocado
git submodule update --init --recursive
premake5 gmake
make config=release_x64 -j4
# Running
> ./build/release_x64/avocado.app
./build/release_x64/avocado.app
```

See .travis/macos/build.sh in case of problems.

Update:
```
> git pull && git submodule update --init --recursive
> premake5 gmake
> make config=release_x64 -j4
git pull && git submodule update --init --recursive
premake5 gmake
make config=release_x64 -j4
```

## Bugs
Expand Down
2 changes: 1 addition & 1 deletion externals/SDL2
Submodule SDL2 updated 896 files
179 changes: 179 additions & 0 deletions premake/sdl2.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
-- Used for Windows build only

filter "system:windows"
group "externals"
project "sdl2"
uuid "C9CA7048-0F5F-4BE5-BF21-DDEE5F9A2172"
kind "StaticLib"
language "c"
location "../build/libs/sdl"
defines {
"NDEBUG"
}
includedirs {
"../externals/SDL2/src",
"../externals/SDL2/include",
}
files {
"../externals/SDL2/src/atomic/SDL_atomic.c",
"../externals/SDL2/src/atomic/SDL_spinlock.c",
"../externals/SDL2/src/audio/directsound/SDL_directsound.c",
"../externals/SDL2/src/audio/disk/SDL_diskaudio.c",
"../externals/SDL2/src/audio/dummy/SDL_dummyaudio.c",
"../externals/SDL2/src/audio/SDL_audio.c",
"../externals/SDL2/src/audio/SDL_audiocvt.c",
"../externals/SDL2/src/audio/SDL_audiodev.c",
"../externals/SDL2/src/audio/SDL_audiotypecvt.c",
"../externals/SDL2/src/audio/SDL_mixer.c",
"../externals/SDL2/src/audio/SDL_wave.c",
"../externals/SDL2/src/audio/winmm/SDL_winmm.c",
"../externals/SDL2/src/audio/wasapi/SDL_wasapi.c",
"../externals/SDL2/src/audio/wasapi/SDL_wasapi_win32.c",
"../externals/SDL2/src/core/windows/SDL_windows.c",
"../externals/SDL2/src/core/windows/SDL_xinput.c",
"../externals/SDL2/src/cpuinfo/SDL_cpuinfo.c",
"../externals/SDL2/src/dynapi/SDL_dynapi.c",
"../externals/SDL2/src/events/SDL_clipboardevents.c",
"../externals/SDL2/src/events/SDL_displayevents.c",
"../externals/SDL2/src/events/SDL_dropevents.c",
"../externals/SDL2/src/events/SDL_events.c",
"../externals/SDL2/src/events/SDL_gesture.c",
"../externals/SDL2/src/events/SDL_keyboard.c",
"../externals/SDL2/src/events/SDL_mouse.c",
"../externals/SDL2/src/events/SDL_quit.c",
"../externals/SDL2/src/events/SDL_touch.c",
"../externals/SDL2/src/events/SDL_windowevents.c",
"../externals/SDL2/src/file/SDL_rwops.c",
"../externals/SDL2/src/filesystem/windows/SDL_sysfilesystem.c",
"../externals/SDL2/src/haptic/SDL_haptic.c",
"../externals/SDL2/src/haptic/windows/SDL_dinputhaptic.c",
"../externals/SDL2/src/haptic/windows/SDL_windowshaptic.c",
"../externals/SDL2/src/haptic/windows/SDL_xinputhaptic.c",
"../externals/SDL2/src/hidapi/windows/hid.c",
"../externals/SDL2/src/joystick/hidapi/SDL_hidapijoystick.c",
"../externals/SDL2/src/joystick/hidapi/SDL_hidapi_gamecube.c",
"../externals/SDL2/src/joystick/hidapi/SDL_hidapi_ps4.c",
"../externals/SDL2/src/joystick/hidapi/SDL_hidapi_rumble.c",
"../externals/SDL2/src/joystick/hidapi/SDL_hidapi_switch.c",
"../externals/SDL2/src/joystick/hidapi/SDL_hidapi_xbox360.c",
"../externals/SDL2/src/joystick/hidapi/SDL_hidapi_xbox360w.c",
"../externals/SDL2/src/joystick/hidapi/SDL_hidapi_xboxone.c",
"../externals/SDL2/src/joystick/SDL_gamecontroller.c",
"../externals/SDL2/src/joystick/SDL_joystick.c",
"../externals/SDL2/src/joystick/windows/SDL_dinputjoystick.c",
"../externals/SDL2/src/joystick/windows/SDL_mmjoystick.c",
"../externals/SDL2/src/joystick/windows/SDL_windowsjoystick.c",
"../externals/SDL2/src/joystick/windows/SDL_xinputjoystick.c",
"../externals/SDL2/src/libm/e_atan2.c",
"../externals/SDL2/src/libm/e_exp.c",
"../externals/SDL2/src/libm/e_fmod.c",
"../externals/SDL2/src/libm/e_log.c",
"../externals/SDL2/src/libm/e_log10.c",
"../externals/SDL2/src/libm/e_pow.c",
"../externals/SDL2/src/libm/e_rem_pio2.c",
"../externals/SDL2/src/libm/e_sqrt.c",
"../externals/SDL2/src/libm/k_cos.c",
"../externals/SDL2/src/libm/k_rem_pio2.c",
"../externals/SDL2/src/libm/k_sin.c",
"../externals/SDL2/src/libm/k_tan.c",
"../externals/SDL2/src/libm/s_atan.c",
"../externals/SDL2/src/libm/s_copysign.c",
"../externals/SDL2/src/libm/s_cos.c",
"../externals/SDL2/src/libm/s_fabs.c",
"../externals/SDL2/src/libm/s_floor.c",
"../externals/SDL2/src/libm/s_scalbn.c",
"../externals/SDL2/src/libm/s_sin.c",
"../externals/SDL2/src/libm/s_tan.c",
"../externals/SDL2/src/loadso/windows/SDL_sysloadso.c",
"../externals/SDL2/src/power/SDL_power.c",
"../externals/SDL2/src/power/windows/SDL_syspower.c",
"../externals/SDL2/src/render/direct3d11/SDL_shaders_d3d11.c",
"../externals/SDL2/src/render/direct3d/SDL_render_d3d.c",
"../externals/SDL2/src/render/direct3d11/SDL_render_d3d11.c",
"../externals/SDL2/src/render/direct3d/SDL_shaders_d3d.c",
"../externals/SDL2/src/render/opengl/SDL_render_gl.c",
"../externals/SDL2/src/render/opengl/SDL_shaders_gl.c",
"../externals/SDL2/src/render/opengles2/SDL_render_gles2.c",
"../externals/SDL2/src/render/opengles2/SDL_shaders_gles2.c",
"../externals/SDL2/src/render/SDL_d3dmath.c",
"../externals/SDL2/src/render/SDL_render.c",
"../externals/SDL2/src/render/SDL_yuv_sw.c",
"../externals/SDL2/src/render/software/SDL_blendfillrect.c",
"../externals/SDL2/src/render/software/SDL_blendline.c",
"../externals/SDL2/src/render/software/SDL_blendpoint.c",
"../externals/SDL2/src/render/software/SDL_drawline.c",
"../externals/SDL2/src/render/software/SDL_drawpoint.c",
"../externals/SDL2/src/render/software/SDL_render_sw.c",
"../externals/SDL2/src/render/software/SDL_rotate.c",
"../externals/SDL2/src/SDL.c",
"../externals/SDL2/src/SDL_assert.c",
"../externals/SDL2/src/SDL_dataqueue.c",
"../externals/SDL2/src/SDL_error.c",
"../externals/SDL2/src/SDL_hints.c",
"../externals/SDL2/src/SDL_log.c",
"../externals/SDL2/src/sensor/dummy/SDL_dummysensor.c",
"../externals/SDL2/src/sensor/SDL_sensor.c",
"../externals/SDL2/src/stdlib/SDL_getenv.c",
"../externals/SDL2/src/stdlib/SDL_iconv.c",
"../externals/SDL2/src/stdlib/SDL_malloc.c",
"../externals/SDL2/src/stdlib/SDL_qsort.c",
"../externals/SDL2/src/stdlib/SDL_stdlib.c",
"../externals/SDL2/src/stdlib/SDL_string.c",
"../externals/SDL2/src/stdlib/SDL_strtokr.c",
"../externals/SDL2/src/thread/generic/SDL_syscond.c",
"../externals/SDL2/src/thread/SDL_thread.c",
"../externals/SDL2/src/thread/windows/SDL_sysmutex.c",
"../externals/SDL2/src/thread/windows/SDL_syssem.c",
"../externals/SDL2/src/thread/windows/SDL_systhread.c",
"../externals/SDL2/src/thread/windows/SDL_systls.c",
"../externals/SDL2/src/timer/SDL_timer.c",
"../externals/SDL2/src/timer/windows/SDL_systimer.c",
"../externals/SDL2/src/video/dummy/SDL_nullevents.c",
"../externals/SDL2/src/video/dummy/SDL_nullframebuffer.c",
"../externals/SDL2/src/video/dummy/SDL_nullvideo.c",
"../externals/SDL2/src/video/SDL_blit.c",
"../externals/SDL2/src/video/SDL_blit_0.c",
"../externals/SDL2/src/video/SDL_blit_1.c",
"../externals/SDL2/src/video/SDL_blit_A.c",
"../externals/SDL2/src/video/SDL_blit_auto.c",
"../externals/SDL2/src/video/SDL_blit_copy.c",
"../externals/SDL2/src/video/SDL_blit_N.c",
"../externals/SDL2/src/video/SDL_blit_slow.c",
"../externals/SDL2/src/video/SDL_bmp.c",
"../externals/SDL2/src/video/SDL_clipboard.c",
"../externals/SDL2/src/video/SDL_egl.c",
"../externals/SDL2/src/video/SDL_fillrect.c",
"../externals/SDL2/src/video/SDL_pixels.c",
"../externals/SDL2/src/video/SDL_rect.c",
"../externals/SDL2/src/video/SDL_RLEaccel.c",
"../externals/SDL2/src/video/SDL_shape.c",
"../externals/SDL2/src/video/SDL_stretch.c",
"../externals/SDL2/src/video/SDL_surface.c",
"../externals/SDL2/src/video/SDL_video.c",
"../externals/SDL2/src/video/SDL_vulkan_utils.c",
"../externals/SDL2/src/video/SDL_yuv.c",
"../externals/SDL2/src/video/windows/SDL_windowsclipboard.c",
"../externals/SDL2/src/video/windows/SDL_windowsevents.c",
"../externals/SDL2/src/video/windows/SDL_windowsframebuffer.c",
"../externals/SDL2/src/video/windows/SDL_windowskeyboard.c",
"../externals/SDL2/src/video/windows/SDL_windowsmessagebox.c",
"../externals/SDL2/src/video/windows/SDL_windowsmodes.c",
"../externals/SDL2/src/video/windows/SDL_windowsmouse.c",
"../externals/SDL2/src/video/windows/SDL_windowsopengl.c",
"../externals/SDL2/src/video/windows/SDL_windowsopengles.c",
"../externals/SDL2/src/video/windows/SDL_windowsshape.c",
"../externals/SDL2/src/video/windows/SDL_windowsvideo.c",
"../externals/SDL2/src/video/windows/SDL_windowsvulkan.c",
"../externals/SDL2/src/video/windows/SDL_windowswindow.c",
"../externals/SDL2/src/video/yuv2rgb/yuv_rgb.c",
}
links {
"setupapi",
"winmm",
"imm32",
"version",
}
defines {
"SDL_DISABLE_WINDOWS_IME",
"HAVE_LIBC",
}
19 changes: 5 additions & 14 deletions premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ include "premake/miniz.lua"
include "premake/fmt.lua"
include "premake/stb.lua"

if os.istarget("windows") then
include "premake/sdl2.lua"
end

project "core"
uuid "176665c5-37ff-4a42-bef8-02edaeb1b426"
kind "StaticLib"
Expand Down Expand Up @@ -239,25 +243,12 @@ project "avocado"
"src/platform/windows/**.*"
}
links {
"SDL2",
"sdl2",
"glad",
"imgui",
"OpenGL32"
}

filter {"system:windows", "not options:headless", "platforms:x86"}
libdirs {
"externals/SDL2/lib/x86",
"externals/SDL2/VisualC/Win32/Release",
}

filter {"system:windows", "not options:headless", "platforms:x64"}
libdirs {
"externals/SDL2/lib/x64",
"externals/SDL2/VisualC/x64/Release",
}


filter {"system:linux", "not options:headless"}
files {
"src/imgui/**.*",
Expand Down

0 comments on commit a516535

Please sign in to comment.