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

Remove the dependency on Docker from Android/Linux build instructions #1181

Open
yukawa opened this issue Feb 13, 2025 · 0 comments
Open

Remove the dependency on Docker from Android/Linux build instructions #1181

yukawa opened this issue Feb 13, 2025 · 0 comments
Assignees

Comments

@yukawa
Copy link
Collaborator

yukawa commented Feb 13, 2025

Summary

While our Dockerfile has been helping us defining a reference build environment, it might be time to just simply explain how to build libmozc.so and binaries for Linux desktop without using Dockerfile

Context

When we first introduced Dockerfile for Mozc (d7a7e61) more than 10 years ago, things were much more complicated.

  • Mozc supported NaCl and Android app on top of GYP.
    • Supporting NaCl required us to keep track of which version of NaCl SDK to be used.
  • There was no GitHub Actions. We had already relied on Travis CI though.

Now that we switched to Bazel and GitHub Actions, it could be acceptable for us to just explain the main building command and ask developers to follow our GitHub Actions rules for details for Linux/Android executables. This is actually what we are currently doing for macOS and Windows.

Migration Plan

  1. Split out the build instructions for libmozc.so into a separate file (e.g. build_mozc_for_android.md) from the existing build_mozc_in_docker.md. In this step, we can also make it clear that building libmozc.so is indeed now possible not only in Linux environment but also in macOS environment. We can also update the existing update_deps.py so that the expected version of Android NDK can be downloaded for the running environment.
  2. Split out the build instructions for Linux desktop into a separate file (e.g. build_mozc_for_linux.md) from the existing build_mozc_in_docker.md. For existing web pages that currently refer to build_mozc_in_docker.md, we can keep build_mozc_in_docker.md to explain that the content has moved to a new file.

Version or commit-id

f8bb199

yukawa added a commit to yukawa/mozc that referenced this issue Feb 14, 2025
This is a preparation before removing the dependency on Docker from our
Android build instructions (google#1181).

Suppose we want to set 'path' attribute to 'android_ndk_repository_extension' so
that we can specify the actual path to the Android NDK in our MODULE.bazel.

  android_ndk_repository_extension = use_extension(
      "@rules_android_ndk//:extension.bzl",
      "android_ndk_repository_extension",
  )
  android_ndk_repository_extension.configure(
      path = "$WORKSPACE_ROOT/third_party/ndk/android-ndk-r28",
  )
  use_repo(android_ndk_repository_extension, "androidndk")

The problem is that there is currently no way to conditionally the the above
path attribute depending on the host platform and/or the target platform. As a
result, the above configuration takes effect not only on Linux but also on
Windows environment, where we do not plan to support building libmozc.so right
now.

To gracefully handle the above scenario, this commit updates our patch to
'rules_android_ndk' to generate an empty BUILD.bazel file when an Android NDK
does not exist at the location specified by ANDROID_NDK_HOME or the path
attribute. Basically this is a superset of the behavior of the current patch,
where an empty BUILD.bazel file is generated unless ANDROID_NDK_HOME is
explicitly specified or the path attribute is set.

In general there should be no observable behavior change as long as the build
is currently passing.
yukawa added a commit to yukawa/mozc that referenced this issue Feb 14, 2025
This is a preparation before removing the dependency on Docker from our
Android build instructions (google#1181).

Suppose we want to specify 'path' attribute to
'android_ndk_repository_extension' so that we can specify the actual
path to the Android NDK in our MODULE.bazel.

  android_ndk_repository_extension = use_extension(
      "@rules_android_ndk//:extension.bzl",
      "android_ndk_repository_extension",
  )
  android_ndk_repository_extension.configure(
      path = "$WORKSPACE_ROOT/third_party/ndk/android-ndk-r28",
  )
  use_repo(android_ndk_repository_extension, "androidndk")

The problem is that there is currently no way to conditionally the the
above path attribute depending on the host platform and/or the target
platform. As a result, the above configuration takes effect not only on
Linux but also on Windows environment, where we do not plan to support
building libmozc.so right now.

To gracefully handle the above scenario, this commit updates our patch
to 'rules_android_ndk' to generate an empty BUILD.bazel file when an
Android NDK does not exist at the location specified by ANDROID_NDK_HOME
or the path attribute. Basically this is a superset of the behavior of
the current patch, where an empty BUILD.bazel file is generated unless
ANDROID_NDK_HOME is explicitly specified or the path attribute is set.

In general there should be no observable behavior change as long as the
build is currently passing.
yukawa added a commit to yukawa/mozc that referenced this issue Feb 14, 2025
This is a preparation before removing the dependency on Docker from our
Android build instructions (google#1181).

Suppose we want to specify 'path' attribute to
'android_ndk_repository_extension' so that we can specify the actual
path to the Android NDK in our MODULE.bazel.

  android_ndk_repository_extension = use_extension(
      "@rules_android_ndk//:extension.bzl",
      "android_ndk_repository_extension",
  )
  android_ndk_repository_extension.configure(
      path = "$WORKSPACE_ROOT/third_party/ndk/android-ndk-r28",
  )
  use_repo(android_ndk_repository_extension, "androidndk")

The problem is that there is currently no way to conditionally the the
above path attribute depending on the host platform and/or the target
platform. As a result, the above configuration takes effect not only on
Linux but also on Windows environment, where we do not plan to support
building libmozc.so right now.

To gracefully handle the above scenario, this commit updates our patch
to 'rules_android_ndk' to generate an empty BUILD.bazel file when an
Android NDK does not exist at the location specified by ANDROID_NDK_HOME
or the path attribute. Basically this is a superset of the behavior of
the current patch, where an empty BUILD.bazel file is generated unless
ANDROID_NDK_HOME is explicitly specified or the path attribute is set.

In general there should be no observable behavior change as long as the
build is currently passing.
yukawa added a commit to yukawa/mozc that referenced this issue Feb 14, 2025
This is a preparation before removing the dependency on Docker from our
Android build instructions (google#1181).

With this commit running the `update_deps.py` also downloads Android NDK
for macOS and Linux then extract it under third_party/ndk/.

This would enable us to fully control which version of Android NDK
should be used to build Android Library ('libmozc.so') in a subsequent
commit.

At this moment only the observable difference is that the Android NDK
will be extracted under third_party/ndk/. There must be no difference
in the final artifact yet.
yukawa added a commit to yukawa/mozc that referenced this issue Feb 14, 2025
This is a preparation before removing the dependency on Docker from our
Android build instructions (google#1181).

With this commit running the 'update_deps.py' also downloads Android NDK
for macOS and Linux then extract it under third_party/ndk/.

This would enable us to fully control which version of Android NDK
should be used to build Android Library ('libmozc.so') in a subsequent
commit.

At this moment only the observable difference is that the Android NDK
will be extracted under third_party/ndk/. There must be no difference
in the final artifact yet.
@yukawa yukawa self-assigned this Feb 16, 2025
hiroyuki-komatsu pushed a commit that referenced this issue Feb 18, 2025
This is a preparation before removing the dependency on Docker from our
Android build instructions (#1181).

With this commit running the 'update_deps.py' also downloads Android NDK
for macOS and Linux then extract it under third_party/ndk/.

This would enable us to fully control which version of Android NDK
should be used to build Android Library ('libmozc.so') in a subsequent
commit.

At this moment only the observable difference is that the Android NDK
will be extracted under third_party/ndk/. There must be no difference
in the final artifact yet.

PiperOrigin-RevId: 728118756
hiroyuki-komatsu pushed a commit that referenced this issue Feb 18, 2025
This is a preparation before removing the dependency on Docker from our
Android build instructions (#1181).

Suppose we want to specify 'path' attribute to
'android_ndk_repository_extension' so that we can specify the actual
path to the Android NDK in our MODULE.bazel.

  android_ndk_repository_extension = use_extension(
      "@rules_android_ndk//:extension.bzl",
      "android_ndk_repository_extension",
  )
  android_ndk_repository_extension.configure(
      path = "$WORKSPACE_ROOT/third_party/ndk/android-ndk-r28",
  )
  use_repo(android_ndk_repository_extension, "androidndk")

The problem is that there is currently no way to conditionally the the
above path attribute depending on the host platform and/or the target
platform. As a result, the above configuration takes effect not only on
Linux but also on Windows environment, where we do not plan to support
building libmozc.so right now.

To gracefully handle the above scenario, this commit updates our patch
to 'rules_android_ndk' to generate an empty BUILD.bazel file when an
Android NDK does not exist at the location specified by ANDROID_NDK_HOME
or the path attribute. Basically this is a superset of the behavior of
the current patch, where an empty BUILD.bazel file is generated unless
ANDROID_NDK_HOME is explicitly specified or the path attribute is set.

In general there should be no observable behavior change as long as the
build is currently passing.

PiperOrigin-RevId: 728118761
yukawa added a commit to yukawa/mozc that referenced this issue Feb 18, 2025
This is the first part towards removing the dependency on Docker from
our build instructions for Linux desktop and Android (google#1181).

This commit makes it clear that you can build 'libmozc.so' on both Linux
and macOS by the same Bazel command with actually demonstrating it in

  .github/workflows/android.yaml

that 'libmozc.so' can be built on both Linux and macOS GitHub Actions
runners.

With above our 'Dockerfile' can stop setting up Android NDK since
'build_mozc_in_docker.md' does not mention Android any more.

This commit is only about the build instructions of 'libmozc.so' for
Android. There must be no difference in the final artifacts.
hiroyuki-komatsu pushed a commit that referenced this issue Feb 21, 2025
This is the first part towards removing the dependency on Docker from
our build instructions for Linux desktop and Android (#1181).

This commit makes it clear that you can build 'libmozc.so' on both Linux
and macOS by the same Bazel command with actually demonstrating it in

  .github/workflows/android.yaml

that 'libmozc.so' can be built on both Linux and macOS GitHub Actions
runners.

With above our 'Dockerfile' can stop setting up Android NDK since
'build_mozc_in_docker.md' does not mention Android any more.

This commit is only about the build instructions of 'libmozc.so' for
Android. There must be no difference in the final artifacts.

PiperOrigin-RevId: 729468755
yukawa added a commit to yukawa/mozc that referenced this issue Feb 21, 2025
This follows up to my previous commit [1], which introduced

  docs/build_mozc_for_android.md

as a dedicated build instruction page for building libmozc.so for
Android as part of removing the dependency on Docker from our build
instructions (google#1181).

This commit fixes the link to the above new page in README.md.

 [1]: f215eaf
yukawa added a commit to yukawa/mozc that referenced this issue Feb 23, 2025
This follows up to my previous commit [1], which introduced

  docs/build_mozc_for_android.md

as a dedicated build instruction page for building 'libmozc.so' for
Android as part of removing the dependency on Docker from our build
instructions (google#1181).

While the above document uses 'python3' elsewhere, there was one place
where 'python' was used instead. It would be better to avoid 'python'
in favor of PEP 394 [2].

 [1]: f215eaf
 [2]: https://peps.python.org/pep-0394/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant