Ejemplo n.º 1
0
def run(params):
    proj_path = params['proj_path']
    target_name = params['target_name']
    target_config = target.get_target_config(proj_path, target_name)

    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',
                    '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))
Ejemplo n.º 2
0
def run(params):
    proj_path = params['proj_path']
    target_name = params['target_name']
    target_config = target.get_target_config(proj_path, target_name)

    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))
Ejemplo n.º 3
0
def run(params):
    proj_path = params['proj_path']
    target_name = params['target_name']
    target_config = target.get_target_config(proj_path, target_name)

    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 dependencies
                deps_bin_dir = os.path.join(proj_path, const.DIR_NAME_BUILD,
                                            target_name, build_type,
                                            arch['conan_arch'],
                                            const.DIR_NAME_BUILD_CONAN, 'bin')

                build_bin_dir = os.path.join(build_dir, 'bin')

                if os.path.isdir(deps_bin_dir):
                    file.copy_all_inside(deps_bin_dir, build_bin_dir)
    else:
        log.error(
            'Arch list for "{0}" is invalid or empty'.format(target_name))
Ejemplo n.º 4
0
def run(params):
    proj_path = params['proj_path']
    target_name = params['target_name']
    target_config = target.get_target_config(proj_path, target_name)

    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',
                    'build_type={0}'.format(build_type),
                    '-o',
                    '{0}:ios_arch={1}'.format(target_name, arch['arch']),
                    '-o',
                    '{0}:ios_platform={1}'.format(target_name,
                                                  arch['platform']),
                    '-o',
                    '{0}:ios_deployment_target={1}'.format(
                        target_name, target_config['min_version']),
                    '-o',
                    '{0}:enable_bitcode={1}'.format(
                        target_name,
                        ('1' if target_config['bitcode'] else '0')),
                    '-o',
                    '{0}:enable_arc={1}'.format(
                        target_name,
                        ('1' if target_config['enable_arc'] else '0')),
                    '-o',
                    '{0}:enable_visibility={1}'.format(
                        target_name,
                        ('1' if target_config['enable_visibility'] else '0')),
                    '-o',
                    '{0}:cmake_toolchain_file={1}'.format(
                        target_name,
                        os.path.join(
                            proj_path,
                            const.DIR_NAME_FILES,
                            const.DIR_NAME_FILES_CMAKE,
                            const.DIR_NAME_FILES_CMAKE_TOOLCHAINS,
                            'ios.cmake',
                        )),
                    '-o',
                    'darwin-toolchain:bitcode={0}'.format(
                        'True' if target_config['bitcode'] 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))
Ejemplo n.º 5
0
def run(params):
    proj_path = params['proj_path']
    target_name = params['target_name']
    target_config = target.get_target_config(proj_path, target_name)

    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_all_inside(
                                source_header_dir,
                                dist_headers_dir,
                            )
                        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))
Ejemplo n.º 6
0
def run(params):
    proj_path = params['proj_path']
    target_name = params['target_name']
    target_config = target.get_target_config(proj_path, target_name)

    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))