parameters: (source_dir, action_if_fail, processed_source_dirs, blade)
docstring: _load_build_file to load the BUILD and place the targets into database.
  
      Invoked by _load_targets.  Load and execute the BUILD
      file, which is a Python script, in source_dir.  Statements in BUILD
      depends on global variable current_source_dir, and will register build
      target/rules into global variables target_database.  If path/BUILD
      does NOT exsit, take action corresponding to action_if_fail.  The
      parameters processed_source_dirs refers to a set defined in the
      caller and used to avoid duplicated execution of BUILD files.
docstring_summary: _load_build_file to load the BUILD and place the targets into database.
docstring_tokens: _load_build_file to load the BUILD and place the targets into database .
function: def _load_build_file(source_dir, action_if_fail, processed_source_dirs, blade):
      """_load_build_file to load the BUILD and place the targets into database.
  
      Invoked by _load_targets.  Load and execute the BUILD
      file, which is a Python script, in source_dir.  Statements in BUILD
      depends on global variable current_source_dir, and will register build
      target/rules into global variables target_database.  If path/BUILD
      does NOT exsit, take action corresponding to action_if_fail.  The
      parameters processed_source_dirs refers to a set defined in the
      caller and used to avoid duplicated execution of BUILD files.
  
      """
  
      # Initialize the build_target at first time, to be used for BUILD file
      # loaded by execfile
      global build_target
      if build_target is None:
          build_target = TargetAttributes(blade.get_options())
          build_rules.register_variable('build_target', build_target)
  
      source_dir = os.path.normpath(source_dir)
      # TODO(yiwang): the character '#' is a magic value.
      if source_dir in processed_source_dirs or source_dir == '#':
          return
      processed_source_dirs.add(source_dir)
  
      if not os.path.exists(source_dir):
          _report_not_exist(source_dir, source_dir, blade)
  
      old_current_source_path = blade.get_current_source_path()
      blade.set_current_source_path(source_dir)
      build_file = os.path.join(source_dir, 'BUILD')
      if os.path.exists(build_file):
          try:
              # The magic here is that a BUILD file is a Python script,
              # which can be loaded and executed by execfile().
              execfile(build_file, build_rules.get_all(), None)
          except SystemExit:
              console.error_exit('%s: fatal error, exit...' % build_file)
          except:
              console.error_exit('Parse error in %s, exit...\n%s' % (
                      build_file, traceback.format_exc()))
      else:
          if action_if_fail == ABORT_IF_FAIL:
              _report_not_exist(source_dir, build_file, blade)
  
      blade.set_current_source_path(old_current_source_path)
function_tokens: def _load_build_file ( source_dir , action_if_fail , processed_source_dirs , blade ) : # Initialize the build_target at first time, to be used for BUILD file # loaded by execfile global build_target if build_target is None : build_target = TargetAttributes ( blade . get_options ( ) ) build_rules . register_variable ( 'build_target' , build_target ) source_dir = os . path . normpath ( source_dir ) # TODO(yiwang): the character '#' is a magic value. if source_dir in processed_source_dirs or source_dir == '#' : return processed_source_dirs . add ( source_dir ) if not os . path . exists ( source_dir ) : _report_not_exist ( source_dir , source_dir , blade ) old_current_source_path = blade . get_current_source_path ( ) blade . set_current_source_path ( source_dir ) build_file = os . path . join ( source_dir , 'BUILD' ) if os . path . exists ( build_file ) : try : # The magic here is that a BUILD file is a Python script, # which can be loaded and executed by execfile(). execfile ( build_file , build_rules . get_all ( ) , None ) except SystemExit : console . error_exit ( '%s: fatal error, exit...' % build_file ) except : console . error_exit ( 'Parse error in %s, exit...\n%s' % ( build_file , traceback . format_exc ( ) ) ) else : if action_if_fail == ABORT_IF_FAIL : _report_not_exist ( source_dir , build_file , blade ) blade . set_current_source_path ( old_current_source_path )