Ejemplo n.º 1
0
        def get_platform(value, machine=None):
            """Platform based on string value.

            :param value: a string representing a platform or None
            :type value: str | None
            :param machine: machine name
            :type machine: str | None
            :rtype: a Platform instance or None
            """
            if value is None:
                return None

            # We expect 4 fields for build and host and target
            split_value = ([k if k else None
                            for k in value.split(',')] + [None] * 4)[0:4]

            if split_value[0] == 'build':
                return saved_build
            elif split_value[0] == 'host':
                return saved_host
            elif split_value[0] == 'target':
                return saved_target
            else:
                # Propagate machine name if necessary
                if split_value[2] is None:
                    split_value[2] = machine
                return Platform.get(*split_value)
Ejemplo n.º 2
0
    def set_build(self, name=None, version=None, machine=None, mode=None):
        """Set build platform.

        :param name: a string that identify the system to be considered
            as the build. If None then build is unchanged. Note that passing
            an empty value will force the autodetection and possibly reset to
            the default value.
        :type name: str | None
        :param version: a string containing the system version. If set
            to None the version is either a default or autodetected when
            possible
        :type version: str | None
        :param machine: a string containing the name of the target
            machine.
        :type machine: str | None
        :param mode: a string containing the name of the mode. This
            notion is needed on some targets such as VxWorks to switch between
            kernel mode and other modes such as rtp

        When calling set_build, the target and host systems are reset to the
        build one. Thus you should call set_build before calling either
        set_host or set_target.
        """
        e3.log.debug('set_build (build_name=%s, build_version=%s)', name,
                     version)
        self.build = Platform.get(platform_name=name,
                                  version=version,
                                  machine=machine,
                                  mode=mode)
        self.host = self.build
        self.target = self.build
Ejemplo n.º 3
0
    def set_target(self, name=None, version=None, machine=None, mode=None):
        """Set target platform.

        :param name: a string that identify the system to be considered
            as the host. If None then host is set to the host one. If set to
            'build' or 'host' then target is set respectively to current
            'build' or 'host' value. In that case target_version and
            target_machine are ignored.
        :type name: str | None
        :param version: a string containing the system version. If set
            to None the version is either a default or autodetected when
            possible.
        :type version: str | None
        :param machine: a string containing the name of the target
            machine.
        :type machine: str | None
        :param mode: a string containing the name of the mode. This
            notion is needed on some targets such as VxWorks to switch between
            kernel mode and other modes such as rtp

        The target parameters are ignored if the target_name is equal to the
        host platform.
        """
        if name is None:
            name = 'host'

        if name == 'host':
            self.target = self.host
        elif name == 'build':
            self.target = self.build
        else:
            self.target = Platform.get(platform_name=name,
                                       version=version,
                                       machine=machine,
                                       mode=mode)
Ejemplo n.º 4
0
    def set_host(self, name=None, version=None, machine=None, mode=None):
        """Set host platform.

        :param name: a string that identify the system to be considered
            as the host. If None then host is set to the build one (the
            autodetected platform). If set to 'build' or 'target' then host
            is set respectively to current 'build' or 'target' value
        :type name: str | None
        :param version: a string containing the system version. If set to
            None the version is either a default or autodetected when possible
        :type version: str | None
        :param machine: a string containing the name of the target
            machine.
        :type machine: str | None
        :param mode: a string containing the name of the mode. This
            notion is needed on some targets such as VxWorks to switch between
            kernel mode and other modes such as rtp

        When calling set_host, the target system is reset to the host one.
        Thus you should call set_host before set_target otherwise your call
        to set_target will be ignored. Note also that is the host_name is
        equal to the build platform, host_version will be ignored.
        """
        if name is None:
            name = "build"

        if name == "target":
            self.host = self.target
        elif name == "build":
            self.host = self.build
        else:
            self.host = Platform.get(platform_name=name, version=version, machine=machine, mode=mode)
        self.target = self.host
Ejemplo n.º 5
0
    def set_target(self, name=None, version=None, machine=None, mode=None):
        """Set target platform.

        :param name: a string that identify the system to be considered
            as the host. If None then host is set to the host one. If set to
            'build' or 'host' then target is set respectively to current
            'build' or 'host' value. In that case target_version and
            target_machine are ignored.
        :type name: str | None
        :param version: a string containing the system version. If set
            to None the version is either a default or autodetected when
            possible.
        :type version: str | None
        :param machine: a string containing the name of the target
            machine.
        :type machine: str | None
        :param mode: a string containing the name of the mode. This
            notion is needed on some targets such as VxWorks to switch between
            kernel mode and other modes such as rtp

        The target parameters are ignored if the target_name is equal to the
        host platform.
        """
        if name is None:
            name = "host"

        if name == "host":
            self.target = self.host
        elif name == "build":
            self.target = self.build
        else:
            self.target = Platform.get(platform_name=name, version=version, machine=machine, mode=mode)
Ejemplo n.º 6
0
    def set_build(self, build_name=None, build_version=None):
        """Set build platform.

        :param build_name: a string that identify the system to be considered
            as the build. If None then build is unchanged. Note that passing
            an empty value will force the autodetection and possibly reset to
            the default value.
        :type build_name: str | None
        :param build_version: a string containing the system version. If set
            to None the version is either a default or autodetected when
            possible
        :type build_version: str | None

        When calling set_build, the target and host systems are reset to the
        build one. Thus you should call set_build before calling either
        set_host or set_target.
        """
        e3.log.debug(
            'set_build (build_name=%s, build_version=%s)',
            build_name, build_version)
        if build_name is not None:
            self.build = Platform.get(platform_name=build_name,
                                      is_host=True,
                                      version=build_version)
        self.host = self.build
        self.target = self.build
Ejemplo n.º 7
0
    def set_build(self, name=None, version=None, machine=None, mode=None):
        """Set build platform.

        :param name: a string that identify the system to be considered
            as the build. If None then build is unchanged. Note that passing
            an empty value will force the autodetection and possibly reset to
            the default value.
        :type name: str | None
        :param version: a string containing the system version. If set
            to None the version is either a default or autodetected when
            possible
        :type version: str | None
        :param machine: a string containing the name of the target
            machine.
        :type machine: str | None
        :param mode: a string containing the name of the mode. This
            notion is needed on some targets such as VxWorks to switch between
            kernel mode and other modes such as rtp

        When calling set_build, the target and host systems are reset to the
        build one. Thus you should call set_build before calling either
        set_host or set_target.
        """
        e3.log.debug("set_build (build_name=%s, build_version=%s)", name, version)
        self.build = Platform.get(platform_name=name, version=version, machine=machine, mode=mode)
        self.host = self.build
        self.target = self.build
Ejemplo n.º 8
0
    def set_host(self, name=None, version=None, machine=None, mode=None):
        """Set host platform.

        :param name: a string that identify the system to be considered
            as the host. If None then host is set to the build one (the
            autodetected platform). If set to 'build' or 'target' then host
            is set respectively to current 'build' or 'target' value
        :type name: str | None
        :param version: a string containing the system version. If set to
            None the version is either a default or autodetected when possible
        :type version: str | None
        :param machine: a string containing the name of the target
            machine.
        :type machine: str | None
        :param mode: a string containing the name of the mode. This
            notion is needed on some targets such as VxWorks to switch between
            kernel mode and other modes such as rtp

        When calling set_host, the target system is reset to the host one.
        Thus you should call set_host before set_target otherwise your call
        to set_target will be ignored. Note also that is the host_name is
        equal to the build platform, host_version will be ignored.
        """
        if name is None:
            name = "build"

        if name == "target":
            self.host = self.target
        elif name == "build":
            self.host = self.build
        else:
            self.host = Platform.get(
                platform_name=name, version=version, machine=machine, mode=mode
            )
        self.target = self.host
Ejemplo n.º 9
0
 def __init__(self, build=None, host=None, target=None):
     if not self._initialized:
         self.build = Platform.get() if build is None else build
         self.host = self.build if host is None else host
         self.target = self.host if target is None else target
         self.environ = None
         self.cwd = None
         self.main_options = None
Ejemplo n.º 10
0
 def __init__(self, build=None, host=None, target=None):
     if not self._initialized:
         self.build = Platform.get() if build is None else build
         self.host = self.build if host is None else host
         self.target = self.host if target is None else target
         self.environ = None
         self.cwd = None
         self.main_options = None
Ejemplo n.º 11
0
 def __init__(
     self,
     build: Optional[Platform] = None,
     host: Optional[Platform] = None,
     target: Optional[Platform] = None,
 ):
     if not self._initialized:
         self.build = Platform.get() if build is None else build
         self.host = self.build if host is None else host
         self.target = self.host if target is None else target
         self.environ: Optional[dict] = None
         self.cwd: Optional[str] = None
         self.main_options: Optional[Namespace] = None
Ejemplo n.º 12
0
        def get_platform(value, propagate_build_info=False):
            """Platform based on string value.

            :param value: a string representing a platform or None
            :type value: str | None
            :param propagate_build_info: whether to propagate machine name
                and OS version if no machine name set
            :type propagate_build_info: bool
            :rtype: a Platform instance or None
            """
            if value is None:
                return None

            # We expect 4 fields for build and host and target
            split_value = ([k if k else None for k in value.split(",")] + [None] * 4)[
                0:4
            ]

            if split_value[0] == "build":
                return saved_build
            elif split_value[0] == "host":
                return saved_host
            elif split_value[0] == "target":
                return saved_target
            elif not propagate_build_info:
                return Platform.get(*split_value)
            else:

                # Propagate machine name and OS version if necessary
                if split_value[2] is None:
                    # No new machine name specified, reuse the current one
                    split_value[2] = saved_build.machine

                    # And if there is no OS version set also keep the
                    # current one, setting build='x86-linux' on a 64bit
                    # Linux machine should not change the OS version
                    if split_value[1] is None:
                        split_value[1] = saved_build.os.version
                return Platform.get(*split_value)
Ejemplo n.º 13
0
    def set_target(self,
                   target_name=None,
                   target_version=None,
                   target_machine=None,
                   target_mode=None):
        """Set target platform.

        :param target_name: a string that identify the system to be considered
            as the host. If None then host is set to the host one. If set to
            'build' or 'host' then target is set respectively to current
            'build' or 'host' value. In that case target_version and
            target_machine are ignored.
        :type target_name: str | None
        :param target_version: a string containing the system version. If set
            to None the version is either a default or autodetected when
            possible.
        :type target_version: str | None
        :param target_machine: a string containing the name of the target
            machine.
        :type target_machine: str | None
        :param target_mode: a string containing the name of the mode. This
            notion is needed on some targets such as VxWorks to switch between
            kernel mode and other modes such as rtp

        The target parameters are ignored if the target_name is equal to the
        host platform.
        """
        # Handle special values
        if target_name is not None:
            if target_name == 'host':
                target_name = self.host.platform
                target_version = self.host.os.version
                target_machine = self.host.machine
            elif target_name == 'build':
                target_name = self.build.platform
                target_version = self.build.os.version
                target_machine = self.build.machine

        if target_name is not None and target_name != self.host.platform:
            self.target = Platform.get(platform_name=target_name,
                                       version=target_version,
                                       machine=target_machine,
                                       mode=target_mode)
        else:
            self.target = self.host
Ejemplo n.º 14
0
    def set_host(self, host_name=None, host_version=None):
        """Set host platform.

        :param host_name: a string that identify the system to be considered
            as the host. If None then host is set to the build one (the
            autodetected platform). If set to 'build' or 'target' then host
            is set respectively to current 'build' or 'target' value
        :type host_name: str | None
        :param host_version: a string containing the system version. If set to
            None the version is either a default or autodetected when possible
        :type host_version: str | None

        When calling set_host, the target system is reset to the host one.
        Thus you should call set_host before set_target otherwise your call
        to set_target will be ignored. Note also that is the host_name is
        equal to the build platform, host_version will be ignored.
        """
        # Handle special parameters 'target' and 'build'
        if host_name is not None:
            if host_name == 'target':
                host_name = self.target.platform
                host_version = self.target.os.version
            elif host_name == 'build':
                host_name = self.build.platform
                host_version = self.target.os.version

        if host_name is not None and host_name != self.build.platform:
            is_host = False
            if (self.build.platform, host_name) in CANADIAN_EXCEPTIONS:
                # We are not in a canadian configuration, so we can invoke
                # our methods to guess some information such as os version,...
                is_host = True

            self.host = Platform.get(platform_name=host_name,
                                     is_host=is_host,
                                     version=host_version,
                                     machine=self.build.machine)
        else:
            self.host = self.build

        self.target = self.host
Ejemplo n.º 15
0
        def get_platform(value, machine=None):
            """Platform based on string value.

            :param value: a string representing a platform or None
            :type value: str | None
            :rtype: a Platform instance or None
            """
            if value is None:
                return None

            # We expect 4 fields for build and host and target
            split_value = ([k if k else None for k in value.split(",")] + [None] * 4)[0:4]

            if split_value[0] == "build":
                return saved_build
            elif split_value[0] == "host":
                return saved_host
            elif split_value[0] == "target":
                return saved_target
            else:
                # Propagate machine name if necessary
                if split_value[2] is None:
                    split_value[2] = machine
                return Platform.get(*split_value)