Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ See docs/process.md for more on how version tagging works.

3.1.30 (in development)
-----------------------
- The SDLv1 header directory is no longer added to the include path by default.
This means if you include SDL headers without the explicit version in them
(e.g. `SDL_events.h`) you will now need to add `-sUSE_SDL` explicitly at
compile time. If you include the SDL headers with the directory name included
(e.g. `SDL/SDL_events.h`) you will not be affected by this change. (#18443)

3.1.29 - 01/03/23
-----------------
Expand Down
6 changes: 3 additions & 3 deletions emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,9 @@ def array_contains_any_of(hay, needles):
if array_contains_any_of(user_args, SIMD_NEON_FLAGS):
cflags += ['-D__ARM_NEON__=1']

if not settings.USE_SDL:
cflags += ['-Xclang', '-iwithsysroot' + os.path.join('/include', 'fakesdl')]

return cflags + ['-Xclang', '-iwithsysroot' + os.path.join('/include', 'compat')]


Expand Down Expand Up @@ -1916,9 +1919,6 @@ def phase_linker_setup(options, state, newargs):
default_setting('IGNORE_MISSING_MAIN', 0)
default_setting('ALLOW_UNIMPLEMENTED_SYSCALLS', 0)

if not settings.AUTO_JS_LIBRARIES:
default_setting('USE_SDL', 0)

if 'GLOBAL_BASE' not in user_settings and not settings.SHRINK_LEVEL and not settings.OPT_LEVEL:
# When optimizing for size it helps to put static data first before
# the stack (sincs this makes instructions for accessing this data
Expand Down
2 changes: 1 addition & 1 deletion src/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -1406,7 +1406,7 @@ var LEGALIZE_JS_FFI = true;
// When AUTO_JS_LIBRARIES is set to 0 this defaults to 0 and SDL
// is not linked in.
// [compile+link]
var USE_SDL = 1;
var USE_SDL = 0;

// Specify the SDL_gfx version that is being linked against. Must match USE_SDL
// [compile+link]
Expand Down
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_assert.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_atomic.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_audio.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_blendmode.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_clipboard.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_compat.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_copying.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_cpuinfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_endian.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_error.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_events.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_gesture.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_gfxPrimitives.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_haptic.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_hints.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_image.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_input.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_joystick.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_keyboard.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_keycode.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_loadso.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_log.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_main.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_mixer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_mouse.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_mutex.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_name.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_opengl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_opengles.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_opengles2.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_pixels.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_platform.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_power.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_quit.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_rect.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_render.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_revision.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_rotozoom.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_rwops.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_scancode.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_shape.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_stdinc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_surface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_syswm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_thread.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_timer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_touch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_ttf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
1 change: 1 addition & 0 deletions system/include/fakesdl/SDL_video.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
4 changes: 2 additions & 2 deletions test/browser/test_sdl_alloctext.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/

#include <stdio.h>
#include <SDL.h>
#include <SDL_ttf.h>
#include <SDL/SDL.h>
#include <SDL/SDL_ttf.h>

int main()
{
Expand Down
2 changes: 1 addition & 1 deletion test/browser/test_sdl_surface_refcount.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <emscripten.h>
#include <assert.h>
#include <SDL.h>
#include <SDL/SDL.h>
#include <stdio.h>
#include <stdlib.h>

Expand Down
4 changes: 2 additions & 2 deletions test/browser/test_sdl_ttf_render_text_solid.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/

#include <stdio.h>
#include <SDL.h>
#include <SDL_ttf.h>
#include <SDL/SDL.h>
#include <SDL/SDL_ttf.h>

int main()
{
Expand Down
2 changes: 1 addition & 1 deletion test/emscripten_api_browser.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <SDL.h>
#include <SDL/SDL.h>
#include <emscripten.h>
#include <assert.h>

Expand Down
1 change: 1 addition & 0 deletions test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2483,6 +2483,7 @@ def test_llvmswitch(self):

@no_wasm2js('massive switches can break js engines')
def test_bigswitch(self):
self.set_setting('USE_SDL')
self.do_runf(test_file('bigswitch.cpp'), '''34962: GL_ARRAY_BUFFER (0x8892)
26214: what?
35040: GL_STREAM_DRAW (0x88E0)
Expand Down
26 changes: 19 additions & 7 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -1970,8 +1970,21 @@ def test_js_link(self):
self.run_process([EMXX, 'main.cpp', '--pre-js', 'before.js', '--post-js', 'after.js', '-sWASM_ASYNC_COMPILATION=0'])
self.assertContained('hello from main\nhello from js\n', self.run_js('a.out.js'))

def test_sdl_none(self):
create_file('main.c', r'''
#include <stdio.h>
#include <SDL.h>

int main() {
return 0;
}
''')
err = self.expect_fail([EMCC, 'main.c'])
self.assertContained('SDL.h:1:2: error: "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"', err)
self.run_process([EMCC, 'main.c', '-sUSE_SDL'])

def test_sdl_endianness(self):
create_file('main.cpp', r'''
create_file('main.c', r'''
#include <stdio.h>
#include <SDL/SDL.h>

Expand All @@ -1980,11 +1993,10 @@ def test_sdl_endianness(self):
return 0;
}
''')
self.run_process([EMXX, 'main.cpp'])
self.assertContained('1234, 1234, 4321\n', self.run_js('a.out.js'))
self.do_runf('main.c', '1234, 1234, 4321\n')

def test_sdl_scan_code_from_key(self):
create_file('main.cpp', r'''
create_file('main.c', r'''
#include <stdio.h>
#include <SDL/SDL_keyboard.h>

Expand All @@ -1993,7 +2005,7 @@ def test_sdl_scan_code_from_key(self):
return 0;
}
''')
self.do_runf('main.cpp', '204\n')
self.do_runf('main.c', '204\n')

def test_sdl2_mixer_wav(self):
self.emcc(test_file('browser/test_sdl2_mixer_wav.c'), ['-sUSE_SDL_MIXER=2'], output_filename='a.out.js')
Expand Down Expand Up @@ -2168,7 +2180,7 @@ def test_undefined_symbols(self, action):
delete_file('a.out.js')
print('checking "%s" %s' % (args, value))
extra = ['-s', action + '_ON_UNDEFINED_SYMBOLS=%d' % value] if action else []
proc = self.run_process([EMXX, 'main.cpp'] + extra + args, stderr=PIPE, check=False)
proc = self.run_process([EMXX, '-sUSE_SDL', 'main.cpp'] + extra + args, stderr=PIPE, check=False)
print(proc.stderr)
if value or action is None:
# The default is that we error in undefined symbols
Expand Down Expand Up @@ -8154,7 +8166,7 @@ def test_standalone_system_headers(self):
# everything it needs.
directories = {'': []}
for elem in os.listdir(path_from_root('system/include')):
if elem == 'compat':
if elem in ('compat', 'fakesdl'):
continue
full = path_from_root('system/include', elem)
if os.path.isdir(full):
Expand Down
2 changes: 1 addition & 1 deletion tools/ports/sdl2_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def create(final):
src_dir = os.path.join(ports.get_dir(), 'sdl2_net', 'SDL2_net-' + TAG)
ports.install_headers(src_dir, target='SDL2')
excludes = ['chatd.c', 'chat.cpp', 'showinterfaces.c']
ports.build_port(src_dir, final, 'sdl2_net', exclude_files=excludes)
ports.build_port(src_dir, final, 'sdl2_net', exclude_files=excludes, flags=['-sUSE_SDL=2'])

return [shared.cache.get_lib('libSDL2_net.a', create, what='port')]

Expand Down