android-toolchain now handles the ndk.zip download. I still need to remove the ndk file entry from the firefox config. Getting firefox project working with the latest android-toolchain changes is next on my list.
The exit 0 is there since mach package builds the apk, which I believe is the final packaging we want. It didn't seem the Mozilla Archive that follows is relevant to Android.
The exit 0 is there since mach package builds the apk, which I believe is the final packaging we want. It didn't seem the Mozilla Archive that follows is relevant to Android.
I think that ./mach package will create the apk in the build directory. However we exit immediately after that, so it seems to me we are just losing the result of the build after it finished. I think we are missing something to move the apk file, and probably the martools, to the destination directory.
Could you push your new revisions to new branches instead of force-pushing on the same branch? This makes it harder to see what was changed since the previous revision.
Could you also rebase it on current master? It is currently based on a commit that is more than 2 months old.
I am not sure I understand what those lines are doing. This seems to be creating a gcc -> gcc symlink?
+[% IF c('var/android') %]+ ln -s gcc $ANDROID_NDK_HOME/arm/bin/gcc+[% END -%]
could you add a comment explaining why we need the projects/firefox/gradle.patch? Maybe this is something we want to patch in tor-browser.git directly?
there is a trailing whitespace in projects/firefox/mozconfig-android-armv7 at the end of the --with-android-sdk= line
do we really need our own build of binutils for the android build of firefox?
commit 6af47ae272b6098eac1c9ba886ff9ab04e3fc441 seems to have the wrong bug number
could you explain why we need projects/firefox/android.patch? It seems to be removing some code behind #if defined(GP_OS_linux) and forcing use of the code previously behind #elif defined(GP_OS_android). Shouldn't defined(GP_OS_linux) be false and defined(GP_OS_android) be true in the android build?
Some additional minor cleanup items left.
What to include in dist package. Just apks?
I think projects/firefox/build can just copy the generated apk files, for now. Later we will probably need to repackage them in projects/tor-browser/build to include other components such as tor and Orbot, but this can be done later.
Use a new var to indicate if mar tools should be built (rather than platform var)
Don't we want to build mar files for android too? Or is the firefox updater based on mar files not working on android?
Use a new var to indicate if mar tools should be built (rather than platform var)
Don't we want to build mar files for android too? Or is the firefox updater based on mar files not working on android?
Using the Firefox updater for mobile is pretty much untested. I think we want to do that at some point for bundles we distribute on our website but it's okay to start without it.
I rebased to the latest code from trunk. It looks like the current gradle build has upgraded the sdk to 26. I made changes to update in android-toolchain but the firefox build is still broken. I'll need to investigate causes and fix.
I think those comments are still valid for commit 2276a44b14edf82f0f44ac98c50597a8637e5883:
could you add a comment explaining why we need the projects/firefox/gradle.patch? Maybe this is something we want to patch in tor-browser.git directly?
could you explain why we need projects/firefox/android.patch? It seems to be removing some code behind #if defined(GP_OS_linux) and forcing use of the code previously behind #elif defined(GP_OS_android). Shouldn't defined(GP_OS_linux) be false and defined(GP_OS_android) be true in the android build?
And also:
the patch is adding an i after the creation of the martools zip file. Those lines should be indented for the IF.
Removed gradle and android patches. With the correct version of NDK/SDK we don't need the android.patch
Use android-version 22 for the NDK. The target sdk is still 26. This is the highest version that correctly compiles the project w/o patches. Verified that the apk runs successfully,
Removed ac_add_options --disable-install-strip from mozconfig. This causes a runtime error of apk. After researching forums, this is the suggested solution.
Removed 'i' character at end of file
Removed commented out options from mozconfig
Fixed formatting issues in build file
After these fixes, we have a successful end-to-end build with the latest code and no patches needed. Apk runs on device. App branded with tor resources.
Looking at commit 370168b7b2b00dcd72e51e6a229d7720cfe69c5d, currently the output of the build is a tor-browser.tar.gz file containing two apk files in a Browser/ directory. Instead I think we could just copy the two apk files to the destination directory ([% dest_dir _ '/' _ c('filename') %]), after creating it. And after the apk files are copied, I think we can add a [% RETURN %] if none of the following lines apply to the android build (and in that case also remove all the var/martools changes).
Here are three things that I think that should get addressed:
mozconfig-android-armv7 is not in sync with the .mozconfig-android file in the tor-browser repo, which we use for building Tor Browser for Android right now. E.g. do you disable optimizations while we have that enabled in the .mozconfig file we use for official builds. MOZILLA_OFFICIAL is note exported either etc. Please double-check the file in the tor-browser repo and fix up the mozconfig file in the tor-browser-build repo.
Where are all those Gradle dependencies coming from? How do we make sure we got all in the .txt fils (and only those we need)? Can we document the process of generating/updating the .txt file in that file itself (both to preserve knowledge and make the process transparent)?
It seems to me not all the packages in arch_deps are needed (e.g. chrpath was just added for selfrando on Linux). Can we clean that up accordingly?
Trac: Status: needs_review to needs_revision Keywords: TorBrowserTeam201810R deleted, TorBrowserTeam201810 added
mozconfig-android-armv7: Enabled optimization and cache options. I added the MOZILLA_OFFICIAL export to align with what is in tor-browser git repo. Although I'm not convinced this is really needed, it won't do any harm.
I think we can disable the ccache related things. We are building within containers from scratch and ccache should not help much in that scenario. However, it might do so in local builds which is why it is there. Sorry, for not being more explicit here. :(
I think a filename like how-to-create-gradle-dependencies-list.txt would be more clear (as this is only about the gradle dependencies). Wrapping lines to ~80 characters would make it easier to read.
I looks like the export MOZILLA_OFFICIAL does change behavior of the build. It triggers the unit tests on the build. I'll add the test libraries to the gradle-dependencies and then get that checked in. I'll also add a comment in mozconfig explaining the reasons for the export.
The MOZILLA_OFFICIAL export executes some tasks that handles dependencies in a different way. Basically the build just fails with missing artifacts, rather than trying to download them. Many of these artifacts are in different repositories than we were using on the first list of dependencies.
Its tedious tracking each dependency through manually so I'm looking for an easier way to handle this.
{{{
+ac_add_options --with-android-version=22
}}}
Do we need this? We've used the default value without a problem (the default is 9 for 32-bit CPU archs, and 21 for 64-bit).
Under the current build configuration, it defaults to 9 in all cases. Is there someway to tell the build that its for 32 or 64 bit?
From my testing, 22 is the highest version that works. This is the only way I'm aware of to configure the android version.
echo "[% artifact.sha256sum %] downloaded_file" | sha256sum -c
}}}
Does the script fail when this line returns non-zero? There's no error handling, so I'm guessing this is caught another way?
There is a set -e at the beginning of the script, so the script should fail if one of the commands fail.
Okay, I spent quite some time testing and reviewing the updated patch. I feel we are close. Here are three things that I found so far which should be fixed:
You have --disable-strip in the mozconfig file. Please use --enable-strip instead (even though the resulting binaries are indeed stripped), as this is less confusing.
Could you add a comment in the mozconfig file above
explaining that we need that for the Stylo build part and the preferred way, using LLVM_CONFIG, is not available as there is no llvm-config in the ndk. (at least I could not find it)
The gradle deps download script mentions issues with setting LC_ALL=C. Please add the bug number as reference (it is #28117 (moved)).
Finally, could you explain what breaks without setting --with-android-version=22? You mentioned "22 is the highest version that works" but what does that mean?
Oh, I forgot one and a half thing to fix actually:
I followed the instructions on how to create the gradle dependency list. In particular I tested:
It may also be the case that you wish to cleanup old versions of the artifacts.For this you will need to run the build with an emptygradle-dependencies-list.txt file and proceed to reconstruct the list fromscratch.
assuming "empty" means still there but without contents. That actually breaks the build. So, I am not sure which step you had in mind for cleaning up old versions of the artifacts. Could you reformulate that part?
So, the last thing that bothers me is --with-android-version=22. sisbell: what breaks here for you? I ran e.g. a built with version 21 and it worked well. We should at least document with a TODO what made us pick that option.
Okay, the errors I get are:
{{{
68:58.69 /var/tmp/build/firefox-d60cb3854f94/tools/profiler/core/shared-libraries-linux.cc:191: error: undefined reference to 'dl_iterate_phdr'
68:58.69 /var/tmp/build/firefox-d60cb3854f94/tools/profiler/core/shared-libraries-linux.cc:0: error: undefined reference to 'dl_iterate_phdr'
68:58.69 armv7-linux-androideabi/release/libgkrust.a(elf.o):elf.c:function backtrace_initialize: error: undefined reference to 'dl_iterate_phdr'
68:58.69 armv7-linux-androideabi/release/libgkrust.a(mmapio.o):mmapio.c:function backtrace_get_view: error: undefined reference to 'getpagesize'
68:58.69 clang++: error: linker command failed with exit code 1 (use -v to see invocation)
68:58.69 /var/tmp/build/firefox-d60cb3854f94/config/rules.mk:699: recipe for target 'libxul.so' failed
68:58.69 make[4]: *** [libxul.so] Error 1
}}}
Yes, this is the error that shows up if we don't use 21 or 22 NDK. I previously had a patch that could make it run on other versions but I think it would be better to use a version of the NDK that doesn't require a patch. I'm ok with either 21 or 22, I just chose 22 since I default to the highest compile version is best, due to possible bug fixes.