Beispiel #1
0
    def _generate_project(self, toolchain_file, parameters):
        '''runs CMake to generate Makefiles or Project'''
        # Obtain generator
        settings = self.hive_disk_image.settings
        generator = settings.cmake.generator

        # Define toolchain if necessary, for arduino or cross building
        toolchain = '' if not toolchain_file else '-DCMAKE_TOOLCHAIN_FILE=%s' % toolchain_file

        # Define command to run
        parameters = ' '.join(parameters)
        cmake_rel_path = os.path.relpath(self.bii_paths.cmake,
                                         self.bii_paths.build)
        command = ('"%s" %s -G "%s" -Wno-dev %s %s' % (cmake_command(
            self.bii_paths), toolchain, generator, parameters, cmake_rel_path))
        self.user_io.out.write('Running: %s\n' % command)

        if 'NMake' in generator:
            # VS specific: it is neccesary to call vcvarall
            self.user_io.out.warn(
                'NMake generator must run in a shell with compiler defined.\n'
                'It might not work if not')
            command = command_with_vcvars(generator, self.bii_paths.build,
                                          command)

        retcode, cmake_output = execute(command,
                                        self.user_io,
                                        cwd=self.bii_paths.build)
        if 'Does not match the generator used previously' in cmake_output:
            try:
                self.user_io.out.warn(
                    'Previous generator does not match. Deleting build folder '
                    'and trying again')
                self.hive_disk_image.delete_build_folder()
            except Exception as e:
                self.user_io.out.warn('Could not complete deletion %s' %
                                      str(e))
            self.user_io.out.warn('Running cmake again')
            retcode, cmake_output = execute(command,
                                            self.user_io,
                                            cwd=self.bii_paths.build)
        if retcode != 0:
            logger.error(cmake_output)
            raise BiiException('CMake failed')

        if 'Eclipse' in self.hive_disk_image.settings.cmake.generator:
            ide = Eclipse(self.bii_paths)
            ide.configure_project()
            self.user_io.out.success(
                'Eclipse project in %s\n'
                'Open eclipse, select "File > Import > General > '
                'Existing project into Workspace" '
                'and select folder\n' % self.bii_paths.project_root)
Beispiel #2
0
    def _generate_project(self, toolchain_file, parameters):
        '''runs CMake to generate Makefiles or Project'''
        # Obtain generator
        settings = self.hive_disk_image.settings
        generator = settings.cmake.generator

        # Define toolchain if necessary, for arduino or cross building
        toolchain = '' if not toolchain_file else '-DCMAKE_TOOLCHAIN_FILE=%s' % toolchain_file

        # Define command to run
        parameters = ' '.join(parameters)
        cmake_rel_path = os.path.relpath(self.bii_paths.cmake, self.bii_paths.build)
        command = ('"%s" %s -G "%s" -Wno-dev %s %s'
                   % (cmake_command(self.bii_paths), toolchain, generator, parameters,
                      cmake_rel_path))
        self.user_io.out.write('Running: %s\n' % command)

        if 'NMake' in generator:
            # VS specific: it is neccesary to call vcvarall
            self.user_io.out.warn('NMake generator must run in a shell with compiler defined.\n'
                                  'It might not work if not')
            command = command_with_vcvars(generator, self.bii_paths.build, command)

        retcode, cmake_output = execute(command, self.user_io, cwd=self.bii_paths.build)
        if 'Does not match the generator used previously' in cmake_output:
            try:
                self.user_io.out.warn('Previous generator does not match. Deleting build folder '
                                      'and trying again')
                self.hive_disk_image.delete_build_folder()
            except Exception as e:
                self.user_io.out.warn('Could not complete deletion %s' % str(e))
            self.user_io.out.warn('Running cmake again')
            retcode, cmake_output = execute(command, self.user_io, cwd=self.bii_paths.build)
        if retcode != 0:
            logger.error(cmake_output)
            raise BiiException('CMake failed')

        if 'Eclipse' in self.hive_disk_image.settings.cmake.generator:
            ide = Eclipse(self.bii_paths)
            ide.configure_project()
            self.user_io.out.success('Eclipse project in %s\n'
                                     'Open eclipse, select "File > Import > General > '
                                     'Existing project into Workspace" '
                                     'and select folder\n' % self.bii_paths.project_root)
Beispiel #3
0
    def _build(self, *parameters):
        paths_to_add = self.prepare_build_path()
        with CustomEnvPath(paths_to_add=paths_to_add):
            paths = self.bii.bii_paths
            if len(parameters) == 1:  # It's tuple, first element is list with actual parameters
                parameters = parameters[0]
            self._handle_parallel_build(parameters)
            build_options = ' '.join(parameters)

            # Necessary for building in windows (cygwin in path)
            cmd = '"%s" --build . %s' % (cmake_command(paths), build_options)
            self.bii.user_io.out.write('Building: %s\n' % cmd)
            retcode = simple_exe(cmd, cwd=paths.build)
            if 'Eclipse' in self.bii.hive_disk_image.settings.cmake.generator:
                ide = Eclipse(paths)
                try:
                    ide.configure_project()
                except IOError:
                    pass
            if retcode != 0:
                raise BiiException('Build failed')
Beispiel #4
0
    def _build(self, *parameters):
        paths_to_add = self.prepare_build_path()
        with CustomEnvPath(paths_to_add=paths_to_add):
            paths = self.bii.bii_paths
            if len(
                    parameters
            ) == 1:  # It's tuple, first element is list with actual parameters
                parameters = parameters[0]
            self._handle_parallel_build(parameters)
            build_options = ' '.join(parameters)

            # Necessary for building in windows (cygwin in path)
            cmd = '"%s" --build . %s' % (cmake_command(paths), build_options)
            self.bii.user_io.out.write('Building: %s\n' % cmd)
            retcode = simple_exe(cmd, cwd=paths.build)
            if 'Eclipse' in self.bii.hive_disk_image.settings.cmake.generator:
                ide = Eclipse(paths)
                try:
                    ide.configure_project()
                except IOError:
                    pass
            if retcode != 0:
                raise BiiException('Build failed')