def options(ctx):
	ctx.add_option('--target', action='store', default='xua_lite_example.xe')
	ctx.add_option('--debug', action='store_true')


def configure(conf):
	conf.load('xwaf.compiler_xcc')
	conf.env.PROJECT_ROOT = '../../..'

def build(bld):
	target_path = 'bin/' + bld.options.target
	bld.env.TARGET_ARCH ='config/RPI_HAT_60QFN.xn'
	bld.env.XSCOPE = bld.path.find_resource('config.xscope')
	depends_on = ['lib_xua','lib_i2s','lib_xud','lib_mic_array', 'lib_i2c']
	#bld.env.XCC_FLAGS = ['-O2', '-g', '-Wall', '-fcmdline-buffer-bytes=512', '-report', '-DDISABLE_STAGE_C']
        bld.env.XCC_FLAGS = ['-fcomment-asm','-Xmapper','--map','-Xmapper','MAPFILE',
                     '-Os','-report','-g','-Wno-unused-function','-Wno-timing',
                     '-DXUD_SERIES_SUPPORT=XUD_X200_SERIES','-DUSB_TILE=tile[1]',
		     '-DMIC_ARRAY_CH0=PIN0','-DMIC_ARRAY_CH1=PIN4', '-DDEBUG_PRINT_ENABLE=1']
	if bld.options.debug:
		bld.env.XCC_FLAGS.append('-DDEBUG')

	source = bld.path.ant_glob(['src/**/*.xc', 'src/**/*.c',
                                    'xua_lite/**/*.xc', 'xua_lite/**/*.c'])
        includes = ['config']
	bld.program(source=source, includes=includes, depends_on=depends_on,target=target_path)
