示例#1
0
    def test_convert_cxx_language_version(self):
        conanfile = MockConanfileWithFolders(
            MockSettings({
                'os': 'Linux',
                'compiler': 'gcc'
            }))

        qbs_toolchain = qbs.QbsProfile(conanfile)
        self.assertEqual(qbs_toolchain._cxx_language_version, None)
        conanfile = MockConanfileWithFolders(
            MockSettings({
                'os': 'Linux',
                'compiler': 'gcc',
                'compiler.cppstd': 17
            }))

        qbs_toolchain = qbs.QbsProfile(conanfile)
        self.assertEqual(qbs_toolchain._cxx_language_version, 'c++17')

        for cppstd, cxx_language_version in qbs._cxx_language_version.items():
            conanfile = MockConanfileWithFolders(
                MockSettings({
                    'os': 'Linux',
                    'compiler': 'gcc',
                    'compiler.cppstd': cppstd
                }))

            qbs_toolchain = qbs.QbsProfile(conanfile)
            self.assertEqual(qbs_toolchain._cxx_language_version,
                             cxx_language_version)
示例#2
0
    def test_convert_target_platform(self):
        conanfile = MockConanfileWithFolders(MockSettings({'compiler': 'gcc'}))

        qbs_toolchain = qbs.QbsProfile(conanfile)
        self.assertEqual(qbs_toolchain._target_platform, None)

        for os, target_platform in qbs._target_platform.items():
            conanfile = MockConanfileWithFolders(
                MockSettings({
                    'os': os,
                    'compiler': 'gcc'
                }))

            qbs_toolchain = qbs.QbsProfile(conanfile)
            self.assertEqual(qbs_toolchain._target_platform, target_platform)
示例#3
0
    def test_convert_runtime_library(self):
        conanfile = MockConanfileWithFolders(
            MockSettings({'compiler': 'Visual Studio'}))

        qbs_toolchain = qbs.QbsProfile(conanfile)
        self.assertEqual(qbs_toolchain._runtime_library, None)

        for runtime, runtime_library in qbs._runtime_library.items():
            conanfile = MockConanfileWithFolders(
                MockSettings({
                    'compiler': 'Visual Studio',
                    'compiler.runtime': runtime
                }))

            qbs_toolchain = qbs.QbsProfile(conanfile)
            self.assertEqual(qbs_toolchain._runtime_library, runtime_library)
示例#4
0
    def test_convert_optimization(self):
        conanfile = MockConanfileWithFolders(MockSettings({
            'os': 'Linux',
            'compiler': 'gcc'}))

        qbs_toolchain = qbs.QbsProfile(conanfile)
        self.assertEqual(qbs_toolchain._optimization, None)

        for build_type, optimization in qbs._optimization.items():
            conanfile = MockConanfileWithFolders(MockSettings({
                'os': 'Linux',
                'compiler': 'gcc',
                'build_type': build_type}))

            qbs_toolchain = qbs.QbsProfile(conanfile)
            self.assertEqual(qbs_toolchain._optimization, optimization)
示例#5
0
    def test_convert_architecture(self):
        conanfile = MockConanfileWithFolders(MockSettings({
            'os': 'Linux',
            'compiler': 'gcc'}))

        qbs_toolchain = qbs.QbsProfile(conanfile)
        self.assertEqual(qbs_toolchain._architecture, None)

        for arch, architecture in qbs._architecture.items():
            conanfile = MockConanfileWithFolders(MockSettings({
                'os': 'Linux',
                'compiler': 'gcc',
                'arch': arch}))

            qbs_toolchain = qbs.QbsProfile(conanfile)
            self.assertEqual(qbs_toolchain._architecture, architecture)
示例#6
0
    def test_convert_build_variant(self):
        conanfile = MockConanfileWithFolders(MockSettings({
            'os': 'Linux',
            'compiler': 'gcc'}))

        qbs_toolchain = qbs.QbsProfile(conanfile)
        self.assertEqual(qbs_toolchain._build_variant, None)

        for build_type, build_variant in qbs._build_variant.items():
            conanfile = MockConanfileWithFolders(MockSettings({
                'os': 'Linux',
                'compiler': 'gcc',
                'build_type': build_type}))

            qbs_toolchain = qbs.QbsProfile(conanfile)
            self.assertEqual(qbs_toolchain._build_variant, build_variant)
示例#7
0
    def test_toolchain_content(self):
        expected_content = textwrap.dedent('''\
            import qbs

            Project {
                Profile {
                    name: "conan_toolchain_profile"

                    /* detected via qbs-setup-toolchains */
                    cpp.cCompilerName: "gcc"
                    cpp.compilerName: "g++"
                    cpp.cxxCompilerName: "g++"
                    cpp.driverFlags: ["-march=armv7e-m", "-mtune=cortex-m4", "--specs=nosys.specs"]
                    cpp.platformCommonCompilerFlags: undefined
                    cpp.platformLinkerFlags: undefined
                    cpp.toolchainInstallPath: "/usr/bin"
                    cpp.toolchainPrefix: "arm-none-eabi-"
                    qbs.someBoolProp: true
                    qbs.someIntProp: 13
                    qbs.toolchain: ["gcc"]

                    /* deduced from environment */
                    qbs.sysroot: "/foo/bar/path"

                    /* conan settings */
                    qbs.buildVariant: "release"
                    qbs.architecture: "x86_64"
                    qbs.targetPlatform: "linux"
                    qbs.optimization: "small"
                    cpp.cxxLanguageVersion: "c++17"

                    /* package options */
                    cpp.positionIndependentCode: true
                }
            }''')

        conanfile = MockConanfileWithFolders(
            MockSettings({
                'compiler': 'gcc',
                'compiler.cppstd': 17,
                'os': 'Linux',
                'build_type': 'MinSizeRel',
                'arch': 'x86_64'
            }),
            options=MockOptions({
                'fPIC': True
            }),
            runner=RunnerMock(
                expectations=[
                    RunnerMock.Expectation(),
                    RunnerMock.Expectation(
                        output=self._generate_qbs_config_output()),
                ]))

        with tools.environment_append({'SYSROOT': '/foo/bar/path'}):
            qbs_toolchain = qbs.QbsProfile(conanfile)

        self.assertEqual(qbs_toolchain.content, expected_content)
示例#8
0
    def test_use_sysroot_from_env(self):
        conanfile = MockConanfileWithFolders(MockSettings({
            'os': 'Linux',
            'compiler': 'gcc'}))

        sysroot = '/path/to/sysroot/foo/bar'
        with tools.environment_append({'SYSROOT': sysroot}):
            qbs_toolchain = qbs.QbsProfile(conanfile)
        self.assertEqual(qbs_toolchain._sysroot, sysroot)
示例#9
0
    def test_detect_fpic_from_options(self):
        f_pic = {True: 'true', False: 'false', None: None}

        for option, value in f_pic.items():
            conanfile = MockConanfileWithFolders(
                MockSettings({
                    'os': 'Linux',
                    'compiler': 'gcc'
                }), MockOptions({'fPIC': option}))

            qbs_toolchain = qbs.QbsProfile(conanfile)
            self.assertEqual(qbs_toolchain._position_independent_code, value)
示例#10
0
    def test_toolchain_content_msvc(self):
        expected_content = textwrap.dedent('''\
            import qbs

            Project {
                Profile {
                    name: "conan_toolchain_profile"

                    /* detected via qbs-setup-toolchains */
                    cpp.compilerVersion: "19.28.29333"
                    cpp.toolchainInstallPath: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64"
                    qbs.architecture: "x86_64"
                    qbs.targetPlatform: "windows"
                    qbs.toolchainType: "msvc"
                    cpp.driverFlags: ["-march=armv7e-m", "-mtune=cortex-m4", "--specs=nosys.specs"]
                    qbs.someBoolProp: true
                    qbs.someIntProp: 13

                    /* deduced from environment */
                    qbs.sysroot: "/foo/bar/path"

                    /* conan settings */
                    qbs.buildVariant: "release"
                    qbs.optimization: "small"
                    cpp.runtimeLibrary: "dynamic"

                    /* package options */
                    cpp.positionIndependentCode: true
                }
            }''')

        conanfile = MockConanfileWithFolders(
            MockSettings({
                'compiler': 'Visual Studio',
                'compiler.version': 15,
                'compiler.runtime': 'MD',
                'os': 'Windows',
                'build_type': 'MinSizeRel',
                'arch': 'x86_64',
            }),
            options=MockOptions({'fPIC': True}),
            runner=RunnerMock(expectations=[
                RunnerMock.Expectation(),
                RunnerMock.Expectation(
                    output=self._generate_qbs_config_output_msvc()),
            ]))

        with tools.environment_append({'SYSROOT': '/foo/bar/path'}):
            qbs_toolchain = qbs.QbsProfile(conanfile)

        self.assertEqual(qbs_toolchain.content, expected_content)