Skip to content

Commit 97f13a1

Browse files
authored
Add libgif port (#13139)
This is useful in building the JPEG XL reference software, for example.
1 parent c5cde8a commit 97f13a1

File tree

8 files changed

+1222
-4
lines changed

8 files changed

+1222
-4
lines changed

embuilder.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
'bzip2',
5858
'cocos2d',
5959
'freetype',
60+
'giflib',
6061
'harfbuzz',
6162
'icu',
6263
'libjpeg',
@@ -193,6 +194,8 @@ def main():
193194
build_port('vorbis', 'libvorbis.a')
194195
elif what == 'ogg':
195196
build_port('ogg', 'libogg.a')
197+
elif what == 'giflib':
198+
build_port('giflib', 'libgif.a')
196199
elif what == 'libjpeg':
197200
build_port('libjpeg', 'libjpeg.a')
198201
elif what == 'libpng':

src/settings.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ var STRICT = 0;
913913
// include `_main`.
914914
var IGNORE_MISSING_MAIN = 1;
915915

916-
// Automatically attempt to add archive indexes at link time to archives that
916+
// Automatically attempt to add archive indexes at link time to archives that
917917
// don't already have them. This can happen when GNU ar or GNU ranlib is used
918918
// rather than `llvm-ar` or `emar` since the former don't understand the wasm
919919
// object format.
@@ -971,7 +971,7 @@ var DETERMINISTIC = 0;
971971
// (If WASM_ASYNC_COMPILATION is off, that is, if compilation is
972972
// *synchronous*, then it would not make sense to return a Promise, and instead
973973
// the Module object itself is returned, which is ready to be used.)
974-
//
974+
//
975975
// The default name of the function is `Module`, but can be changed using the
976976
// `EXPORT_NAME` option. We recommend renaming it to a more typical name for a
977977
// factory function, e.g. `createModule`.
@@ -980,14 +980,14 @@ var DETERMINISTIC = 0;
980980
// You use the factory function like so:
981981
//
982982
// const module = await EXPORT_NAME();
983-
//
983+
//
984984
// or:
985985
//
986986
// let module;
987987
// EXPORT_NAME().then(instance => {
988988
// module = instance;
989989
// });
990-
//
990+
//
991991
//
992992
// The factory function accepts 1 parameter, an object with default values for
993993
// the module instance:
@@ -1201,6 +1201,9 @@ var USE_ZLIB = 0;
12011201
// 1 = use bzip2 from emscripten-ports
12021202
var USE_BZIP2 = 0;
12031203

1204+
// 1 = use giflib from emscripten-ports
1205+
var USE_GIFLIB = 0;
1206+
12041207
// 1 = use libjpeg from emscripten-ports
12051208
var USE_LIBJPEG = 0;
12061209

tests/test_other.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,6 +1499,11 @@ def test_libpng(self):
14991499
output = self.run_js('a.out.js')
15001500
self.assertContained('libpng passes test', output)
15011501

1502+
def test_giflib(self):
1503+
shutil.copyfile(path_from_root('tests', 'third_party', 'giflib', 'treescap.gif'), 'treescap.gif')
1504+
building.emcc(path_from_root('tests', 'third_party', 'giflib', 'giftext.c'), ['--embed-file', 'treescap.gif', '-s', 'USE_GIFLIB'], output_filename='a.out.js')
1505+
self.assertContained('GIF file terminated normally', self.run_js('a.out.js', args=['treescap.gif']))
1506+
15021507
def test_libjpeg(self):
15031508
shutil.copyfile(path_from_root('tests', 'screenshot.jpg'), 'screenshot.jpg')
15041509
building.emcc(path_from_root('tests', 'jpeg_test.c'), ['--embed-file', 'screenshot.jpg', '-s', 'USE_LIBJPEG'], output_filename='a.out.js')

0 commit comments

Comments
 (0)