Fix compiler path with meson on Windows when using Android NDK#15760
Fix compiler path with meson on Windows when using Android NDK#15760elvisdukaj wants to merge 2 commits into
Conversation
|
Another solution could be just use the clang exexutable and pass |
e550eb1 to
2b0bea9
Compare
|
I updated the test to check that when cross compiling with Android the right compiler path are set on Windows, Linux and MacOs. |
memsharded
left a comment
There was a problem hiding this comment.
Thanks for your contribution!
| @pytest.mark.tool("android_ndk") | ||
| @pytest.mark.skipif(platform.system() != "Darwin", reason="Android NDK only tested in MacOS for now") | ||
| def test_android_meson_toolchain_cross_compiling(arch, expected_arch): | ||
| api_level = 21 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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:
Details
$ 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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
2b0bea9 to
1aab5a4
Compare
Changelog: Fix | Bugfix): Describe here your pull request
Docs: https://github.com/conan-io/docs/pull/XXXX
developbranch, documenting this one.Description
Trying to build
lcms/2.14on Windows using Android NDK results in a build error.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: