Пример #1
0
    def _build_environment(self):
        env = os.environ.copy()
        env['GOPATH'] = self._gopath
        env['GOBIN'] = self._gopath_bin

        include_paths = []
        for root in [self.installdir, self.project.stage_dir]:
            include_paths.extend(
                common.get_library_paths(root, self.project.arch_triplet))

        flags = common.combine_paths(include_paths, '-L', ' ')
        env['CGO_LDFLAGS'] = '{} {} {}'.format(
            env.get('CGO_LDFLAGS', ''), flags, env.get('LDFLAGS', ''))

        if self.project.is_cross_compiling:
            env['CC'] = '{}-gcc'.format(self.project.arch_triplet)
            env['CXX'] = '{}-g++'.format(self.project.arch_triplet)
            env['CGO_ENABLED'] = '1'
            # See https://golang.org/doc/install/source#environment
            go_archs = {
                'armhf': 'arm',
                'i386': '386',
                'ppc64el': 'ppc64le',
            }
            env['GOARCH'] = go_archs.get(self.project.deb_arch,
                                         self.project.deb_arch)
            if self.project.deb_arch == 'armhf':
                env['GOARM'] = '7'
        return env
Пример #2
0
    def _build_environment(self):
        env = os.environ.copy()
        env["GOPATH"] = self._gopath
        env["GOBIN"] = self._gopath_bin

        include_paths = []
        for root in [self.installdir, self.project.stage_dir]:
            include_paths.extend(
                common.get_library_paths(root, self.project.arch_triplet))

        flags = common.combine_paths(include_paths, "-L", " ")
        env["CGO_LDFLAGS"] = "{} {} {}".format(env.get("CGO_LDFLAGS", ""),
                                               flags, env.get("LDFLAGS", ""))

        if self.project.is_cross_compiling:
            env["CC"] = "{}-gcc".format(self.project.arch_triplet)
            env["CXX"] = "{}-g++".format(self.project.arch_triplet)
            env["CGO_ENABLED"] = "1"
            # See https://golang.org/doc/install/source#environment
            go_archs = {"armhf": "arm", "i386": "386", "ppc64el": "ppc64le"}
            env["GOARCH"] = go_archs.get(self.project.deb_arch,
                                         self.project.deb_arch)
            if self.project.deb_arch == "armhf":
                env["GOARM"] = "7"
        return env
    def _extra_config(self):
        extra_config = []
        print(self.installdir)

        for root in [self.installdir, self.project.stage_dir]:
            paths = common.get_library_paths(root, self.project.arch_triplet)
            for path in paths:
                extra_config.append("LIBS+=\"-L{}\"".format(path))
            extra_config.append("LIBS+=\"-L{}\"".format(
                QmakePlugin._build_qt_path('lib')))
            extra_config.append("QMAKE_LIBS+=\"-L{}\"".format(
                QmakePlugin._build_qt_path('lib')))
            extra_config.append("QMAKE_LIBDIR+=\"{}\"".format(
                QmakePlugin._build_qt_path('lib')))

            paths = common.get_include_paths(root, self.project.arch_triplet)
            for path in paths:
                extra_config.append("INCLUDEPATH+=\"{}\"".format(path))
            extra_config.append("INCLUDEPATH+=\"{}\"".format(
                QmakePlugin._build_qt_path('include')))

            extra_config.append("QML_IMPORT_PATH+=\"{}\"".format(
                QmakePlugin._build_qt_path('qml')))
            extra_config.append("QML2_IMPORT_PATH+=\"{}\"".format(
                QmakePlugin._build_qt_path('qml')))

        return extra_config
Пример #4
0
    def _build_environment(self):
        env = os.environ.copy()
        env['GOPATH'] = self._gopath
        env['GOBIN'] = self._gopath_bin

        include_paths = []
        for root in [self.installdir, self.project.stage_dir]:
            include_paths.extend(
                common.get_library_paths(root, self.project.arch_triplet))

        flags = common.combine_paths(include_paths, '-L', ' ')
        env['CGO_LDFLAGS'] = '{} {} {}'.format(env.get('CGO_LDFLAGS', ''),
                                               flags, env.get('LDFLAGS', ''))

        if self.project.is_cross_compiling:
            env['CC'] = '{}-gcc'.format(self.project.arch_triplet)
            env['CXX'] = '{}-g++'.format(self.project.arch_triplet)
            env['CGO_ENABLED'] = '1'
            # See https://golang.org/doc/install/source#environment
            go_archs = {
                'armhf': 'arm',
                'i386': '386',
                'ppc64el': 'ppc64le',
            }
            env['GOARCH'] = go_archs.get(self.project.deb_arch,
                                         self.project.deb_arch)
            if self.project.deb_arch == 'armhf':
                env['GOARM'] = '7'
        return env
Пример #5
0
    def _build_environment(self) -> Dict[str, str]:
        env = os.environ.copy()
        env["GOPATH"] = self._gopath
        env["GOBIN"] = self._gopath_bin

        library_paths: List[str] = []
        for root in [self.installdir, self.project.stage_dir]:
            library_paths.extend(
                common.get_library_paths(root, self.project.arch_triplet))

        cgo_ldflags = _get_cgo_ldflags(library_paths)
        if cgo_ldflags:
            env["CGO_LDFLAGS"] = cgo_ldflags

        if self.project.is_cross_compiling:
            env["CC"] = "{}-gcc".format(self.project.arch_triplet)
            env["CXX"] = "{}-g++".format(self.project.arch_triplet)
            env["CGO_ENABLED"] = "1"
            # See https://golang.org/doc/install/source#environment
            go_archs = {"armhf": "arm", "i386": "386", "ppc64el": "ppc64le"}
            env["GOARCH"] = go_archs.get(self.project.deb_arch,
                                         self.project.deb_arch)
            if self.project.deb_arch == "armhf":
                env["GOARM"] = "7"
        return env
Пример #6
0
    def _build_environment(self):
        env = os.environ.copy()
        env["GOPATH"] = self._gopath
        env["GOBIN"] = self._gopath_bin

        include_paths = []
        for root in [self.installdir, self.project.stage_dir]:
            include_paths.extend(
                common.get_library_paths(root, self.project.arch_triplet)
            )

        flags = common.combine_paths(include_paths, "-L", " ")
        env["CGO_LDFLAGS"] = "{} {} {}".format(
            env.get("CGO_LDFLAGS", ""), flags, env.get("LDFLAGS", "")
        )

        if self.project.is_cross_compiling:
            env["CC"] = "{}-gcc".format(self.project.arch_triplet)
            env["CXX"] = "{}-g++".format(self.project.arch_triplet)
            env["CGO_ENABLED"] = "1"
            # See https://golang.org/doc/install/source#environment
            go_archs = {"armhf": "arm", "i386": "386", "ppc64el": "ppc64le"}
            env["GOARCH"] = go_archs.get(self.project.deb_arch, self.project.deb_arch)
            if self.project.deb_arch == "armhf":
                env["GOARM"] = "7"
        return env
Пример #7
0
    def env(self, root):
        """Runtime environment for ROS binaries and services."""

        paths = common.get_library_paths(root, self.project.arch_triplet)
        ld_library_path = formatting_utils.combine_paths(paths,
                                                         prepend='',
                                                         separator=':')

        env = [
            # This environment variable tells ROS nodes where to find ROS
            # master. It does not affect ROS master, however-- this is just the
            # default URI.
            'ROS_MASTER_URI=http://localhost:11311',

            # Various ROS tools (e.g. rospack, roscore) keep a cache or a log,
            # and use $ROS_HOME to determine where to put them.
            'ROS_HOME=${SNAP_USER_DATA:-/tmp}/ros',

            # FIXME: LP: #1576411 breaks ROS snaps on the desktop, so we'll
            # temporarily work around that bug by forcing the locale to
            # C.UTF-8.
            'LC_ALL=C.UTF-8',

            # The Snapcraft Core will ensure that we get a good LD_LIBRARY_PATH
            # overall, but it defines it after this function runs. Some ROS
            # tools will cause binaries to be run when we source the setup.sh,
            # below, so we need to have a sensible LD_LIBRARY_PATH before then.
            'LD_LIBRARY_PATH=$LD_LIBRARY_PATH:{}'.format(ld_library_path),
        ]

        # There's a chicken and egg problem here, everything run get's an
        # env built, even package installation, so the first runs for these
        # will likely fail.
        try:
            # The ROS packaging system tools (e.g. rospkg, etc.) don't go
            # into the ROS install path (/opt/ros/$distro), so we need the
            # PYTHONPATH to include the dist-packages in /usr/lib as well.
            env.append('PYTHONPATH={0}:$PYTHONPATH'.format(
                common.get_python2_path(root)))
        except EnvironmentError as e:
            logger.debug(e)

        # The setup.sh we source below requires the in-snap python. Here we
        # make sure it's in the PATH before it's run.
        env.append('PATH=$PATH:{}/usr/bin'.format(root))

        if self.options.underlay:
            script = '. {}'.format(
                os.path.join(self.rosdir, 'snapcraft-setup.sh'))
        else:
            script = self._source_setup_sh(root, None)

        # Each of these lines is prepended with an `export` when the
        # environment is actually generated. In order to inject real shell code
        # we have to hack it in by appending it on the end of an item already
        # in the environment. FIXME: There should be a better way to do this.
        env[-1] = env[-1] + '\n\n' + script

        return env
Пример #8
0
    def _extra_config(self):
        extra_config = []

        for root in [self.installdir, self.project.stage_dir]:
            paths = common.get_library_paths(root, self.project.arch_triplet)
            for path in paths:
                extra_config.append("LIBS+=\"-L{}\"".format(path))

            paths = common.get_include_paths(root, self.project.arch_triplet)
            for path in paths:
                extra_config.append("INCLUDEPATH+=\"{}\"".format(path))

        return extra_config
    def _extra_config(self):
        extra_config = []

        for root in [self.installdir, self.project.stage_dir]:
            paths = common.get_library_paths(root, self.project.arch_triplet)
            for path in paths:
                extra_config.append("LIBS+=\"-L{}\"".format(path))

            paths = common.get_include_paths(root, self.project.arch_triplet)
            for path in paths:
                extra_config.append("INCLUDEPATH+=\"{}\"".format(path))

        return extra_config
Пример #10
0
    def _build_environment(self):
        env = os.environ.copy()
        env['GOPATH'] = self._gopath

        include_paths = []
        for root in [self.installdir, self.project.stage_dir]:
            include_paths.extend(
                common.get_library_paths(root, self.project.arch_triplet))

        flags = common.combine_paths(include_paths, '-L', ' ')
        env['CGO_LDFLAGS'] = '{} {} {}'.format(
            env.get('CGO_LDFLAGS', ''), flags, env.get('LDFLAGS', ''))

        return env
Пример #11
0
    def environment(self):
        env = os.environ.copy()

        paths = common.get_library_paths(
            self._compilers_install_path, self._project.arch_triplet)
        ld_library_path = formatting_utils.combine_paths(
            paths, prepend='', separator=':')

        env['LD_LIBRARY_PATH'] = (
            env.get('LD_LIBRARY_PATH', '') + ':' + ld_library_path)

        env['PATH'] = env.get('PATH', '') + ':' + os.path.join(
            self._compilers_install_path, 'usr', 'bin')

        return env
Пример #12
0
    def environment(self):
        env = os.environ.copy()

        paths = common.get_library_paths(
            self._compilers_install_path, self._project.arch_triplet)
        ld_library_path = formatting_utils.combine_paths(
            paths, prepend='', separator=':')

        env['LD_LIBRARY_PATH'] = (
            env.get('LD_LIBRARY_PATH', '') + ':' + ld_library_path)

        env['PATH'] = env.get('PATH', '') + ':' + os.path.join(
            self._compilers_install_path, 'usr', 'bin')

        return env
Пример #13
0
    def environment(self):
        env = os.environ.copy()

        paths = common.get_library_paths(self._compilers_install_path,
                                         self._project.arch_triplet)
        ld_library_path = formatting_utils.combine_paths(paths,
                                                         prepend="",
                                                         separator=":")

        env["LD_LIBRARY_PATH"] = env.get("LD_LIBRARY_PATH",
                                         "") + ":" + ld_library_path

        env["PATH"] = (
            env.get("PATH", "") + ":" +
            os.path.join(self._compilers_install_path, "usr", "bin"))

        return env
    def _build_environment(self):
        env = os.environ.copy()
        env['GOPATH'] = self._gopath

        # Add $GOPATH/bin so godeps is actually callable.
        env['PATH'] = '{}:{}'.format(os.path.join(self._gopath, 'bin'),
                                     env.get('PATH', ''))

        include_paths = []
        for root in [self.installdir, self.project.stage_dir]:
            include_paths.extend(
                common.get_library_paths(root, self.project.arch_triplet))

        flags = common.combine_paths(include_paths, '-L', ' ')
        env['CGO_LDFLAGS'] = '{} {} {}'.format(env.get('CGO_LDFLAGS', ''),
                                               flags, env.get('LDFLAGS', ''))

        return env
Пример #15
0
    def _build_environment(self):
        env = os.environ.copy()
        env['GOPATH'] = self._gopath

        # Add $GOPATH/bin so godeps is actually callable.
        env['PATH'] = '{}:{}'.format(
            os.path.join(self._gopath, 'bin'), env.get('PATH', ''))

        include_paths = []
        for root in [self.installdir, self.project.stage_dir]:
            include_paths.extend(
                common.get_library_paths(root, self.project.arch_triplet))

        flags = common.combine_paths(include_paths, '-L', ' ')
        env['CGO_LDFLAGS'] = '{} {} {}'.format(
            env.get('CGO_LDFLAGS', ''), flags, env.get('LDFLAGS', ''))

        return env
Пример #16
0
    def _build_environment(self):
        env = os.environ.copy()
        env["GOPATH"] = self._gopath
        env["GOBIN"] = self._gopath_bin

        # Add $GOPATH/bin so godeps is actually callable.
        env["PATH"] = "{}:{}".format(os.path.join(self._gopath, "bin"),
                                     env.get("PATH", ""))

        include_paths = []
        for root in [self.installdir, self.project.stage_dir]:
            include_paths.extend(
                common.get_library_paths(root, self.project.arch_triplet))

        flags = common.combine_paths(include_paths, "-L", " ")
        env["CGO_LDFLAGS"] = "{} {} {}".format(env.get("CGO_LDFLAGS", ""),
                                               flags, env.get("LDFLAGS", ""))

        return env
Пример #17
0
    def environment(self):
        env = os.environ.copy()

        paths = common.get_library_paths(
            self._compilers_install_path, self._project.arch_triplet
        )
        ld_library_path = formatting_utils.combine_paths(
            paths, prepend="", separator=":"
        )

        env["LD_LIBRARY_PATH"] = env.get("LD_LIBRARY_PATH", "") + ":" + ld_library_path

        env["PATH"] = (
            env.get("PATH", "")
            + ":"
            + os.path.join(self._compilers_install_path, "usr", "bin")
        )

        return env
Пример #18
0
    def _extra_config(self):
        extra_config = []

        for root in [self.installdir, self.project.stage_dir]:
            paths = common.get_library_paths(root, self.project.arch_triplet)
            for path in paths:
                extra_config.append("LIBS+=\"-L{}\"".format(path))
            extra_config.append("LIBS+=\"-L{}\"".format(self.project.parts_dir + '/qt-5-11-1/install/lib'))
            extra_config.append("QMAKE_LIBS+=\"-L{}\"".format(self.project.parts_dir + '/qt-5-11-1/install/lib'))
            extra_config.append("QMAKE_LIBDIR+=\"{}\"".format(self.project.parts_dir + '/qt-5-11-1/install/lib'))

            paths = common.get_include_paths(root, self.project.arch_triplet)
            for path in paths:
                extra_config.append("INCLUDEPATH+=\"{}\"".format(path))
            extra_config.append("INCLUDEPATH+=\"{}\"".format(self.project.parts_dir + '/qt-5-11-1/install/include'))

            extra_config.append("QML_IMPORT_PATH+=\"{}\"".format(self.project.parts_dir + '/qt-5-11-1/install/qml'))
            extra_config.append("QML2_IMPORT_PATH+=\"{}\"".format(self.project.parts_dir + '/qt-5-11-1/install/qml'))

        return extra_config
Пример #19
0
    def env(self, root):
        """Runtime environment for ROS binaries and services."""

        env = [
            # The Snapcraft Core will ensure that we get a good LD_LIBRARY_PATH
            # overall, but it defines it after this function runs. Some ROS
            # tools will cause binaries to be run when we source the setup.sh,
            # below, so we need to have a sensible LD_LIBRARY_PATH before then.
            'LD_LIBRARY_PATH="$LD_LIBRARY_PATH:{}"'.format(
                formatting_utils.combine_paths(
                    common.get_library_paths(root, self.project.arch_triplet),
                    prepend="",
                    separator=":",
                ))
        ]

        # Each of these lines is prepended with an `export` when the environment is
        # actually generated. In order to inject real shell code we have to hack it in
        # by appending it on the end of an item already in the environment.
        # FIXME: There should be a better way to do this. LP: #1792034
        env[-1] = env[-1] + "\n\n" + self._source_setup_sh(root)

        return env
Пример #20
0
    def env(self, root):
        """Runtime environment for ROS binaries and services."""

        paths = common.get_library_paths(root, self.project.arch_triplet)
        ld_library_path = formatting_utils.combine_paths(paths,
                                                         prepend="",
                                                         separator=":")

        env = [
            # This environment variable tells ROS nodes where to find ROS
            # master. It does not affect ROS master, however-- this is just the
            # URI.
            "ROS_MASTER_URI={}".format(self.options.catkin_ros_master_uri),
            # Various ROS tools (e.g. roscore) keep a cache or a log,
            # and use $ROS_HOME to determine where to put them.
            "ROS_HOME=${SNAP_USER_DATA:-/tmp}/ros",
            # FIXME: LP: #1576411 breaks ROS snaps on the desktop, so we'll
            # temporarily work around that bug by forcing the locale to
            # C.UTF-8.
            "LC_ALL=C.UTF-8",
            # The Snapcraft Core will ensure that we get a good LD_LIBRARY_PATH
            # overall, but it defines it after this function runs. Some ROS
            # tools will cause binaries to be run when we source the setup.sh,
            # below, so we need to have a sensible LD_LIBRARY_PATH before then.
            "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:{}".format(ld_library_path),
        ]

        # There's a chicken and egg problem here, everything run gets an
        # env built, even package installation, so the first runs for these
        # will likely fail.
        try:
            # The ROS packaging system tools (e.g. rospkg, etc.) don't go
            # into the ROS install path (/opt/ros/$distro), so we need the
            # PYTHONPATH to include the dist-packages in /usr/lib as well.
            #
            # Note: Empty segments in PYTHONPATH are interpreted as `.`, thus
            # adding the current working directory to the PYTHONPATH. That is
            # not desired in this situation, so take proper precautions when
            # expanding PYTHONPATH: only add it if it's not empty.
            env.append("PYTHONPATH={}${{PYTHONPATH:+:$PYTHONPATH}}".format(
                common.get_python2_path(root)))
        except errors.SnapcraftEnvironmentError as e:
            logger.debug(e)

        # The setup.sh we source below requires the in-snap python. Here we
        # make sure it's in the PATH before it's run.
        env.append("PATH=$PATH:{}/usr/bin".format(root))

        if self.options.underlay:
            script = textwrap.dedent("""
                if [ -f {snapcraft_setup} ]; then
                    . {snapcraft_setup}
                fi
            """).format(snapcraft_setup=os.path.join(self.rosdir,
                                                     "snapcraft-setup.sh"))
        else:
            script = self._source_setup_sh(root, None)

        # Each of these lines is prepended with an `export` when the
        # environment is actually generated. In order to inject real shell code
        # we have to hack it in by appending it on the end of an item already
        # in the environment. FIXME: There should be a better way to do this.
        # LP: #1792034
        env[-1] = env[-1] + "\n\n" + script

        return env
Пример #21
0
 def ldflags(self):
     paths = common.get_library_paths(
         self._compilers_install_path, self._project.arch_triplet)
     return formatting_utils.combine_paths(
         paths, prepend='-L', separator=' ')
Пример #22
0
 def ldflags(self):
     paths = common.get_library_paths(self._compilers_install_path,
                                      self._project.arch_triplet)
     return formatting_utils.combine_paths(paths,
                                           prepend='-L',
                                           separator=' ')
Пример #23
0
    def env(self, root):
        """Runtime environment for ROS binaries and services."""

        paths = common.get_library_paths(root, self.project.arch_triplet)
        ld_library_path = formatting_utils.combine_paths(
            paths, prepend='', separator=':')

        env = [
            # This environment variable tells ROS nodes where to find ROS
            # master. It does not affect ROS master, however-- this is just the
            # URI.
            'ROS_MASTER_URI={}'.format(self.options.catkin_ros_master_uri),

            # Various ROS tools (e.g. rospack, roscore) keep a cache or a log,
            # and use $ROS_HOME to determine where to put them.
            'ROS_HOME=${SNAP_USER_DATA:-/tmp}/ros',

            # FIXME: LP: #1576411 breaks ROS snaps on the desktop, so we'll
            # temporarily work around that bug by forcing the locale to
            # C.UTF-8.
            'LC_ALL=C.UTF-8',

            # The Snapcraft Core will ensure that we get a good LD_LIBRARY_PATH
            # overall, but it defines it after this function runs. Some ROS
            # tools will cause binaries to be run when we source the setup.sh,
            # below, so we need to have a sensible LD_LIBRARY_PATH before then.
            'LD_LIBRARY_PATH=$LD_LIBRARY_PATH:{}'.format(ld_library_path),
        ]

        # There's a chicken and egg problem here, everything run get's an
        # env built, even package installation, so the first runs for these
        # will likely fail.
        try:
            # The ROS packaging system tools (e.g. rospkg, etc.) don't go
            # into the ROS install path (/opt/ros/$distro), so we need the
            # PYTHONPATH to include the dist-packages in /usr/lib as well.
            #
            # Note: Empty segments in PYTHONPATH are interpreted as `.`, thus
            # adding the current working directory to the PYTHONPATH. That is
            # not desired in this situation, so take proper precautions when
            # expanding PYTHONPATH: only add it if it's not empty.
            env.append('PYTHONPATH={}${{PYTHONPATH:+:$PYTHONPATH}}'.format(
                common.get_python2_path(root)))
        except errors.SnapcraftEnvironmentError as e:
            logger.debug(e)

        # The setup.sh we source below requires the in-snap python. Here we
        # make sure it's in the PATH before it's run.
        env.append('PATH=$PATH:{}/usr/bin'.format(root))

        if self.options.underlay:
            script = '. {}'.format(os.path.join(
                self.rosdir, 'snapcraft-setup.sh'))
        else:
            script = self._source_setup_sh(root, None)

        # Each of these lines is prepended with an `export` when the
        # environment is actually generated. In order to inject real shell code
        # we have to hack it in by appending it on the end of an item already
        # in the environment. FIXME: There should be a better way to do this.
        env[-1] = env[-1] + '\n\n' + script

        return env