/[escript]/branches/diaplayground/site_scons/site_tools/nvcc.py
ViewVC logotype

Diff of /branches/diaplayground/site_scons/site_tools/nvcc.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4987 by caltinay, Wed Jun 4 00:59:41 2014 UTC revision 5085 by caltinay, Mon Jun 30 01:20:41 2014 UTC
# Line 12  This file copied with modifications from Line 12  This file copied with modifications from
12  import SCons.Tool  import SCons.Tool
13  import SCons.Scanner.C  import SCons.Scanner.C
14  import SCons.Defaults  import SCons.Defaults
15    import subprocess
16    from tempfile import TemporaryFile
17    
18  CUDASuffixes = ['.cu']  CUDASuffixes = ['.cu']
19    
# Line 19  CUDASuffixes = ['.cu'] Line 21  CUDASuffixes = ['.cu']
21  # cuda uses the c preprocessor, so we can use the CScanner  # cuda uses the c preprocessor, so we can use the CScanner
22  CUDAScanner = SCons.Scanner.C.CScanner()  CUDAScanner = SCons.Scanner.C.CScanner()
23    
24    class ToolCudaWarning(SCons.Warnings.Warning):
25        pass
26    
27    class CudaCompilerNotFound(ToolCudaWarning):
28        pass
29    
30    SCons.Warnings.enableWarningClass(ToolCudaWarning)
31    
32    def _detect(env):
33        """ Try to detect the CUDA compiler """
34        try:
35            nvcc = env['NVCC']
36        except KeyError:
37            nvcc = env.WhereIs('nvcc')
38    
39        try:
40            p=subprocess.call([nvcc,'-V'], stdout=TemporaryFile())
41        except:
42            raise SCons.Errors.StopError(CudaCompilerNotFound(
43                    "The NVIDIA CUDA compiler could not be found. Try setting "
44                    "'nvcc' in your options file or on the command line."))
45        return nvcc
46    
47  def add_common_nvcc_variables(env):  def add_common_nvcc_variables(env):
48    """    """
49    Add underlying common "NVIDIA CUDA compiler" variables that    Add underlying common "NVIDIA CUDA compiler" variables that
# Line 61  def generate(env): Line 86  def generate(env):
86    add_common_nvcc_variables(env)    add_common_nvcc_variables(env)
87    
88    # set the "CUDA Compiler Command" environment variable    # set the "CUDA Compiler Command" environment variable
89    env['NVCC'] = 'nvcc'    env['NVCC'] = _detect(env)
90    env['SHNVCC'] = 'nvcc'    env['SHNVCC'] = env['NVCC']
91        
92    # set the include path, and pass both c compiler flags and c++ compiler flags    # set the include path, and pass both c compiler flags and c++ compiler flags
93    env['NVCCFLAGS'] = SCons.Util.CLVar('')    env['NVCCFLAGS'] = SCons.Util.CLVar('')
# Line 77  def generate(env): Line 102  def generate(env):
102    
103    
104  def exists(env):  def exists(env):
105    return env.Detect('nvcc')    return _detect(env)
106    

Legend:
Removed from v.4987  
changed lines
  Added in v.5085

  ViewVC Help
Powered by ViewVC 1.1.26