Exemplo n.º 1
0
    def settings(self, *parameters):
        '''Configure project settings for arduino'''
        parser = argparse.ArgumentParser(description=self.settings.__doc__,
                                         prog="bii %s:settings" % self.group)
        parser.add_argument(
            '--sdk',
            help='SDK directory. Write "default" if you want biicode'
            ' tries to find some default directory')
        parser.add_argument("--board", help="Arduino board's name")
        parser.add_argument("--port",
                            help='Port where your Arduino is connected')
        parser.add_argument(
            "--need_reset",
            choices=['true', 'false'],
            help="True or False if your port'd need to be reseted")
        args = parser.parse_args(*parameters)  # for -h

        settings = self.hive_disk_image.settings
        if any([args.sdk, args.board, args.port, args.need_reset]):
            arduino_settings_args(self.bii.user_io, args, settings)
        else:
            arduino_settings_wizard(self.bii.user_io, settings)
        self.hive_disk_image.settings = settings
        install_arduino_toolchain(self.bii)
        regenerate_arduino_settings_cmake(self.bii)
Exemplo n.º 2
0
    def _handle_toolchain(self, name):
        """ name KEEP_CURRENT_TOOLCHAIN string means keep current.
            name = None means invalidate current
        and use default
        """
        settings = self.hive_disk_image.settings
        current_toolchain = settings.cmake.toolchain
        if (name == KEEP_CURRENT_TOOLCHAIN):
            name = current_toolchain
            if name is None:  # There was no previous toolchain
                return None

        if name and name != current_toolchain:  # Toolchain change
            toolchain_path = os.path.join(self.bii_paths.bii,
                                          '%s_toolchain.cmake' % name)
            if not os.path.exists(toolchain_path):
                if name == "arduino":
                    raise BiiException(
                        "Arduino toolchain not found, please execute"
                        " 'bii arduino:settings' first")
                elif name == "rpi":
                    raise BiiException(
                        "Raspberry Pi toolchain not found, please execute"
                        " 'bii rpi:settings' first")
                else:
                    raise BiiException("CMake %s toolchain not found" %
                                       toolchain_path)
            self.user_io.out.warn(
                'Toolchain changed to %s, regenerating project' %
                toolchain_path)
            self.hive_disk_image.delete_build_folder()
        elif name is None:  # Remove toolchain
            toolchain_path = None
            self.user_io.out.warn('Removing toolchain, regenerating project')
            self.hive_disk_image.delete_build_folder()
        else:  # Keep old toolchain
            toolchain_path = os.path.join(self.bii_paths.bii,
                                          '%s_toolchain.cmake' % name)

        # If arduino, regenerate arduino_settings.cmake from settings
        # (needed if manual change without arduino:settings)
        if name == "arduino":
            regenerate_arduino_settings_cmake(self.bii)

        settings.cmake.toolchain = name
        self.hive_disk_image.settings = settings
        return toolchain_path
Exemplo n.º 3
0
    def settings(self, *parameters):
        '''Configure project settings for arduino'''
        parser = argparse.ArgumentParser(description=self.settings.__doc__,
                                         prog="bii %s:settings" % self.group)
        parser.add_argument('--sdk', help='SDK directory. Write "default" if you want biicode'
                                 ' tries to find some default directory')
        parser.add_argument("--board", help="Arduino board's name")
        parser.add_argument("--port", help='Port where your Arduino is connected')
        parser.add_argument("--need_reset", choices=['true', 'false'],
                            help="True or False if your port'd need to be reseted")
        args = parser.parse_args(*parameters)  # for -h

        settings = self.hive_disk_image.settings
        if any([args.sdk, args.board, args.port, args.need_reset]):
            arduino_settings_args(self.bii.user_io, args, settings)
        else:
            arduino_settings_wizard(self.bii.user_io, settings)
        self.hive_disk_image.settings = settings
        install_arduino_toolchain(self.bii)
        regenerate_arduino_settings_cmake(self.bii)
Exemplo n.º 4
0
    def _handle_toolchain(self, name):
        """ name KEEP_CURRENT_TOOLCHAIN string means keep current.
            name = None means invalidate current
        and use default
        """
        settings = self.hive_disk_image.settings
        current_toolchain = settings.cmake.toolchain
        if (name == KEEP_CURRENT_TOOLCHAIN):
            name = current_toolchain
            if name is None:  # There was no previous toolchain
                return None

        if name and name != current_toolchain:  # Toolchain change
            toolchain_path = os.path.join(self.bii_paths.bii, '%s_toolchain.cmake' % name)
            if not os.path.exists(toolchain_path):
                if name == "arduino":
                    raise BiiException("Arduino toolchain not found, please execute"
                                       " 'bii arduino:settings' first")
                elif name == "rpi":
                    raise BiiException("Raspberry Pi toolchain not found, please execute"
                                       " 'bii rpi:settings' first")
                else:
                    raise BiiException("CMake %s toolchain not found" % toolchain_path)
            self.user_io.out.warn('Toolchain changed to %s, regenerating project' % toolchain_path)
            self.hive_disk_image.delete_build_folder()
        elif name is None:  # Remove toolchain
            toolchain_path = None
            self.user_io.out.warn('Removing toolchain, regenerating project')
            self.hive_disk_image.delete_build_folder()
        else:  # Keep old toolchain
            toolchain_path = os.path.join(self.bii_paths.bii, '%s_toolchain.cmake' % name)

        # If arduino, regenerate arduino_settings.cmake from settings
        # (needed if manual change without arduino:settings)
        if name == "arduino":
            regenerate_arduino_settings_cmake(self.bii)

        settings.cmake.toolchain = name
        self.hive_disk_image.settings = settings
        return toolchain_path