tapasco-build-libs 2.48 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/python
import argparse
import sys
import subprocess
from   socket import gethostname
import os

parser = argparse.ArgumentParser()
parser.add_argument('--mode', help='build mode (default: %(default)s)', default='release', choices=['clean', 'release', 'debug', 'driver_debug'])
parser.add_argument('--rebuild', help='force rebuild libs (default: %(default)s)', action='store_true')
args = parser.parse_args()

clean        = args.mode == 'clean'
debug        = args.mode == 'debug' or args.mode == 'driver_debug'
driver_debug = args.mode == 'driver_debug'

print 'Build mode: ' + args.mode

19
20
if not 'TAPASCO_PLATFORM' in os.environ:
	print('Environment variable TAPASCO_PLATFORM is not set, guessing Platform ...')
21
	if gethostname() in ['zed', 'zedboard', 'zc706', 'zynq', 'pynq']:
22
		os.environ['TAPASCO_PLATFORM'] = 'zynq'
23
	else:
24
		os.environ['TAPASCO_PLATFORM'] = 'vc709'
25

26
print('Platform: ' + os.environ['TAPASCO_PLATFORM'])
27

28
29
moddir = '$TAPASCO_HOME/platform/$TAPASCO_PLATFORM/module'
pdir   = '$TAPASCO_HOME/platform/$TAPASCO_PLATFORM/build'
30
adir   = '$TAPASCO_HOME/arch/axi4mm/build'
31
tdir   = '$TAPASCO_HOME/arch/tests/build'
32
33
34
35

if clean or args.rebuild:
	subprocess.call(['rm -rf ' + pdir], shell=True)
	subprocess.call(['rm -rf ' + adir], shell=True)
36
	subprocess.call(['rm -rf ' + tdir], shell=True)
37
38
39
40
	subprocess.call(['cd ' + moddir + ' && make clean'], shell=True)

if not clean:
	if debug:
41
		print('Building debug mode libraries...')
42
	else:
43
44
45
46
		print('Building release mode libraries, pass "debug" as first argument to build debug libs...')
	
	if not os.environ['LINUX_HOME'] is None:
		subprocess.call(['make -C ' + os.environ['LINUX_HOME'] + ' scripts'], shell=True)
47
	
48
	if os.environ['TAPASCO_PLATFORM'] is 'vc709':
49
50
51
52
53
54
		print 'cd ' + moddir + ' && make ' + ('DEBUG_VERBOSE=y ' if driver_debug else ' ')
		subprocess.call(['cd ' + moddir + ' && make ' + ('DEBUG_VERBOSE=y ' if driver_debug else ' ')], shell=True)
	else:
		subprocess.call(['cd ' + moddir + ' && make ' + ('' if driver_debug else 'release ')], shell=True)
	subprocess.call(['mkdir -p ' + pdir + ' && cd ' + pdir + ' && cmake ' + ('' if debug else '-DCMAKE_BUILD_TYPE=Release') + ' .. && make && make install'], shell=True)
	subprocess.call(['mkdir -p ' + adir + ' && cd ' + adir + ' && cmake ' + ('' if debug else '-DCMAKE_BUILD_TYPE=Release') + ' .. && make && make install'], shell=True)
55
	subprocess.call(['mkdir -p ' + tdir + ' && cd ' + tdir + ' && cmake ' + ('' if debug else '-DCMAKE_BUILD_TYPE=Release') + ' .. && make && make install'], shell=True)