Compile tilebus file into only .h files corresponding to config variables for inclusion in a library
760093
def tb_h_file_creation(target, source, env):
    """"""

    files = [str(x) for x in source]

    try:
        desc = TBDescriptor(files)
    except pyparsing.ParseException as e:
        raise BuildError("Could not parse tilebus file", parsing_exception=e)

    block = desc.get_block(config_only=True)
    block.render_template(block.CommandHeaderTemplate, out_path=str(target[0]))
    block.render_template(block.ConfigHeaderTemplate, out_path=str(target[1]))
558584
function compile(source) {
    var module = assemblyscript_1.Compiler.compileString(source, {
        target: assemblyscript_1.CompilerTarget.WASM32,
        memoryModel: assemblyscript_1.CompilerMemoryModel.MALLOC,
        silent: true
    });
    var wasmFile;
    if (!module) {
        throw Error('compilation failed');
    }
    module.optimize();
    if (!module.validate()) {
        throw Error('validation failed');
    }
    wasmFile = module.emitBinary();
    module.dispose();
    return new Buffer(wasmFile);
}
888309
function compileAllFiles (src, isDebug, options)
{
    glob(src,
        function (err, files)
        {
            if (err) throw err;

            for (var i = 0, l = files.length; i < l; i++)
            {
                // only start compilation at root files
                if (sassHelpers.isRootFile(files[i]))
                {
                    compileSingleFile(files[i], isDebug, options);
                }
            }
        }
    );
}
1310213
def _make_cmake(config_info):
    """"""
    configure_args = ["-DCMAKE_EXPORT_COMPILE_COMMANDS=ON"]
    cmake_args = {}

    options, option_fns = _make_all_options()

    def _add_value(value, key):
        args_key, args_value = _EX_ARG_FNS[key](value)
        cmake_args[args_key] = args_value

    devpipeline_core.toolsupport.args_builder(
        "cmake",
        config_info,
        options,
        lambda v, key: configure_args.extend(option_fns[key](v)),
    )
    devpipeline_core.toolsupport.args_builder(
        "cmake", config_info, _EX_ARGS, _add_value
    )
    cmake = CMake(cmake_args, config_info, configure_args)
    build_type = config_info.config.get("cmake.build_type")
    if build_type:
        cmake.set_build_type(build_type)
    return devpipeline_build.make_simple_builder(cmake, config_info)
496005
def compile(cls, code, path=None, libraries=None,
                contract_name='', extra_args=None):
        
        result = cls._code_or_path(
            code,
            path,
            contract_name,
            libraries,
            'bin',
            extra_args)
        return result['bin']
652889
def main(raw_args=None):
    

    multifile_choices = frozenset(['c_files'])

    if raw_args is None:
        raw_args = sys.argv[1:]

    parser = build_parser()
    args = parser.parse_args(raw_args)

    if args.output is None and args.format in multifile_choices:
        print("You must specify an output file with -o, --output when "
              "using a format that produces multiple files (-f %s)" % args.format)
        return 1

    desc = TBDescriptor(args.bus_definition)

    if args.format == 'json':
        print("JSON output is not yet supported")
        return 1

    block = desc.get_block()

    template_map = {
        'command_map_c': 'command_map_c.c.tpl',
        'command_map_h': 'command_map_c.h.tpl',
        'config_map_c': 'config_variables_c.c.tpl',
        'config_map_h': 'config_variables_c.h.tpl'
    }

    template_name = template_map.get(args.format)
    data = block.render_template(template_name)
    print(data)

    return 0
648930
private static void exportTiles(Xml nodeTransition, Collection<TileRef> tilesRef)
    {
        for (final TileRef tileRef : tilesRef)
        {
            final Xml nodeTileRef = TileConfig.exports(tileRef);
            nodeTransition.add(nodeTileRef);
        }
    }
627242
@Override
    public void makeBuildVariables(AbstractBuild build, Map<String, String> variables) {
        // global var/password pairs
        MaskPasswordsConfig config = MaskPasswordsConfig.getInstance();
        List<VarPasswordPair> globalVarPasswordPairs = config.getGlobalVarPasswordPairs();
        // we can't use variables.putAll() since passwords are ciphered when in varPasswordPairs
        for(VarPasswordPair globalVarPasswordPair: globalVarPasswordPairs) {
            variables.put(globalVarPasswordPair.getVar(), globalVarPasswordPair.getPassword());
        }

        // job's var/password pairs
        if(varPasswordPairs != null) {
            // cf. comment above
            for(VarPasswordPair varPasswordPair: varPasswordPairs) {
                if(StringUtils.isNotBlank(varPasswordPair.getVar())) {
                    variables.put(varPasswordPair.getVar(), varPasswordPair.getPassword());
                }
            }
        }
    }
721377
def build_program(tile, elfname, chip, patch=True):
    

    dirs = chip.build_dirs()

    output_name = '%s_%s.elf' % (elfname, chip.arch_name(),)
    output_binname = '%s_%s.bin' % (elfname, chip.arch_name(),)
    patched_name = '%s_%s_patched.elf' % (elfname, chip.arch_name(),)
    patchfile_name = '%s_%s_patchcommand.txt' % (elfname, chip.arch_name(),)
    map_name = '%s_%s.map' % (elfname, chip.arch_name(),)

    VariantDir(dirs['build'], os.path.join('firmware', 'src'), duplicate=0)

    args_file = os.path.join('.', dirs['build'], 'gcc_args.txt')
    prog_env = setup_environment(chip, args_file=args_file)

    prog_env['OUTPUT'] = output_name
    prog_env['BUILD_DIR'] = dirs['build']
    prog_env['OUTPUT_PATH'] = os.path.join(dirs['build'], output_name)
    prog_env['OUTPUTBIN'] = os.path.join(dirs['build'], output_binname)
    prog_env['PATCHED'] = os.path.join(dirs['build'], patched_name)
    prog_env['PATCH_FILE'] = os.path.join(dirs['build'], patchfile_name)
    prog_env['PATCH_FILENAME'] = patchfile_name
    prog_env['MODULE'] = elfname

    # Setup all of our dependencies and make sure our output depends on them being built
    tilebus_defs = setup_dependencies(tile, prog_env)

    # Setup specific linker flags for building a program
    # Specify the linker script
    # We can find a linker script in one of two places, either in a dependency or in an explicit 'linker' property
    # First check for a linker script in our dependencies
    ldscripts = list(itertools.chain(*[x.find_products('linker_script') for x in prog_env['DEPENDENCIES']]))

    # Make sure we don't have multiple linker scripts coming in from dependencies
    if len(ldscripts) > 1:
        raise BuildError("Multiple linker scripts included from dependencies, at most one may be included",
                         linker_scripts=ldscripts)

    # Make sure we don't have a linker script from a dependency and explicity specified
    if len(ldscripts) == 1 and chip.property('linker', None) is not None:
        raise BuildError("Linker script specified in dependency and explicitly in module_settings",
                         explicit_script=chip.property('linker'), dependency_script=ldscripts[0])

    if len(ldscripts) == 1:
        ldscript = ldscripts[0]
    else:
        ldscript = utilities.join_path(chip.property('linker'))

    # Find the linker script directory in case it includes other linker scripts in the same directory
    lddir = os.path.abspath(os.path.dirname(ldscript))
    prog_env['LIBPATH'] += [lddir]

    prog_env['LINKFLAGS'].append('-T"%s"' % ldscript)

    # Specify the output map file
    prog_env['LINKFLAGS'].extend(['-Xlinker', '-Map="%s"' % os.path.join(dirs['build'], map_name)])
    Clean(os.path.join(dirs['build'], output_name), [os.path.join(dirs['build'], map_name)])

    # Compile the TileBus command and config variable definitions
    # Try to use the modern 'tilebus' directory or the old 'cdb' directory
    tbname = os.path.join('firmware', 'src', 'tilebus', prog_env["MODULE"] + ".bus")
    if not os.path.exists(tbname):
        tbname = os.path.join('firmware', 'src', 'cdb', prog_env["MODULE"] + ".cdb")

    compile_tilebus(tilebus_defs + [tbname], prog_env)

    # Ensure that our argument file to gcc is created
    args_node = prog_env.Command([args_file], [],
                                 action=prog_env.Action(create_arg_file, "Creating GCC Arguments"))
    prog_env.AlwaysBuild(args_node)

    # Compile an elf for the firmware image
    objs = SConscript(os.path.join(dirs['build'], 'SConscript'), exports='prog_env')
    for obj in objs:
        Depends(obj, args_file)

    outfile = prog_env.Program(os.path.join(dirs['build'], prog_env['OUTPUT']), objs)

    if patch:
        # Create a patched ELF including a proper checksum
        # First create a binary dump of the program flash
        outbin = prog_env.Command(prog_env['OUTPUTBIN'], os.path.join(dirs['build'], prog_env['OUTPUT']),
                                  "arm-none-eabi-objcopy -O binary $SOURCES $TARGET")

        # Now create a command file containing the linker command needed to patch the elf
        outhex = prog_env.Command(prog_env['PATCH_FILE'], outbin, action=prog_env.Action(checksum_creation_action,
                                                                                         "Generating checksum file"))

        # Next relink a new version of the binary using that patch file to define the image checksum
        patch_env = prog_env.Clone()
        patch_env['LINKFLAGS'].append(['-Xlinker', '@%s' % patch_env['PATCH_FILE']])

        patched_file = patch_env.Program(prog_env['PATCHED'], objs)
        patch_env.Depends(patched_file, [os.path.join(dirs['build'], output_name), patch_env['PATCH_FILE']])

        prog_env.Depends(os.path.join(dirs['build'], output_name), [ldscript])

        prog_env.InstallAs(os.path.join(dirs['output'], output_name), os.path.join(dirs['build'], patched_name))
    else:
        prog_env.InstallAs(os.path.join(dirs['output'], output_name), outfile)

    prog_env.InstallAs(os.path.join(dirs['output'], map_name), os.path.join(dirs['build'], map_name))

    return os.path.join(dirs['output'], output_name)
967087
def BuildInstallerPkg(self, output_file):
    """"""
    self.CreateInstallDirs()
    self.InterpolateFiles()
    self.RenameGRRPyinstallerBinaries()
    self.SignGRRPyinstallerBinaries()
    self.WriteClientConfig()
    self.Set755Permissions()
    self.RunPkgBuild()
    self.RunProductBuild()
    self.RenamePkgToTemplate(output_file)
1044863
private static TileDirectory buildTileDirectory(File directory) {

		TileDirectory tileDirectory = new TileDirectory();
		tileDirectory.directory = directory;

		// Search for zoom level directories
		for (File zoomDirectory : directory.listFiles()) {
			if (zoomDirectory.isDirectory()) {
				try {
					Integer zoomLevel = Integer
							.valueOf(zoomDirectory.getName());
					ZoomDirectory zoom = tileDirectory.new ZoomDirectory();
					zoom.directory = new File(tileDirectory.directory,
							zoomDirectory.getName());
					zoom.zoom = zoomLevel;
					tileDirectory.zooms.put(zoomLevel, zoom);
					tileDirectory.minZoom = Math.min(tileDirectory.minZoom,
							zoomLevel);
					tileDirectory.maxZoom = Math.max(tileDirectory.maxZoom,
							zoomLevel);

					// Search for x level directories
					for (File xDirectory : zoomDirectory.listFiles()) {
						if (xDirectory.isDirectory()) {
							try {
								Integer xValue = Integer.valueOf(xDirectory
										.getName());
								XDirectory x = tileDirectory.new XDirectory();
								x.directory = new File(zoom.directory,
										xDirectory.getName());
								x.x = xValue;
								zoom.xValues.put(xValue, x);
								zoom.minX = Math.min(zoom.minX, xValue);
								zoom.maxX = Math.max(zoom.maxX, xValue);

								// Search for y level directories
								for (File yImage : xDirectory.listFiles()) {
									if (yImage.isFile()) {
										try {
											String yImageName = yImage
													.getName();
											int extensionLocation = yImageName
													.lastIndexOf(".");
											if (extensionLocation >= 0) {
												yImageName = yImageName
														.substring(0,
																extensionLocation);
											}
											YFile y = tileDirectory.new YFile();
											y.y = Integer.valueOf(yImageName);
											y.file = new File(x.directory,
													yImage.getName());

											x.yValues.put(y.y, y);
											x.minY = Math.min(x.minY, y.y);
											x.maxY = Math.max(x.maxY, y.y);
										} catch (NumberFormatException e) {
											LOGGER.log(
													Level.INFO,
													"Skipping file: "
															+ yImage.getAbsolutePath());
										}

									} else {
										LOGGER.log(
												Level.INFO,
												"Skipping directory: "
														+ yImage.getAbsolutePath());
									}
								}

								zoom.minY = Math.min(zoom.minY, x.minY);
								zoom.maxY = Math.max(zoom.maxY, x.maxY);

							} catch (NumberFormatException e) {
								LOGGER.log(Level.INFO, "Skipping directory: "
										+ xDirectory.getAbsolutePath());
							}
						} else {
							LOGGER.log(Level.INFO, "Skipping file: "
									+ xDirectory.getAbsolutePath());
						}
					}
				} catch (NumberFormatException e) {
					LOGGER.log(Level.INFO, "Skipping directory: "
							+ zoomDirectory.getAbsolutePath());
				}
			} else {
				LOGGER.log(Level.INFO,
						"Skipping file: " + zoomDirectory.getAbsolutePath());
			}
		}

		return tileDirectory;
	}
884267
def _CompileProtos():
  """"""
  proto_files = []
  for dir_path, _, filenames in os.walk(THIS_DIRECTORY):
    for filename in filenames:
      if filename.endswith(".proto"):
        proto_files.append(os.path.join(dir_path, filename))
  if not proto_files:
    return
  protoc_command = [
      "python", "-m", "grpc_tools.protoc",
      "--python_out", THIS_DIRECTORY,
      "--grpc_python_out", THIS_DIRECTORY,
      "--proto_path", THIS_DIRECTORY,
  ]
  protoc_command.extend(proto_files)
  subprocess.check_output(protoc_command)
911633
def compile_cxxcode(module_name, cxxcode, output_binary=None, keep_temp=False,
                    **kwargs):
    '''

    '''

    # Get a temporary C++ file to compile
    fdpath = _write_temp(cxxcode, '.cpp')
    output_binary = compile_cxxfile(module_name, fdpath,
                                    output_binary, **kwargs)
    if not keep_temp:
        # remove tempfile
        os.remove(fdpath)
    else:
        logger.warn("Keeping temporary generated file:" + fdpath)

    return output_binary
1021781
def configure(self, src_dir, build_dir, **kwargs):
        """"""
        del kwargs
        ex_path = self._ex_args.get("project_path")
        if ex_path:
            src_dir = os.path.join(src_dir, ex_path)

        return [{"args": ["cmake", src_dir] + self._config_args, "cwd": build_dir}]
1267687
function compile(fileNames, options, verbose) {
  const program = ts.createProgram(fileNames, options)
  const emitResult = program.emit()

  /* istanbul ignore next */
  if (verbose) {
    const allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics)

    allDiagnostics.forEach((diagnostic) => {
      if (diagnostic.file) {
        const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(
          diagnostic.start
        )
        const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")
        console.log(
          `${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`
        )
      } else {
        console.log(`${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`)
      }
    })
  }
}
1366449
def compile(source, ezo):
        '''
        
        '''
        try:
            compiled = compile_source(source)
            compiled_list = []
            for name in compiled:
                c = Contract(name, ezo)
                interface = compiled[name]
                c.abi = interface['abi']
                c.bin = interface['bin']
                compiled_list.append(c)

        except Exception as e:
            return None, e
        return compiled_list, None
1080653
def generate_confs(tileset, ignore_warnings=True, renderd=False):
    
    mapproxy_conf_json = """
    {
      "services":{
        "wms":{
          "on_source_errors":"raise",
          "image_formats": ["image/png"]
        }
      },
      "layers":[
        {
          "name":"",
          "title":"",
          "sources":[
            "tileset_cache"
          ]
        }
      ],
      "caches":{
        "tileset_cache":{
          "grids":[
            "webmercator"
          ],
          "sources":[
            "tileset_source"
          ],
          "cache":{
            "type":"mbtiles",
            "filename": "/provide/valid/path/to/file.mbtiles"
          }
        }
      },
      "sources":{
        "tileset_source":{
        }
      },
      "grids":{
        "webmercator":{
          "base":"GLOBAL_MERCATOR"
        }
      },
      "globals": {
        "image": {
          "paletted": false
        }
      }
    }
    """

    seed_conf_json = """
    {
      "coverages": {
        "tileset_geom": {
          "bbox": [-77.47, 38.72, -76.72, 39.08],
          "datasource": "path/to/geom/file.xxx",
          "srs": "EPSG:4326"
        }
      },

      "seeds": {
        "tileset_seed": {
          "refresh_before": {
            "minutes": 0
          },
          "caches": [
            "tileset_cache"
          ],
          "levels": {
            "from": 0,
            "to": 2
          },
          "coverages": ["tileset_geom"]
        }
      }
    }
    """

    seed_conf = yaml.safe_load(seed_conf_json)
    mapproxy_conf = yaml.safe_load(mapproxy_conf_json)

    print '---- mbtiles file to generate: {}'.format(get_tileset_filename(tileset.name))

    mapproxy_conf['sources']['tileset_source']['type'] = u_to_str(tileset.server_service_type)

    if u_to_str(tileset.server_service_type) == 'wms':
        """
        "req":{
          "url":"http://admin:geoserver@192.168.99.100/geoserver/wms?",
          "layers":"geonode:ne_50m_admin_0_countries"
        },
        """
        mapproxy_conf['sources']['tileset_source']['req'] = {}
        mapproxy_conf['sources']['tileset_source']['req']['url'] = u_to_str(tileset.server_url)
        mapproxy_conf['sources']['tileset_source']['req']['layers'] = u_to_str(tileset.layer_name)
    elif u_to_str(tileset.server_service_type) == 'tile':
        """
        "url": "http://a.tile.openstreetmap.org/%(z)s/%(x)s/%(y)s.png",
        """
        mapproxy_conf['sources']['tileset_source']['url'] = u_to_str(tileset.server_url)

    mapproxy_conf['layers'][0]['name'] = u_to_str(tileset.layer_name)
    mapproxy_conf['layers'][0]['title'] = u_to_str(tileset.layer_name)
    mapproxy_conf['caches']['tileset_cache']['cache']['filename'] = get_tileset_filename(tileset.name, 'generating')

    if tileset.layer_zoom_start > tileset.layer_zoom_stop:
        raise ConfigurationError('invalid configuration - zoom start is greater than zoom stop')
    seed_conf['seeds']['tileset_seed']['levels']['from'] = tileset.layer_zoom_start
    seed_conf['seeds']['tileset_seed']['levels']['to'] = tileset.layer_zoom_stop
    # any specified refresh before for mbtiles will result in regeneration of the tile set
    seed_conf['seeds']['tileset_seed']['refresh_before']['minutes'] = 0

    if tileset.geom:
        geom_type = 'other'
        if tileset.geom.startswith('{"'):
            geom_type = 'geojson'
        elif tileset.geom.lower().startswith('polygon') or tileset.geom.lower().startswith('multipolygon'):
            geom_type = 'txt'
        elif tileset.geom.startswith('['):
            geom_type = 'bbox'

        if geom_type in ['geojson', 'txt']:
            geom_dir = '{}/geoms'.format(get_tileset_dir())
            if not os.path.exists(geom_dir):
                os.makedirs(geom_dir)
            # TODO: remove geom files when done or pair them up with the actual tileset files?
            geom_filename = '{}/geoms/{}.{}'.format(get_tileset_dir(), tileset.name, geom_type)
            with open(geom_filename, 'w+') as geom_file:
                geom_file.write(tileset.geom)
            seed_conf['coverages']['tileset_geom']['datasource'] = geom_filename
            seed_conf['coverages']['tileset_geom'].pop('bbox', None)
        elif geom_type is 'bbox':
            seed_conf['coverages']['tileset_geom']['bbox'] = yaml.safe_load(tileset.geom)
            seed_conf['coverages']['tileset_geom'].pop('datasource', None)
        else:
            # if not bbox or file, just set it as is to the datasource since mapproxy can handle other datastores
            # and they should work as is
            seed_conf['coverages']['tileset_geom']['datasource'] = yaml.safe_load(tileset.geom)

        print '---- tileset geom_type: {}, geom: {}'.format(geom_type, tileset.geom)

    else:
        # if a geom is not specified, remove the coverages key from tileset_seed
        seed_conf['seeds']['tileset_seed'].pop('coverages', None)
        seed_conf['coverages']['tileset_geom'].pop('datasource', None)
        seed_conf['coverages']['tileset_geom'].pop('bbox', None)

    print '--[ mapproxy_conf: '
    print yaml.dump(mapproxy_conf)
    print '--[ seed_conf: '
    print yaml.dump(seed_conf)

    if tileset.server_username and tileset.server_password:
        """
        "http":{
          "headers":{
            "Authorization":"Basic YWRtaW46Z2Vvc2VydmVy"
          }
        }
        """
        encoded = base64.b64encode('{}:{}'.format(tileset.server_username, tileset.server_password))
        mapproxy_conf['sources']['tileset_source']['http'] = {}
        mapproxy_conf['sources']['tileset_source']['http']['headers'] = {}
        mapproxy_conf['sources']['tileset_source']['http']['headers']['Authorization'] = 'Basic {}'.format(encoded)

    errors, informal_only = validate_mapproxy_conf(mapproxy_conf)
    for error in errors:
        print error
    if not informal_only or (errors and not ignore_warnings):
        raise ConfigurationError('invalid configuration - {}'.format(', '.join(errors)))
    cf = ProxyConfiguration(mapproxy_conf, conf_base_dir=get_tileset_dir(), seed=seed, renderd=renderd)

    errors, informal_only = validate_seed_conf(seed_conf)
    for error in errors:
        print error
    if not informal_only:
        raise SeedConfigurationError('invalid seed configuration - {}'.format(', '.join(errors)))
    seed_cf = SeedingConfiguration(seed_conf, mapproxy_conf=cf)

    return cf, seed_cf