-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbuild_external.py
100 lines (88 loc) · 3.02 KB
/
build_external.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
from os import environ
from sys import argv
from contextlib import contextmanager
from build_common import *
DERIVED_FILES_DIR = environ['DERIVED_FILES_DIR']
BUILT_PRODUCTS_DIR = environ['BUILT_PRODUCTS_DIR']
FULL_PRODUCT_NAME = environ['FULL_PRODUCT_NAME']
MACOSX_VERSION_MIN = '10.10'
CFLAGS = f'-mmacosx-version-min={MACOSX_VERSION_MIN}'
CC = f'cc {CFLAGS}'
CXX = f'c++ {CFLAGS}'
SOURCES = {
'unrar': {
'url': 'https://www.rarlab.com/rar/unrarsrc-5.7.5.tar.gz',
},
'rar2fs': {
'url': 'https://github.com/hasse69/rar2fs',
'version': 'v1.27.2',
},
'libzip': {
'url': 'https://github.com/nih-at/libzip',
'version': 'rel-1-5-1',
'cherry-pick': ['49b35508503812dbac5286d3f6dda53cdb7b7b59']
},
'fuse-zip': {
'url': 'https://bitbucket.org/agalanin/fuse-zip',
'version': '0.5.0'
}
}
@contextmanager
def cloned(component, vcs = 'git'):
url = SOURCES[component]['url']
version = SOURCES[component]['version']
rmrf(component)
run(f'{vcs} clone "{url}" "{component}"')
with cd(component):
run(f'{vcs} checkout "{version}"')
if 'cherry-pick' in SOURCES[component]:
for commit in SOURCES[component]['cherry-pick']:
run(f'{vcs} cherry-pick "{commit}"')
yield
def build_libunrar():
rmrf('unrar')
run(f'curl -o - "{SOURCES["unrar"]["url"]}" | tar xvzf -')
with cd('unrar'):
make(f'lib CXX="{CXX}"')
def build_rar2fs():
build_libunrar()
with cloned('rar2fs'):
run('autoreconf -f -i 2> /dev/null')
run(f'ac_cv_func_utimensat=no CC="{CC}" CXX="{CXX}" ./configure --with-fuse=/usr/local/include/osxfuse --with-unrar=../unrar')
make('rar2fs')
def build_libzip():
with cloned('libzip'):
run('mkdir build')
with cd('build'):
run(f'CC="{CC}" CXX="{CXX}" cmake -DBUILD_SHARED_LIBS=OFF ..')
make()
def build_fusezip():
build_libzip()
with cloned('fuse-zip', 'hg'):
DERIVED_FILES_DIR_E = DERIVED_FILES_DIR.replace(" ", "\ ")
ZIPFLAGS=f'-I{DERIVED_FILES_DIR_E}/libzip/lib -I{DERIVED_FILES_DIR_E}/libzip/build'
LIBS=f'-Llib -lfusezip \$(shell pkg-config fuse --libs) -L{DERIVED_FILES_DIR_E}/libzip/build/lib -lzip -lz -lbz2'
make(f'ZIPFLAGS="{ZIPFLAGS}" LIBS="{LIBS}" CXX="{CXX} -std=c++11"')
def build_all():
build_rar2fs()
build_fusezip()
def copy_all():
targetDir = f'{BUILT_PRODUCTS_DIR}/{FULL_PRODUCT_NAME}/Contents/Executables'
run(f'mkdir -p "{targetDir}"')
run(f'cp rar2fs/rar2fs "{targetDir}"')
run(f'cp fuse-zip/fuse-zip "{targetDir}"')
if __name__ == '__main__':
PATH = environ['PATH']
HOME = environ['HOME']
environ.clear()
environ['PATH'] = PATH
environ['HOME'] = HOME
if len(argv) != 2:
raise Exception('Wrong number of arguments')
with cd(DERIVED_FILES_DIR):
if argv[1] == 'build':
build_all()
elif argv[1] == 'copy':
copy_all()
else:
raise Exception('Wrong arguments')