Example #1
0
    def _create_tarball(self, src, dst, include=None, exclude=None):
        # remap root
        if (include and len(include) == 1
                and os.path.isdir(os.path.join(src, include[0]))):
            src = os.path.join(src, include[0])
            include = None

        src_filters = self.compute_src_filters(include, exclude)
        with tarfile.open(dst, "w:gz") as tar:
            for f in fs.match_src_files(src, src_filters, followlinks=False):
                tar.add(os.path.join(src, f), f)
        return dst
Example #2
0
    def _create_tarball(self, src, dst, manifest):
        include = manifest.get("export", {}).get("include")
        exclude = manifest.get("export", {}).get("exclude")
        # remap root
        if (include and len(include) == 1
                and os.path.isdir(os.path.join(src, include[0]))):
            src = os.path.join(src, include[0])
            with open(os.path.join(src, "library.json"), "w") as fp:
                manifest_updated = manifest.copy()
                del manifest_updated["export"]["include"]
                json.dump(manifest_updated, fp, indent=2, ensure_ascii=False)
            include = None

        src_filters = self.compute_src_filters(include, exclude)
        with tarfile.open(dst, "w:gz") as tar:
            for f in fs.match_src_files(src, src_filters, followlinks=False):
                tar.add(os.path.join(src, f), f)
        return dst
Example #3
0
def MatchSourceFiles(env, src_dir, src_filter=None):
    src_filter = env.subst(src_filter) if src_filter else None
    src_filter = src_filter or SRC_FILTER_DEFAULT
    return fs.match_src_files(env.subst(src_dir), src_filter,
                              SRC_BUILD_EXT + SRC_HEADER_EXT)
Example #4
0
generated_src_dir = os.path.join(build_dir, 'nanopb', 'generated-src')
generated_build_dir = os.path.join(build_dir, 'nanopb', 'generated-build')
md5_dir = os.path.join(build_dir, 'nanopb', 'md5')

nanopb_protos = env.GetProjectOption("custom_nanopb_protos", "")
nanopb_plugin_options = env.GetProjectOption("custom_nanopb_options", "")

if not nanopb_protos:
    print("[nanopb] No generation needed.")
else:
    if isinstance(nanopb_plugin_options, (list, tuple)):
        nanopb_plugin_options = " ".join(nanopb_plugin_options)

    nanopb_plugin_options = nanopb_plugin_options.split()

    protos_files = fs.match_src_files(project_dir, nanopb_protos)
    if not len(protos_files):
        print("[nanopb] ERROR: No files matched pattern:")
        print(f"custom_nanopb_protos: {nanopb_protos}")
        exit(1)

    protoc_generator = os.path.join(nanopb_root, 'generator', 'protoc')

    nanopb_options = ""
    nanopb_options += f" --nanopb_out={generated_src_dir}"
    for opt in nanopb_plugin_options:
        nanopb_options += (" --nanopb_opt=" + opt)

    try:
        os.makedirs(generated_src_dir)
    except FileExistsError: