Comments (7)
Hi @ViliusSutkus89 thanks a lot for taking the time to report the issue, we appreciate it.
We'll take a look into this as soon as we can, you might be onto something :)
from conan.
I have a workaround in def generate(self):
which sets the correct ENV vars for the toolchain, but it's not really fun applying that workaround to each affected package.
def generate(self):
tc = AutotoolsToolchain(self)
# ...
env = tc.environment()
if cross_building(self) and self.settings.os == "Android":
# NDK binary paths need to be supplied as posixpath, not os path, even on windows
# This means no backslashes, because scripts in NDK don't like backslashes
android_ndk_home = self.conf.get("tools.android:ndk_path").replace("\\", "/")
target_host_triple = {
"armv7": "armv7a-linux-androideabi",
"armv8": "aarch64-linux-android",
"x86": "i686-linux-android",
"x86_64": "x86_64-linux-android",
}[self.settings.get_safe("arch")]
api_level = self.settings.os.get_safe("api_level")
build_machine = "{}-x86_64".format({"Linux": "linux", "Macos": "darwin","Windows": "windows"}[str(self.settings_build.os)])
toolchain = posixpath.join(android_ndk_home, "toolchains", "llvm", "prebuilt", build_machine, "bin")
if self.settings_build.os == "Windows":
executable_suffix = ".exe"
else:
executable_suffix = ""
env.define("AR", posixpath.join(toolchain, "llvm-ar" + executable_suffix))
env.define("AS", posixpath.join(toolchain, "llvm-as" + executable_suffix))
env.define("RANLIB", posixpath.join(toolchain, "llvm-ranlib" + executable_suffix))
env.define("CC", posixpath.join(toolchain, "{}{}-clang".format(target_host_triple, api_level)))
env.define("CXX", posixpath.join(toolchain, "{}{}-clang++".format(target_host_triple, api_level)))
env.define("LD", posixpath.join(toolchain, "ld" + executable_suffix))
env.define("STRIP", posixpath.join(toolchain, "llvm-strip" + executable_suffix))
tc.generate(env)
from conan.
I've ran into more autotools packages that I want to use, so instead of patching every single one of them, I've added the toolchain to my host profile:
{% set android_home = os.getenv("ANDROID_HOME") %}
{% set ndk_version = "26.3.11579264" %}
{% set api_level = "21" %}
[settings]
os=Android
os.api_level={{api_level}}
arch=armv8
build_type=RelWithDebInfo
compiler=clang
compiler.version=17
compiler.cppstd=20
compiler.libcxx=c++_static
[conf]
tools.android:ndk_path={{android_home}}/ndk/{{ndk_version}}
[buildenv]
AR={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar
AS={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-as
RANLIB={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ranlib
CC={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android{{api_level}}-clang
CXX={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android{{api_level}}-clang++
LD={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/ld
STRIP={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip
CC
and CXX
are different for each abi:
CC={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi{{api_level}}-clang
CXX={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi{{api_level}}-clang++
CC={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android{{api_level}}-clang
CXX={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android{{api_level}}-clang++
CC={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android{{api_level}}-clang
CXX={{android_home}}/ndk/{{ndk_version}}/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android{{api_level}}-clang++
I still count this as a workaround, not a proper solution, because I would have to add it to host profiles of every downstream user of my Android libraries.
from conan.
(Corrected armv7 CC and CXX values in the previous comment)
from conan.
tools.android:ndk_path
is not a silver bullet.
There is indeed some magic in CMakeToolchain & MesonToolchain when tools.android:ndk_path
is set:
- For CMakeToolchain, the path of CMake toolchain of Android NDK is deduced and injected
- For MesonToolchain, paths to binaries are deduced in order to fill CC, CXX & AR
Except of that there is no magic, so your profile must provide these information. It's not really an issue for conancenter, but for conan client.
The confusion comes from the fact that this micro-management of Android NDK details has been implemented in some conan helpers and not in others, so there is now an expectation from users that it should work out of the box irrespective of underlying build system.
from conan.
Fully agree with the part that this is a conan client, not a conan center issue. Sorry about misfiling. Haven't looked much into conan client code yet, but I assume that it would be the correct place for a proper solution, not these profile workarounds.
from conan.
moving this to conan client -!
from conan.
Related Issues (20)
- [question] conan info --graph replacement? HOT 2
- [question] Conan1 vs Conan2 package id compatibility + possibility of Artifactory hash collision? HOT 2
- Conan2 Config Uninstall HOT 3
- [question] test_package does not respect dependency includes/libs HOT 2
- [question] How to pass resource file path to consumer? HOT 3
- [feature] Extend revision_mode 'scm_folder' to allow for multiple folders HOT 5
- [bug] Large conan package gets downloaded to a wrong subfolder in windows HOT 5
- [question] Is Python inheritance allowed or not? HOT 2
- [question] core.cache:storage_path + Docker HOT 2
- [question] How to implement a validation in the best way? HOT 4
- [question] LD_LIBRARY_PATH and DYLD_LIBRARY_PATH are not added in CMakePresets.json HOT 4
- [suggestion] Access properties of profile's tool requirements in [conf] section HOT 7
- [question] Is IMPORTED_LOCATION missing for conan_package_library_targets? HOT 2
- [bug] yasm/1.3.0 doesn't compile with MSVC in release HOT 2
- [question] How to support conanfile.py in a subdirectory, using Bazel
- [bug] generated BUILD.bazel file does not import dll when shared=True for some packages
- [question] Access Resource file in cmake module HOT 1
- [bug] Conan install/graph explain don't find package because they don't filter based on settings/options before selecting package candidate HOT 1
- [question] Header library automatic downstream header propagation HOT 4
- [bug] `conan.tools.files.copy()` fails silently. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from conan.