Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/tools/ports/libjpeg.py
4133 views
1
# Copyright 2014 The Emscripten Authors. All rights reserved.
2
# Emscripten is available under two separate licenses, the MIT license and the
3
# University of Illinois/NCSA Open Source License. Both these licenses can be
4
# found in the LICENSE file.
5
6
import os
7
import shutil
8
9
VERSION = '9f'
10
HASH = '7f733d79cf176c690dcf127352f9aa7ec48000455944f286faae606cdeada6f6865b4a3f9f01bda8947b5b1089bb3e52d2b56879b6e871279ec5cbd1829304dc'
11
12
13
def needed(settings):
14
return settings.USE_LIBJPEG
15
16
17
def get(ports, settings, shared):
18
# Archive mirrored from http://www.ijg.org/files/jpegsrc.v9f.tar.gz.
19
# We have issues where python urllib was not able to load from the www.ijg.org webserver
20
# and was resulting in 403: Forbidden.
21
ports.fetch_project('libjpeg', f'https://storage.googleapis.com/webassembly/emscripten-ports/jpegsrc.v{VERSION}.tar.gz', sha512hash=HASH)
22
23
def create(final):
24
source_path = ports.get_dir('libjpeg', f'jpeg-{VERSION}')
25
jconfig_h = os.path.join(os.path.dirname(__file__), 'libjpeg/jconfig.h')
26
shutil.copyfile(jconfig_h, os.path.join(source_path, 'jconfig.h'))
27
28
ports.install_headers(source_path)
29
ports.make_pkg_config('libjpeg', VERSION, '-sUSE_LIBJPEG')
30
excludes = [
31
'ansi2knr.c', 'cjpeg.c', 'cjpegalt.c', 'ckconfig.c', 'djpeg.c', 'djpegalt.c', 'example.c',
32
'jmemansi.c', 'jmemdos.c', 'jmemmac.c', 'jmemname.c',
33
'jpegtran.c', 'rdjpgcom.c', 'wrjpgcom.c',
34
]
35
ports.build_port(source_path, final, 'libjpeg', exclude_files=excludes)
36
37
return [shared.cache.get_lib('libjpeg.a', create, what='port')]
38
39
40
def clear(ports, settings, shared):
41
shared.cache.erase_lib('libjpeg.a')
42
43
44
def show():
45
return 'libjpeg (-sUSE_LIBJPEG or --use-port=libjpeg; BSD license)'
46
47