-
Notifications
You must be signed in to change notification settings - Fork 338
/
Copy pathbuild.py
58 lines (42 loc) · 1.43 KB
/
build.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
#!/usr/bin/env python
import os
import os.path
import shutil
import sys
import stat
def build(source_path, build_path, install_path, targets):
def _build():
# python source
src_py = os.path.join(source_path, "python")
dest_py = os.path.join(build_path, "python")
if not os.path.exists(dest_py):
shutil.copytree(src_py, dest_py)
# binaries
mode = (stat.S_IRUSR | stat.S_IRGRP |
stat.S_IXUSR | stat.S_IXGRP)
src_bin = os.path.join(source_path, "bin")
dest_bin = os.path.join(build_path, "bin")
if not os.path.exists(dest_bin):
shutil.copytree(src_bin, dest_bin)
for name in os.listdir(dest_bin):
filepath = os.path.join(dest_bin, name)
os.chmod(filepath, mode)
def _install():
for name in ("bin", "python"):
src = os.path.join(build_path, name)
dest = os.path.join(install_path, name)
if os.path.exists(dest):
shutil.rmtree(dest)
print(src)
print(dest)
shutil.copytree(src, dest)
_build()
if "install" in (targets or []):
_install()
if __name__ == '__main__':
build(
source_path=os.environ['REZ_BUILD_SOURCE_PATH'],
build_path=os.environ['REZ_BUILD_PATH'],
install_path=os.environ['REZ_BUILD_INSTALL_PATH'],
targets=sys.argv[1:]
)