Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 2 additions & 0 deletions emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ def apply_user_settings():
if key == 'WASM_OBJECT_FILES':
settings.LTO = 0 if value else 'full'

ports.check_ports_settings(settings)


def cxx_to_c_compiler(cxx):
# Convert C++ compiler name into C compiler name
Expand Down
27 changes: 27 additions & 0 deletions site/source/docs/tools_reference/settings_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1700,6 +1700,15 @@ Specify the GLFW version that is being linked against. Only relevant, if you
are linking against the GLFW library. Valid options are 2 for GLFW2 and 3
for GLFW3.

.. _ports:

PORTS
=====

Specify which ports to use. If there is only one port to use, it can be
specified this way -sPORTS=port. If multiple ports are need, you
specify it that way: -sPORTS=[port1,port2].

.. _wasm:

WASM
Expand Down Expand Up @@ -1849,6 +1858,7 @@ Specify the SDL version that is being linked against.
2 is a port of the SDL C code on emscripten-ports
When AUTO_JS_LIBRARIES is set to 0 this defaults to 0 and SDL
is not linked in.
Alternate syntax for using the port: -sPORTS=sdl2

.. note:: Applicable during both linking and compilation

Expand Down Expand Up @@ -1894,6 +1904,7 @@ USE_ICU
=======

1 = use icu from emscripten-ports
Alternate syntax: -sPORTS=icu

.. note:: Applicable during both linking and compilation

Expand All @@ -1903,6 +1914,7 @@ USE_ZLIB
========

1 = use zlib from emscripten-ports
Alternate syntax: -sPORTS=zlib

.. note:: Applicable during both linking and compilation

Expand All @@ -1912,6 +1924,7 @@ USE_BZIP2
=========

1 = use bzip2 from emscripten-ports
Alternate syntax: -sPORTS=bzip2

.. note:: Applicable during both linking and compilation

Expand All @@ -1921,6 +1934,7 @@ USE_GIFLIB
==========

1 = use giflib from emscripten-ports
Alternate syntax: -sPORTS=giflib

.. note:: Applicable during both linking and compilation

Expand All @@ -1930,6 +1944,7 @@ USE_LIBJPEG
===========

1 = use libjpeg from emscripten-ports
Alternate syntax: -sPORTS=libjpeg

.. note:: Applicable during both linking and compilation

Expand All @@ -1939,6 +1954,7 @@ USE_LIBPNG
==========

1 = use libpng from emscripten-ports
Alternate syntax: -sPORTS=libpng

.. note:: Applicable during both linking and compilation

Expand All @@ -1948,6 +1964,7 @@ USE_REGAL
=========

1 = use Regal from emscripten-ports
Alternate syntax: -sPORTS=regal

.. note:: Applicable during both linking and compilation

Expand All @@ -1957,6 +1974,7 @@ USE_BOOST_HEADERS
=================

1 = use Boost headers from emscripten-ports
Alternate syntax: -sPORTS=boost_headers

.. note:: Applicable during both linking and compilation

Expand All @@ -1966,6 +1984,7 @@ USE_BULLET
==========

1 = use bullet from emscripten-ports
Alternate syntax: -sPORTS=bullet

.. note:: Applicable during both linking and compilation

Expand All @@ -1975,6 +1994,7 @@ USE_VORBIS
==========

1 = use vorbis from emscripten-ports
Alternate syntax: -sPORTS=vorbis

.. note:: Applicable during both linking and compilation

Expand All @@ -1984,6 +2004,7 @@ USE_OGG
=======

1 = use ogg from emscripten-ports
Alternate syntax: -sPORTS=ogg

.. note:: Applicable during both linking and compilation

Expand All @@ -1993,6 +2014,7 @@ USE_MPG123
==========

1 = use mpg123 from emscripten-ports
Alternate syntax: -sPORTS=mpg123

.. note:: Applicable during both linking and compilation

Expand All @@ -2002,6 +2024,7 @@ USE_FREETYPE
============

1 = use freetype from emscripten-ports
Alternate syntax: -sPORTS=freetype

.. note:: Applicable during both linking and compilation

Expand All @@ -2021,6 +2044,7 @@ USE_HARFBUZZ
============

1 = use harfbuzz from harfbuzz upstream
Alternate syntax: -sPORTS=harfbuzz

.. note:: Applicable during both linking and compilation

Expand All @@ -2030,6 +2054,7 @@ USE_COCOS2D
===========

3 = use cocos2d v3 from emscripten-ports
Alternate syntax: -sPORTS=cocos2d

.. note:: Applicable during both linking and compilation

Expand All @@ -2039,6 +2064,7 @@ USE_MODPLUG
===========

1 = use libmodplug from emscripten-ports
Alternate syntax: -sPORTS=libmodplug

.. note:: Applicable during both linking and compilation

Expand All @@ -2063,6 +2089,7 @@ USE_SQLITE3
===========

1 = use sqlite3 from emscripten-ports
Alternate syntax: -sPORTS=sqlite3

.. note:: Applicable during both linking and compilation

Expand Down
24 changes: 24 additions & 0 deletions src/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -1339,6 +1339,12 @@ var EMSCRIPTEN_TRACING = false;
// [link]
var USE_GLFW = 0;

// Specify which ports to use. If there is only one port to use, it can be
// specified this way -sPORTS=port. If multiple ports are need, you
// specify it that way: -sPORTS=[port1,port2].
// [link]
var PORTS = [];

// Whether to use compile code to WebAssembly. Set this to 0 to compile to JS
// instead of wasm.
//
Expand Down Expand Up @@ -1455,6 +1461,7 @@ var LEGALIZE_JS_FFI = true;
// 2 is a port of the SDL C code on emscripten-ports
// When AUTO_JS_LIBRARIES is set to 0 this defaults to 0 and SDL
// is not linked in.
// Alternate syntax for using the port: -sPORTS=sdl2
// [compile+link]
var USE_SDL = 0;

Expand All @@ -1475,54 +1482,67 @@ var USE_SDL_TTF = 1;
var USE_SDL_NET = 1;

// 1 = use icu from emscripten-ports
// Alternate syntax: -sPORTS=icu
// [compile+link]
var USE_ICU = false;

// 1 = use zlib from emscripten-ports
// Alternate syntax: -sPORTS=zlib
// [compile+link]
var USE_ZLIB = false;

// 1 = use bzip2 from emscripten-ports
// Alternate syntax: -sPORTS=bzip2
// [compile+link]
var USE_BZIP2 = false;

// 1 = use giflib from emscripten-ports
// Alternate syntax: -sPORTS=giflib
// [compile+link]
var USE_GIFLIB = false;

// 1 = use libjpeg from emscripten-ports
// Alternate syntax: -sPORTS=libjpeg
// [compile+link]
var USE_LIBJPEG = false;

// 1 = use libpng from emscripten-ports
// Alternate syntax: -sPORTS=libpng
// [compile+link]
var USE_LIBPNG = false;

// 1 = use Regal from emscripten-ports
// Alternate syntax: -sPORTS=regal
// [compile+link]
var USE_REGAL = false;

// 1 = use Boost headers from emscripten-ports
// Alternate syntax: -sPORTS=boost_headers
// [compile+link]
var USE_BOOST_HEADERS = false;

// 1 = use bullet from emscripten-ports
// Alternate syntax: -sPORTS=bullet
// [compile+link]
var USE_BULLET = false;

// 1 = use vorbis from emscripten-ports
// Alternate syntax: -sPORTS=vorbis
// [compile+link]
var USE_VORBIS = false;

// 1 = use ogg from emscripten-ports
// Alternate syntax: -sPORTS=ogg
// [compile+link]
var USE_OGG = false;

// 1 = use mpg123 from emscripten-ports
// Alternate syntax: -sPORTS=mpg123
// [compile+link]
var USE_MPG123 = false;

// 1 = use freetype from emscripten-ports
// Alternate syntax: -sPORTS=freetype
// [compile+link]
var USE_FREETYPE = false;

Expand All @@ -1532,14 +1552,17 @@ var USE_FREETYPE = false;
var USE_SDL_MIXER = 1;

// 1 = use harfbuzz from harfbuzz upstream
// Alternate syntax: -sPORTS=harfbuzz
// [compile+link]
var USE_HARFBUZZ = false;

// 3 = use cocos2d v3 from emscripten-ports
// Alternate syntax: -sPORTS=cocos2d
// [compile+link]
var USE_COCOS2D = 0;

// 1 = use libmodplug from emscripten-ports
// Alternate syntax: -sPORTS=libmodplug
// [compile+link]
var USE_MODPLUG = false;

Expand All @@ -1553,6 +1576,7 @@ var SDL2_IMAGE_FORMATS = [];
var SDL2_MIXER_FORMATS = ["ogg"];

// 1 = use sqlite3 from emscripten-ports
// Alternate syntax: -sPORTS=sqlite3
// [compile+link]
var USE_SQLITE3 = false;

Expand Down
20 changes: 20 additions & 0 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -2250,20 +2250,25 @@ def test_sdl_scan_code_from_key(self):

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')
self.emcc(test_file('browser/test_sdl2_mixer_wav.c'), ['-sPORTS=sdl2_mixer'], output_filename='a.out.js')

def test_sdl2_linkable(self):
# Ensure that SDL2 can be built with LINKABLE. This implies there are no undefined
# symbols in the library (because LINKABLE includes the entire library).
self.emcc(test_file('browser/test_sdl2_misc.c'), ['-sLINKABLE', '-sUSE_SDL=2'], output_filename='a.out.js')
self.emcc(test_file('browser/test_sdl2_misc.c'), ['-sLINKABLE', '-sPORTS=sdl2'], output_filename='a.out.js')

def test_sdl2_gfx_linkable(self):
# Same as above but for sdl2_gfx library
self.emcc(test_file('browser/test_sdl2_misc.c'), ['-Wl,-fatal-warnings', '-sLINKABLE', '-sUSE_SDL_GFX=2'], output_filename='a.out.js')
self.emcc(test_file('browser/test_sdl2_misc.c'), ['-Wl,-fatal-warnings', '-sLINKABLE', '-sPORTS=sdl2_gfx'], output_filename='a.out.js')

def test_libpng(self):
shutil.copyfile(test_file('third_party/libpng/pngtest.png'), 'pngtest.png')
self.do_runf('third_party/libpng/pngtest.c', 'libpng passes test',
emcc_args=['--embed-file', 'pngtest.png', '-sUSE_LIBPNG'])
self.do_runf('third_party/libpng/pngtest.c', 'libpng passes test',
emcc_args=['--embed-file', 'pngtest.png', '-sPORTS=libpng'])

@node_pthreads
def test_libpng_with_pthreads(self):
Expand All @@ -2284,23 +2289,34 @@ def test_giflib(self):
'GIF file terminated normally',
emcc_args=['--embed-file', 'treescap.gif', '-sUSE_GIFLIB', '-sMAIN_MODULE'],
args=['treescap.gif'])
self.do_runf('third_party/giflib/giftext.c',
'GIF file terminated normally',
emcc_args=['--embed-file', 'treescap.gif', '-sPORTS=giflib'],
args=['treescap.gif'])

def test_libjpeg(self):
shutil.copyfile(test_file('screenshot.jpg'), 'screenshot.jpg')
self.do_runf('jpeg_test.c', 'Image is 600 by 450 with 3 components',
emcc_args=['--embed-file', 'screenshot.jpg', '-sUSE_LIBJPEG'],
args=['screenshot.jpg'])
self.do_runf('jpeg_test.c', 'Image is 600 by 450 with 3 components',
emcc_args=['--embed-file', 'screenshot.jpg', '-sPORTS=libjpeg'],
args=['screenshot.jpg'])

def test_bullet(self):
self.do_runf('bullet_hello_world.cpp', 'BULLET RUNNING', emcc_args=['-sUSE_BULLET'])
self.do_runf('bullet_hello_world.cpp', 'BULLET RUNNING', emcc_args=['-sPORTS=bullet'])

def test_vorbis(self):
# This will also test if ogg compiles, because vorbis depends on ogg
self.do_runf('vorbis_test.c', 'ALL OK', emcc_args=['-sUSE_VORBIS'])
self.do_runf('vorbis_test.c', 'ALL OK', emcc_args=['-sPORTS=vorbis'])

def test_bzip2(self):
self.do_runf('bzip2_test.c', 'usage: unzcrash filename',
emcc_args=['-sUSE_BZIP2', '-Wno-pointer-sign'])
self.do_runf('bzip2_test.c', 'usage: unzcrash filename',
emcc_args=['-sPORTS=bzip2', '-Wno-pointer-sign'])

@with_both_sjlj
def test_freetype(self):
Expand Down Expand Up @@ -2328,6 +2344,8 @@ def test_freetype(self):
# build test program with the font file embed in it
self.do_runf('freetype_test.c', expectedOutput,
emcc_args=['-sUSE_FREETYPE', '--embed-file', 'LiberationSansBold.ttf'])
self.do_runf('freetype_test.c', expectedOutput,
emcc_args=['-sPORTS=freetype', '--embed-file', 'LiberationSansBold.ttf'])

def test_freetype_with_pthreads(self):
# Verify that freetype supports compilation requiring pthreads
Expand All @@ -2340,6 +2358,7 @@ def test_icu(self):
def test_sdl2_ttf(self):
# This is a compile-only to test to verify that sdl2-ttf (and freetype and harfbuzz) are buildable.
self.emcc(test_file('browser/test_sdl2_ttf.c'), args=['-sUSE_SDL=2', '-sUSE_SDL_TTF=2'], output_filename='a.out.js')
self.emcc(test_file('browser/test_sdl2_ttf.c'), args=['-sPORTS=sdl2_ttf'], output_filename='a.out.js')

def test_link_memcpy(self):
# memcpy can show up *after* optimizations, so after our opportunity to link in libc, so it must be special-cased
Expand Down Expand Up @@ -11411,6 +11430,7 @@ def test_em_asm_invalid(self):

def test_boost_graph(self):
self.do_runf('test_boost_graph.cpp', emcc_args=['-std=c++14', '-sUSE_BOOST_HEADERS'])
self.do_runf('test_boost_graph.cpp', emcc_args=['-std=c++14', '-sPORTS=boost_headers'])

def test_setjmp_em_asm(self):
create_file('src.c', '''
Expand Down
Loading