Esempio n. 1
0
    def executableTarget(self, config, targetName):
        cmakeTargetToRun = None

        for cmakeConfiguration in self.codeModel["configurations"]:
            if cmakeConfiguration["name"] == '' or cmakeConfiguration[
                    "name"] == config:
                self.logger.debug("Found config: %s",
                                  cmakeConfiguration["name"])

                for cmakeProject in cmakeConfiguration["projects"]:
                    self.logger.debug(" Found project: %s",
                                      cmakeProject["name"])

                    for cmakeTarget in cmakeProject["targets"]:
                        self.logger.debug("  Found target: %s",
                                          cmakeTarget["name"])

                        if cmakeTarget["name"] == targetName:
                            cmakeTargetToRun = cmakeTarget

        if not cmakeTargetToRun:
            raise error.ProgramArgumentError("Couldn't find module %s" %
                                             self.args.target)

        if cmakeTargetToRun["type"] != "EXECUTABLE":
            raise error.ProgramArgumentError("Module %s is not an executable" %
                                             self.args.target)

        return cmakeTargetToRun
Esempio n. 2
0
    def run(self, configuration):
        if not self.args.target:
            raise error.ProgramArgumentError("Please specify a module name with --module MODULE")
        
        if not self.args.platform:
            raise error.ProgramArgumentError("Please specify the platform name with --platform PLATFORM")
        
        if not self.args.config:
            raise error.ProgramArgumentError("Please specify the configuration name with --config CONFIG")

        if configuration.platform == "ios":
            if configuration.arch == "device":
                raise error.ProgramArgumentError("Can't run on ios devices yet")
            if configuration.arch == "std" and configuration.buildsystem == 'Xcode':
                raise error.ProgramArgumentError("Can't run on ios devices yet, specifiy architecture 'simulator' to run.")

            iosRunner = IOSRunner(self.buildExecutor.cmake)
            exitCode = iosRunner.run(configuration, self.args)

        elif configuration.platform == "android":
            if configuration.buildsystem == "AndroidStudio":
                androidRunner = AndroidRunner(self.buildFolder, self.androidExecutor)
                exitCode = androidRunner.run(configuration, self.args)
            else:
                self.logger.critical("Only AndroidStudio configurations can be run")
                exit(1)

        else:
            appRunner = DesktopRunner(self.buildExecutor.cmake, configuration, self.args)
            exitCode = appRunner.run()

        if exitCode != 0:
            raise error.ErrorWithExitCode( "Application failed with exit code: 0x{:02x}".format(exitCode), exitCode)
Esempio n. 3
0
    def generate(self, args):
        template_folder = os.path.normpath(
            os.path.join(os.path.realpath(__file__), '..', 'templates', 'app'))
        boden_folder = os.path.normpath(
            os.path.join(os.path.realpath(__file__), '..', '..'))
        project_folder = os.path.join(os.path.abspath(args.project_folder),
                                      args.project_name)

        if os.path.exists(project_folder) and len(
                os.listdir(project_folder)) > 0:
            raise error.ProgramArgumentError(
                "Selected folder %s is not empty!" % project_folder)

        boden_relative_path = os.path.relpath(boden_folder, project_folder)

        vars = {
            'project_name': args.project_name,
            'project_folder': project_folder,
            'boden_relative_path': boden_relative_path
        }

        self.logger.info("Creating project in %s", project_folder)

        shutil.copytree(template_folder, project_folder)

        for entries in os.walk(project_folder):
            for file in entries[2]:
                self.process_template(os.path.join(entries[0], file), vars)
Esempio n. 4
0
    def runExecutable(self, artifactToRun, args):
        self.ios_simulator_device_type = self.iosInfo.getSelectedDeviceType(
            args)
        self.ios_simulator_os = self.iosInfo.getSelectedOS(args)

        self.logger.debug("IOS Device type:  %s",
                          self.ios_simulator_device_type)
        self.logger.debug("IOS Simulator OS: %s", self.ios_simulator_os)

        self.logger.debug("Executable: %s", artifactToRun)

        if not artifactToRun:
            raise error.ProgramArgumentError(
                "Couldn't find path to exectuable for Module %s" % args.target)

        if artifactToRun.endswith('.app') and os.path.isdir(artifactToRun):
            r = self.readPList(os.path.join(artifactToRun, "Info.plist"))
            executable = r["CFBundleExecutable"]
            artifactToRun = os.path.join(artifactToRun, executable)

        if not os.path.exists(artifactToRun):
            raise error.ProgramArgumentError(
                "exectuable for Module %s does not exists at: %s" %
                (args.target, artifactToRun))

        bundlePath = self.getBundlePathFromExecutable(artifactToRun)

        bundleId = self.getBundleIdentifier(bundlePath)
        self.logger.debug("Bundle Identifier: %s", bundleId)

        simulatorId = None
        try:
            simulatorId = self.createSimulatorDevice()

            self.logger.debug("Simulator Id: %s", simulatorId)

            self.bootSimulator(simulatorId)
            self.installApp(simulatorId, bundlePath)
            processId = self.startApp(simulatorId, bundleId, args)
            self.waitForAppToExit(simulatorId, processId, bundleId)
        finally:
            if simulatorId:
                self.shutdownSimulator(simulatorId)

        return 0
Esempio n. 5
0
    def findDeviceType(self, name):
        deviceTypes = self.getAvailableDeviceTypes()
        if name in deviceTypes:
            return deviceTypes[name]

        self.logger.critical("Couldn't find Device type %s", name)
        self.logger.info("Available device types:")
        for name, deviceId in deviceTypes.items():
            self.logger.info("  %s" % (name))

        raise error.ProgramArgumentError("--ios-device-type invalid")
Esempio n. 6
0
    def unlockKeychain(self, keychainPath, password):
        self.logger.debug('Unlock: %s *****', keychainPath)
        currentKeychains = self.getCurrentKeychains()
        if not keychainPath in currentKeychains:
            raise error.ProgramArgumentError('Keychain %s is not registered!' %
                                             keychainPath)

        result = self.callAndGetError(
            [self.sec, 'unlock-keychain', '-p', password, keychainPath])
        if len(result) > 0:
            self.logger.critical(result)
Esempio n. 7
0
    def generate(self, args):
        template_folder = os.path.normpath(
            os.path.join(os.path.realpath(__file__), '..', 'templates', 'app'))
        boden_folder = os.path.normpath(
            os.path.join(os.path.realpath(__file__), '..', '..'))
        project_folder = os.path.join(os.path.abspath(args.project_folder),
                                      args.project_name)

        if os.path.exists(project_folder) and len(
                os.listdir(project_folder)) > 0:
            raise error.ProgramArgumentError(
                "Selected folder %s is not empty!" % project_folder)

        if args.project_name == 'test':
            raise error.ProgramArgumentError(
                "'test' is not a valid project name, since cmake regards it as a special target!"
            )

        if "-" in args.project_name:
            raise error.ProgramArgumentError(
                "You cannot use '-' in the project name, as Android can not handle it"
            )

        boden_relative_path = os.path.relpath(boden_folder, project_folder)

        vars = {
            'project_name': args.project_name,
            'project_folder': project_folder,
            'boden_relative_path': boden_relative_path
        }

        self.logger.info("Creating project in %s", project_folder)

        shutil.copytree(template_folder, project_folder)

        for entries in os.walk(project_folder):
            for file in entries[2]:
                self.process_template(os.path.join(entries[0], file), vars)
Esempio n. 8
0
    def findSimulatorOS(self, name):
        versions = self.getAvailableSimulatorOSVersions()
        if ' ' in name:
            n, version = name.split(' ')[:2]
            fversion = float(version)

            if n in versions:
                if fversion in versions[n]:
                    return versions[n][fversion]

        self.logger.critical("Couldn't find iOS version %s", name)
        self.logger.info("Available versions:")
        for type, v in versions.items():
            for version in v.keys():
                self.logger.info("  %s %s" % (type, version))

        raise error.ProgramArgumentError("--ios-simulator-version invalid")
Esempio n. 9
0
    def run(self):
        cmakeTargetToRun = self.cmake.executableTarget(self.args.config,
                                                       self.args.target)
        artifactToRun = self.cmake.executableArtifactPath(cmakeTargetToRun)

        self.logger.debug("Executable: %s", artifactToRun)

        if not artifactToRun:
            raise error.ProgramArgumentError(
                "Couldn't find path to exectuable for Module %s" %
                self.args.target)

        self.logger.debug("Path: %s", artifactToRun)

        if sys.platform == "win32":
            return self.runWindowsApplication(artifactToRun)
        else:
            return self.runUnixApplication(artifactToRun)
Esempio n. 10
0
    def process(self):
        command = self.args.command;

        self.logger.debug('Starting command: %s', command)

        selectedConfigurations = self.buildFolder.getBuildConfigurationsForCommand();
        self.logger.debug("Selected platform list:")
        for config in selectedConfigurations:
            self.logger.debug("* %s", config)

        if len(selectedConfigurations)==0:
            defaultLadderKey = (self.args.platform, self.args.build_system)
            architecture = self.args.arch
            configuration = self.args.config
            if not architecture:
                architecture = "std"

            if defaultLadderKey in self.defaultLadder:
                defaults = self.defaultLadder[defaultLadderKey]

                self.logger.info("Defaulting to: %s - %s" % (defaults[0], defaults[1]))
                selectedConfigurations = [
                    BuildConfiguration(platform=defaults[0], arch=architecture, buildsystem=defaults[1], config=configuration)
                ]
            else:
                raise error.IncorrectCallError("Could not determine default platform / buildsystem ( and configuration ). Please specifiy one via -p, -b (and -c)")

        for configuration in selectedConfigurations:
            if configuration.platform not in self.bauerGlobals.platformMap:
                raise error.InvalidPlatformNameError(configuration.platform);

            buildDirectory = self.buildFolder.getBuildDir(configuration)
    
            with GeneratorState(buildDirectory) as platformState:
                if not "build-configuration" in platformState.state or BuildConfiguration(*platformState.state["build-configuration"]) != configuration:
                    if os.path.exists(buildDirectory):
                        self.logger.info("Build system does not match the one used when the projects for this platform were first prepared. Cleaning existing build files.");
                        if "build-configuration" in platformState.state:
                            self.logger.debug("Old config: ", BuildConfiguration(*platformState.state["build-configuration"]))
                        else:
                            self.logger.debug("(No previous state found)")
                        self.logger.debug("New config: %s", configuration)
                        shutil.rmtree(buildDirectory);

                platformState.state["build-configuration"] = configuration;
        
                if command=="prepare":
                    self.prepare(configuration, platformState);

                elif command=="build":
                    self.prepare(configuration, platformState);
                    self.build(configuration);

                elif command=="clean":
                    self.clean(configuration);

                elif command=="distclean":
                    self.distClean(buildDirectory);

                elif command=="builddeps":
                    self.buildDeps(configuration);

                elif command=="run":
                    self.prepare(configuration, platformState);
                    #self.build(configuration);
                    self.run(configuration);
                elif command=="package":
                    self.prepare(configuration, platformState);
                    self.package(configuration);
                elif command=="codesign":
                    self.prepare(configuration, platformState);
                    self.codesign(configuration)
                elif command=="copy":
                    self.copy(buildDirectory)
                elif command=="open":
                    self.prepare(configuration, platformState)
                    self.open(configuration, buildDirectory)
                else:
                    raise error.ProgramArgumentError("Invalid command: '%s'" % command);