#! /usr/bin/python

# @file
# This file is part of SWE.
#
# @author Alexander Breuer (breuera AT in.tum.de, http://www5.in.tum.de/wiki/index.php/Dipl.-Math._Alexander_Breuer)
#
# @section LICENSE
#
# SWE is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# SWE is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with SWE.  If not, see <http://www.gnu.org/licenses/>.
#
#
# @section DESCRIPTION
#
# Definition of the source files.
#

Import('env')

# Code without CUDA
if env['parallelization'] not in ['cuda', 'mpi_with_cuda']:
  if env['solver'] != 'rusanov':
    sourceFiles = ['SWE_WavePropagationBlock.cpp']
  else:
    sourceFiles = ['SWE_RusanovBlock.cpp']

# Code with CUDA
else:
  sourceFiles = [ 'SWE_BlockCUDA.cu',
                  'SWE_BlockCUDA_kernels.cu']
  if env['solver'] == 'rusanov':
    sourceFiles.append( [ 'SWE_RusanovBlockCUDA.cu',
                          'SWE_RusanovBlockCUDA_kernels.cu']
                      )
  elif env['solver'] == 'fwave':
    sourceFiles.append( [ 'SWE_WavePropagationBlockCuda.cu',
                          'SWE_WavePropagationBlockCuda_kernels.cu']
                      )
  if env['openGL'] == True:
    sourceFiles.append( ['opengl/simulation.cu'] )
  
# compile the files defined so far, important step because of possible different compilers                  
for i in sourceFiles:
  env.src_files.append(env.Object(i))

# SWE_Block is used in every implementation
sourceFiles = ['SWE_Block.cpp']

# OpenGL CPU-files
if env['openGL'] == True:
  sourceFiles.append( ['scenarios/SWE_VtkScenario.cpp'] )
  sourceFiles.append( ['scenarios/SWE_VtkScenarioVisInfo.cpp'] )
  sourceFiles.append( ['opengl/camera.cpp'] )
  sourceFiles.append( ['opengl/controller.cpp'] )
  sourceFiles.append( ['opengl/shader.cpp'] )
  sourceFiles.append( ['opengl/visualization.cpp'] )

# netCDF writer
if env['writeNetCDF'] == True:
  sourceFiles.append( ['tools/NetCdfWriter.cpp'] )

# xml reader
if env['xmlRuntime'] == True:
  sourceFiles.append( ['tools/CXMLConfig.cpp'] )

# file containing the main-function
if env['parallelization'] in ['none', 'cuda']:
  if env['solver'] != 'rusanov':
    if env['openGL'] == False:
      sourceFiles.append( ['examples/swe_wavepropagation.cpp'] )
    else:
      sourceFiles.append( ['examples/swe_opengl.cpp'] )
  else:
   print '** The selected configuration is not implemented.'
   Exit(1)
elif env['parallelization'] in ['mpi_with_cuda', 'mpi']:
    sourceFiles.append( ['examples/swe_mpi.cpp'] )
else:
  print '** The selected configuration is not implemented.'
  Exit(1)

# CPU compilation for sure
for i in sourceFiles:
  env.src_files.append(env.Object(i))

Export('env')
