Repository: conan-io/conan-center-index

Issue:
[package] android-ndk/r24: Cross compile from macOS,armv8 not supported
Android ndk r24 should have m1 mac (arm64) support, but the conan package doesn't seem to support it


### Package and Environment Details (include every applicable attribute)
  * Package Name/Version: **android-ndk/r24**
  * Operating System+version: **macOS 12.3.1**
  * Conan version: **conan 1.47.0**


### Conan profile (output of `conan profile show default` or `conan profile show <profile>` if custom profile is in use)
```
Configuration (profile_host):
[settings]
arch=armv7
arch_build=armv8
build_type=RelWithDebInfo
compiler=clang
compiler.cppstd=20
compiler.libcxx=libc++
compiler.version=11
os=Android
os.api_level=28
os_build=Macos
[options]
[build_requires]
*: android-ndk/r24
[env]

Configuration (profile_build):
[settings]
arch=armv8
arch_build=armv8
build_type=Release
compiler=apple-clang
compiler.cppstd=20
compiler.libcxx=libc++
compiler.version=13
os=Macos
os_build=Macos
[options]
[build_requires]
[env]
```


### Steps to reproduce (Include if Applicable)

Try to cross-compile from m1 mac to Android using the android-ndk package

### Logs (Include/Attach if Applicable)
<details><summary>Click to expand log</summary>

```
Cross-build from 'Macos:armv8' to 'Android:armv7'
Installing (downloading, building) binaries...
ERROR: There are invalid packages (packages that cannot exist for this configuration):
android-ndk/r24: Invalid ID: os,arch=Macos,armv8 is not supported by android-ndk (no binaries are available)
android-ndk/r24: Invalid ID: os,arch=Macos,armv8 is not supported by android-ndk (no binaries are available)
android-ndk/r24: Invalid ID: os,arch=Macos,armv8 is not supported by android-ndk (no binaries are available)
android-ndk/r24: Invalid ID: os,arch=Macos,armv8 is not supported by android-ndk (no binaries are available)
android-ndk/r24: Invalid ID: os,arch=Macos,armv8 is not supported by android-ndk (no binaries are available)
android-ndk/r24: Invalid ID: os,arch=Macos,armv8 is not supported by android-ndk (no binaries are available)
android-ndk/r24: Invalid ID: os,arch=Macos,armv8 is not supported by android-ndk (no binaries are available)
android-ndk/r24: Invalid ID: os,arch=Macos,armv8 is not supported by android-ndk (no binaries are available)
android-ndk/r24: Invalid ID: os,arch=Macos,armv8 is not supported by android-ndk (no binaries are available)
android-ndk/r24: Invalid ID: os,arch=Macos,armv8 is not supported by android-ndk (no binaries are available)
android-ndk/r24: Invalid ID: os,arch=Macos,armv8 is not supported by android-ndk (no binaries are available)
```

</details>



Discussion:
https://github.com/conan-io/conan-center-index/pull/9976
Just tried compiling again after the above pr was merged, and it seems to be working fine now.

Thanks everyone!
Actually, scratch that. Compilation fails a bit further down the chain with these error messages:

<details><summary>Click to expand log</summary>

```
android-ndk/r24: Creating ANDROID_NDK_ROOT environment variable: /Users/_/.conan/data/android-ndk/r24/_/_/package/06d313f2ce6737a31e5d7ccd4d516d2ac742276a
android-ndk/r24: Creating ANDROID_NDK_HOME environment variable: /Users/_/.conan/data/android-ndk/r24/_/_/package/06d313f2ce6737a31e5d7ccd4d516d2ac742276a
android-ndk/r24: WARN: Could not find a valid CMAKE_SYSTEM_PROCESSOR variable, supported by CMake
android-ndk/r24: Creating NDK_ROOT environment variable: /Users/_/.conan/data/android-ndk/r24/_/_/package/06d313f2ce6737a31e5d7ccd4d516d2ac742276a/toolchains/llvm/prebuilt/darwin-armv8
android-ndk/r24: Creating CHOST environment variable: arm-linux-androideabi
android-ndk/r24: Creating CONAN_CMAKE_FIND_ROOT_PATH environment variable: /Users/_/.conan/data/android-ndk/r24/_/_/package/06d313f2ce6737a31e5d7ccd4d516d2ac742276a/toolchains/llvm/prebuilt/darwin-armv8/sysroot
android-ndk/r24: Creating SYSROOT environment variable: /Users/_/.conan/data/android-ndk/r24/_/_/package/06d313f2ce6737a31e5d7ccd4d516d2ac742276a/toolchains/llvm/prebuilt/darwin-armv8/sysroot
android-ndk/r24: Creating self.cpp_info.sysroot: /Users/_/.conan/data/android-ndk/r24/_/_/package/06d313f2ce6737a31e5d7ccd4d516d2ac742276a/toolchains/llvm/prebuilt/darwin-armv8/sysroot
android-ndk/r24: Creating ANDROID_NATIVE_API_LEVEL environment variable: 28
android-ndk/r24: Creating CONAN_CMAKE_PROGRAM environment variable: /Users/_/.conan/data/android-ndk/r24/_/_/package/06d313f2ce6737a31e5d7ccd4d516d2ac742276a/cmake-wrapper
android-ndk/r24: Creating CONAN_CMAKE_TOOLCHAIN_FILE environment variable: /Users/_/.conan/data/android-ndk/r24/_/_/package/06d313f2ce6737a31e5d7ccd4d516d2ac742276a/build/cmake/android.toolchain.cmake
android-ndk/r24: ERROR: 'Environment variable CC could not be created: '/Users/_/.conan/data/android-ndk/r24/_/_/package/06d313f2ce6737a31e5d7ccd4d516d2ac742276a/toolchains/llvm/prebuilt/darwin-armv8/bin/armv7a-linux-androideabi28-clang'
android-ndk/r24: ERROR: 'Environment variable CXX could not be created: '/Users/_/.conan/data/android-ndk/r24/_/_/package/06d313f2ce6737a31e5d7ccd4d516d2ac742276a/toolchains/llvm/prebuilt/darwin-armv8/bin/armv7a-linux-androideabi28-clang++'
android-ndk/r24: ERROR: 'Environment variable AR could not be created: '/Users/_/.conan/data/android-ndk/r24/_/_/package/06d313f2ce6737a31e5d7ccd4d516d2ac742276a/toolchains/llvm/prebuilt/darwin-armv8/bin/llvm-ar'
android-ndk/r24: ERROR: 'Environment variable AS could not be created: '/Users/_/.conan/data/android-ndk/r24/_/_/package/06d313f2ce6737a31e5d7ccd4d516d2ac742276a/toolchains/llvm/prebuilt/darwin-armv8/bin/llvm-as'
android-ndk/r24: ERROR: 'Environment variable RANLIB could not be created: '/Users/_/.conan/data/android-ndk/r24/_/_/package/06d313f2ce6737a31e5d7ccd4d516d2ac742276a/toolchains/llvm/prebuilt/darwin-armv8/bin/llvm-ranlib'
android-ndk/r24: ERROR: 'Environment variable STRIP could not be created: '/Users/_/.conan/data/android-ndk/r24/_/_/package/06d313f2ce6737a31e5d7ccd4d516d2ac742276a/toolchains/llvm/prebuilt/darwin-armv8/bin/llvm-strip'
android-ndk/r24: ERROR: 'Environment variable ADDR2LINE could not be created: '/Users/_/.conan/data/android-ndk/r24/_/_/package/06d313f2ce6737a31e5d7ccd4d516d2ac742276a/toolchains/llvm/prebuilt/darwin-armv8/bin/llvm-addr2line'
android-ndk/r24: ERROR: 'Environment variable NM could not be created: '/Users/_/.conan/data/android-ndk/r24/_/_/package/06d313f2ce6737a31e5d7ccd4d516d2ac742276a/toolchains/llvm/prebuilt/darwin-armv8/bin/llvm-nm'
android-ndk/r24: ERROR: 'Environment variable OBJCOPY could not be created: '/Users/_/.conan/data/android-ndk/r24/_/_/package/06d313f2ce6737a31e5d7ccd4d516d2ac742276a/toolchains/llvm/prebuilt/darwin-armv8/bin/llvm-objcopy'
android-ndk/r24: ERROR: 'Environment variable OBJDUMP could not be created: '/Users/_/.conan/data/android-ndk/r24/_/_/package/06d313f2ce6737a31e5d7ccd4d516d2ac742276a/toolchains/llvm/prebuilt/darwin-armv8/bin/llvm-objdump'
android-ndk/r24: ERROR: 'Environment variable READELF could not be created: '/Users/_/.conan/data/android-ndk/r24/_/_/package/06d313f2ce6737a31e5d7ccd4d516d2ac742276a/toolchains/llvm/prebuilt/darwin-armv8/bin/llvm-readelf'
android-ndk/r24: ERROR: 'Environment variable LD could not be created: '/Users/_/.conan/data/android-ndk/r24/_/_/package/06d313f2ce6737a31e5d7ccd4d516d2ac742276a/toolchains/llvm/prebuilt/darwin-armv8/bin/ld'
```

</details>
@uilianries can you check? as it's M1
I can confirm that behavior, I have the same locally:

```
Configuration (profile_host):
[settings]
arch=armv7
build_type=RelWithDebInfo
compiler=clang
compiler.cppstd=20
compiler.libcxx=libc++
compiler.version=11
os=Android
os.api_level=28
[options]
[build_requires]
*: android-ndk/r24
[env]

Configuration (profile_build):
[settings]
arch=armv8
arch_build=armv8
build_type=Release
compiler=apple-clang
compiler.libcxx=libc++
compiler.version=13.1
os=Macos
os_build=Macos
[options]
[build_requires]
[env]

....

android-ndk/r24: Package '06d313f2ce6737a31e5d7ccd4d516d2ac742276a' created
android-ndk/r24: Created package revision 17afc40f04d56fa4857a44d36a157302
android-ndk/r24: Creating ANDROID_NDK_ROOT environment variable: /Users/conan/.conan/data/android-ndk/r24/_/_/package/06d313f2ce6737a31e5d7ccd4d516d2ac742276a
android-ndk/r24: Creating ANDROID_NDK_HOME environment variable: /Users/conan/.conan/data/android-ndk/r24/_/_/package/06d313f2ce6737a31e5d7ccd4d516d2ac742276a
android-ndk/r24: WARN: Could not find a valid CMAKE_SYSTEM_PROCESSOR variable, supported by CMake
android-ndk/r24: Creating NDK_ROOT environment variable: /Users/conan/.conan/data/android-ndk/r24/_/_/package/06d313f2ce6737a31e5d7ccd4d516d2ac742276a/toolchains/llvm/prebuilt/darwin-armv8
android-ndk/r24: Creating CHOST environment variable: arm-linux-androideabi
android-ndk/r24: Creating CONAN_CMAKE_FIND_ROOT_PATH environment variable: /Users/conan/.conan/data/android-ndk/r24/_/_/package/06d313f2ce6737a31e5d7ccd4d516d2ac742276a/toolchains/llvm/prebuilt/darwin-armv8/sysroot
android-ndk/r24: Creating SYSROOT environment variable: /Users/conan/.conan/data/android-ndk/r24/_/_/package/06d313f2ce6737a31e5d7ccd4d516d2ac742276a/toolchains/llvm/prebuilt/darwin-armv8/sysroot
android-ndk/r24: Creating self.cpp_info.sysroot: /Users/conan/.conan/data/android-ndk/r24/_/_/package/06d313f2ce6737a31e5d7ccd4d516d2ac742276a/toolchains/llvm/prebuilt/darwin-armv8/sysroot
android-ndk/r24: Creating ANDROID_NATIVE_API_LEVEL environment variable: 28
android-ndk/r24: Creating CONAN_CMAKE_PROGRAM environment variable: /Users/conan/.conan/data/android-ndk/r24/_/_/package/06d313f2ce6737a31e5d7ccd4d516d2ac742276a/cmake-wrapper
android-ndk/r24: Creating CONAN_CMAKE_TOOLCHAIN_FILE environment variable: /Users/conan/.conan/data/android-ndk/r24/_/_/package/06d313f2ce6737a31e5d7ccd4d516d2ac742276a/build/cmake/android.toolchain.cmake
android-ndk/r24: ERROR: 'Environment variable CC could not be created: '/Users/conan/.conan/data/android-ndk/r24/_/_/package/06d313f2ce6737a31e5d7ccd4d516d2ac742276a/toolchains/llvm/prebuilt/darwin-armv8/bin/armv7a-linux-androideabi28-clang'
android-ndk/r24: ERROR: 'Environment variable CXX could not be created: '/Users/conan/.conan/data/android-ndk/r24/_/_/package/06d313f2ce6737a31e5d7ccd4d516d2ac742276a/toolchains/llvm/prebuilt/darwin-armv8/bin/armv7a-linux-androideabi28-clang++'
android-ndk/r24: ERROR: 'Environment variable AR could not be created: '/Users/conan/.conan/data/android-ndk/r24/_/_/package/06d313f2ce6737a31e5d7ccd4d516d2ac742276a/toolchains/llvm/prebuilt/darwin-armv8/bin/llvm-ar'
android-ndk/r24: ERROR: 'Environment variable AS could not be created: '/Users/conan/.conan/data/android-ndk/r24/_/_/package/06d313f2ce6737a31e5d7ccd4d516d2ac742276a/toolchains/llvm/prebuilt/darwin-armv8/bin/llvm-as'
android-ndk/r24: ERROR: 'Environment variable RANLIB could not be created: '/Users/conan/.conan/data/android-ndk/r24/_/_/package/06d313f2ce6737a31e5d7ccd4d516d2ac742276a/toolchains/llvm/prebuilt/darwin-armv8/bin/llvm-ranlib'
android-ndk/r24: ERROR: 'Environment variable STRIP could not be created: '/Users/conan/.conan/data/android-ndk/r24/_/_/package/06d313f2ce6737a31e5d7ccd4d516d2ac742276a/toolchains/llvm/prebuilt/darwin-armv8/bin/llvm-strip'
android-ndk/r24: ERROR: 'Environment variable ADDR2LINE could not be created: '/Users/conan/.conan/data/android-ndk/r24/_/_/package/06d313f2ce6737a31e5d7ccd4d516d2ac742276a/toolchains/llvm/prebuilt/darwin-armv8/bin/llvm-addr2line'
android-ndk/r24: ERROR: 'Environment variable NM could not be created: '/Users/conan/.conan/data/android-ndk/r24/_/_/package/06d313f2ce6737a31e5d7ccd4d516d2ac742276a/toolchains/llvm/prebuilt/darwin-armv8/bin/llvm-nm'
android-ndk/r24: ERROR: 'Environment variable OBJCOPY could not be created: '/Users/conan/.conan/data/android-ndk/r24/_/_/package/06d313f2ce6737a31e5d7ccd4d516d2ac742276a/toolchains/llvm/prebuilt/darwin-armv8/bin/llvm-objcopy'
android-ndk/r24: ERROR: 'Environment variable OBJDUMP could not be created: '/Users/conan/.conan/data/android-ndk/r24/_/_/package/06d313f2ce6737a31e5d7ccd4d516d2ac742276a/toolchains/llvm/prebuilt/darwin-armv8/bin/llvm-objdump'
android-ndk/r24: ERROR: 'Environment variable READELF could not be created: '/Users/conan/.conan/data/android-ndk/r24/_/_/package/06d313f2ce6737a31e5d7ccd4d516d2ac742276a/toolchains/llvm/prebuilt/darwin-armv8/bin/llvm-readelf'
android-ndk/r24: ERROR: 'Environment variable LD could not be created: '/Users/conan/.conan/data/android-ndk/r24/_/_/package/06d313f2ce6737a31e5d7ccd4d516d2ac742276a/toolchains/llvm/prebuilt/darwin-armv8/bin/ld'
[HOOK - conan-center.py] post_package_info(): [CMAKE FILE NOT IN BUILD FOLDERS (KB-H019)] OK
[HOOK - conan-center.py] post_package_info(): [LIBRARY DOES NOT EXIST (KB-H054)] OK
```


Resolving patch:
diff --git a/recipes/android-ndk/all/conanfile.py b/recipes/android-ndk/all/conanfile.py
--- a/recipes/android-ndk/all/conanfile.py
+++ b/recipes/android-ndk/all/conanfile.py
@@ -12,10 +12,10 @@ class AndroidNDKConan(ConanFile):
     description = "The Android NDK is a toolset that lets you implement parts of your app in native code, using languages such as C and C++"
     url = "https://github.com/conan-io/conan-center-index"
     homepage = "https://developer.android.com/ndk/"
-    topics = ("android", "NDK", "toolchain", "compiler")
+    topics = ("android", "ndk", "toolchain", "compiler")
     license = "Apache-2.0"
 
-    settings = "os", "arch"
+    settings = "os", "arch", "build_type", "compiler"
 
     short_paths = True
     exports_sources = "cmake-wrapper.cmd", "cmake-wrapper"
@@ -55,6 +55,8 @@ def build(self):
     def package_id(self):
         if self._is_universal2:
             self.info.settings.arch = "universal:armv8/x86_64"
+        del self.info.settings.compiler
+        del self.info.settings.build_type
 
     def package(self):
         self.copy("*", src=self._source_subfolder, dst=".", keep_path=True, symlinks=True)
@@ -165,7 +167,7 @@ def _fix_broken_links(self):
 
     @property
     def _host(self):
-        return f"{self._platform}-{self.settings.arch}"
+        return f"{self._platform}-{self._arch}"
 
     @property
     def _ndk_root(self):
@@ -240,6 +242,7 @@ def package_info(self):
 
         self.output.info(f"Creating ANDROID_NDK_HOME environment variable: {self.package_folder}")
         self.env_info.ANDROID_NDK_HOME = self.package_folder
+        self.cpp_info.includedirs = []
 
         #  this is not enough, I can kill that .....
         if not hasattr(self, "settings_target"):
@@ -317,7 +320,7 @@ def package_info(self):
             self.env_info.OBJDUMP = self._define_tool_var("OBJDUMP", "objdump")
             self.env_info.READELF = self._define_tool_var("READELF", "readelf")
             self.env_info.ELFEDIT = self._define_tool_var("ELFEDIT", "elfedit")
-        
+
         # The `ld` tool changed naming conventions earlier than others
         if self._ndk_version_major >= 22:
             self.env_info.LD = self._define_tool_var_naked("LD", "ld")
@@ -351,7 +354,7 @@ def is_symlink_zipinfo(zi):
     import zipfile
     with zipfile.ZipFile(filename, "r") as z:
         zip_info = z.infolist()
-        
+
         names = [n.replace("\\", "/") for n in z.namelist()]
         common_folder = os.path.commonprefix(names).split("/", 1)[0]
 


Test patch: