TBA: Make sure this function works for libraries under src/testbench as
well and make sure it returns nil, if the library name cannot be determined.
TBA: Update this function to first look for any sources.rb files within the
project folder structure.
960830
def get_library_from_file_path
      return nil if is_outside_project?
      sources_file_dir = find_sources_file_dir 
      if sources_file_dir
        #A sources.rb file was found."
        #Check if an existing library is already mapped to that folder. If so, return that library
        #and otherwise return a new library that is named according to the  folder
        already_mapped_lib = @project.library_mapped_to(sources_file_dir.to_s)
        return already_mapped_lib if already_mapped_lib
        #Use the name of the folder as the library name:"
        lib_dir = sources_file_dir
      else
#        puts "        #Could not find an existing sources.rb file for the given source file"
        lib_dir = get_default_library_dir_from_file_path
      end
      unless lib_dir.nil?
        lib_name = lib_dir.basename.to_s
        Ecic::Library.new(@project, lib_name, get_library_type_from_file_path, :path => lib_dir)
      end
    end
398436
private static URL findLibraryResource(final String libraryFileName) {
    String osName = System.getProperty("os.name").toLowerCase();
    String osArch = System.getProperty("os.arch").toLowerCase();
    String resourceName = null;

    LOG.trace("Load library \"{}\" for os {}:{}", libraryFileName, osName, osArch);

    if (osName.startsWith(OS_WIN)) {
      resourceName = determineWindowsLibrary(libraryFileName, osName, osArch);
    } else if (osName.startsWith(OS_LINUX)) {
      resourceName = determineLinuxLibrary(libraryFileName, osName, osArch);
    } else if (osName.startsWith(OS_FREEBSD)) {
      resourceName = determineFreebsdLibrary(libraryFileName, osName, osArch);
    } else if (osName.startsWith(OS_MAC)) {
      resourceName = determineMacLibrary(libraryFileName);
    } else {
      unsupportedPlatform(osName, osArch);
    }

    URL resource = NativeLoader.class.getResource(resourceName);

    if (null == resource) {
      unsupportedPlatform(osName, osArch, resourceName);
    }

    return resource;
  }
81975
def target_dir( f = nil )
      if File.exists?( config_file_path )
        form_file_name( target_dir_from_config, f )
      else
        form_file_name( File.join( ::Rails.root.to_s, 'public/docs' ), f )
      end
    end
301541
def find_library(name, cached=True, internal=True):
    

    # a new one
    if not cached:
        return cdll.LoadLibrary(_so_mapping[name])

    # from the shared internal set or a new one
    if internal:
        if name not in _internal:
            _internal[name] = cdll.LoadLibrary(_so_mapping[name])
        return _internal[name]

    # a shared one
    return getattr(cdll, _so_mapping[name])
499233
def dlopen_yajl_library
      found = false
      ( expanded_library_names + library_names ).each do |libname|
        begin
          dlopen(libname)
          found = true
          break
        rescue ArgumentError
        end
      end
      raise "cannot find yajl library for platform" unless found
    end
1170842
function extractLibraries (ast, rootFileDir) {
  if (ast.mappings === undefined) return {}
  const useStatement = ast.mappings.filter(function (e) {
    return e.key.value === 'uses'
  })
  if (useStatement[0] === undefined) return {}
  const libraries = useStatement[0].value.mappings.reduce(function (libs, e) {
    const libraryString = fs.readFileSync(path.join(rootFileDir, e.value.value))
    const libraryAst = yap.load(libraryString)
    const libraryJs = {}
    traverse(libraryJs, libraryAst, rootFileDir)
    libs[e.key.value] = libraryJs
    return libs
  }, {})
  const libs = Object.keys(libraries).reduce(function (lib, name) {
    lib[name] = {}
    Object.keys(libraries[name]).map(function (skip) {
      Object.keys(libraries[name][skip]).map(function (key) {
        lib[name][key] = libraries[name][skip][key]
      })
    })
    return lib
  }, {})
  return libs
}
1099731
function (lib) {
            var found = false,
                exists = false,
                path = "./nodes/"+lib+".js";

            if ( !nodes[lib] ) {

                // Try built-in if the file exists
                try {
                    exists = fs.statSync(__dirname + "/" + path);
                } catch (x) {
                    exists = false;
                }

                if( exists && exists.isFile() ) {
                    found = true;
                    try {
                        nodes[lib] = require(path);
                    } catch (z) {
                        log.throw("core", "Requested node \"" + lib + "\" could not be imported. Check that its dependecies is installed.\n\nStack:\n\n"+  z.stack);
                    }
                }

                if ( !found ) {
                    try {
                        // Try external
                        nodes[lib] = require(lib);
                    } catch (y) {
                        log.throw("core", "Requested node \"" + lib + "\" not available (2). Try `npm install " + lib + "`\n\n");
                    }
                }
            }
        }
1248185
def _check_lib(self, remake, compiler, debug, profile):
        
        from os import path
        if self.link is None or not path.isfile(self.link):
            self.makelib(remake, True, compiler, debug, profile)
417979
def find_executable(name)
      @project.from_directory do
        Find.find("kit") do |path|
          next unless path =~ %r{(.*bin)/#{name}$} && File.executable?(path)
          result = Regexp.last_match[1]

          log.debug("found #{name} executable in #{result}")
          return result
        end
      end

      nil
    end
11209
def [](task_name, scopes=nil)
      task_name = task_name.to_s
      self.lookup(task_name, scopes) or
        enhance_with_matching_rule(task_name) or
        synthesize_file_task(task_name) or
        fail "Don't know how to build task '#{task_name}'"
    end
206187
def install?
      s = super
      return s unless s
      fail InstallFailed, 'No file source path specified.' if source_path.nil?
      fail InstallFailed, "Source path does not exist: #{source}" unless File.exist? source_path
      true
    end
1035090
function getSourceDirectories() {
	var dirs = [ 'lib', 'src', 'app' ],
		result = [];

	dirs.forEach(function(dir) {
		if (test('-d', dir)) {
			result.push(dir);
		}
	});

	return result;
}
384843
function _addLibrary(app, item) {
  if (!item.name || item.name === '') {
    try {
      if (typeof item.fn.publicName === 'string') item.name = item.fn.publicName;
    } catch (e) {
    }
  }
  item.name = item.name.trim();
  if (item.name.indexOf('thorin-lib-') === 0) {
    item.name = item.name.substr(11);
  }
  if (typeof app[libraries][item.name] !== 'undefined') {
    throw new Error('Thorin.addLibrary: library ' + item.name + " is already registered. Please use a different name.");
  }
  /* Check if we have a constructor or an already created object. */
  let libType = Object.prototype.toString.call(item.fn);
  let itemObj;
  if (libType === '[object Object]') {
    itemObj = item.fn;
  } else {
    itemObj = new item.fn(app);
  }
  app[libraries][item.name] = itemObj;
}
330437
def dependency(lib = nil)
      lib ? require(lib) : yield
    rescue LoadError, NameError => e
      self.load_error = e
    end
678777
function library(argv, config, args) {
  if (!isValidPackageName(args.name)) {
    return Promise.reject(
      args.name + ' is not a valid name for a project. Please use a valid ' +
      'identifier name (alphanumeric).'
    );
  }

  const root = process.cwd();
  const libraries = path.resolve(root, 'Libraries');
  const libraryDest = path.resolve(libraries, args.name);
  const source = path.resolve('node_modules', 'react-native', 'Libraries', 'Sample');

  if (!fs.existsSync(libraries)) {
    fs.mkdir(libraries);
  }

  if (fs.existsSync(libraryDest)) {
    return Promise.reject(`Library already exists in ${libraryDest}`);
  }

  walk(source).forEach(f => {
    if (f.indexOf('project.xcworkspace') !== -1 ||
        f.indexOf('.xcodeproj/xcuserdata') !== -1) {
      return;
    }

    const dest = f.replace(/Sample/g, args.name).replace(/^_/, '.');
    copyAndReplace(
      path.resolve(source, f),
      path.resolve(libraryDest, dest),
      {'Sample': args.name}
    );
  });

  console.log('Created library in', libraryDest);
  console.log('Next Steps:');
  console.log('   Link your library in Xcode:');
  console.log(
    '   https://facebook.github.io/react-native/docs/' +
    'linking-libraries-ios.html#content\n'
  );
}
670394
def all(files=nil, options={})
      # if you want the default 'app.files', you can just pass in the options
      if files.is_a?(Hash) && options == {}
        options = files
        files = nil
      end

      check_platform = options.fetch(:platform, nil)
      current_platform = App.respond_to?(:template) ? App.template : :ios
      return unless Motion::Require.check_platform(current_platform, check_platform)

      Motion::Project::App.setup do |app|
        app.exclude_from_detect_dependencies << ext_file

        if files.nil? || files.empty?
          app.files.push ext_file
          app.exclude_from_detect_dependencies += app.files
          app.files_dependencies dependencies_for(app.files.flatten)
        else
        # Place files prior to those in ./app, otherwise at the end.
          preceding_app = app.files.index { |f| f =~ %r(^(?:\./)?app/) } || -1
          required = Array(files).map { |f| explicit_relative(f) }
          app.exclude_from_detect_dependencies += required
          app.files.insert(preceding_app, ext_file, *required)
          app.files.uniq! # Prevent redundancy

          app.files_dependencies dependencies_for(required)
        end
      end
    end
828352
def load
      load_source_and_set_module
      module_callbacks if @module
      yield if block_given? # load dependencies
      detect_additions { load_commands } if load_commands?
      set_library_commands
      loaded_correctly? && (@loaded = true)
    end