Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compiler path with meson on Windows when using Android NDK #15760

Conversation

elvisdukaj
Copy link
Contributor

Changelog: Fix | Bugfix): Describe here your pull request
Docs: https://github.com/conan-io/docs/pull/XXXX

  • Refer to the issue that supports this Pull Request.
  • If the issue has missing info, explain the purpose/use case/pain/need that covers this Pull Request.
  • I've read the Contributing guide.
  • I've followed the PEP8 style guides for Python code.
  • I've opened another PR in the Conan docs repo to the develop branch, documenting this one.

Description

Trying to build lcms/2.14 on Windows using Android NDK results in a build error.

..\src\meson.build:1:0: ERROR: Failed running 'C:\\Users\\edukaj\\.conan2\\p\\b\\andro0a7659df7e598\\p\\bin\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\aarch64-linux-android29-clang', binary or interpreter not executable.
Possibly wrong architecture or the executable bit is not set.

The issue is that on Windows the right path for the toolchain should end with .cmd.

I opened an issue on conan-center-index, and I am proposing a fix here:

@CLAassistant
Copy link

CLAassistant commented Feb 27, 2024

CLA assistant check
All committers have signed the CLA.

@elvisdukaj
Copy link
Contributor Author

Another solution could be just use the clang exexutable and pass --target=<arxh>-linux-android<api_level> options.

@elvisdukaj
Copy link
Contributor Author

I updated the test to check that when cross compiling with Android the right compiler path are set on Windows, Linux and MacOs.

@elvisdukaj elvisdukaj marked this pull request as draft February 27, 2024 13:48
Copy link
Member

@memsharded memsharded left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution!

def test_android_meson_toolchain_cross_compiling(arch, expected_arch):
api_level = 21
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, if the test is not broken, it is much better to leave existing tests as-is, to guarantee we are not breaking existing behavior, and add new tests that capture the fixes or improvements.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I was seeing a lot of duplication. I can create a new test case.
I am not sure why this test is for Mac only. The problem is that I cannot run them locally and I don't know how to set up the environment so I can run tests locally. I cannot either see the result from the pipeline either.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @memsharded ! I added a complete new test case to cover cross-compilation for mason on Windows and Linux. I tested that it works fine locally on both system (Windows 10, and I've use WSL2 with Ubuntu 22.04) and meson produces the right path for c and cpp in the conan_meson_cross.ini file.

Tests are red but I don't know how to make them right? What do I need to run tests locally? I've tried:

$ pytest .\conans\test\functional\toolchains\meson\test_cross_compilation.py

=============================================================================================================== test session starts ===============================================================================================================
platform win32 -- Python 3.11.3, pytest-6.2.5, py-1.11.0, pluggy-1.4.0
rootdir: C:\qxr\repo\conan, configfile: pytest.ini
plugins: xdist-3.5.0
collected 15 items

conans\test\functional\toolchains\meson\test_cross_compilation.py ssssssEssssEEEE                                                                                                                                                            [100%]

===================================================================================================================== ERRORS ====================================================================================================================== 
_______________________________________________________________________________________________ ERROR at setup of test_windows_cross_compiling_x86 ________________________________________________________________________________________________ 

item = <Function test_windows_cross_compiling_x86>

    def pytest_runtest_setup(item):
        tools_paths = []
        tools_env_vars = dict()
        for mark in item.iter_markers():
            if mark.name.startswith("tool_"):
                raise Exception("Invalid decorator @pytest.mark.{}".format(mark.name))

        kwargs = [mark.kwargs for mark in item.iter_markers(name="tool")]
        if any(kwargs):
            raise Exception("Invalid decorator @pytest.mark Do not use kwargs: {}".format(kwargs))
        tools_params = [mark.args for mark in item.iter_markers(name="tool")]
        for tool_params in tools_params:
            if len(tool_params) == 1:
                tool_name = tool_params[0]
                tool_version = None
            elif len(tool_params) == 2:
                tool_name, tool_version = tool_params
            else:
                raise Exception("Invalid arguments for mark.tool: {}".format(tool_params))

            result = _get_tool(tool_name, tool_version)
            if result is True:
                version_msg = "Any" if tool_version is None else tool_version
>               pytest.fail("Required '{}' tool version '{}' is not available".format(tool_name,
                                                                                      version_msg))
E               Failed: Required 'meson' tool version 'Any' is not available

conans\test\conftest.py:374: Failed
___________________________________________________________________________ ERROR at setup of test_android_meson_toolchain_cross_compiling_on_win_linux[armv8-aarch64] ____________________________________________________________________________ 

item = <Function test_android_meson_toolchain_cross_compiling_on_win_linux[armv8-aarch64]>

    def pytest_runtest_setup(item):
        tools_paths = []
        tools_env_vars = dict()
        for mark in item.iter_markers():
            if mark.name.startswith("tool_"):
                raise Exception("Invalid decorator @pytest.mark.{}".format(mark.name))

        kwargs = [mark.kwargs for mark in item.iter_markers(name="tool")]
        if any(kwargs):
            raise Exception("Invalid decorator @pytest.mark Do not use kwargs: {}".format(kwargs))
        tools_params = [mark.args for mark in item.iter_markers(name="tool")]
        for tool_params in tools_params:
            if len(tool_params) == 1:
                tool_name = tool_params[0]
                tool_version = None
            elif len(tool_params) == 2:
                tool_name, tool_version = tool_params
            else:
                raise Exception("Invalid arguments for mark.tool: {}".format(tool_params))

            result = _get_tool(tool_name, tool_version)
            if result is True:
                version_msg = "Any" if tool_version is None else tool_version
>               pytest.fail("Required '{}' tool version '{}' is not available".format(tool_name,
                                                                                      version_msg))
E               Failed: Required 'meson' tool version 'Any' is not available

conans\test\conftest.py:374: Failed
_____________________________________________________________________________ ERROR at setup of test_android_meson_toolchain_cross_compiling_on_win_linux[armv7-arm] ______________________________________________________________________________ 

item = <Function test_android_meson_toolchain_cross_compiling_on_win_linux[armv7-arm]>

    def pytest_runtest_setup(item):
        tools_paths = []
        tools_env_vars = dict()
        for mark in item.iter_markers():
            if mark.name.startswith("tool_"):
                raise Exception("Invalid decorator @pytest.mark.{}".format(mark.name))

        kwargs = [mark.kwargs for mark in item.iter_markers(name="tool")]
        if any(kwargs):
            raise Exception("Invalid decorator @pytest.mark Do not use kwargs: {}".format(kwargs))
        tools_params = [mark.args for mark in item.iter_markers(name="tool")]
        for tool_params in tools_params:
            if len(tool_params) == 1:
                tool_name = tool_params[0]
                tool_version = None
            elif len(tool_params) == 2:
                tool_name, tool_version = tool_params
            else:
                raise Exception("Invalid arguments for mark.tool: {}".format(tool_params))

            result = _get_tool(tool_name, tool_version)
            if result is True:
                version_msg = "Any" if tool_version is None else tool_version
>               pytest.fail("Required '{}' tool version '{}' is not available".format(tool_name,
                                                                                      version_msg))
E               Failed: Required 'meson' tool version 'Any' is not available

conans\test\conftest.py:374: Failed
______________________________________________________________________________ ERROR at setup of test_android_meson_toolchain_cross_compiling_on_win_linux[x86-i386] ______________________________________________________________________________ 

item = <Function test_android_meson_toolchain_cross_compiling_on_win_linux[x86-i386]>

    def pytest_runtest_setup(item):
        tools_paths = []
        tools_env_vars = dict()
        for mark in item.iter_markers():
            if mark.name.startswith("tool_"):
                raise Exception("Invalid decorator @pytest.mark.{}".format(mark.name))

        kwargs = [mark.kwargs for mark in item.iter_markers(name="tool")]
        if any(kwargs):
            raise Exception("Invalid decorator @pytest.mark Do not use kwargs: {}".format(kwargs))
        tools_params = [mark.args for mark in item.iter_markers(name="tool")]
        for tool_params in tools_params:
            if len(tool_params) == 1:
                tool_name = tool_params[0]
                tool_version = None
            elif len(tool_params) == 2:
                tool_name, tool_version = tool_params
            else:
                raise Exception("Invalid arguments for mark.tool: {}".format(tool_params))

            result = _get_tool(tool_name, tool_version)
            if result is True:
                version_msg = "Any" if tool_version is None else tool_version
>               pytest.fail("Required '{}' tool version '{}' is not available".format(tool_name,
                                                                                      version_msg))
E               Failed: Required 'meson' tool version 'Any' is not available

conans\test\conftest.py:374: Failed
___________________________________________________________________________ ERROR at setup of test_android_meson_toolchain_cross_compiling_on_win_linux[x86_64-x86_64] ____________________________________________________________________________ 

item = <Function test_android_meson_toolchain_cross_compiling_on_win_linux[x86_64-x86_64]>

    def pytest_runtest_setup(item):
        tools_paths = []
        tools_env_vars = dict()
        for mark in item.iter_markers():
            if mark.name.startswith("tool_"):
                raise Exception("Invalid decorator @pytest.mark.{}".format(mark.name))

        kwargs = [mark.kwargs for mark in item.iter_markers(name="tool")]
        if any(kwargs):
            raise Exception("Invalid decorator @pytest.mark Do not use kwargs: {}".format(kwargs))
        tools_params = [mark.args for mark in item.iter_markers(name="tool")]
        for tool_params in tools_params:
            if len(tool_params) == 1:
                tool_name = tool_params[0]
                tool_version = None
            elif len(tool_params) == 2:
                tool_name, tool_version = tool_params
            else:
                raise Exception("Invalid arguments for mark.tool: {}".format(tool_params))

            result = _get_tool(tool_name, tool_version)
            if result is True:
                version_msg = "Any" if tool_version is None else tool_version
>               pytest.fail("Required '{}' tool version '{}' is not available".format(tool_name,
                                                                                      version_msg))
E               Failed: Required 'meson' tool version 'Any' is not available

conans\test\conftest.py:374: Failed
================================================================================================================ warnings summary ================================================================================================================= 
..\..\..\Users\edukaj\.virtualenvs\conan2\Lib\site-packages\bottle.py:38
  C:\Users\edukaj\.virtualenvs\conan2\Lib\site-packages\bottle.py:38: DeprecationWarning: 'cgi' is deprecated and slated for removal in Python 3.13
    import base64, cgi, email.utils, functools, hmac, itertools, mimetypes,\

conans\test\utils\tools.py:368
  C:\qxr\repo\conan\conans\test\utils\tools.py:368: PytestCollectionWarning: cannot collect test class 'TestClient' because it has a __init__ constructor (from: conans/test/functional/toolchains/meson/test_cross_compilation.py)
    class TestClient(object):

-- Docs: https://docs.pytest.org/en/stable/warnings.html
============================================================================================================= short test summary info ============================================================================================================= 
ERROR conans/test/functional/toolchains/meson/test_cross_compilation.py::test_windows_cross_compiling_x86 - Failed: Required 'meson' tool version 'Any' is not available
ERROR conans/test/functional/toolchains/meson/test_cross_compilation.py::test_android_meson_toolchain_cross_compiling_on_win_linux[armv8-aarch64] - Failed: Required 'meson' tool version 'Any' is not available
ERROR conans/test/functional/toolchains/meson/test_cross_compilation.py::test_android_meson_toolchain_cross_compiling_on_win_linux[armv7-arm] - Failed: Required 'meson' tool version 'Any' is not available
ERROR conans/test/functional/toolchains/meson/test_cross_compilation.py::test_android_meson_toolchain_cross_compiling_on_win_linux[x86-i386] - Failed: Required 'meson' tool version 'Any' is not available
ERROR conans/test/functional/toolchains/meson/test_cross_compilation.py::test_android_meson_toolchain_cross_compiling_on_win_linux[x86_64-x86_64] - Failed: Required 'meson' tool version 'Any' is not available
==================================================================================================== 10 skipped, 2 warnings, 5 errors in 0.30s ==================================================================================================== 

Also running pytest . really doesn't produce green tests on my system. Any hint about this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, sorry about that, the test configuration system that we are using at the moment is not well documented, nor great. The key is in this file: https://github.com/conan-io/conan/blob/develop2/conans/test/conftest.py

It instructs you to define your own conftest_user.py that defines your installed tools and custom locations to those tools in your machine. With those correctly configured in conftest_user.py the tests should be enabled and start to run.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for coming back to me! I will try to run the tests locally and then make them green :) if I manage that I will remove the draft and ask for a review.

@elvisdukaj elvisdukaj force-pushed the fix/meson_wrong_compiler_path_on_windows_when_andrdoid_ndk branch from 2b0bea9 to 1aab5a4 Compare February 28, 2024 11:23
@elvisdukaj elvisdukaj closed this Feb 29, 2024
@elvisdukaj elvisdukaj deleted the fix/meson_wrong_compiler_path_on_windows_when_andrdoid_ndk branch February 29, 2024 15:54
@elvisdukaj elvisdukaj restored the fix/meson_wrong_compiler_path_on_windows_when_andrdoid_ndk branch March 1, 2024 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants