github.com/hwaf/hwaf@v0.0.0-20140814122253-5465f73b20f1/py-hwaftools/find_heppdt.py (about)

     1  # -*- python -*-
     2  
     3  # stdlib imports ---
     4  import os
     5  import os.path as osp
     6  
     7  # waf imports ---
     8  import waflib.Utils
     9  import waflib.Logs as msg
    10  from waflib.Configure import conf
    11  
    12  #
    13  _heptooldir = osp.dirname(osp.abspath(__file__))
    14  
    15  def options(ctx):
    16      ctx.load('hwaf-base', tooldir=_heptooldir)
    17      ctx.add_option(
    18          '--with-heppdt',
    19          default=None,
    20          help="Look for HepPDT at the given path")
    21      return
    22  
    23  def configure(ctx):
    24      ctx.load('hwaf-base', tooldir=_heptooldir)
    25      return
    26  
    27  @conf
    28  def find_heppdt(ctx, **kwargs):
    29      
    30      ctx.load('hwaf-base', tooldir=_heptooldir)
    31  
    32      if not ctx.env.HWAF_FOUND_C_COMPILER:
    33          ctx.fatal('load a C compiler first')
    34          pass
    35  
    36      if not ctx.env.HWAF_FOUND_CXX_COMPILER:
    37          ctx.fatal('load a C++ compiler first')
    38          pass
    39  
    40      # find heppdt
    41      ctx.check_with(
    42          ctx.check,
    43          "heppdt",
    44          features='cxx cxxprogram',
    45          header_name="HepPDT/Version.hh",
    46          lib='HepPDT',
    47          uselib_store='HepPDT',
    48          **kwargs
    49          )
    50  
    51      version = ctx.check_cxx(
    52          msg="Checking HepPDT version",
    53          okmsg="ok",
    54          fragment='''\
    55          #include "HepPDT/Version.hh"
    56          #include <iostream>
    57  
    58          int main(int argc, char* argv[]) {
    59            std::cout << HepPDT::versionName();
    60            return 0;
    61          }
    62          ''',
    63          use="HepPDT",
    64          define_name = "HWAF_HEPPDT_VERSION",
    65          define_ret = True,
    66          execute  = True,
    67          mandatory=True,
    68          )
    69      ctx.start_msg("HepPDT version")
    70      ctx.end_msg(version)
    71  
    72      ctx.env.HEPPDT_VERSION = version
    73      ctx.env.HWAF_FOUND_HEPPDT = 1
    74  
    75  
    76      # find heppid
    77      ctx.check_with(
    78          ctx.check,
    79          "heppdt", # yes... heppdt. re-use the same path for heppid
    80          features='cxx cxxprogram',
    81          header_name="HepPID/Version.hh",
    82          lib='HepPID',
    83          uselib_store='HepPID',
    84          **kwargs
    85          )
    86  
    87      version = ctx.check_cxx(
    88          msg="Checking HepPID version",
    89          okmsg="ok",
    90          fragment='''\
    91          #include "HepPID/Version.hh"
    92          #include <iostream>
    93  
    94          int main(int argc, char* argv[]) {
    95            std::cout << HepPID::versionName();
    96            return 0;
    97          }
    98          ''',
    99          use="HepPID",
   100          define_name = "HWAF_HEPPID_VERSION",
   101          define_ret = True,
   102          execute  = True,
   103          mandatory=True,
   104          )
   105      ctx.start_msg("HepPID version")
   106      ctx.end_msg(version)
   107  
   108      ctx.env.HEPPID_VERSION = version
   109      ctx.env.HWAF_FOUND_HEPPID = 1
   110      return
   111  
   112  ## EOF ##