8 __version__ = 
"$Revision: 795362 $" 
    9 __author__ = 
"Will buttinger" 
   10 __doc__ = 
"streamline and ease the creation of new cmake packages" 
   16 import PyUtils.acmdlib 
as acmdlib
 
   24     help=
"(fully qualified) name of the new package" 
   29     help=
'name of the author of this new package' 
   33     """create a new cmake package with sensible atlas-oriented defaults 
   36      $ acmd cmake new-pkg Control/MyContainer/NewPackage 
   40     full_pkg_name = args.pkgname
 
   41     if full_pkg_name[0] == 
'/':
 
   42         full_pkg_name = full_pkg_name[1:]
 
   44     pkg_path = os.path.dirname(os.getcwd() + 
"/" + full_pkg_name)
 
   45     pkg_name = os.path.basename(full_pkg_name)
 
   46     pkg_vers = 
'%s-00-00-00' % pkg_name
 
   47     author = os.path.expanduser(os.path.expandvars(args.author))
 
   49     if os.path.exists(pkg_path+
"/"+pkg_name):
 
   50         print(
"ERROR: %s package already exists" % full_pkg_name)
 
   53     print(textwrap.dedent(
"""\ 
   54     ::: creating package [%(full_pkg_name)s]... 
   55     :::   - pkg name:    %(pkg_name)s 
   56     :::   - pkg version: %(pkg_vers)s 
   57     :::   - pkg path:    %(pkg_path)s 
   58     :::   - author:      %(author)s""" % locals()))
 
   63         os.makedirs(pkg_path+
"/"+pkg_name+
"/"+pkg_name)
 
   64         os.makedirs(pkg_path+
"/"+pkg_name+
"/src")
 
   65         os.makedirs(pkg_path+
"/"+pkg_name+
"/share")
 
   66         os.makedirs(pkg_path+
"/"+pkg_name+
"/python")
 
   67         with open(pkg_path+
"/"+pkg_name+
"/python/__init__.py",
'w') 
as f: 
pass 
   68         os.makedirs(pkg_path+
"/"+pkg_name+
"/data")
 
   69         with open(pkg_path+
"/"+pkg_name+
"/data/ExampleData",
'w') 
as f: f.write(
"this file will be accessible through PathResolverFindDataFile(\""+pkg_name+
"/ExampleData\")")
 
   70         os.makedirs(pkg_path+
"/"+pkg_name+
"/util")
 
   71         os.makedirs(pkg_path+
"/"+pkg_name+
"/scripts")
 
   73         print(
"ERROR while making directories for " % (pkg_path+
"/"+pkg_name+
"/src"))
 
   77     with open(os.path.join(pkg_path+
"/"+pkg_name,
'CMakeLists.txt'), 
'w') 
as req:
 
   78         print(textwrap.dedent(
"""\ 
   79         ## automatically generated CMakeLists.txt file 
   82         atlas_subdir( %(pkg_name)s ) 
   84         # Declare external dependencies ... default here is to include ROOT 
   85         find_package( ROOT COMPONENTS MathCore RIO Core Tree Hist ) 
   87         # Declare public and private dependencies 
   88         # Public dependencies are anything that appears in the headers in public include dir 
   89         # Private is anything else 
   91         # An example is included 
   92         atlas_depends_on_subdirs( 
   96             # Control/AthAnalysisBaseComps 
   99         # Declare package as a library 
  100         # Note the convention that library names get "Lib" suffix 
  101         # Any package you add to dependencies above, you should add 
  102         # to LINK_LIBRARIES line below (see the example) 
  103         atlas_add_library( %(pkg_name)sLib src/*.cxx 
  104                            PUBLIC_HEADERS %(pkg_name)s 
  105                            INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} 
  106                            LINK_LIBRARIES ${ROOT_LIBRARIES} 
  107                                             #AthAnalysisBaseCompsLib 
  110         # if you add components (tools, algorithms) to this package 
  111         # uncomment the next lines 
  112         # atlas_add_component( %(pkg_name)s src/components/*.cxx 
  114         #                      LINK_LIBRARIES %(pkg_name)sLib  
  117         # if you add an application (exe) to this package 
  118         # declare it like this (note convention that apps live in util dir) 
  119         # atlas_add_executable( MyApp util/myApp.cxx 
  120         #                       LINK_LIBRARIES %(pkg_name)sLib 
  123         # Install python modules, joboptions, and share content 
  124         atlas_install_python_modules( python/*.py ) 
  125         atlas_install_joboptions( share/*.py ) 
  126         atlas_install_data( data/* ) 
  127         # You can access your data from code using path resolver, e.g. 
  128         # PathResolverFindCalibFile("%(pkg_name)s/file.txt") 
  131         """%locals()),file=req)
 
  134     with open(os.path.join(pkg_path+
"/"+pkg_name,
'version.cmake'), 
'w') 
as req:
 
  135         print((
"%s-00-00-01" % pkg_name),file=req)
 
  139     workDir = os.environ.get(
"WorkDir_DIR")
 
  141         print(
"::: ERROR No WorkDir_DIR env var, did you forget to source the setup.sh script?")
 
  142         print( 
"::: ERROR Please do this and reconfigure cmake manually!")
 
  144         print( 
":::  INFO Reconfiguring cmake %s/../." % workDir)
 
  145         res = subprocess.getstatusoutput(
'cmake %s/../.' % workDir)
 
  147             print (
":::  WARNING reconfigure unsuccessful. Please reconfigure manually!")
 
  150     print (
"::: creating package [%(full_pkg_name)s]... [done]" % locals())