#!/usr/bin/env python

import os

Import('envzerodop')
envGPUtopozero = envzerodop.Clone()
package = envGPUtopozero['PACKAGE']
project = 'GPUtopozero'
envGPUtopozero['PROJECT'] = project
install = envGPUtopozero['PRJ_SCONS_INSTALL'] + '/' + package + '/' + project

###Fixing current name clash in isceLib and utilLib
util_package_path = package.split('/')
util_package_path = [util_package_path[0],'isceobj','Util','Library','include']
util_package_path = '/'.join(util_package_path)
old_lib_path = os.path.join(envGPUtopozero['PRJ_SCONS_BUILD'],util_package_path)
cpp_path = []
for path in envGPUtopozero['CPPPATH']:
    if path != old_lib_path:
        cpp_path.append(path)
envGPUtopozero['CPPPATH'] = cpp_path

initFile = '__init__.py'
if not os.path.exists(initFile):
    with open(initFile, 'w') as fout:
        fout.write('#!/usr/bin/env python3')

listFiles = [initFile]
envGPUtopozero.Install(install, listFiles)
envGPUtopozero.Alias('install', install)
Export('envGPUtopozero')

build = envGPUtopozero['PRJ_SCONS_BUILD'] + '/' + package + '/' + project + '/src'
envGPUtopozero.Install(build,'GPUtopozero.pyx')
envGPUtopozero.Alias('install', build)

###include
includeScons = 'include/SConscript'
SConscript(includeScons)

cudaScons = 'cuda/SConscript'
SConscript(cudaScons)

###src
srcScons = 'src/SConscript'
SConscript(srcScons, variant_dir = build)
