Пример #1
0
    def test_get_build_commands_with_cmake_parameters(self):
        class Options:
            cmake_parameters = [
                "-DVERBOSE=1",
                "-DCMAKE_INSTALL_PREFIX=/foo",
                '-DCMAKE_SPACED_ARGS="foo bar"',
                '-DCMAKE_USING_ENV="$SNAPCRAFT_PART_INSTALL"/bar',
            ]

        plugin = CMakePlugin(part_name="my-part", options=Options())

        self.assertThat(
            plugin.get_build_commands(),
            Equals(
                [
                    'cmake "${SNAPCRAFT_PART_SRC}" '
                    "-DVERBOSE=1 "
                    "-DCMAKE_INSTALL_PREFIX=/foo "
                    '-DCMAKE_SPACED_ARGS="foo bar" '
                    '-DCMAKE_USING_ENV="$SNAPCRAFT_PART_INSTALL"/bar',
                    'cmake --build . -- -j"${SNAPCRAFT_PARALLEL_BUILD_COUNT}"',
                    'cmake --build . --target install -- DESTDIR="${SNAPCRAFT_PART_INSTALL}"',
                ]
            ),
        )
Пример #2
0
    def test_get_build_environment(self):
        plugin = CMakePlugin(part_name="my-part", options=lambda: None)

        self.assertThat(
            plugin.get_build_environment(),
            Equals({"SNAPCRAFT_CMAKE_INSTALL_PREFIX": "/"}),
        )
Пример #3
0
def test_get_build_environment():
    class Options:
        cmake_parameters = list()
        cmake_generator = "Unix Makefiles"

    plugin = CMakePlugin(part_name="my-part", options=Options())

    assert plugin.get_build_environment() == {"CMAKE_PREFIX_PATH": "${SNAPCRAFT_STAGE}"}
Пример #4
0
def test_get_build_packages_ninja():
    class Options:
        cmake_parameters = list()
        cmake_generator = "Ninja"

    plugin = CMakePlugin(part_name="my-part", options=Options())

    assert plugin.get_build_packages() == {"gcc", "cmake", "ninja-build"}
Пример #5
0
def test_get_build_packages():
    class Options:
        cmake_parameters = list()
        cmake_generator = "Unix Makefiles"

    plugin = CMakePlugin(part_name="my-part", options=Options())

    assert plugin.get_build_packages() == {"gcc", "cmake"}
Пример #6
0
def test_out_of_source_build():
    class Options:
        cmake_parameters = list()
        cmake_generator = "Unix Makefiles"

    plugin = CMakePlugin(part_name="my-part", options=Options())

    assert plugin.out_of_source_build is True
Пример #7
0
def test_get_build_commands():
    class Options:
        cmake_parameters = list()

    plugin = CMakePlugin(part_name="my-part", options=Options())

    assert plugin.get_build_commands() == [
        'cmake "${SNAPCRAFT_PART_SRC_WORK}"',
        'cmake --build . -- -j"${SNAPCRAFT_PARALLEL_BUILD_COUNT}"',
        'cmake --build . --target install -- DESTDIR="${SNAPCRAFT_PART_INSTALL}"',
    ]
Пример #8
0
def test_get_build_commands_ninja():
    class Options:
        cmake_parameters = list()
        cmake_generator = "Ninja"

    plugin = CMakePlugin(part_name="my-part", options=Options())

    assert plugin.get_build_commands() == [
        'cmake "${SNAPCRAFT_PART_SRC_WORK}" -G "Ninja" ${SNAPCRAFT_CMAKE_ARGS}',
        'cmake --build . -- -j"${SNAPCRAFT_PARALLEL_BUILD_COUNT}"',
        'DESTDIR="${SNAPCRAFT_PART_INSTALL}" cmake --build . --target install',
    ]
Пример #9
0
    def test_get_build_commands(self):
        class Options:
            configflags = list()

        plugin = CMakePlugin(part_name="my-part", options=Options())

        self.assertThat(
            plugin.get_build_commands(),
            Equals([
                'cmake . -DCMAKE_INSTALL_PREFIX="${SNAPCRAFT_CMAKE_INSTALL_PREFIX}"',
                'cmake --build . -- -j"${SNAPCRAFT_PARALLEL_BUILD_COUNT}"',
                'cmake --build . --target install -- DESTDIR="${SNAPCRAFT_PART_INSTALL}"',
            ]),
        )
Пример #10
0
def test_get_build_commands_with_cmake_parameters():
    class Options:
        cmake_parameters = [
            "-DVERBOSE=1",
            "-DCMAKE_INSTALL_PREFIX=/foo",
            '-DCMAKE_SPACED_ARGS="foo bar"',
            '-DCMAKE_USING_ENV="$SNAPCRAFT_PART_INSTALL"/bar',
        ]
        cmake_generator = "Unix Makefiles"

    plugin = CMakePlugin(part_name="my-part", options=Options())

    assert plugin.get_build_commands() == [
        'cmake "${SNAPCRAFT_PART_SRC_WORK}" -G "Unix Makefiles" '
        "-DVERBOSE=1 "
        "-DCMAKE_INSTALL_PREFIX=/foo "
        '-DCMAKE_SPACED_ARGS="foo bar" '
        '-DCMAKE_USING_ENV="$SNAPCRAFT_PART_INSTALL"/bar',
        'cmake --build . -- -j"${SNAPCRAFT_PARALLEL_BUILD_COUNT}"',
        'DESTDIR="${SNAPCRAFT_PART_INSTALL}" cmake --build . --target install',
    ]
Пример #11
0
    def test_get_build_environment(self):
        plugin = CMakePlugin(part_name="my-part", options=lambda: None)

        self.assertThat(plugin.get_build_environment(), Equals(dict()))
Пример #12
0
    def test_get_build_packages(self):
        plugin = CMakePlugin(part_name="my-part", options=lambda: None)

        self.assertThat(plugin.get_build_packages(), Equals({"gcc", "cmake"}))
Пример #13
0
def test_get_build_environment():
    plugin = CMakePlugin(part_name="my-part", options=lambda: None)

    assert plugin.get_build_environment() == {
        "CMAKE_PREFIX_PATH": "${SNAPCRAFT_STAGE}"
    }
Пример #14
0
def test_get_build_packages():
    plugin = CMakePlugin(part_name="my-part", options=lambda: None)

    assert plugin.get_build_packages() == {"gcc", "cmake"}