Skip to content
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

[qtbase] enable ci for android #35845

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open

Conversation

m-kuhn
Copy link
Contributor

@m-kuhn m-kuhn commented Dec 23, 2023

Enable support for feature egl for android for qtbase.
Specifying it as default-feature for android but at the same time specifying the feature as not supported is inconsistent.

@m-kuhn
Copy link
Contributor Author

m-kuhn commented Dec 23, 2023

ANDROID_SDK_ROOT needs to be available to build qt for android in CI (which was NOT done so far).

if(VCPKG_TARGET_IS_ANDROID AND NOT ANDROID_SDK_ROOT)
message(FATAL_ERROR "${PORT} requires ANDROID_SDK_ROOT to be set. Consider adding it to the triplet." )
endif()

The SDK is not installed from what I can see (only the NDK).

# Download Android NDK
RUN \
wget https://dl.google.com/android/repository/android-ndk-r25c-linux.zip && \
unzip android-ndk-r25c-linux.zip && \
rm -rf android-ndk-r25c-linux.zip
ENV ANDROID_NDK_HOME /android-ndk-r25c

We could:

  • Disable these tests
  • Install the SDK
    • and detect the location from env vars directly in the qt ports (I am starting to wonder if this would be the correct approach. The NDK is also detected from ANDROID_NDK_HOME if I'm not wrong)
    • stick to the current approach and require the user to provide ANDROID_SDK_ROOT via triplet, but then we need an overlay triplet for the tests

@Adela0814 Adela0814 self-assigned this Dec 25, 2023
@Adela0814 Adela0814 added the category:port-feature The issue is with a library, which is requesting new capabilities that didn’t exist label Dec 25, 2023
@m-kuhn
Copy link
Contributor Author

m-kuhn commented Dec 26, 2023

I added the android sdk. It probably needs more to install specific packages with the sdkmanager (tests will tell).

@m-kuhn
Copy link
Contributor Author

m-kuhn commented Dec 27, 2023

Either I am missing something here (I just looked at how ANDROID_NDK_HOME is and tried to apply the same to ANDROID_SDK_ROOT) or the changes in the Dockerfile are not automatically taken into account.
Does someone see why the ENV var from the Dockerfile doesn't make it into the port?

@dg0yt
Copy link
Contributor

dg0yt commented Dec 27, 2023

I guess the docker file is only regenerated once a month.
This is how I currently experiment with NDK r26:
https://github.com/microsoft/vcpkg/pull/35851/files#diff-b810c6816d42fd5c52f27e1ca0da28fd595a2bd00cbb448b443eff8e1739fe57

@m-kuhn
Copy link
Contributor Author

m-kuhn commented Dec 27, 2023

Thanks for the hint.
Still seems not sufficient. I was thinking about VCPKG_ENV_PASSTHROUGH but that's windows specific.

@m-kuhn m-kuhn force-pushed the qtbase_android branch 5 times, most recently from b0926a3 to 5a7757f Compare December 30, 2023 02:18
@m-kuhn
Copy link
Contributor Author

m-kuhn commented Dec 30, 2023

Looks like the toolchain file is not loaded at the point where the check happens.

@m-kuhn m-kuhn force-pushed the qtbase_android branch 2 times, most recently from 7d74cef to a8938b6 Compare December 30, 2023 02:23
Comment on lines 11 to 12
if(VCPKG_TARGET_IS_ANDROID AND NOT ANDROID_SDK_ROOT)
message(FATAL_ERROR "${PORT} requires ANDROID_SDK_ROOT to be set. Consider adding it to the triplet." )
if(VCPKG_TARGET_IS_ANDROID AND NOT ANDROID_SDK_ROOT AND NOT DEFINED ENV{ANDROID_SDK_ROOT}) # The scripts/toolchains/android.cmake file handles writing the env var to a cmake var
message(FATAL_ERROR "${PORT} requires ANDROID_SDK_ROOT to be set. Set ANDROID_SDK_ROOT as environment variable or in the triplet." )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qt_install_submodule operates in script mode. It doesn't see results from the toolchain, and AFAICS it uses a cmake variable ANDROID_SDK_ROOT at the moment, not an environment variable. So it would need to be set e.g. in the triplet file.
You may change this file to use the environment variable to initialize the cmake variable iff unset. It is the only use of ANDROID_SDK_ROOT.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Triplets is what I do in my own repo, but I was wondering if we could do this transparently (after all, the ndk path is also picked up from the environment without triplet involved).
But it would certainly be easier to do with the triplet.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's why I suggested that the portfile could pick the environement variable. (Fully switching to the environment variable might break users.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting it in the triplet ensures the desired (?!) effect on ABI hashes, but is more intrusive on the user side.
The NDK environment variable already affects ABI hashing via the compiler binaries hashes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mabye useful in the future: microsoft/vcpkg-tool#1315. This would hash the extra script, and the triplet could remain unchanged.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's why I suggested that the portfile could pick the environement variable. (Fully switching to the environment variable might break users.)

If it's set to an absolute path, yes. But that would mean every user has to provide a local triplet. And if it's set via env var (as done with the latest iteration of this PR) it means that the ABI hash of the triplet is not really reliable.

@@ -4,3 +4,4 @@ set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_CMAKE_SYSTEM_NAME Android)
set(VCPKG_MAKE_BUILD_TRIPLET "--host=armv7a-linux-androideabi")
set(VCPKG_CMAKE_CONFIGURE_OPTIONS -DANDROID_ABI=armeabi-v7a -DANDROID_ARM_NEON=ON)
set(ANDROID_SDK_ROOT $ENV{ANDROID_SDK_ROOT})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't help with ABI hashes: The content of the triplet files remains independent of the content of ENV{ANDROID_SDK_ROOT}.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only way I know to bring this into ABI hashes is by (a) writing it into an overlay triplet, but as you mentioned, this is intrusive on user side.
Or we respect environment variables, either by inspecting them (b) in the triplet (done currently) or (c) in the android toolchain (done before) or (d) in the port and forward it to cmake configure from there.

And if I understand correctly, your preference is (d)?

@m-kuhn m-kuhn force-pushed the qtbase_android branch 6 times, most recently from 793dc60 to d0e9db8 Compare December 30, 2023 14:46
@m-kuhn
Copy link
Contributor Author

m-kuhn commented Dec 30, 2023

I'm afraid I am hitting a wall with installing the SDK through test-modified-ports.ps1, it seems that it runs with limited permissions and I cannot install java.

@m-kuhn m-kuhn changed the title [qtbase] enable egl for android [qtbase] enable ci for android Jan 1, 2024
@m-kuhn
Copy link
Contributor Author

m-kuhn commented Jan 5, 2024

@dan-shaw @BillyONeal what is the best way to get an update into the android ci docker image? I assume the current changes should be sufficient.

NB: happy to update the version as soon as the path forward is clear, there are currently other PRs waiting for qtbase which are probably merged earlier.

@dg0yt
Copy link
Contributor

dg0yt commented Jul 28, 2024

Please try m-kuhn#1

@dg0yt
Copy link
Contributor

dg0yt commented Aug 3, 2024

Hm, still not successful in CI.

Setting up the Android SDK in /vcpkg/android-sdk
Loading package information...                                                  
Loading local repository...                                                     
[                                       ] 3% Loading local repository...        
[                                       ] 3% Fetch remote repository...         
[=                                      ] 3% Fetch remote repository...         
                                                                                
[=                                      ] 3% Fetch remote repository...         
Warning: Failed to download any source lists!
                                                                                
Warning: IO exception while downloading manifest
[=                                      ] 3% Fetch remote repository...         
                                                                                
Warning: IO exception while downloading manifest
[=                                      ] 3% Fetch remote repository...         
Warning: Still waiting for package manifests to be fetched remotely.
                                                                                
[=                                      ] 3% Fetch remote repository...         
[=                                      ] 3% Computing updates...               
[===                                    ] 8% Computing updates...               
[===                                    ] 10% Computing updates...              
                                                                                
[===                                    ] 10% Computing updates...              
Warning: Failed to find package 'platform-tools'
yes: standard output: Broken pipe
Loading package information...                                                  
Loading local repository...                                                     
[=========                              ] 25% Loading local repository...       
[=========                              ] 25% Fetch remote repository...        
[=======================================] 100% Fetch remote repository...       

@m-kuhn
Copy link
Contributor Author

m-kuhn commented Aug 3, 2024

Is network connectivity blocked except through vcpkg tool?

@dg0yt
Copy link
Contributor

dg0yt commented Aug 3, 2024

Is network connectivity blocked except through vcpkg tool?

IDK. Let's try m-kuhn#2.

@dg0yt
Copy link
Contributor

dg0yt commented Aug 3, 2024

Installed packages:
  Path                 | Version | Description                       | Location            
  -------              | ------- | -------                           | -------             
  build-tools;34.0.0   | 34.0.0  | Android SDK Build-Tools 34        | build-tools/34.0.0  
  platform-tools       | 35.0.1  | Android SDK Platform-Tools 35.0.1 | platform-tools      
  platforms;android-34 | 3       | Android SDK Platform 34, rev 3    | platforms/android-34

Good.

CMake Error at ports/qtbase/cmake/qt_install_submodule.cmake:13 (message):
  qtbase requires ANDROID_SDK_ROOT to be set.  Set ANDROID_SDK_ROOT as
  environment variable or in the triplet.

Okay, the CI script sets ANDROID_HOME because this is what is given in https://developer.android.com/tools/variables#envar, but the Qt still wants ANDROID_SDK_ROOT. This should be bridged in the port.

@m-kuhn
Copy link
Contributor Author

m-kuhn commented Aug 4, 2024

Okay, the CI script sets ANDROID_HOME because this is what is given in https://developer.android.com/tools/variables#envar, but the Qt still wants ANDROID_SDK_ROOT. This should be bridged in the port.

I tried to implement this in the port, but it seems ENV{ANDROID_HOME} is not visible there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:port-feature The issue is with a library, which is requesting new capabilities that didn’t exist
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants