Skip to content

Commit 138e596

Browse files
committed
Pass ldflags when building with Conan
Signed-off-by: Uilian Ries <uilianries@gmail.com>
1 parent 4b004ea commit 138e596

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

classes/conan.bbclass

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ CONAN_SETTINGS_COMPILER_CPPSTD ?= "gnu17"
2727
CONAN_SETTINGS_COMPILER_LIBCXX ?= "libstdc++11"
2828
CONAN_CONFIG_URL ?= ""
2929
CONAN_PROFILE_HOST_OPTIONS ?= "*/*:shared=True"
30-
CONAN_BUILD_POLICY ?= "never"
30+
CONAN_BUILD_POLICY ?= "missing"
3131
CONAN_SETTINGS_BUILD_TYPE ?= "${@'Debug' if d.getVar('DEBUG_BUILD') == '1' else 'Release'}"
32-
CONAN_EXTRA_CFLAGS ?= ""
33-
CONAN_EXTRA_CXXFLAGS ?= ""
32+
CONAN_EXTRA_CFLAGS ?= "${TUNE_CCARGS}"
33+
CONAN_EXTRA_CXXFLAGS ?= "${TUNE_CCARGS}"
34+
CONAN_EXTRA_CONFIG ?= ""
3435

3536
export CONAN_HOME
3637
export CONAN_LOG_LEVEL="${CONAN_LOGLEVEL}"
@@ -49,7 +50,7 @@ def map_yocto_arch_to_conan_arch(d, arch_var):
4950
"mips64": "mips64",
5051
"ppc7400": "ppc32"
5152
}.get(arch, arch)
52-
bb.note("\nINFO: Arch value '{}' from '{}' mapped to '{}'".format(arch, arch_var, ret))
53+
bb.debug(1, f"INFO: Arch value '{arch}' from '{arch_var}' mapped to '{ret}'")
5354
return ret
5455

5556
def convert_flags_to_list(d, flags):
@@ -60,6 +61,13 @@ def convert_flags_to_list(d, flags):
6061
result = f'[{", ".join(quoted_flags)}]'
6162
return str(result)
6263

64+
def convert_list_to_lines(d, list_var):
65+
if not list_var:
66+
return ""
67+
list_items = list_var.split()
68+
result = "\n".join(list_items)
69+
return str(result)
70+
6371
do_configure[network] = "1"
6472
conan_do_configure() {
6573
bbnote "Creating Conan home directory: ${CONAN_HOME}"
@@ -102,6 +110,7 @@ conan_do_configure() {
102110
bbnote "Generating host profile for ${CONAN_PROFILE_HOST_PATH}"
103111
formatted_cflags="${@convert_flags_to_list(d, '${CONAN_EXTRA_CFLAGS}')}"
104112
formatted_cxxflags="${@convert_flags_to_list(d, '${CONAN_EXTRA_CXXFLAGS}')}"
113+
formatted_ldflags="${@convert_flags_to_list(d, '${LDFLAGS}')}"
105114
cat > "${CONAN_PROFILE_HOST_PATH}" <<EOF
106115
[settings]
107116
os=Linux
@@ -112,10 +121,15 @@ compiler.libcxx=${CONAN_SETTINGS_COMPILER_LIBCXX}
112121
compiler.cppstd=${CONAN_SETTINGS_COMPILER_CPPSTD}
113122
build_type=${CONAN_SETTINGS_BUILD_TYPE}
114123
[options]
115-
${CONAN_PROFILE_HOST_OPTIONS}
124+
${@convert_list_to_lines(d, '${CONAN_PROFILE_HOST_OPTIONS}')}
116125
[conf]
117126
tools.build:cxxflags=${formatted_cxxflags}
118127
tools.build:cflags=${formatted_cflags}
128+
tools.build:sysroot=${RECIPE_SYSROOT}
129+
tools.build:compiler_executables={'c': '${cc_name}', 'cpp': '${cxx_name}'}
130+
tools.build:compiler_executables={'c': '${cc_name}', 'cpp': '${cxx_name}'}
131+
tools.build:sharedlinkflags=${formatted_ldflags}
132+
${@convert_list_to_lines(d, '${CONAN_EXTRA_CONFIG}')}
119133
EOF
120134

121135
bbnote "Profile configuration:"

0 commit comments

Comments
 (0)