예제 #1
0
파일: djinni.py 프로젝트: lopesivan/ezored
def generate(params):
    proj_path = params["proj_path"]

    # check djinni folder
    djinni_modules_path = os.path.join(proj_path, const.DIR_NAME_FILES,
                                       const.DIR_NAME_DJINNI)

    if not os.path.isdir(djinni_modules_path):
        log.error("Djinni modules folder not exists: {0}".format(
            djinni_modules_path))

    # get djinni modules
    djinni_config = config.run(proj_path, None, params)
    modules = djinni_config["modules"]

    if modules:
        log.info("Generating files for all modules...")

        for module in modules:
            djinni_module_dir = os.path.join(djinni_modules_path, module)
            djinni_module_file = os.path.join(djinni_module_dir, "generate.py")

            if file.file_exists(djinni_module_file):
                log.info('Generating djinni files for "{0}"...'.format(module))

                runner.run(["python", "generate.py"], djinni_module_dir)

        log.ok()
    else:
        log.error("No djinni modules to generate")
예제 #2
0
def run(params):
    proj_path = params["proj_path"]
    target_name = params["target_name"]
    target_config = config.run(proj_path, target_name, params)

    archs = target_config["archs"]
    build_types = target_config["build_types"]

    if archs and len(archs) > 0:
        for arch in archs:
            for build_type in build_types:
                log.info(
                    "Building for: {0}/{1}...".format(arch["conan_arch"], build_type)
                )

                # conan install
                build_dir = os.path.join(
                    proj_path,
                    const.DIR_NAME_BUILD,
                    target_name,
                    build_type,
                    arch["conan_arch"],
                    const.DIR_NAME_BUILD_CONAN,
                )

                file.remove_dir(build_dir)
                file.create_dir(build_dir)

                run_args = [
                    "conan",
                    "install",
                    os.path.join(
                        proj_path,
                        const.DIR_NAME_FILES,
                        const.DIR_NAME_FILES_TARGETS,
                        target_name,
                        const.DIR_NAME_FILES_TARGET_CONAN,
                        const.DIR_NAME_FILES_TARGET_CONAN_RECIPE,
                        const.FILE_NAME_FILES_TARGET_CONAN_RECIPE_CONANFILE_PY,
                    ),
                    "--profile",
                    arch["conan_profile"],
                    "-s",
                    "arch={0}".format(arch["conan_arch"]),
                    "-s",
                    "os.api_level={0}".format(arch["api_level"]),
                    "-s",
                    "build_type={0}".format(build_type),
                    "--build=missing",
                    "--update",
                ]

                runner.run(run_args, build_dir)
    else:
        log.error('Arch list for "{0}" is invalid or empty'.format(target_name))
예제 #3
0
파일: dist.py 프로젝트: lopesivan/ezored
def pack_dist_folder(params):
    proj_path = params["proj_path"]

    dist_file = os.path.join(proj_path, const.FILE_NAME_DIST_PACKED)
    dist_folder = os.path.join(proj_path, const.DIR_NAME_DIST)

    if not os.path.isdir(dist_folder):
        log.error("Distribution folder not exists: {0}".format(dist_folder))

    log.info("Removing old file...")
    file.remove_file(const.FILE_NAME_DIST_PACKED)

    log.info("Packing {0} folder...".format(const.DIR_NAME_DIST))
    pack.make_zipfile(dist_file, dist_folder)

    log.ok("")
예제 #4
0
def run(params):
    proj_path = params["proj_path"]
    target_name = params["target_name"]
    target_config = config.run(proj_path, target_name, params)

    archs = target_config["archs"]
    build_types = target_config["build_types"]

    log.info("Packaging...")

    if archs and len(archs) > 0:
        for arch in archs:
            for build_type in build_types:
                log.info("Copying for: {0}/{1}...".format(
                    arch["conan_arch"], build_type))

                # create folders
                dist_dir = os.path.join(
                    proj_path,
                    const.DIR_NAME_DIST,
                    target_name,
                    build_type,
                    arch["conan_arch"],
                )

                file.remove_dir(dist_dir)
                file.create_dir(dist_dir)

                build_dir = os.path.join(
                    proj_path,
                    const.DIR_NAME_BUILD,
                    target_name,
                    build_type,
                    arch["conan_arch"],
                    const.DIR_NAME_BUILD_TARGET,
                    "bin",
                )

                # copy files
                file.copy_all_inside(build_dir, dist_dir)
    else:
        log.error(
            'Arch list for "{0}" is invalid or empty'.format(target_name))
예제 #5
0
파일: dist.py 프로젝트: lopesivan/ezored
def download(params):
    proj_path = params["proj_path"]

    log.info("Removing old file...")
    file.remove_file(const.FILE_NAME_DIST_PACKED)

    log.info("Downloading {0} file...".format(const.FILE_NAME_DIST_PACKED))
    dst_file = os.path.join(proj_path, const.FILE_NAME_DIST_PACKED)
    net.download(const.URL_DIST_FILE_PACKED, dst_file)

    log.info("Removing old folder...")
    file.remove_dir(os.path.join(proj_path, const.DIR_NAME_DIST))

    log.info("Unpacking downloaded file...")
    pack.unpack(dst_file, proj_path)

    log.ok("")
예제 #6
0
def run(params):
    proj_path = params["proj_path"]
    target_name = params["target_name"]
    target_config = config.run(proj_path, target_name, params)

    archs = target_config["archs"]
    build_types = target_config["build_types"]
    param_dry_run = util.list_has_key(params["args"], "--dry-run")

    if param_dry_run:
        log.info("Running in dry mode...")

    if archs and len(archs) > 0:
        for arch in archs:
            for build_type in build_types:
                log.info(
                    "Building for: {0}/{1}...".format(arch["conan_arch"], build_type)
                )

                # conan build
                build_dir = os.path.join(
                    proj_path,
                    const.DIR_NAME_BUILD,
                    target_name,
                    build_type,
                    arch["conan_arch"],
                    const.DIR_NAME_BUILD_TARGET,
                )

                clean_build_dir = True

                if param_dry_run and os.path.isdir(build_dir):
                    clean_build_dir = False

                if clean_build_dir:
                    file.remove_dir(build_dir)
                    file.create_dir(build_dir)

                run_args = [
                    "conan",
                    "build",
                    os.path.join(
                        proj_path,
                        const.DIR_NAME_FILES,
                        const.DIR_NAME_FILES_TARGETS,
                        target_name,
                        const.DIR_NAME_FILES_TARGET_CONAN,
                        const.DIR_NAME_FILES_TARGET_CONAN_RECIPE,
                        const.FILE_NAME_FILES_TARGET_CONAN_RECIPE_CONANFILE_PY,
                    ),
                    "--source-folder",
                    os.path.join(
                        proj_path,
                        const.DIR_NAME_FILES,
                        const.DIR_NAME_FILES_TARGETS,
                        target_name,
                        const.DIR_NAME_FILES_TARGET_CMAKE,
                    ),
                    "--build-folder",
                    os.path.join(
                        proj_path,
                        const.DIR_NAME_BUILD,
                        target_name,
                        build_type,
                        arch["conan_arch"],
                        const.DIR_NAME_BUILD_TARGET,
                    ),
                    "--install-folder",
                    os.path.join(
                        proj_path,
                        const.DIR_NAME_BUILD,
                        target_name,
                        build_type,
                        arch["conan_arch"],
                        const.DIR_NAME_BUILD_CONAN,
                    ),
                ]

                runner.run(run_args, build_dir)

                # copy assets
                if "assets_dir" in target_config:
                    assets_dir = target_config["assets_dir"]

                    assets_dir = os.path.join(proj_path, assets_dir)

                    if os.path.isdir(assets_dir):
                        build_assets_dir = os.path.join(
                            build_dir, "bin", os.path.basename(assets_dir)
                        )

                        file.remove_dir(build_assets_dir)
                        file.copy_dir(assets_dir, build_assets_dir, symlinks=True)
    else:
        log.error('Arch list for "{0}" is invalid or empty'.format(target_name))
예제 #7
0
def run(params):
    proj_path = params["proj_path"]
    target_name = params["target_name"]
    target_config = config.run(proj_path, target_name, params)

    archs = target_config["archs"]
    build_types = target_config["build_types"]

    log.info("Packaging universal xcframework...")

    if archs and len(archs) > 0:
        if build_types and len(build_types) > 0:
            for build_type in build_types:
                log.info("Generating for: {0}...".format(build_type))

                # generate group list
                groups = []
                groups_command = []

                for arch in archs:
                    if not arch["group"] in groups:
                        groups.append(arch["group"])

                        groups_command.append("-framework")
                        groups_command.append(
                            os.path.join(
                                proj_path,
                                const.DIR_NAME_BUILD,
                                target_name,
                                build_type,
                                arch["group"],
                                "xcframework",
                                "{0}.framework".format(target_config["project_name"]),
                            )
                        )

                if len(groups) == 0:
                    log.error(
                        "Group list are empty, make sure you have defined group name for each arch in config file for this target"
                    )

                # generate framework for each group
                for group in groups:
                    # get first framework data for current group
                    base_framework_arch = None

                    for arch in archs:
                        if arch["group"] == group:
                            base_framework_arch = arch

                    if not base_framework_arch:
                        log.error("Group framework was not found: {0}".format(group))

                    # copy base framework
                    framework_dir = os.path.join(
                        proj_path,
                        const.DIR_NAME_BUILD,
                        target_name,
                        build_type,
                        base_framework_arch["group"],
                        base_framework_arch["conan_arch"],
                        const.DIR_NAME_BUILD_TARGET,
                        "lib",
                        "{0}.framework".format(target_config["project_name"]),
                    )

                    group_xcframework_dir = os.path.join(
                        proj_path,
                        const.DIR_NAME_BUILD,
                        target_name,
                        build_type,
                        group,
                        "xcframework",
                        "{0}.framework".format(target_config["project_name"]),
                    )

                    file.remove_dir(group_xcframework_dir)
                    file.copy_dir(framework_dir, group_xcframework_dir, symlinks=True)

                    # generate single framework for group
                    lipo_archs_args = []

                    for arch in archs:
                        if arch["group"] == group:
                            lipo_archs_args.append(
                                os.path.join(
                                    proj_path,
                                    const.DIR_NAME_BUILD,
                                    target_name,
                                    build_type,
                                    arch["group"],
                                    arch["conan_arch"],
                                    const.DIR_NAME_BUILD_TARGET,
                                    "lib",
                                    "{0}.framework".format(
                                        target_config["project_name"]
                                    ),
                                    target_config["project_name"],
                                )
                            )

                    lipo_args = [
                        "lipo",
                        "-create",
                        "-output",
                        os.path.join(
                            group_xcframework_dir, target_config["project_name"]
                        ),
                    ]

                    lipo_args.extend(lipo_archs_args)

                    runner.run(lipo_args, proj_path)

                # generate xcframework
                xcframework_dir = os.path.join(
                    proj_path,
                    const.DIR_NAME_DIST,
                    target_name,
                    build_type,
                    "{0}.xcframework".format(target_config["project_name"]),
                )

                file.remove_dir(xcframework_dir)

                xcodebuild_command = ["xcodebuild", "-create-xcframework"]

                xcodebuild_command += groups_command

                xcodebuild_command += ["-output", xcframework_dir]

                runner.run(xcodebuild_command, proj_path)

                # check file
                log.info("Checking file for: {0}...".format(build_type))

                runner.run(["ls", xcframework_dir], proj_path)
        else:
            log.info(
                'Build type list for "{0}" is invalid or empty'.format(target_name)
            )
    else:
        log.info('Arch list for "{0}" is invalid or empty'.format(target_name))
예제 #8
0
파일: package.py 프로젝트: lopesivan/ezored
def run(params):
    proj_path = params["proj_path"]
    target_name = params["target_name"]
    target_config = config.run(proj_path, target_name, params)

    archs = target_config["archs"]
    build_types = target_config["build_types"]

    log.info("Packaging universal framework...")

    if archs and len(archs) > 0:
        if build_types and len(build_types) > 0:
            for build_type in build_types:
                log.info("Copying for: {0}...".format(build_type))

                # add minimum version inside plist to submit for apple
                for arch in archs:
                    plist_path = os.path.join(
                        proj_path,
                        const.DIR_NAME_BUILD,
                        target_name,
                        build_type,
                        arch["conan_arch"],
                        const.DIR_NAME_BUILD_TARGET,
                        "lib",
                        "{0}.framework".format(target_config["project_name"]),
                        "Info.plist",
                    )

                    runner.run(
                        [
                            "plutil",
                            "-replace",
                            "MinimumOSVersion",
                            "-string",
                            arch["min_version"],
                            plist_path,
                        ],
                        proj_path,
                    )

                # copy first folder for base
                framework_dir = os.path.join(
                    proj_path,
                    const.DIR_NAME_BUILD,
                    target_name,
                    build_type,
                    archs[0]["conan_arch"],
                    const.DIR_NAME_BUILD_TARGET,
                    "lib",
                    "{0}.framework".format(target_config["project_name"]),
                )

                dist_dir = os.path.join(
                    proj_path,
                    const.DIR_NAME_DIST,
                    target_name,
                    build_type,
                    "{0}.framework".format(target_config["project_name"]),
                )

                file.remove_dir(dist_dir)
                file.copy_dir(framework_dir, dist_dir)

                # lipo
                lipo_archs_args = []

                for arch in archs:
                    lipo_archs_args.append(
                        os.path.join(
                            proj_path,
                            const.DIR_NAME_BUILD,
                            target_name,
                            build_type,
                            arch["conan_arch"],
                            const.DIR_NAME_BUILD_TARGET,
                            "lib",
                            "{0}.framework".format(
                                target_config["project_name"]),
                            target_config["project_name"],
                        ))

                lipo_args = [
                    "lipo",
                    "-create",
                    "-output",
                    os.path.join(dist_dir, target_config["project_name"]),
                ]

                lipo_args.extend(lipo_archs_args)

                runner.run(lipo_args, proj_path)

                # check file
                log.info("Checking file for: {0}...".format(build_type))

                runner.run(
                    [
                        "file",
                        os.path.join(dist_dir, target_config["project_name"])
                    ],
                    proj_path,
                )
        else:
            log.info('Build type list for "{0}" is invalid or empty'.format(
                target_name))
    else:
        log.info('Arch list for "{0}" is invalid or empty'.format(target_name))
예제 #9
0
파일: conan.py 프로젝트: f541/ezored
def run(params):
    proj_path = params["proj_path"]
    target_name = params["target_name"]
    target_config = config.run(proj_path, target_name, params)

    archs = target_config["archs"]
    build_types = target_config["build_types"]

    if archs and len(archs) > 0:
        for arch in archs:
            for build_type in build_types:
                log.info("Building for: {0}/{1}...".format(
                    arch["conan_arch"], build_type))

                # conan install
                build_dir = os.path.join(
                    proj_path,
                    const.DIR_NAME_BUILD,
                    target_name,
                    build_type,
                    arch["group"],
                    arch["conan_arch"],
                    const.DIR_NAME_BUILD_CONAN,
                )

                file.remove_dir(build_dir)
                file.create_dir(build_dir)

                run_args = [
                    "conan",
                    "install",
                    os.path.join(
                        proj_path,
                        const.DIR_NAME_FILES,
                        const.DIR_NAME_FILES_TARGETS,
                        target_name,
                        const.DIR_NAME_FILES_TARGET_CONAN,
                        const.DIR_NAME_FILES_TARGET_CONAN_RECIPE,
                        const.FILE_NAME_FILES_TARGET_CONAN_RECIPE_CONANFILE_PY,
                    ),
                    "--profile",
                    arch["conan_profile"],
                    "-s",
                    "arch={0}".format(arch["conan_arch"]),
                    "-s",
                    "build_type={0}".format(build_type),
                    "-s",
                    "os.version={0}".format(arch["min_version"]),
                    "-o",
                    "group={0}".format(arch["group"]),
                    "-o",
                    "darwin-toolchain:enable_bitcode={0}".format(
                        (arch["enable_bitcode"]
                         if "enable_bitcode" in arch else None)),
                    "-o",
                    "darwin-toolchain:enable_arc={0}".format(
                        (arch["enable_arc"]
                         if "enable_arc" in arch else None)),
                    "-o",
                    "darwin-toolchain:enable_visibility={0}".format(
                        (arch["enable_visibility"]
                         if "enable_visibility" in arch else None)),
                    "-o",
                    "darwin-toolchain:enable_catalyst={0}".format(
                        (arch["enable_catalyst"]
                         if "enable_catalyst" in arch else False)),
                    "-o",
                    "darwin-toolchain:catalyst_version={0}".format(
                        (arch["catalyst_version"]
                         if "catalyst_version" in arch else "")),
                    "-o",
                    "sqlite3:disable_gethostuuid={0}".format(
                        (arch["enable_catalyst"]
                         if "enable_catalyst" in arch else False)),
                    "--build=missing",
                    "--update",
                ]

                runner.run(run_args, build_dir)
    else:
        log.error(
            'Arch list for "{0}" is invalid or empty'.format(target_name))
예제 #10
0
def run(params):
    proj_path = params["proj_path"]
    target_name = params["target_name"]
    target_config = config.run(proj_path, target_name, params)

    archs = target_config["archs"]
    build_types = target_config["build_types"]
    install_headers = target_config["install_headers"]
    param_dry_run = util.list_has_key(params["args"], "--dry-run")

    if param_dry_run:
        log.info("Running in dry mode...")

    if archs and len(archs) > 0:
        for arch in archs:
            for build_type in build_types:
                log.info("Building for: {0}/{1}...".format(
                    arch["conan_arch"], build_type))

                # conan build
                build_dir = os.path.join(
                    proj_path,
                    const.DIR_NAME_BUILD,
                    target_name,
                    build_type,
                    arch["conan_arch"],
                    const.DIR_NAME_BUILD_TARGET,
                )

                clean_build_dir = True

                if param_dry_run and os.path.isdir(build_dir):
                    clean_build_dir = False

                if clean_build_dir:
                    file.remove_dir(build_dir)
                    file.create_dir(build_dir)

                run_args = [
                    "conan",
                    "build",
                    os.path.join(
                        proj_path,
                        const.DIR_NAME_FILES,
                        const.DIR_NAME_FILES_TARGETS,
                        target_name,
                        const.DIR_NAME_FILES_TARGET_CONAN,
                        const.DIR_NAME_FILES_TARGET_CONAN_RECIPE,
                        const.FILE_NAME_FILES_TARGET_CONAN_RECIPE_CONANFILE_PY,
                    ),
                    "--source-folder",
                    os.path.join(
                        proj_path,
                        const.DIR_NAME_FILES,
                        const.DIR_NAME_FILES_TARGETS,
                        target_name,
                        const.DIR_NAME_FILES_TARGET_CMAKE,
                    ),
                    "--build-folder",
                    os.path.join(
                        proj_path,
                        const.DIR_NAME_BUILD,
                        target_name,
                        build_type,
                        arch["conan_arch"],
                        const.DIR_NAME_BUILD_TARGET,
                    ),
                    "--install-folder",
                    os.path.join(
                        proj_path,
                        const.DIR_NAME_BUILD,
                        target_name,
                        build_type,
                        arch["conan_arch"],
                        const.DIR_NAME_BUILD_CONAN,
                    ),
                ]

                runner.run(run_args, build_dir)

                # headers
                dist_headers_dir = os.path.join(
                    proj_path,
                    const.DIR_NAME_BUILD,
                    target_name,
                    build_type,
                    archs[0]["conan_arch"],
                    const.DIR_NAME_BUILD_TARGET,
                    "lib",
                    "{0}.framework".format(target_config["project_name"]),
                    "Headers",
                )

                file.create_dir(dist_headers_dir)

                if install_headers:
                    for header in install_headers:
                        source_header_dir = os.path.join(
                            proj_path, header["path"])

                        if header["type"] == "dir":
                            file.copy_dir(
                                source_header_dir,
                                dist_headers_dir,
                                ignore_file=_header_ignore_list,
                            )
                        else:
                            log.error(
                                "Invalid type for install header list for {0}".
                                format(target_name))

    else:
        log.error(
            'Arch list for "{0}" is invalid or empty'.format(target_name))
예제 #11
0
def run(params):
    proj_path = params["proj_path"]
    target_name = params["target_name"]
    target_config = config.run(proj_path, target_name, params)

    archs = target_config["archs"]
    build_types = target_config["build_types"]

    log.info("Generating bridging header...")

    if archs and len(archs) > 0:
        if build_types and len(build_types) > 0:
            for build_type in build_types:
                log.info("Generating for: {0}...".format(build_type))

                dist_headers_dir = os.path.join(
                    proj_path,
                    const.DIR_NAME_DIST,
                    target_name,
                    build_type,
                    "{0}.framework".format(target_config["project_name"]),
                    "Headers",
                )

                header_files = file.find_files(dist_headers_dir, "*.h")

                bridge_file = os.path.join(
                    proj_path,
                    const.DIR_NAME_DIST,
                    target_name,
                    build_type,
                    "Bridging-Header.h",
                )

                content = ""

                for header_file in header_files:
                    header_file_name = os.path.basename(header_file)

                    if not validate_header_file_name(header_file_name):
                        continue

                    header_file = header_file.replace(dist_headers_dir + "/", "")

                    content = content + '#include "{0}"\n'.format(header_file)

                if len(content) > 0:
                    file.remove_file(bridge_file)

                    file.write_to_file(
                        os.path.join(
                            proj_path, const.DIR_NAME_DIST, target_name, build_type
                        ),
                        "Bridging-Header.h",
                        content,
                    )
                else:
                    log.error(
                        "{0}".format(
                            "File not generate because framework headers is empty"
                        )
                    )
        else:
            log.info(
                'Build type list for "{0}" is invalid or empty'.format(target_name)
            )
    else:
        log.info('Arch list for "{0}" is invalid or empty'.format(target_name))
예제 #12
0
def run(params):
    proj_path = params["proj_path"]
    target_name = params["target_name"]
    target_config = config.run(proj_path, target_name, params)

    archs = target_config["archs"]
    build_types = target_config["build_types"]
    module_name = "library"

    log.info("Creating AAR library...")

    if archs and len(archs) > 0:
        if build_types and len(build_types) > 0:
            for build_type in build_types:
                log.info("Creating AAR library for: {0}...".format(build_type))

                build_dir = os.path.join(proj_path, const.DIR_NAME_BUILD,
                                         target_name, build_type)

                android_library_build_dir = os.path.join(build_dir, "aar")

                file.remove_dir(android_library_build_dir)
                file.create_dir(android_library_build_dir)

                android_project_dir = os.path.join(
                    proj_path,
                    const.DIR_NAME_FILES,
                    const.DIR_NAME_FILES_TARGETS,
                    target_name,
                    const.DIR_NAME_FILES_TARGET_SUPPORT,
                    "android-aar-project",
                )

                file.copy_dir(android_project_dir,
                              android_library_build_dir,
                              symlinks=True)

                # copy djinni support lib files
                djinni_support_lib_dir = os.path.join(proj_path,
                                                      const.DIR_NAME_FILES,
                                                      "djinni", "support-lib")

                file.copy_all_inside(
                    os.path.join(djinni_support_lib_dir, "java"),
                    os.path.join(android_library_build_dir, module_name, "src",
                                 "main", "java"),
                )

                # copy all modules djinni files
                modules_dir = os.path.join(proj_path, const.DIR_NAME_FILES,
                                           "djinni")

                modules = file.find_dirs_simple(modules_dir, "*")

                for module in modules:
                    module_dir_name = os.path.basename(module)

                    if module_dir_name == "support-lib":
                        continue

                    module_dir = os.path.join(modules_dir, module_dir_name,
                                              "generated-src", "java")

                    if file.dir_exists(module_dir):
                        file.copy_all_inside(
                            module_dir,
                            os.path.join(
                                android_library_build_dir,
                                module_name,
                                "src",
                                "main",
                                "java",
                            ),
                        )

                # copy all modules implementation files
                modules_dir = os.path.join(proj_path, const.DIR_NAME_FILES,
                                           const.DIR_NAME_FILES_SRC)

                modules = file.find_dirs_simple(modules_dir, "*")

                for module in modules:
                    module_dir_name = os.path.basename(module)

                    module_dir = os.path.join(modules_dir, module_dir_name,
                                              "java")

                    if file.dir_exists(module_dir):
                        file.copy_all_inside(
                            module_dir,
                            os.path.join(
                                android_library_build_dir,
                                module_name,
                                "src",
                                "main",
                                "java",
                            ),
                        )

                # copy all native libraries
                for arch in archs:
                    compiled_arch_dir = os.path.join(
                        build_dir,
                        arch["conan_arch"],
                        const.DIR_NAME_BUILD_TARGET,
                        "lib",
                    )

                    target_arch_dir = os.path.join(
                        android_library_build_dir,
                        "library",
                        "src",
                        "main",
                        "jniLibs",
                        arch["arch"],
                    )

                    file.copy_all_inside(compiled_arch_dir, target_arch_dir)

                # build aar
                android_module_dir = os.path.join(android_library_build_dir,
                                                  module_name)

                run_args = ["../gradlew", "bundle{0}Aar".format(build_type)]

                runner.run(run_args, android_module_dir)

                # copy files
                arr_dir = os.path.join(android_library_build_dir, module_name,
                                       "build", "outputs", "aar")

                dist_dir = os.path.join(proj_path, const.DIR_NAME_DIST,
                                        target_name, build_type)

                file.remove_dir(dist_dir)

                file.copy_all_inside(arr_dir, dist_dir)
        else:
            log.info('Build type list for "{0}" is invalid or empty'.format(
                target_name))
    else:
        log.info('Arch list for "{0}" is invalid or empty'.format(target_name))
예제 #13
0
파일: build.py 프로젝트: f541/ezored
def run(params):
    proj_path = params["proj_path"]
    target_name = params["target_name"]
    target_config = config.run(proj_path, target_name, params)

    archs = target_config["archs"]
    build_types = target_config["build_types"]
    install_headers = target_config["install_headers"]
    param_dry_run = util.list_has_key(params["args"], "--dry-run")

    if param_dry_run:
        log.info("Running in dry mode...")

    if archs and len(archs) > 0:
        for arch in archs:
            for build_type in build_types:
                log.info(
                    "Building for: {0}/{1}...".format(arch["conan_arch"], build_type)
                )

                # conan build
                build_dir = os.path.join(
                    proj_path,
                    const.DIR_NAME_BUILD,
                    target_name,
                    build_type,
                    arch["group"],
                    arch["conan_arch"],
                    const.DIR_NAME_BUILD_TARGET,
                )

                clean_build_dir = True

                if param_dry_run and os.path.isdir(build_dir):
                    clean_build_dir = False

                if clean_build_dir:
                    file.remove_dir(build_dir)
                    file.create_dir(build_dir)

                run_args = [
                    "conan",
                    "build",
                    os.path.join(
                        proj_path,
                        const.DIR_NAME_FILES,
                        const.DIR_NAME_FILES_TARGETS,
                        target_name,
                        const.DIR_NAME_FILES_TARGET_CONAN,
                        const.DIR_NAME_FILES_TARGET_CONAN_RECIPE,
                        const.FILE_NAME_FILES_TARGET_CONAN_RECIPE_CONANFILE_PY,
                    ),
                    "--source-folder",
                    os.path.join(
                        proj_path,
                        const.DIR_NAME_FILES,
                        const.DIR_NAME_FILES_TARGETS,
                        target_name,
                        const.DIR_NAME_FILES_TARGET_CMAKE,
                    ),
                    "--build-folder",
                    os.path.join(
                        proj_path,
                        const.DIR_NAME_BUILD,
                        target_name,
                        build_type,
                        arch["group"],
                        arch["conan_arch"],
                        const.DIR_NAME_BUILD_TARGET,
                    ),
                    "--install-folder",
                    os.path.join(
                        proj_path,
                        const.DIR_NAME_BUILD,
                        target_name,
                        build_type,
                        arch["group"],
                        arch["conan_arch"],
                        const.DIR_NAME_BUILD_CONAN,
                    ),
                ]

                runner.run(run_args, build_dir)

                # find correct info plist file
                plist_path1 = os.path.join(
                    proj_path,
                    const.DIR_NAME_BUILD,
                    target_name,
                    build_type,
                    arch["group"],
                    arch["conan_arch"],
                    const.DIR_NAME_BUILD_TARGET,
                    "lib",
                    "{0}.framework".format(target_config["project_name"]),
                    "Info.plist",
                )

                plist_path2 = os.path.join(
                    proj_path,
                    const.DIR_NAME_BUILD,
                    target_name,
                    build_type,
                    arch["group"],
                    arch["conan_arch"],
                    const.DIR_NAME_BUILD_TARGET,
                    "lib",
                    "{0}.framework".format(target_config["project_name"]),
                    "Versions",
                    "Current",
                    "Resources",
                    "Info.plist",
                )

                plist_path = ""

                if os.path.exists(plist_path1):
                    plist_path = plist_path1

                if os.path.exists(plist_path2):
                    plist_path = plist_path2

                # add minimum version inside plist
                runner.run(
                    [
                        "plutil",
                        "-replace",
                        "MinimumOSVersion",
                        "-string",
                        arch["min_version"],
                        plist_path,
                    ],
                    proj_path,
                )

                # add supported platform inside plist
                runner.run(
                    [
                        "plutil",
                        "-replace",
                        "CFBundleSupportedPlatforms",
                        "-json",
                        '[ "{0}" ]'.format(arch["supported_platform"]),
                        plist_path,
                    ],
                    proj_path,
                )

                # headers
                dist_headers_dir = os.path.join(
                    proj_path,
                    const.DIR_NAME_BUILD,
                    target_name,
                    build_type,
                    arch["group"],
                    arch["conan_arch"],
                    const.DIR_NAME_BUILD_TARGET,
                    "lib",
                    "{0}.framework".format(target_config["project_name"]),
                    "Headers",
                )

                file.create_dir(dist_headers_dir)

                if install_headers:
                    for header in install_headers:
                        source_header_dir = os.path.join(proj_path, header["path"])

                        if header["type"] == "dir":
                            file.copy_dir(
                                source_header_dir,
                                dist_headers_dir,
                                ignore_file=_header_ignore_list,
                                symlinks=True,
                            )
                        else:
                            log.error(
                                "Invalid type for install header list for {0}".format(
                                    target_name
                                )
                            )

    else:
        log.error('Arch list for "{0}" is invalid or empty'.format(target_name))
예제 #14
0
파일: package.py 프로젝트: f541/ezored
def run(params):
    proj_path = params["proj_path"]
    target_name = params["target_name"]
    target_config = config.run(proj_path, target_name, params)

    archs = target_config["archs"]
    build_types = target_config["build_types"]

    log.info("Packaging universal framework...")

    if archs and len(archs) > 0:
        if build_types and len(build_types) > 0:
            for build_type in build_types:
                log.info("Copying for: {0}...".format(build_type))

                # copy first folder for base
                framework_dir = os.path.join(
                    proj_path,
                    const.DIR_NAME_BUILD,
                    target_name,
                    build_type,
                    archs[0]["group"],
                    archs[0]["conan_arch"],
                    const.DIR_NAME_BUILD_TARGET,
                    "lib",
                    "{0}.framework".format(target_config["project_name"]),
                )

                dist_dir = os.path.join(
                    proj_path,
                    const.DIR_NAME_DIST,
                    target_name,
                    build_type,
                    "{0}.framework".format(target_config["project_name"]),
                )

                file.remove_dir(dist_dir)
                file.copy_dir(framework_dir, dist_dir, symlinks=True)

                # group supported platforms
                supported_platforms = []

                for arch in archs:
                    if not arch["supported_platform"] in supported_platforms:
                        supported_platforms.append(arch["supported_platform"])

                if supported_platforms:
                    # update info plist file
                    plist_path = os.path.join(
                        proj_path,
                        const.DIR_NAME_DIST,
                        target_name,
                        build_type,
                        "{0}.framework".format(target_config["project_name"]),
                        "Info.plist",
                    )

                    if os.path.exists(plist_path):
                        # add supported platforms inside plist
                        runner.run(
                            [
                                "plutil",
                                "-replace",
                                "CFBundleSupportedPlatforms",
                                "-json",
                                '[ "{0}" ]'.format('", "'.join(supported_platforms)),
                                plist_path,
                            ],
                            proj_path,
                        )

                # lipo
                lipo_archs_args = []

                for arch in archs:
                    if is_valid_group(arch["group"]):
                        lipo_archs_args.append(
                            os.path.join(
                                proj_path,
                                const.DIR_NAME_BUILD,
                                target_name,
                                build_type,
                                arch["group"],
                                arch["conan_arch"],
                                const.DIR_NAME_BUILD_TARGET,
                                "lib",
                                "{0}.framework".format(target_config["project_name"]),
                                target_config["project_name"],
                            )
                        )

                lipo_args = [
                    "lipo",
                    "-create",
                    "-output",
                    os.path.join(dist_dir, target_config["project_name"]),
                ]

                lipo_args.extend(lipo_archs_args)

                runner.run(lipo_args, proj_path)

                # check file
                log.info("Checking file for: {0}...".format(build_type))

                runner.run(
                    ["file", os.path.join(dist_dir, target_config["project_name"])],
                    proj_path,
                )
        else:
            log.info(
                'Build type list for "{0}" is invalid or empty'.format(target_name)
            )
    else:
        log.info('Arch list for "{0}" is invalid or empty'.format(target_name))