Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/tools/ports/libmodplug.py
4130 views
1
# Copyright 2021 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 = '11022021'
10
HASH = 'f770031ad6c2152cbed8c8eab8edf2be1d27f9e74bc255a9930c17019944ee5fdda5308ea992c66a78af9fe1d8dca090f6c956910ce323f8728247c10e44036b'
11
12
13
def needed(settings):
14
return settings.USE_MODPLUG
15
16
17
def get(ports, settings, shared):
18
ports.fetch_project('libmodplug', f'https://github.com/jancc/libmodplug/archive/v{TAG}.zip', sha512hash=HASH)
19
20
def create(final):
21
source_path = ports.get_dir('libmodplug', 'libmodplug-' + TAG)
22
src_dir = os.path.join(source_path, 'src')
23
libmodplug_path = os.path.join(src_dir, 'libmodplug')
24
25
config_h = os.path.join(os.path.dirname(__file__), 'libmodplug/config.h')
26
shutil.copyfile(config_h, os.path.join(source_path, 'config.h'))
27
28
flags = [
29
'-Wno-deprecated-register',
30
'-DOPT_GENERIC',
31
'-DREAL_IS_FLOAT',
32
'-DHAVE_CONFIG_H',
33
'-DSYM_VISIBILITY',
34
'-std=gnu++14',
35
'-fno-exceptions',
36
'-ffast-math',
37
'-fno-common',
38
'-fvisibility=hidden',
39
'-I' + source_path,
40
'-I' + libmodplug_path,
41
]
42
srcs = [
43
os.path.join(src_dir, 'fastmix.cpp'),
44
os.path.join(src_dir, 'load_669.cpp'),
45
os.path.join(src_dir, 'load_abc.cpp'),
46
os.path.join(src_dir, 'load_amf.cpp'),
47
os.path.join(src_dir, 'load_ams.cpp'),
48
os.path.join(src_dir, 'load_dbm.cpp'),
49
os.path.join(src_dir, 'load_dmf.cpp'),
50
os.path.join(src_dir, 'load_dsm.cpp'),
51
os.path.join(src_dir, 'load_far.cpp'),
52
os.path.join(src_dir, 'load_it.cpp'),
53
os.path.join(src_dir, 'load_j2b.cpp'),
54
os.path.join(src_dir, 'load_mdl.cpp'),
55
os.path.join(src_dir, 'load_med.cpp'),
56
os.path.join(src_dir, 'load_mid.cpp'),
57
os.path.join(src_dir, 'load_mod.cpp'),
58
os.path.join(src_dir, 'load_mt2.cpp'),
59
os.path.join(src_dir, 'load_mtm.cpp'),
60
os.path.join(src_dir, 'load_okt.cpp'),
61
os.path.join(src_dir, 'load_pat.cpp'),
62
os.path.join(src_dir, 'load_psm.cpp'),
63
os.path.join(src_dir, 'load_ptm.cpp'),
64
os.path.join(src_dir, 'load_s3m.cpp'),
65
os.path.join(src_dir, 'load_stm.cpp'),
66
os.path.join(src_dir, 'load_ult.cpp'),
67
os.path.join(src_dir, 'load_umx.cpp'),
68
os.path.join(src_dir, 'load_wav.cpp'),
69
os.path.join(src_dir, 'load_xm.cpp'),
70
os.path.join(src_dir, 'mmcmp.cpp'),
71
os.path.join(src_dir, 'modplug.cpp'),
72
os.path.join(src_dir, 'snd_dsp.cpp'),
73
os.path.join(src_dir, 'sndfile.cpp'),
74
os.path.join(src_dir, 'snd_flt.cpp'),
75
os.path.join(src_dir, 'snd_fx.cpp'),
76
os.path.join(src_dir, 'sndmix.cpp'),
77
]
78
79
ports.build_port(source_path, final, 'libmodplug', flags=flags, srcs=srcs)
80
81
ports.install_headers(libmodplug_path, pattern="*.h", target='libmodplug')
82
ports.install_headers(src_dir, pattern="modplug.h", target='libmodplug')
83
ports.make_pkg_config('libmodplug', TAG, '-sUSE_MODPLUG')
84
85
return [shared.cache.get_lib('libmodplug.a', create, what='port')]
86
87
88
def clear(ports, settings, shared):
89
shared.cache.erase_lib('libmodplug.a')
90
91
92
def show():
93
return 'libmodplug (-sUSE_MODPLUG or --use-port=libmodplug; public domain)'
94
95