Example #1
0
    def test_find_gnu_arm(self, exists):
        exists.return_value = False
        self.assertEqual((None, None), find_gnu_arm())

        exists.return_value = True
        c_path, cpp_path = find_gnu_arm()
        inst_path = get_biicode_env_folder_path().replace('\\', '/')
        c_path = c_path.replace('\\', '/')
        cpp_path = cpp_path.replace('\\', '/')
        inst_path = '%s/raspberry_cross_compilers/arm-bcm2708/'\
                    'arm-bcm2708hardfp-linux-gnueabi/bin/'\
                    'arm-bcm2708hardfp-linux-gnueabi' % inst_path
        self.assertTrue(cpp_path.endswith('%s-g++' % inst_path))
        self.assertTrue(c_path.endswith('%s-gcc' % inst_path))
Example #2
0
    def test_find_gnu_arm(self, exists):
        exists.return_value = False
        self.assertEqual((None, None), find_gnu_arm())

        exists.return_value = True
        c_path, cpp_path = find_gnu_arm()
        inst_path = get_biicode_env_folder_path().replace('\\', '/')
        c_path = c_path.replace('\\', '/')
        cpp_path = cpp_path.replace('\\', '/')
        inst_path = '%s/raspberry_cross_compilers/arm-bcm2708/'\
                    'arm-bcm2708hardfp-linux-gnueabi/bin/'\
                    'arm-bcm2708hardfp-linux-gnueabi' % inst_path
        self.assertTrue(cpp_path.endswith('%s-g++' % inst_path))
        self.assertTrue(c_path.endswith('%s-gcc' % inst_path))
Example #3
0
    def settings(self, *parameters):
        '''Configure Raspberry Pi project settings'''
        parser = argparse.ArgumentParser(description=self.settings.__doc__,
                                         prog="bii %s:settings" % self.group)
        parser.add_argument('--user', help='Your RPi user session, e.g.: pi')
        parser.add_argument("--ip", help="Your RPi IP, e.g.: 50.1.2.3")
        parser.add_argument(
            "--directory",
            help="Directory where you'll send the binary files, e.g.: bin")
        args = parser.parse_args(*parameters)  # for -h

        settings = self.hive_disk_image.settings
        if any([args.user, args.ip, args.directory]):
            rpi_settings_args(args, settings)
        else:
            rpi_settings_wizard(self.user_io, settings)

        #Write to disk
        self.hive_disk_image.settings = settings
        self.user_io.out.info('Settings saved in:  %s' % self.paths.settings)

        toolchain_rpi_path = os.path.join(self.paths.bii,
                                          "rpi_toolchain.cmake")
        if not os.path.exists(toolchain_rpi_path):
            if OSInfo.is_linux():
                self.user_io.out.write('Creating toolchain for Raspberry PI\n',
                                       Color.BLUE)
                c_path, cpp_path = find_gnu_arm()
                if not c_path or not cpp_path:
                    self.user_io.out.error(
                        "Unable to find RPI cross-compilers.\n"
                        "Try executing bii setup:rpi")

                content = []
                content.append("INCLUDE(CMakeForceCompiler)")
                content.append("SET(CMAKE_SYSTEM_NAME Linux)")
                content.append("SET(CMAKE_SYSTEM_VERSION 1)")
                content.append("SET(CMAKE_C_COMPILER %s)" % c_path)
                content.append("SET(CMAKE_CXX_COMPILER %s)" % cpp_path)
                content = os.linesep.join(content)
                save_blob_if_modified(toolchain_rpi_path, Blob(content))

                self.user_io.out.success(
                    'Run "bii configure -t rpi" to activate it')
                self.user_io.out.success(
                    'Run "bii configure -t" to disable it')
            else:
                self.user_io.out.error(
                    "Toolchain for R-Pi only available in Linux now")
                self.user_io.out.error(
                    "You can try to define your own bii/rpi_toolchain.cmake")
Example #4
0
    def settings(self, *parameters):
        '''Configure Raspberry Pi project settings'''
        parser = argparse.ArgumentParser(description=self.settings.__doc__,
                                         prog="bii %s:settings" % self.group)
        parser.add_argument('--user', help='Your RPi user session, e.g.: pi')
        parser.add_argument("--ip", help="Your RPi IP, e.g.: 50.1.2.3")
        parser.add_argument("--directory", help="Directory where you'll send the binary files, e.g.: bin")
        args = parser.parse_args(*parameters)  # for -h

        settings = self.hive_disk_image.settings
        if any([args.user, args.ip, args.directory]):
            rpi_settings_args(args, settings)
        else:
            rpi_settings_wizard(self.user_io, settings)

        #Write to disk
        self.hive_disk_image.settings = settings
        self.user_io.out.info('Settings saved in:  %s' % self.paths.settings)

        toolchain_rpi_path = os.path.join(self.paths.bii, "rpi_toolchain.cmake")
        if not os.path.exists(toolchain_rpi_path):
            if OSInfo.is_linux():
                self.user_io.out.write('Creating toolchain for Raspberry PI\n', Color.BLUE)
                c_path, cpp_path = find_gnu_arm()
                if not c_path or not cpp_path:
                    self.user_io.out.error("Unable to find RPI cross-compilers.\n"
                                           "Try executing bii setup:rpi")

                content = []
                content.append("INCLUDE(CMakeForceCompiler)")
                content.append("SET(CMAKE_SYSTEM_NAME Linux)")
                content.append("SET(CMAKE_SYSTEM_VERSION 1)")
                content.append("SET(CMAKE_C_COMPILER %s)" % c_path)
                content.append("SET(CMAKE_CXX_COMPILER %s)" % cpp_path)
                content = os.linesep.join(content)
                save_blob_if_modified(toolchain_rpi_path, Blob(content))

                self.user_io.out.success('Run "bii configure -t rpi" to activate it')
                self.user_io.out.success('Run "bii configure -t" to disable it')
            else:
                self.user_io.out.error("Toolchain for R-Pi only available in Linux now")
                self.user_io.out.error("You can try to define your own bii/rpi_toolchain.cmake")