How to use the west.build.is_zephyr_build function in west

To help you get started, we’ve selected a few west examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zephyrproject-rtos / west / src / west / commands / build.py View on Github external
def _setup_build_dir(self):
        # Initialize build_dir and created_build_dir attributes.
        log.dbg('setting up build directory', level=log.VERBOSE_EXTREME)
        if self.args.build_dir:
            build_dir = self.args.build_dir
        else:
            cwd = os.getcwd()
            if is_zephyr_build(cwd):
                build_dir = cwd
            else:
                build_dir = DEFAULT_BUILD_DIR
        build_dir = os.path.abspath(build_dir)

        if os.path.exists(build_dir):
            if not os.path.isdir(build_dir):
                log.die('build directory {} exists and is not a directory'.
                        format(build_dir))
        else:
            os.makedirs(build_dir, exist_ok=False)
            self.created_build_dir = True
            self.run_cmake = True

        self.build_dir = build_dir
github zephyrproject-rtos / zephyr / scripts / meta / west / commands / build.py View on Github external
def _setup_build_dir(self):
        # Initialize build_dir and created_build_dir attributes.
        log.dbg('setting up build directory', level=log.VERBOSE_EXTREME)
        if self.args.build_dir:
            build_dir = self.args.build_dir
        else:
            cwd = os.getcwd()
            if is_zephyr_build(cwd):
                build_dir = cwd
            else:
                build_dir = DEFAULT_BUILD_DIR
        build_dir = os.path.abspath(build_dir)

        if os.path.exists(build_dir):
            if not os.path.isdir(build_dir):
                log.die('build directory {} exists and is not a directory'.
                        format(build_dir))
        else:
            os.makedirs(build_dir, exist_ok=False)
            self.created_build_dir = True
            self.run_cmake = True

        self.build_dir = build_dir
github zephyrproject-rtos / west / src / west / commands / run_common.py View on Github external
def _build_dir(args, die_if_none=True):
    # Get the build directory for the given argument list and environment.
    if args.build_dir:
        return args.build_dir

    cwd = getcwd()
    default = path.join(cwd, DEFAULT_BUILD_DIR)
    if is_zephyr_build(default):
        return default
    elif is_zephyr_build(cwd):
        return cwd
    elif die_if_none:
        log.die('--build-dir was not given, and neither {} '
                'nor {} are zephyr build directories.'.
                format(default, cwd))
    else:
        return None
github zephyrproject-rtos / west / src / west / commands / run_common.py View on Github external
def _build_dir(args, die_if_none=True):
    # Get the build directory for the given argument list and environment.
    if args.build_dir:
        return args.build_dir

    cwd = getcwd()
    default = path.join(cwd, DEFAULT_BUILD_DIR)
    if is_zephyr_build(default):
        return default
    elif is_zephyr_build(cwd):
        return cwd
    elif die_if_none:
        log.die('--build-dir was not given, and neither {} '
                'nor {} are zephyr build directories.'.
                format(default, cwd))
    else:
        return None
github zephyrproject-rtos / west / src / west / commands / build.py View on Github external
def _sanity_check(self):
        # Sanity check the build configuration.
        # Side effect: may update cmake_cache attribute.
        log.dbg('sanity checking the build', level=log.VERBOSE_EXTREME)
        if self.source_dir == self.build_dir:
            # There's no forcing this.
            log.die('source and build directory {} cannot be the same; '
                    'use --build-dir {} to specify a build directory'.
                    format(self.source_dir, self.build_dir))

        srcrel = os.path.relpath(self.source_dir)
        if is_zephyr_build(self.source_dir):
            self._check_force('it looks like {srcrel} is a build directory: '
                              'did you mean -build-dir {srcrel} instead?'.
                              format(srcrel=srcrel))
        elif 'CMakeLists.txt' not in os.listdir(self.source_dir):
            self._check_force('source directory "{srcrel}" does not contain '
                              'a CMakeLists.txt; is that really what you '
                              'want to build? (Use -s SOURCE_DIR to specify '
                              'the application source directory)'.
                              format(srcrel=srcrel))

        if not is_zephyr_build(self.build_dir) and not self.args.board:
            self._check_force('this looks like a new or clean build, '
                              'please provide --board')

        if not self.cmake_cache:
            return          # That's all we can check without a cache.
github zephyrproject-rtos / zephyr / scripts / meta / west / commands / build.py View on Github external
def _sanity_check(self):
        # Sanity check the build configuration.
        # Side effect: may update cmake_cache attribute.
        log.dbg('sanity checking the build', level=log.VERBOSE_EXTREME)
        if self.source_dir == self.build_dir:
            # There's no forcing this.
            log.die('source and build directory {} cannot be the same; '
                    'use --build-dir {} to specify a build directory'.
                    format(self.source_dir, self.build_dir))

        srcrel = os.path.relpath(self.source_dir)
        if is_zephyr_build(self.source_dir):
            self._check_force('it looks like {srcrel} is a build directory: '
                              'did you mean -build-dir {srcrel} instead?'.
                              format(srcrel=srcrel))
        elif 'CMakeLists.txt' not in os.listdir(self.source_dir):
            self._check_force('source directory "{srcrel}" does not contain '
                              'a CMakeLists.txt; is that really what you '
                              'want to build? (Use -s SOURCE_DIR to specify '
                              'the application source directory)'.
                              format(srcrel=srcrel))

        if not is_zephyr_build(self.build_dir) and not self.args.board:
            self._check_force('this looks like a new or clean build, '
                              'please provide --board')

        if not self.cmake_cache:
            return          # That's all we can check without a cache.
github zephyrproject-rtos / zephyr / scripts / meta / west / commands / run_common.py View on Github external
def _build_dir(args, die_if_none=True):
    # Get the build directory for the given argument list and environment.
    if args.build_dir:
        return args.build_dir

    cwd = getcwd()
    default = path.join(cwd, DEFAULT_BUILD_DIR)
    if is_zephyr_build(default):
        return default
    elif is_zephyr_build(cwd):
        return cwd
    elif die_if_none:
        log.die('--build-dir was not given, and neither {} '
                'nor {} are zephyr build directories.'.
                format(default, cwd))
    else:
        return None