DBus for android is required to build several KDE Frameworks package on KDE CI system (see https://phabricator.kde.org/R857:da6f5208d5e087870af2b3d0eeb83941fca500d2 for a list) and there are no related build information.
Created attachment 135866 [details] [review] Add build information for Android platforms Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de> Bug:
Comment on attachment 135866 [details] [review] Add build information for Android platforms Review of attachment 135866 [details] [review]: ----------------------------------------------------------------- Last time we tried to do this (Bug #42531) the central question was: how is (this particular build of) dbus going to be used / meant to be used on Android? and we never really got a satisfactory answer to that question. Is this intended to be bundled into an Android app (as in .apk), or is it intended to be used in some specific KDE-on-Android "stack" analogous to https://guardianproject.info/code/lildebi/ or https://termux.com/ (or, perhaps closer to your usual area of interest for dbus, analogous to Cygwin or MSYS), or what? If the answer is "we don't know what it's for" then we won't be able to make coherent technical decisions about it. We've been there with D-Bus-over-TCP and with D-Bus-after-su, and I don't really want to be trying to document another situation where people report bugs and we don't know whether the behaviour they describe is intentional or not. If KDE is building a "stack" like lildebi or termux, then the precise details of how builds are done seem like they should perhaps be something to maintain within that "stack", the same way the precise details of how I build dbus in Debian are part of the Debian packaging rather than part of upstream dbus? ::: README.android @@ +48,5 @@ > + -DANDROID_STANDALONE_TOOLCHAIN=$ANDROID_NDK \ > + -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \ > + -DANDROID_NATIVE_API_LEVEL=$ANDROID_NATIVE_API_LEVEL \ > + -DANDROID_ABI=$ANDROID_ABI \ > + -DCMAKE_INSTALL_PREFIX=/data/local/tmp/dbus \ This doesn't seem like a particularly helpful prefix? Aren't Android apps meant to be installed in /data/app/com.example.ReversedDomainName or something? @@ +59,5 @@ > +5. fetch and build dbus > +------------------------ > + > +git clone git://anongit.freedesktop.org/git/dbus/dbus > +mkdir dbus-android-buil Typo, should be "build" presumably @@ +62,5 @@ > +git clone git://anongit.freedesktop.org/git/dbus/dbus > +mkdir dbus-android-buil > +cd dbus-android-build > + > +$ANDROID_CMAKE \ I'd usually recommend Autotools for all Unix platforms (for example https://gist.github.com/nddrylliog/4688209 is a reasonably conventional set of variable overrides for the Android NDK)... but Android is admittedly a really weird Unix platform. @@ +70,5 @@ > + -DANDROID_NATIVE_API_LEVEL=$ANDROID_NATIVE_API_LEVEL \ > + -DANDROID_ABI=$ANDROID_ABI \ > + -DDBUS_ENABLE_XML_DOCS=OFF \ > + -DEXPAT_INCLUDE_DIR=$ANDROID_INSTALL_DIR/data/local/tmp/dbus/include \ > + -DEXPAT_LIBRARY=$ANDROID_INSTALL_DIR/data/local/tmp/dbus/lib/libexpat.so \ Not "-L.../lib -lexpat"? @@ +89,5 @@ > + > +adb shell > +cd /data/local/tmp/dbus/ > +export LD_LIBRARY_PATH=$PWD/lib > +eval `bin/dbus-launch --config-file=share/dbus-1/session.conf --sh-syntax` On Unix platforms, dbus-launch is mainly for X11 autolaunching. I would prefer not to be recommending it on Android, where X11 is not used. Please prefer to use `dbus-run-session -- sh` to start a shell with a session bus for development and testing.
(In reply to Simon McVittie from comment #2) > Last time we tried to do this (Bug #42531) the central question was: how is > (this particular build of) dbus going to be used / meant to be used on > Android? and we never really got a satisfactory answer to that question. > > Is this intended to be bundled into an Android app (as in .apk), not planned from my side yet. > or is it intended to be used in some specific KDE-on-Android "stack" analogous to > https://guardianproject.info/code/lildebi/ or https://termux.com/ (or, > perhaps closer to your usual area of interest for dbus, analogous to Cygwin > or MSYS), or what? The KDE Continuous integration system cross builds KDE Frameworks 5 related packages for Android (https://build.kde.org/search/?q=android) using the "Android native development kit" (NDK). Several KDE Frameworks packages requires a DBus development package to be buildable (see the link in comment 1), so I tried out how to build with the help of NDK provided cmake support and added those doc into the readme. > If KDE is building a "stack" like lildebi or termux, then the precise > details of how builds are done seem like they should perhaps be something to > maintain within that "stack", the same way the precise details of how I > build dbus in Debian are part of the Debian packaging rather than part of > upstream dbus? The how to could be used as a guide for KDE CI but is independent from the KDE CI and depends only on an installed NDK, so where to locate this readme else ? > ::: README.android > @@ +48,5 @@ > > + -DANDROID_STANDALONE_TOOLCHAIN=$ANDROID_NDK \ > > + -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \ note: the cmake toolchain file is provided by the NDK > > + -DANDROID_NATIVE_API_LEVEL=$ANDROID_NATIVE_API_LEVEL \ > > + -DANDROID_ABI=$ANDROID_ABI \ > > + -DCMAKE_INSTALL_PREFIX=/data/local/tmp/dbus \ > > This doesn't seem like a particularly helpful prefix? Aren't Android apps > meant to be installed in /data/app/com.example.ReversedDomainName or > something? This is true if dbus would be packaged inside an apk, which is not the current use case. The choosen prefix makes is possible to run dbus outside of an apk as normal user without any root access rights. If clients want to include dbus into they application they need to setup LD_LIBRARY_PATH to find dbus shared library or need to add a copy of the shared library into there install root. > @@ +59,5 @@ > > +5. fetch and build dbus > > +------------------------ > > + > > +git clone git://anongit.freedesktop.org/git/dbus/dbus > > +mkdir dbus-android-buil > > Typo, should be "build" presumably sure, thanks for this pointer. > @@ +62,5 @@ > > +git clone git://anongit.freedesktop.org/git/dbus/dbus > > +mkdir dbus-android-buil > > +cd dbus-android-build > > + > > +$ANDROID_CMAKE \ > > I'd usually recommend Autotools for all Unix platforms (for example > https://gist.github.com/nddrylliog/4688209 is a reasonably conventional set > of variable overrides for the Android NDK)... but Android is admittedly a > really weird Unix platform. NDK has build in support for cmake for windows and unix like os hosts, which looks to be maintained in future and reduces the support burden. > @@ +70,5 @@ > > + -DANDROID_NATIVE_API_LEVEL=$ANDROID_NATIVE_API_LEVEL \ > > + -DANDROID_ABI=$ANDROID_ABI \ > > + -DDBUS_ENABLE_XML_DOCS=OFF \ > > + -DEXPAT_INCLUDE_DIR=$ANDROID_INSTALL_DIR/data/local/tmp/dbus/include \ > > + -DEXPAT_LIBRARY=$ANDROID_INSTALL_DIR/data/local/tmp/dbus/lib/libexpat.so \ > Not "-L.../lib -lexpat"? EXPAT_LIBRARY is normally set in FindEXPAT.cmake package (see https://github.com/Kitware/CMake/blob/v3.6.0/Modules/FindEXPAT.cmake#L32) and returns the full path of the shared library and could be overriden to support non standard install locations, which is the case here. > @@ +89,5 @@ > > + > > +adb shell > > +cd /data/local/tmp/dbus/ > > +export LD_LIBRARY_PATH=$PWD/lib > > +eval `bin/dbus-launch --config-file=share/dbus-1/session.conf --sh-syntax` > > On Unix platforms, dbus-launch is mainly for X11 autolaunching. I would > prefer not to be recommending it on Android, where X11 is not used. Please > prefer to use `dbus-run-session -- sh` to start a shell with a session bus > for development and testing. dbus-run-session is currently not installed by cmake build system on unix os. I need to add it and to update the patch. From https://stackoverflow.com/questions/4567904/how-to-start-an-application-using-android-adb-tools?noredirect=1&lq=1 I get the impression that running a gui application should be possible with adb shell monkey -p <appid> -c android.intent.category.LAUNCHER 1 With dbus this may be possible by using the following commands adb shell LD_LIBRARY_PATH=/data/local/tmp/dbus/lib /data/local/tmp/dbus/bin/dbus-run-session -- monkey -p <appid> -c android.intent.category.LAUNCHER 1 ? I'm going to try that
Created attachment 136046 [details] [review] Add build information for Android platforms With this commit dbus-run-session is build and installed on non Windows platforms. - use spaces instead of tabs - intended code lines in README.android - add run session topic
(In reply to Ralf Habacker from comment #4) > - intended code lines in README.android indented code, sorry for misspelling
It may be also for interest to have an android apk example based on the recent dbus java binding https://cgit.freedesktop.org/dbus/dbus-java/
Comment on attachment 136046 [details] [review] Add build information for Android platforms Review of attachment 136046 [details] [review]: ----------------------------------------------------------------- ::: README.android @@ +70,5 @@ > + -DANDROID_NATIVE_API_LEVEL=$ANDROID_NATIVE_API_LEVEL \ > + -DANDROID_ABI=$ANDROID_ABI \ > + -DDBUS_ENABLE_XML_DOCS=OFF \ > + -DEXPAT_INCLUDE_DIR=$ANDROID_INSTALL_DIR/data/local/tmp/dbus/include \ > + -DEXPAT_LIBRARY=$ANDROID_INSTALL_DIR/data/local/tmp/dbus/lib/libexpat.so \ While working at another android project I learned that the expat related defines could be replaced by -DCMAKE_FIND_ROOT_PATH=$ANDROID_INSTALL_DIR/data/local/tmp/dbus \
Created attachment 136076 [details] [review] Add build information for Android platforms - split out cmake fix into separate patch - add environment variable ANDROID_INSTALL_PREFIX - use CMAKE_FIND_ROOT_PATH to find installed expat library
Created attachment 136077 [details] [review] Build dbus-run-session on non Windows platforms with cmake dbus-run-session is the prefered way to run a dbus session with native applications on android. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=104022 Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
Created attachment 136078 [details] [review] Fix -Wsign-compare warnings on cross compiling for android Bug: https://bugs.freedesktop.org/show_bug.cgi?id=104022 Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
-- GitLab Migration Automatic Message -- This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/dbus/dbus/issues/193.
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.