예제 #1
0
    def set_prefix_path(prefix_path, build_dir=os.getcwd()):
        config.REPO_ROOT_DIR = prefix_path
        config.BUILD_SCRIPT_DIR = posixpath.join(config.REPO_ROOT_DIR,
                                                 'scripts')
        config.CODE_DIR = posixpath.join(config.REPO_ROOT_DIR, 'driver')
        config.RESOURCE_DIR = posixpath.join(config.REPO_ROOT_DIR, 'resources')
        config.BINDINGS_DIR = posixpath.join(config.REPO_ROOT_DIR, 'python')
        config.PY_BINDINGS_DIR = config.BINDINGS_DIR
        config.TEST_DIR = posixpath.join(config.CODE_DIR, 'tests')

        config.BUILD_DIR = build_dir
        config.SERIALIZATION_BUILD_DIR = posixpath.join(
            config.BUILD_DIR, 'driver')
        config.BINDINGS_BUILD_DIR = posixpath.join(config.BUILD_DIR, 'python')
        config.PY_BINDINGS_BUILD_DIR = posixpath.join(
            config.BINDINGS_BUILD_DIR, 'python')
        config.TEST_REPORT_DIR = posixpath.join(config.BUILD_DIR,
                                                'test_reports')
        config.RELEASE_DIR = posixpath.join(config.BUILD_DIR, 'release')
        config.NRF51_SDK_DIR = Sdk(config.ARTIFACTS_ROOT,
                                   config.SDK_VERSION).path
        config.NRF51_SDK_SOURCE_DIR = posixpath.join(config.NRF51_SDK_DIR,
                                                     'components')
        config.NRF51_SDK_INCLUDE_DIR = posixpath.join(config.NRF51_SDK_DIR,
                                                      'components')
예제 #2
0
def main():
    args = parse_command_line()

    root_dir = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..'))

    config.config_init(args.version, args.revision, args.version_name,
                       args.sdk_root_path, args.sdk_version,
                       root_dir)

    sdk = Sdk(config.ARTIFACTS_ROOT, config.SDK_VERSION)

    # Assumes that source root dir is .. since build.py is ran in directory build_scripts
    patch_dir = os.path.join(root_dir, 'patches')

    try:
        if args.clean:
            clean.clean_all(sdk)

        if args.create_patch_filename:
            sdk.prepare_sdk()
            old_path = sdk.path

            tempdir_path = None

            try:
                tempdir_path = tempfile.mkdtemp(prefix='nordicsemi')
                sdk.path = os.path.join(tempdir_path, "orig_sdk")
                sdk.prepare_sdk()
                p = Patch(patch_dir=patch_dir,
                          apply_patch_root_dir=sdk.path,
                          strip=0  # The old patches has 4 more components
                          )
                p.create_patch(tempdir_path, old_path, os.path.join(patch_dir, args.create_patch_filename))
            finally:
                sdk.path = old_path
                shutil.rmtree(tempdir_path)

        if args.dependencies:
            sdk.prepare_sdk()
            patch_tag_file = posixpath.join(sdk.path, ".patched")

            if os.path.exists(patch_tag_file):
                logger.info("Patches are already applied to this SDK, skipping patching")
            else:
                open(patch_tag_file, 'w').close()
                p = Patch(patch_dir=patch_dir,
                          apply_patch_root_dir=sdk.path,
                          strip=0  # The old patches has 4 more components
                          )
                p.apply_patches(dry_run=False)

        if args.build:
            serialization_dll.build()

        if args.test:
            error_code = tests.do_testing()

            if error_code != 0:
                return error_code

        if args.package:
            package_release()

        if args.examples:
            examples.build_examples()

    except Exception, ex:
        logger.exception(ex)
        return -1
예제 #3
0
def build():
    logger.info('Building serialization dll artifacts with CMake')

    sdk_info = Sdk(config.ARTIFACTS_ROOT, config.SDK_VERSION)

    utility.make_directory(config.SERIALIZATION_BUILD_DIR)

    if config.PLATFORM_SYSTEM == 'Windows':
        generator = 'MinGW Makefiles'
    elif config.PLATFORM_SYSTEM in ['Linux', 'Darwin']:
        generator = 'Unix Makefiles'
    else:
        raise SystemError('Unknown platform. Not able to determine generator.')

    cmake_environment = None

    # Remove any git/bin path in environment variable PATH
    if config.PLATFORM_SYSTEM == 'Windows':
        environment_path = os.environ['PATH']
        environment_path_list = environment_path.split(';')
        environment_path_list = [
            path for path in environment_path_list if 'Git\\bin' not in path
        ]
        environment_path = ';'.join(environment_path_list)

        cmake_environment = copy.copy(os.environ)
        cmake_environment['PATH'] = environment_path

    for artifact in ['driver', 'binding']:
        cmake_args = [
            'cmake', '-G', '{0}'.format(generator),
            '-DNRF51_SDK_PATH={0}'.format(sdk_info.path),
            '-DSERIALIZATION_VERSION={0}'.format(config.VERSION),
            '-DSERIALIZATION_REVISION={0}'.format(config.REVISION),
            '-DARTIFACT={0}'.format(artifact), config.REPO_ROOT_DIR
        ]

        logging.debug("Starting to build with command: %s",
                      " ".join(cmake_args))

        return_code = None

        try:
            return_code = subprocess.call(cmake_args,
                                          shell=False,
                                          env=cmake_environment)

            if return_code != 0:
                err_msg = 'Failed to prepare build of {0} libraries. Error code: {1}.'.format(
                    artifact, return_code)
                utility.add_log_message(err_msg)
                raise SystemError(err_msg)

            return_code = subprocess.call([config.PLATFORM_MAKE], shell=True)

            if return_code != 0:
                err_msg = 'Failed to build artifact {0}. Error code: {0}.'.format(
                    artifact, return_code)
                utility.add_log_message(err_msg)
                raise SystemError(err_msg)
        except Exception, e:
            logger.fatal(e)
            return return_code