tapasco-build-libs 2.23 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 30
moddir = '$TAPASCO_HOME/platform/$TAPASCO_PLATFORM/module'
pdir   = '$TAPASCO_HOME/platform/$TAPASCO_PLATFORM/build'
adir   = '$TAPASCO_HOME/arch/baseline/build'
31 32 33 34 35 36 37 38

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

if not clean:
	if debug:
39
		print('Building debug mode libraries...')
40
	else:
41 42 43 44
		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)
45
	
46
	if os.environ['TAPASCO_PLATFORM'] is 'vc709':
47 48 49 50 51 52
		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)