recursively perform #include substitutions and build *.js parts list
190583
function processSourceFile(work_directory, file_path) {

    var path = create('fs.path', work_directory).combine(file_path),
        source = create('fs.filereader(utf8)', path).readSync();

    // replace /*#include filename.ext*/
    var result = source.replace(/\/\*#include \S+\*\//gm, function(line) {
        var include_file_path = /\/\*#include (\S+)\*\//.exec(line)[1];
        // list .js file
        watch_list.push(include_file_path);
        // recursively perform substitutions
        return processSourceFile(path.getParentPath().path, include_file_path);
    });

    return result;
}
386203
protected function _includeComponents(): void
    {
        // for now, we just include all components
        $appComponentFolder = WWW_ROOT . 'js/app/components/';
        $folder = new Folder($appComponentFolder);
        $files = $folder->find('.*\.js');
        if (!empty($files)) {
            foreach ($files as $file) {
                $this->_dependencies[] = 'app/components/' . $file;
            }
        }

        // Add Plugin Components
        foreach (Plugin::loaded() as $pluginName) {
            $pluginJsComponentsFolder = Plugin::path($pluginName) . '/webroot/js/app/components/';
            if (is_dir($pluginJsComponentsFolder)) {
                $folder = new Folder($pluginJsComponentsFolder);
                $files = $folder->find('.*\.js');
                foreach ($files as $file) {
                    $this->_dependencies[] = '/' . Inflector::underscore($pluginName) . '/js/app/components/' . $file;
                }
            }
        }
    }
812998
def merge_includes(code):
    """"""

    pattern = '\#\s*include\s*"(?P<filename>[a-zA-Z0-9\_\-\.\/]+)"'
    regex = re.compile(pattern)
    includes = []

    def replace(match):
        filename = match.group("filename")

        if filename not in includes:
            includes.append(filename)
            path = glsl.find(filename)
            if not path:
                logger.critical('"%s" not found' % filename)
                raise RuntimeError("File not found", filename)
            text = '\n// --- start of "%s" ---\n' % filename
            with open(path) as fh:
                text += fh.read()
            text += '// --- end of "%s" ---\n' % filename
            return text
        return ''

    # Limit recursion to depth 10
    for i in range(10):
        if re.search(regex, code):
            code = re.sub(regex, replace, code)
        else:
            break

    return code
747666
function Buildit(opts) {
	opts = opts || {};

	this.cwd = opts.baseUrl || process.cwd();
	this.name = opts.name;
	this.locals = {};
	this.externals = [];

	if (opts.define) {
		this.define = opts.define;
	}

	if (opts.exports) {
		this.exports = opts.exports;
	}

	if (opts.extensions) {
		this.extensions = opts.extensions;
	}
}
1363697
function compileFileSync(
  buildDir /*: string */,
  moduleType /*: BsModuleFormat | 'js' */,
  path /*: string */,
) /*: string */ {
  try {
    runBuildSync(buildDir)
  } catch (e) {
    throw utils.processBsbError(e.output.toString())
  }

  const res = readFileSync(path)
  return utils.transformSrc(moduleType, res.toString())
}
1337399
function compile() {
        debug('read %s', cssPath);
        fs.readFile(stylusPath, 'utf8', function(err, str){
          if (err) return error(err);
          var style = options.compile(str, stylusPath);
          var paths = style.options._imports = [];
          imports[stylusPath] = null;
          style.render(function(err, css){
            if (err) return next(err);
            debug('render %s', stylusPath);
            imports[stylusPath] = paths;
            mkdir(dirname(cssPath), { mode: parseInt('0700', 8), recursive: true }, function(err){
              if (err) return error(err);
              fs.writeFile(cssPath, css, 'utf8', next);
            });
          });
        });
      }
687567
function optimizeModules () {
			grunt.log.write("Optimizing...");

			var mainModuleOverride = {
				// Specify a callback to be called for writing down app root modules content.
				// The callback wraps modules content into several nested 'require' calls (one for each layer modules)
				onBuildWrite: function (moduleName, modulePath, contents) {
					if (contents.indexOf("require(") < 0) { return contents; }
					if (modules.indexOf(moduleName) < 0) { return contents; }
					var start = "", end = "";
					layers.forEach(function (l) {
						start += "require([\"" + l.name + "\"], function () {\n";
						end += "\n});";
					});
					return contents.replace("require(", start + "require(") + end;
				}
			};
			function writeGenericCss (moduleName, modulePath, content) {
				grunt.verbose.writeln('Combining ' + moduleName + ' into ' + genericCssPath);
				var genericCssContent;
				if (file.exists(genericCssPath)) {
					genericCssContent = file.readFile(genericCssPath);
				}
				genericCssContent = genericCssContent ? genericCssContent + "\n" + content : content;
				file.saveFile(genericCssPath, genericCssContent);
				// remove original css
				file.deleteFile(modulePath);
			}
			// See https://github.com/jrburke/r.js/blob/master/build/example.build.js
			var config = lang.extend({}, requireConfig, {
				isOptimizeStage: true,
				optimize: options.optimizeJs,
				optimizeCss: options.optimizeCss,
				appDir: buildDir,
				dir: outputDir,
				baseUrl: "./",
				logLevel: 2, // WARN
				removeCombined: true,
				//skipDirOptimize: false,
				skipDirOptimize: true,
				keepBuildDir: false,
				locale: options.bundledLocale,
				preserveLicenseComments: options.preserveLicenseComments,
				generateSourceMaps: options.generateSourceMaps,
				writeGenericCss: writeGenericCss,
				// Custom parameter for xcss.js: path from 'generic.css' to baseDir
				genericCssToRootPath: genericCssToRootPath,
				// Pragmas for rjs plugins:
				pragmas: {
					optimize: true,
					build: true
				},
				pragmasOnSave: {
					optimizeSave: true
				},
				modules: [
					// here we'll combine layer modules and app root modules
				]
			});
			if (options.requireConfigOutput) {
				config = lang.extendEx(config, options.requireConfigOutput, {deep: true});
			}

			// Initialize config.modules - root modules to optimize
			// First we're adding "layer modules" (built on the previous step)
			var excludedLayers = options.ignoreModules;
			layers.forEach(function (l) {
				config.modules.push({
					name: l.name,
					exclude: excludedLayers.slice()
				});
				excludedLayers.push(l.name);
			});
			// then add root application modules (main.js and so on)
			modules.forEach(function (m) {
				config.modules.push({
					name: m,
					exclude: excludedLayers,
					override: mainModuleOverride
				});
			});
			// options for particular layers
			if (options.layerOverrides) {
				config.modules.forEach(function (layer) {
					var name = layer.name;
					var overrides = options.layerOverrides[name];
					if (overrides) {
						// convert task's format into rjs format:
						if (overrides.optimizeJs) {
							overrides.optimize = overrides.optimizeJs;
						}
						if (layer.override) {
							layer.override = lang.extendEx(layer.override, overrides, {deep: true});
						} else {
							layer.override = overrides;
						}
					}
				});
			}

			requirejs.optimize(
				config,
				lang.safeCallback(optimizeBootModules),
				lang.errorCallback
			);
		}
1303188
def build(self):
        """"""

        if not self.embed:
            mkdir_recursive(self.output_directory)

        # get list of script files in build order
        self.build_order = remove_dups(
            reduce(lambda a, b: a + glob.glob(b),
                   self.build_targets,
                   []))
        self.build_order_output = [self.out_path_of(t)
                                   for (t) in self.build_order]
        self.path_mapping = dict(zip(
            self.build_order,
            self.build_order_output))

        self.compiled_scripts = {}
        exceptions, values = partition(
            lambda x: isinstance(x, Exception),
            [self.compile_and_process(target)
             for target in self.build_order])

        self.compiled_scripts.update(dict(values))

        saneExceptions, insaneExceptions = partition(
            lambda x: isinstance(x, TaskExecutionException),
            exceptions)

        if len(insaneExceptions) != 0:
            raise insaneExceptions[0]

        if len(exceptions) != 0:
            raise TaskExecutionException(
                "Precompiler Errors (%s):" % type(self).__name__,
                "\n".join([
                    x.header + "\n    " +
                    x.message.replace("\n", "\n    ")
                    for x in exceptions]))

        return self.collect_output()
1043795
function(module) {
        for (var i = 0; i < module.include.length; i++) {
          var curInclude = module.include[i];
          if (curInclude.substr(0, 2) == '^!') {
            module.include[i] = curInclude.substr(2);
            attachBuildIds.push(curInclude.substr(2));
          }
        }
      }
512318
def build_includes():
    
    print("Running scripts in _include:")
    cwd = os.getcwd()
    os.chdir('_include')
    pyfiles = glob.glob('*.py')
    for fn in pyfiles:
        if not fn.startswith('_'):
            print(' {}'.format(fn))
            subprocess.check_output(['python', fn])
    os.chdir(cwd)
667074
function buildScript(file, watch) {
  var props = {
    entries: [ 'example/_src/jsx/app.js'],
    debug : false,
    transform:  [babelify]
  };

  // watchify() if watch requested, otherwise run browserify() once
  var bundler = watch ? watchify(browserify(props)) : browserify(props);


  function rebundle() {
    var stream = bundler.bundle();
    return stream
      .on('error', handleErrors)
      .pipe(source(file))
      // .pipe(gulp.dest(exampleDir + '/js/'))
      // If you also want to uglify it
      .pipe(buffer())
      // .pipe(uglify())
      .pipe(rename('app.js'))
      .pipe(gulp.dest('example/js/'))
      // .pipe(reload({stream:true}))
  }

  // listen for an update and run rebundle
  bundler.on('update', function() {
    rebundle();
    gutil.log('Rebundle...');
  });

  // run it once the first time buildScript is called
  return rebundle();
}
157720
function relativeModuleSource(from, to) {
  const p = join(
    relative(path.dirname(from), path.dirname(to)),
    path.basename(to).replace(/\.\w+$/, ''),
  );

  if (!_.startsWith(p, '.')) return './' + p;
  return p;
}
1128648
def replace_include(source)
      source.gsub!(/^#include\s+<([^>]*)>/) do
        replace_include File.read(File.expand_path("#{$1}.glsl", INCLUDE_PATH))
      end

      source.gsub(/^#include\s+"([^"]*)"/) do
        replace_include File.read($1)
      end
    end
425316
function compileBody(str, options){
  var debug_sources = {};
  debug_sources[options.filename] = str;
  var dependencies = [];
  var plugins = options.plugins || [];
  var ast = load.string(str, {
    filename: options.filename,
    basedir: options.basedir,
    lex: function (str, options) {
      var lexOptions = {};
      Object.keys(options).forEach(function (key) {
        lexOptions[key] = options[key];
      });
      lexOptions.plugins = plugins.filter(function (plugin) {
        return !!plugin.lex;
      }).map(function (plugin) {
        return plugin.lex;
      });
      var contents = applyPlugins(str, {filename: options.filename}, plugins, 'preLex');
      return applyPlugins(lex(contents, lexOptions), options, plugins, 'postLex');
    },
    parse: function (tokens, options) {
      tokens = tokens.map(function (token) {
        if (token.type === 'path' && path.extname(token.val) === '') {
          return {
            type: 'path',
            loc: token.loc,
            val: token.val + '.pug'
          };
        }
        return token;
      });
      tokens = stripComments(tokens, options);
      tokens = applyPlugins(tokens, options, plugins, 'preParse');
      var parseOptions = {};
      Object.keys(options).forEach(function (key) {
        parseOptions[key] = options[key];
      });
      parseOptions.plugins = plugins.filter(function (plugin) {
        return !!plugin.parse;
      }).map(function (plugin) {
        return plugin.parse;
      });

      return applyPlugins(
        applyPlugins(parse(tokens, parseOptions), options, plugins, 'postParse'),
        options, plugins, 'preLoad'
      );
    },
    resolve: function (filename, source, loadOptions) {
      var replacementFunc = findReplacementFunc(plugins, 'resolve');
      if (replacementFunc) {
        return replacementFunc(filename, source, options);
      }

      return load.resolve(filename, source, loadOptions);
    },
    read: function (filename, loadOptions) {
      dependencies.push(filename);

      var contents;

      var replacementFunc = findReplacementFunc(plugins, 'read');
      if (replacementFunc) {
        contents = replacementFunc(filename, options);
      } else {
        contents = load.read(filename, loadOptions);
      }

      var str = applyPlugins(contents, {filename: filename}, plugins, 'preLex');
      debug_sources[filename] = str;
      return str;
    }
  });
  ast = applyPlugins(ast, options, plugins, 'postLoad');
  ast = applyPlugins(ast, options, plugins, 'preFilters');

  var filtersSet = {};
  Object.keys(exports.filters).forEach(function (key) {
    filtersSet[key] = exports.filters[key];
  });
  if (options.filters) {
    Object.keys(options.filters).forEach(function (key) {
      filtersSet[key] = options.filters[key];
    });
  }
  ast = filters.handleFilters(ast, filtersSet, options.filterOptions, options.filterAliases);

  ast = applyPlugins(ast, options, plugins, 'postFilters');
  ast = applyPlugins(ast, options, plugins, 'preLink');
  ast = link(ast);
  ast = applyPlugins(ast, options, plugins, 'postLink');

  // Compile
  ast = applyPlugins(ast, options, plugins, 'preCodeGen');
  var js = generateCode(ast, {
    pretty: options.pretty,
    compileDebug: options.compileDebug,
    doctype: options.doctype,
    inlineRuntimeFunctions: options.inlineRuntimeFunctions,
    globals: options.globals,
    self: options.self,
    includeSources: options.includeSources ? debug_sources : false,
    templateName: options.templateName
  });
  js = applyPlugins(js, options, plugins, 'postCodeGen');
  // Debug compiler
  if (options.debug) {
    console.error('\nCompiled Function:\n\n\u001b[90m%s\u001b[0m', js.replace(/^/gm, '  '));
  }

  return {body: js, dependencies: dependencies};
}
617210
function buildNode(file, watch) {
  if (watch) {
    return gulp.watch(paths.src + file + '.js')
      .on('change', function(file) {
        $.util.log('Copying to lib...');
        gulp.src(file.path)
          .pipe($.plumber())
          .pipe($.babel())
          .pipe(gulp.dest(paths.dist));
      });
  } else {
    return gulp.src(paths.src + file + '.js')
      .pipe($.plumber())
      .pipe($.babel())
      .pipe(gulp.dest(paths.dist));
  }
}
544954
function TS2JS(tsFile) {
  const srcFolder = path.join(__dirname, '..', 'src');
  const distFolder = path.join(__dirname, '..', 'build', 'main');

  const tsPathObj = path.parse(tsFile);

  return path.format({
    dir: tsPathObj.dir.replace(srcFolder, distFolder),
    ext: '.js',
    name: tsPathObj.name,
    root: tsPathObj.root
  });
}
226403
function enumerateBuiltInCommands(config) {
    const builtInCommandParentDirGlob = path_1.join(config.builtInCommandLocation, '/*.js');
    return globby.sync(builtInCommandParentDirGlob, { ignore: '**/*.map' });
}