LSSTApplications  10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
LSSTDataManagementBasePackage
Classes | Functions
Dependencies and Configuration

Classes

class  lsst.sconsUtils.dependencies.Configuration
 Base class for defining how to configure an LSST sconsUtils package. More...
 
class  lsst.sconsUtils.dependencies.ExternalConfiguration
 A Configuration subclass for external (third-party) packages. More...
 
class  lsst.sconsUtils.dependencies.PackageTree
 A class for loading and managing the dependency tree of a package, as defined by its configuration module (.cfg) file. More...
 

Functions

def lsst.sconsUtils.dependencies.configure
 Recursively configure a package using ups/.cfg files. More...
 
def lsst.sconsUtils.dependencies.CustomCFlagCheck
 A configuration test that checks whether a C compiler supports a particular flag. More...
 
def lsst.sconsUtils.dependencies.CustomCppFlagCheck
 A configuration test that checks whether a C++ compiler supports a particular flag. More...
 
def lsst.sconsUtils.dependencies.CustomCompileCheck
 A configuration test that checks whether the given source code compiles. More...
 
def lsst.sconsUtils.dependencies.CustomLinkCheck
 A configuration test that checks whether the given source code compiles and links. More...
 
def lsst.sconsUtils.dependencies.getLibs
 Get the libraries the package should be linked with. More...
 

Detailed Description

Function Documentation

def lsst.sconsUtils.dependencies.configure (   packageName,
  versionString = None,
  eupsProduct = None,
  eupsProductPath = None,
  noCfgFile = False 
)

Recursively configure a package using ups/.cfg files.

Aliased as lsst.sconsUtils.configure().

Usually, LSST packages will call this function through scripts.BasicSConstruct.

Parameters
packageNameName of the package being built; must correspond to a .cfg file in ups/.
versionStringVersion-control system string to be parsed for version information ($HeadURL$ for SVN).
eupsProductName of the EUPS product being built. Defaults to and is almost always the name of the package.
eupsProductPathAn alternate directory where the package should be installed.
noCfgFileIf True, this package has no .cfg file
Returns
an SCons Environment object (which is also available as lsst.sconsUtils.env).

Definition at line 39 of file dependencies.py.

39 
40 def configure(packageName, versionString=None, eupsProduct=None, eupsProductPath=None, noCfgFile=False):
41  if not state.env.GetOption("no_progress"):
42  state.log.info("Setting up environment to build package '%s'." % packageName)
43  if eupsProduct is None:
44  eupsProduct = packageName
45  if versionString is None:
46  versionString = "git"
47  state.env['eupsProduct'] = eupsProduct
48  state.env['packageName'] = packageName
49  #
50  # Setup installation directories and variables
51  #
52  SCons.Script.Help(state.opts.GenerateHelpText(state.env))
53  state.env.installing = [t for t in SCons.Script.BUILD_TARGETS if t == "install"]
54  state.env.declaring = [t for t in SCons.Script.BUILD_TARGETS if t == "declare" or t == "current"]
55  state.env.linkFarmDir = state.env.GetOption("linkFarmDir")
56  if state.env.linkFarmDir:
57  state.env.linkFarmDir = os.path.abspath(os.path.expanduser(state.env.linkFarmDir))
58  prefix = installation.setPrefix(state.env, versionString, eupsProductPath)
59  state.env['prefix'] = prefix
60  state.env["libDir"] = "%s/lib" % prefix
61  state.env["pythonDir"] = "%s/python" % prefix
62  #
63  # Process dependencies
64  #
65  state.log.traceback = state.env.GetOption("traceback")
66  state.log.verbose = state.env.GetOption("verbose")
67  packages = PackageTree(packageName, noCfgFile=noCfgFile)
68  state.log.flush() # if we've already hit a fatal error, die now.
69  state.env.libs = {"main":[], "python":[], "test":[]}
70  state.env.doxygen = {"tags":[], "includes":[]}
71  state.env['CPPPATH'] = []
72  state.env['LIBPATH'] = []
73 
74  # XCPPPATH is a new variable defined by sconsUtils - it's like CPPPATH, but the headers
75  # found there aren't treated as dependencies. This can make scons a lot faster.
76  state.env['XCPPPATH'] = []
77  state.env['_CPPINCFLAGS'] = \
78  "$( ${_concat(INCPREFIX, CPPPATH, INCSUFFIX, __env__, RDirs, TARGET, SOURCE)}"\
79  " ${_concat(INCPREFIX, XCPPPATH, INCSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)"
80  state.env['_SWIGINCFLAGS'] = state.env['_CPPINCFLAGS'].replace("CPPPATH", "SWIGPATH")
81 
82  if state.env.linkFarmDir:
83  for d in [state.env.linkFarmDir, "#"]:
84  state.env.Append(CPPPATH=os.path.join(d, "include"))
85  state.env.Append(LIBPATH=os.path.join(d, "lib"))
86  state.env['SWIGPATH'] = state.env['CPPPATH']
87 
88  if not state.env.GetOption("clean") and not state.env.GetOption("help"):
89  packages.configure(state.env, check=state.env.GetOption("checkDependencies"))
90  for target in state.env.libs:
91  state.log.info("Libraries in target '%s': %s" % (target, state.env.libs[target]))
92  state.env.dependencies = packages
93  state.log.flush()
94 
95 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
def configure
Recursively configure a package using ups/.cfg files.
Definition: dependencies.py:39
A class for loading and managing the dependency tree of a package, as defined by its configuration mo...
def lsst.sconsUtils.dependencies.CustomCFlagCheck (   context,
  flag,
  append = True 
)

A configuration test that checks whether a C compiler supports a particular flag.

Parameters
contextConfiguration context.
flagFlag to test, e.g. "-fvisibility-inlines-hidden".
appendAutomatically append the flag to context.env["CCFLAGS"] if the compiler supports it?

Definition at line 306 of file dependencies.py.

307 def CustomCFlagCheck(context, flag, append=True):
308  context.Message("Checking if C compiler supports " + flag + " flag ")
309  ccflags = context.env["CCFLAGS"];
310  context.env.Append(CCFLAGS = flag)
311  result = context.TryCompile("int main(int argc, char **argv) { return 0; }", ".c")
312  context.Result(result)
313  if not append or not result:
314  context.env.Replace(CCFLAGS = ccflags)
315  return result
def CustomCFlagCheck
A configuration test that checks whether a C compiler supports a particular flag. ...
def lsst.sconsUtils.dependencies.CustomCompileCheck (   context,
  message,
  source,
  extension = ".cc" 
)

A configuration test that checks whether the given source code compiles.

Parameters
contextConfiguration context.
messageMessage disaplyed on console prior to running the test.
sourceSource code to compile. param extension Identifies the language of the source code. Use ".c" for C, and ".cc" for C++ (the default).

Definition at line 344 of file dependencies.py.

345 def CustomCompileCheck(context, message, source, extension=".cc"):
346  context.Message(message)
347 
348  env = context.env
349  if (env.GetOption("clean") or env.GetOption("help") or env.GetOption("no_exec")):
350  result = True
351  else:
352  result = context.TryCompile(source, extension)
353 
354  context.Result(result)
355 
356  return result
def CustomCompileCheck
A configuration test that checks whether the given source code compiles.
def lsst.sconsUtils.dependencies.CustomCppFlagCheck (   context,
  flag,
  append = True 
)

A configuration test that checks whether a C++ compiler supports a particular flag.

Parameters
contextConfiguration context.
flagFlag to test, e.g. "-fvisibility-inlines-hidden".
appendAutomatically append the flag to context.env["CXXFLAGS"] if the compiler supports it?

Definition at line 325 of file dependencies.py.

326 def CustomCppFlagCheck(context, flag, append=True):
327  context.Message("Checking if C++ compiler supports " + flag + " flag ")
328  cxxflags = context.env["CXXFLAGS"];
329  context.env.Append(CXXFLAGS = flag)
330  result = context.TryCompile("int main(int argc, char **argv) { return 0; }", ".cc")
331  context.Result(result)
332  if not append or not result:
333  context.env.Replace(CXXFLAGS = cxxflags)
334  return result
def CustomCppFlagCheck
A configuration test that checks whether a C++ compiler supports a particular flag.
def lsst.sconsUtils.dependencies.CustomLinkCheck (   context,
  message,
  source,
  extension = ".cc" 
)

A configuration test that checks whether the given source code compiles and links.

Parameters
contextConfiguration context.
messageMessage disaplyed on console prior to running the test.
sourceSource code to compile. param extension Identifies the language of the source code. Use ".c" for C, and ".cc" for C++ (the default).

Definition at line 366 of file dependencies.py.

367 def CustomLinkCheck(context, message, source, extension=".cc"):
368  context.Message(message)
369  result = context.TryLink(source, extension)
370  context.Result(result)
371  return result
372 
373 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
def CustomLinkCheck
A configuration test that checks whether the given source code compiles and links.
def lsst.sconsUtils.dependencies.getLibs (   env,
  categories = "main" 
)

Get the libraries the package should be linked with.

Parameters
categoriesA string containing whitespace-delimited categories. Standard categories are "main", "python", and "test". Default is "main". A special virtual category "self" can be provided, returning the results of targets="main" with the env["packageName"] removed.

Typically, main libraries will be linked with LIBS=getLibs("self"), Python modules will be linked with LIBS=getLibs("main python") and C++-coded test programs will be linked with LIBS=getLibs("main test"). """

Definition at line 549 of file dependencies.py.

550 def getLibs(env, categories="main"):
551  libs = []
552  removeSelf = False
553  for category in categories.split():
554  if category == "self":
555  category = "main"
556  removeSelf = True
557  for lib in env.libs[category]:
558  if lib not in libs:
559  libs.append(lib)
560  if removeSelf:
561  try:
562  libs.remove(env["packageName"])
563  except ValueError:
564  pass
565  return libs
566 
567 SConsEnvironment.getLibs = getLibs
def getLibs
Get the libraries the package should be linked with.