Package mbuild
[frames] | no frames]

Source Code for Package mbuild

  1  #BEGIN_LEGAL 
  2  # 
  3  #Copyright (c) 2016 Intel Corporation 
  4  # 
  5  #  Licensed under the Apache License, Version 2.0 (the "License"); 
  6  #  you may not use this file except in compliance with the License. 
  7  #  You may obtain a copy of the License at 
  8  # 
  9  #      http://www.apache.org/licenses/LICENSE-2.0 
 10  # 
 11  #  Unless required by applicable law or agreed to in writing, software 
 12  #  distributed under the License is distributed on an "AS IS" BASIS, 
 13  #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 14  #  See the License for the specific language governing permissions and 
 15  #  limitations under the License. 
 16  #   
 17  #END_LEGAL 
 18  # __init__.py 
 19  # Mark Charney  
 20  """This is mbuild: a simple portable dependence-based build-system 
 21  written in python. 
 22   
 23  mbuild is a python-based build system very similar to scons with some 
 24  philosophical features of make.  mbuild exposes the scan and build phases 
 25  allowing them to be repeated  as necessary. Multiple DAGs can be 
 26  built, one during each scan phase. 
 27   
 28  Conceptually there are 3 major components to mbuild: 
 29    - The environment L{env_t} 
 30    - The directed acyclic graph  L{dag_t} 
 31    - The work queue L{work_queue_t} 
 32   
 33  Using the environment L{env_t} you customize your build configuration 
 34  and construct names for your source files, object files, executables, 
 35  etc.  The environment contains builder methods that create L{plan_t} 
 36  objects. There are builders for C, C++, static and dynamic libraries, 
 37  assembly files and linking programs. The environment and builders 
 38  support string substitution. 
 39   
 40  The L{plan_t} objects are passed to the L{dag_t} which stores the 
 41  dependences that order execution. The L{plan_t} objects describe work 
 42  that needs to be done. Plans typically contain a command line strings 
 43  (with all substitutions done), but can also be python functions that 
 44  will be executed during the build. 
 45   
 46  Using the L{plan_t} objects, the L{dag_t} creates L{command_t} 
 47  objects that are passed to the L{work_queue_t} to ultimately build the 
 48  target or targets. 
 49   
 50  Your build file can have multiple environments, DAGS and work queues. 
 51   
 52   
 53  Using the environment dictionary 
 54  ================================ 
 55   
 56  You can bind or augmenting environment variables from the command 
 57  line. For example, one can say C{build_cpu=ia32} on an x86-64 system 
 58  to change the default compilation behavior.  Similarly, one can say 
 59  C{CXXFLAGS+=-g} to add the C{-g} flag to the existing C{CXXFLAGS} 
 60  variable. 
 61   
 62  Dynamic substitution is also used. Patterns of the form %(I{string})s 
 63  will substitute I{string} dynamically before it is used.  The 
 64  expansion can happen directly from the environment and is 
 65  recursive. The expansion can also use dictionaries that are variables 
 66  in the environment.  A dictionary in the environment is really a tuple 
 67  of the key-variable and the dictionary itself. 
 68   
 69  For example:: 
 70   
 71      env['opt_flag'] = ( 'opt', {'noopt':'', 
 72                                  '0':'%(OPTOPT)s0', 
 73                                  '1':'%(OPTOPT)s1', 
 74                                  '2':'%(OPTOPT)s2', 
 75                                  '3':'%(OPTOPT)s3', 
 76                                  '4':'%(OPTOPT)s4'} ) 
 77   
 78      env['OPTOPT'] = ( 'compiler', { 'gnu':'-O', 
 79                                      'ms':'/O'}) 
 80   
 81   
 82      env['CXXFLAGS'] += ' %(opt_flag)s' 
 83   
 84  The C{OPTOPT} variable depends on C{env['compiler']}. 
 85  If C{env['compiler']='gnu'} then C{env['OPTOPT']} expands to C{-O}. 
 86  If C{env['compiler']='ms'} then C{env['OPTOPT']} expands to C{/O}. 
 87   
 88  If the C{opt} variable is set "C{opt=3}" on the command line, or equivalently 
 89  if C{env['opt']='3'} is 
 90  set in the script, 
 91  then if the C{env['compiler']='gnu'} in the environment at the time of expansion, 
 92  then the flag in the 
 93  C{CXXFLAGS} will be C{-O3}. If C{env['compiler']='ms'} at the time of expansion, 
 94  then the optimiation 
 95  flag would be C{/O3}.  If C{opt=noopt} (on the command line) then there will be no 
 96  optimization flag in the C{CXXFLAGS}. 
 97   
 98   
 99  Introspection 
100  ============= 
101   
102  The L{command_t} that are executed during the build have their output 
103  (stdout/stderr) stored in the L{dag_t}. After a build it is possible 
104  to collect the commands using the L{dag_t.results} function  and analyze the 
105  output. This is very handy for test and validation suites. 
106  """  
107   
108  from base import * 
109  from dag import * 
110  from work_queue import * 
111  from env import * 
112  from util import * 
113  from plan import * 
114  from arar import * 
115  from doxygen import doxygen_run, doxygen_args, doxygen_env 
116  from header_tag import * 
117   
118  __all__ = [ 'base', 
119              'dag', 
120              'work_queue', 
121              'env', 
122              'util', 
123              'plan', 
124              'msvs', 
125              'arar', 
126              'doxygen', 
127              'dfs', 
128              'header_tag' ] 
129   
130   
131  import time 
132 -def mbuild_exit():
133 """mbuild's exit function"""
134 #print "SLEEPING" 135 #time.sleep(0.5) 136 #print "EXITING" 137 138 import atexit 139 atexit.register(mbuild_exit) 140