Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/tools/ports/zlib.py
4130 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 = '1.3.1'
10
HASH = '8c9642495bafd6fad4ab9fb67f09b268c69ff9af0f4f20cf15dfc18852ff1f312bd8ca41de761b3f8d8e90e77d79f2ccacd3d4c5b19e475ecf09d021fdfe9088'
11
12
13
def needed(settings):
14
return settings.USE_ZLIB
15
16
17
def get(ports, settings, shared):
18
ports.fetch_project('zlib', f'https://github.com/madler/zlib/archive/refs/tags/v{VERSION}.tar.gz', sha512hash=HASH)
19
20
def create(final):
21
source_path = ports.get_dir('zlib', 'zlib-' + VERSION)
22
# Overwrite zconf.h with our own version
23
zconf_h = os.path.join(os.path.dirname(__file__), 'zlib/zconf.h')
24
shutil.copyfile(zconf_h, os.path.join(source_path, 'zconf.h'))
25
ports.install_headers(source_path)
26
ports.make_pkg_config('zlib', VERSION, '-sUSE_ZIB')
27
28
# build
29
srcs = 'adler32.c compress.c crc32.c deflate.c gzclose.c gzlib.c gzread.c gzwrite.c infback.c inffast.c inflate.c inftrees.c trees.c uncompr.c zutil.c'.split()
30
flags = ['-Wno-deprecated-non-prototype']
31
ports.build_port(source_path, final, 'zlib', srcs=srcs, flags=flags)
32
33
return [shared.cache.get_lib('libz.a', create, what='port')]
34
35
36
def clear(ports, settings, shared):
37
shared.cache.erase_lib('libz.a')
38
39
40
def show():
41
return 'zlib (-sUSE_ZLIB or --use-port=zlib; zlib license)'
42
43
44