Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/tools/ports/mpg123.py
4130 views
1
# Copyright 2020 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
TAG = '1.26.2'
10
HASH = 'aa63fcb08b243a1e09f7701b3d84a19d7412a87253d54d49f014fdb9e75bbc81d152a41ed750fccde901453929b2a001585a7645351b41845ad205c17a73dcc9'
11
12
13
def needed(settings):
14
return settings.USE_MPG123
15
16
17
def get(ports, settings, shared):
18
ports.fetch_project('mpg123', f'https://www.mpg123.de/download/mpg123-{TAG}.tar.bz2', sha512hash=HASH)
19
20
def create(final):
21
source_path = ports.get_dir('mpg123', 'mpg123-' + TAG)
22
23
src_path = os.path.join(source_path, 'src')
24
libmpg123_path = os.path.join(src_path, 'libmpg123')
25
compat_path = os.path.join(src_path, 'compat')
26
27
config_h = os.path.join(os.path.dirname(__file__), 'mpg123/config.h')
28
mpg123_h = os.path.join(os.path.dirname(__file__), 'mpg123/mpg123.h')
29
shutil.copyfile(config_h, os.path.join(src_path, 'config.h'))
30
shutil.copyfile(mpg123_h, os.path.join(libmpg123_path, 'mpg123.h'))
31
32
# copy header to a location so it can be used as 'MPG123/'
33
ports.install_headers(libmpg123_path, pattern="*123.h", target='')
34
ports.make_pkg_config('mpg123', TAG, '-sUSE_MPG123')
35
36
flags = [
37
'-DOPT_GENERIC',
38
'-DREAL_IS_FLOAT',
39
'-fomit-frame-pointer',
40
'-finline-functions',
41
'-ffast-math',
42
'-I' + src_path,
43
'-I' + compat_path,
44
'-I' + libmpg123_path,
45
]
46
47
srcs = [
48
os.path.join(libmpg123_path, 'dct64.c'),
49
os.path.join(libmpg123_path, 'equalizer.c'),
50
os.path.join(libmpg123_path, 'feature.c'),
51
os.path.join(libmpg123_path, 'format.c'),
52
os.path.join(libmpg123_path, 'frame.c'),
53
os.path.join(libmpg123_path, 'icy.c'),
54
os.path.join(libmpg123_path, 'icy2utf8.c'),
55
os.path.join(libmpg123_path, 'id3.c'),
56
os.path.join(libmpg123_path, 'index.c'),
57
os.path.join(libmpg123_path, 'layer1.c'),
58
os.path.join(libmpg123_path, 'layer2.c'),
59
os.path.join(libmpg123_path, 'layer3.c'),
60
os.path.join(libmpg123_path, 'lfs_alias.c'),
61
os.path.join(libmpg123_path, 'libmpg123.c'),
62
os.path.join(libmpg123_path, 'ntom.c'),
63
os.path.join(libmpg123_path, 'optimize.c'),
64
os.path.join(libmpg123_path, 'parse.c'),
65
os.path.join(libmpg123_path, 'readers.c'),
66
os.path.join(libmpg123_path, 'stringbuf.c'),
67
os.path.join(libmpg123_path, 'synth.c'),
68
os.path.join(libmpg123_path, 'synth_8bit.c'),
69
os.path.join(libmpg123_path, 'synth_real.c'),
70
os.path.join(libmpg123_path, 'synth_s32.c'),
71
os.path.join(libmpg123_path, 'tabinit.c'),
72
os.path.join(compat_path, 'compat.c'),
73
os.path.join(compat_path, 'compat_dl.c'),
74
os.path.join(compat_path, 'compat_str.c'),
75
]
76
77
ports.build_port(source_path, final, 'mpg123', flags=flags, srcs=srcs)
78
79
return [shared.cache.get_lib('libmpg123.a', create, what='port')]
80
81
82
def clear(ports, settings, shared):
83
shared.cache.erase_lib('libmpg123.a')
84
85
86
def show():
87
return 'mpg123 (-sUSE_MPG123 or --use-port=mpg123; zlib license)'
88
89