def _load_tplvars(self): tpl_vars = {"env_name": self.env_name} # default env configuration tpl_vars.update( ProjectConfig.get_instance(join( self.project_dir, "platformio.ini")).items(env=self.env_name, as_dict=True)) # build data tpl_vars.update( load_project_ide_data(self.project_dir, self.env_name) or {}) with util.cd(self.project_dir): tpl_vars.update({ "project_name": basename(self.project_dir), "src_files": self.get_src_files(), "user_home_dir": abspath(expanduser("~")), "project_dir": self.project_dir, "project_src_dir": get_project_src_dir(), "project_lib_dir": get_project_lib_dir(), "project_libdeps_dir": join( get_project_libdeps_dir(), self.env_name), "systype": util.get_systype(), "platformio_path": self._fix_os_path( sys.argv[0] if isfile(sys.argv[0]) else where_is_program("platformio")), "env_pathsep": os.pathsep, "env_path": self._fix_os_path(os.getenv("PATH")) }) # yapf: disable return tpl_vars
def build_autotiler(build_dir, generator, model_path): if isdir(build_dir): fs.rmtree(build_dir) # parse custom library path from `platformio.ini` tmpenv = env.Clone() tmpenv.ProcessFlags(env.get("BUILD_FLAGS")) genv = env.Environment( tools=["ar", "gas", "gcc", "g++", "gnulink"], CC="gcc", CPPPATH=[ join(AUTOTILER_DIR, "include"), join(AUTOTILER_DIR, "generators", generator, "generator", "include") ], LIBPATH=[join(AUTOTILER_DIR, "lib"), get_project_lib_dir()] + tmpenv.get("LIBPATH", []), LIBS=["tile"]) # CHECK "libtile.a" found_libtile = False for d in genv['LIBPATH']: if isfile(genv.subst(join(d, "libtile.a"))): found_libtile = True break if not found_libtile: sys.stderr.write( "Error: AutoTiler library has not been found. Please read => " "https://docs.platformio.org/page/platforms/riscv_gap.html" "#autotiler\n") env.Exit(1) variant_dirs = [(join(build_dir, "model"), dirname(model_path)), (join(build_dir, "generator"), join(AUTOTILER_DIR, "generators", generator, "generator", "src"))] for (var_dir, src_dir) in variant_dirs: if not isdir(genv.subst(var_dir)): makedirs(genv.subst(var_dir)) genv.VariantDir(var_dir, src_dir, duplicate=0) src_files = [join(build_dir, "model", basename(model_path))] src_files.extend(genv.Glob(join(build_dir, "generator", "*Generator?.c"))) for o in genv.Object(src_files): if not int(ARGUMENTS.get("PIOVERBOSE", 0)): genv.Replace(CCCOMSTR="Compiling %s" % relpath(str(o))) o.build() if not int(ARGUMENTS.get("PIOVERBOSE", 0)): genv.Replace(LINKCOMSTR="Linking AutoTiler") return genv.Program(join(build_dir, "program"), src_files)[0].build()
def init_base_project(project_dir): ProjectConfig(join(project_dir, "platformio.ini")).save() with fs.cd(project_dir): dir_to_readme = [ (get_project_src_dir(), None), (get_project_include_dir(), init_include_readme), (get_project_lib_dir(), init_lib_readme), (get_project_test_dir(), init_test_readme), ] for (path, cb) in dir_to_readme: if isdir(path): continue makedirs(path) if cb: cb(path)
def _load_tplvars(self): tpl_vars = { "config": self.config, "systype": util.get_systype(), "project_name": basename(self.project_dir), "project_dir": self.project_dir, "env_name": self.env_name, "user_home_dir": abspath(expanduser("~")), "platformio_path": sys.argv[0] if isfile(sys.argv[0]) else where_is_program("platformio"), "env_path": os.getenv("PATH"), "env_pathsep": os.pathsep } # yapf: disable # default env configuration tpl_vars.update(self.config.items(env=self.env_name, as_dict=True)) # build data tpl_vars.update( load_project_ide_data(self.project_dir, self.env_name) or {}) with fs.cd(self.project_dir): tpl_vars.update({ "src_files": self.get_src_files(), "project_src_dir": get_project_src_dir(), "project_lib_dir": get_project_lib_dir(), "project_libdeps_dir": join( get_project_libdeps_dir(), self.env_name) }) # yapf: disable for key, value in tpl_vars.items(): if key.endswith(("_path", "_dir")): tpl_vars[key] = fs.to_unix_path(value) for key in ("includes", "src_files", "libsource_dirs"): if key not in tpl_vars: continue tpl_vars[key] = [fs.to_unix_path(inc) for inc in tpl_vars[key]] tpl_vars['to_unix_path'] = fs.to_unix_path return tpl_vars
PROJECTCORE_DIR=project_helpers.get_project_core_dir(), PROJECTPACKAGES_DIR=project_helpers.get_project_packages_dir(), PROJECTWORKSPACE_DIR=project_helpers.get_project_workspace_dir(), PROJECTLIBDEPS_DIR=project_helpers.get_project_libdeps_dir(), PROJECTINCLUDE_DIR=project_helpers.get_project_include_dir(), PROJECTSRC_DIR=project_helpers.get_project_src_dir(), PROJECTTEST_DIR=project_helpers.get_project_test_dir(), PROJECTDATA_DIR=project_helpers.get_project_data_dir(), PROJECTBUILD_DIR=project_helpers.get_project_build_dir(), BUILDCACHE_DIR=project_helpers.get_project_optional_dir("build_cache_dir"), BUILD_DIR=join("$PROJECTBUILD_DIR", "$PIOENV"), BUILDSRC_DIR=join("$BUILD_DIR", "src"), BUILDTEST_DIR=join("$BUILD_DIR", "test"), LIBPATH=["$BUILD_DIR"], LIBSOURCE_DIRS=[ project_helpers.get_project_lib_dir(), join("$PROJECTLIBDEPS_DIR", "$PIOENV"), project_helpers.get_project_global_lib_dir() ], PROGNAME="program", PROG_PATH=join("$BUILD_DIR", "$PROGNAME$PROGSUFFIX"), PYTHONEXE=get_pythonexe_path()) if not int(ARGUMENTS.get("PIOVERBOSE", 0)): DEFAULT_ENV_OPTIONS['ARCOMSTR'] = "Archiving $TARGET" DEFAULT_ENV_OPTIONS['LINKCOMSTR'] = "Linking $TARGET" DEFAULT_ENV_OPTIONS['RANLIBCOMSTR'] = "Indexing $TARGET" for k in ("ASCOMSTR", "ASPPCOMSTR", "CCCOMSTR", "CXXCOMSTR"): DEFAULT_ENV_OPTIONS[k] = "Compiling $TARGET" env = DefaultEnvironment(**DEFAULT_ENV_OPTIONS)