-
Notifications
You must be signed in to change notification settings - Fork 993
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
[MesonToolchain] Binaries c
, cpp
and ld
(added recently) can be lists
#14676
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
import pytest | ||
|
||
from conan.tools.meson import MesonToolchain | ||
from conans.test.assets.genconanfile import GenConanfile | ||
from conans.test.utils.tools import TestClient | ||
|
||
|
||
|
@@ -205,3 +206,80 @@ def test_clang_cl_vscrt(build_type, runtime, vscrt): | |
t.run("install . -pr:h=profile -pr:b=profile") | ||
content = t.load(MesonToolchain.native_filename) | ||
assert f"b_vscrt = '{vscrt}'" in content | ||
|
||
|
||
def test_env_vars_from_build_require(): | ||
conanfile = textwrap.dedent(""" | ||
from conan import ConanFile | ||
import os | ||
|
||
class HelloConan(ConanFile): | ||
name = 'hello_compiler' | ||
version = '1.0' | ||
def package_info(self): | ||
self.buildenv_info.define("CC", "CC_VALUE") | ||
self.buildenv_info.define("CC_LD", "CC_LD_VALUE") | ||
self.buildenv_info.define("CXX", "CXX_VALUE") | ||
self.buildenv_info.define("CXX_LD", "CXX_LD_VALUE") | ||
self.buildenv_info.define("AR", "AR_VALUE") | ||
self.buildenv_info.define("STRIP", "STRIP_VALUE") | ||
self.buildenv_info.define("AS", "AS_VALUE") | ||
self.buildenv_info.define("WINDRES", "WINDRES_VALUE") | ||
self.buildenv_info.define("PKG_CONFIG", "PKG_CONFIG_VALUE") | ||
self.buildenv_info.define("LD", "LD_VALUE") | ||
""") | ||
client = TestClient() | ||
client.save({"conanfile.py": conanfile}) | ||
client.run("create .") | ||
|
||
conanfile = textwrap.dedent(""" | ||
from conan import ConanFile | ||
class HelloConan(ConanFile): | ||
name = 'consumer' | ||
version = '1.0' | ||
generators = "MesonToolchain" | ||
settings = "os", "arch", "compiler", "build_type" | ||
|
||
def requirements(self): | ||
self.tool_requires("hello_compiler/1.0", ) | ||
""") | ||
# Now, let's check how all the build env variables are applied at consumer side | ||
client.save({"conanfile.py": conanfile}) | ||
client.run("install . -pr:h=default -pr:b=default") | ||
content = client.load("conan_meson_native.ini") | ||
assert "c = 'CC_VALUE'" in content | ||
assert "cpp = 'CXX_VALUE'" in content | ||
assert "ld = 'LD_VALUE'" in content | ||
assert "c_ld = 'CC_LD_VALUE'" in content | ||
assert "cpp_ld = 'CXX_LD_VALUE'" in content | ||
assert "ar = 'AR_VALUE'" in content | ||
assert "strip = 'STRIP_VALUE'" in content | ||
assert "as = 'AS_VALUE'" in content | ||
assert "windres = 'WINDRES_VALUE'" in content | ||
assert "pkgconfig = 'PKG_CONFIG_VALUE'" in content | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test is coming from the |
||
|
||
|
||
def test_check_c_cpp_ld_list_formats(): | ||
# Issue related: https://github.com/conan-io/conan/issues/14028 | ||
profile = textwrap.dedent(""" | ||
[settings] | ||
os=Windows | ||
arch=x86_64 | ||
compiler=gcc | ||
compiler.version=9 | ||
compiler.cppstd=17 | ||
compiler.libcxx=libstdc++11 | ||
build_type=Release | ||
[buildenv] | ||
CC=aarch64-poky-linux-gcc -mcpu=cortex-a53 -march=armv8-a+crc+crypto | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So Meson needs this defined as a list for the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with that, but the thing is that you can pass all those arguments to the CC in one shot as a list and it seems to be working as it's said in the issue #14028. Overall, we're not changing the behavior at all. We agree that this should not be the way to go, but we're only allowing the users to have those compiler and compiler flags together without changing those env variables (up to them). You can check the Meson documentation too (https://mesonbuild.com/Machine-files.html#binaries). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @memsharded This is unforunately how Yocto configures the |
||
CXX=aarch64-poky-linux-g++ -mcpu=cortex-a53 -march=armv8-a+crc+crypto | ||
LD=aarch64-poky-linux-ld --sysroot=/opt/sysroots/cortexa53-crypto-poky-linux | ||
""") | ||
t = TestClient() | ||
t.save({"conanfile.txt": "[generators]\nMesonToolchain", | ||
"profile": profile}) | ||
t.run("install . -pr:h=profile -pr:b=profile") | ||
content = t.load(MesonToolchain.native_filename) | ||
assert "c = ['aarch64-poky-linux-gcc', '-mcpu=cortex-a53', '-march=armv8-a+crc+crypto']" in content | ||
assert "cpp = ['aarch64-poky-linux-g++', '-mcpu=cortex-a53', '-march=armv8-a+crc+crypto']" in content | ||
assert "ld = ['aarch64-poky-linux-ld', '--sysroot=/opt/sysroots/cortexa53-crypto-poky-linux']" in content |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@franramirez688 According to the Meson documentation here, I didn't think using a multivalue argument for the linker options made sense sense it would have to be one of
gold
,lld
,bfd
for Clang / GCC and only for MSVC / Clang-Cl should it be an executable. I think this is pretty different behavior than how autotools make use of theLD
environment variable.Fyi, I really appreciate you improving the interface for this stuff in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, indeed @jwillikers
I added that possibility only to be sure that I was not missing any corner case where you could want to pass several arguments to LD. Anyway, I hope consumers will use
<>_ld
instead, as Meson recommends in its documentation.