diff --git a/.github/workflows/macos.yaml b/.github/workflows/macos.yaml index e89dc88c52..1875c6f9bb 100644 --- a/.github/workflows/macos.yaml +++ b/.github/workflows/macos.yaml @@ -12,7 +12,7 @@ concurrency: cancel-in-progress: true jobs: - build: + build_arm64: # https://github.com/actions/virtual-environments/blob/main/images/macos/macos-11-Readme.md runs-on: macos-11 timeout-minutes: 90 @@ -49,18 +49,122 @@ jobs: - name: Build Qt working-directory: ./src run: | - python3 build_tools/build_qt.py --release --confirm_license + python3 build_tools/build_qt.py --release --confirm_license --macos_cpus=arm64 + echo "MOZC_QT_PATH=${PWD}/third_party/qt" >> $GITHUB_ENV + + - name: bazel build + working-directory: ./src + run: | + bazel build --config oss_macos package --macos_cpus=arm64 + + - name: upload artifacts + uses: actions/upload-artifact@v3 + with: + name: Mozc.pkg(arm64) + path: src/bazel-bin/mac/Mozc.pkg + if-no-files-found: warn + + build_intel64: + # https://github.com/actions/virtual-environments/blob/main/images/macos/macos-11-Readme.md + runs-on: macos-11 + timeout-minutes: 90 + + steps: + - name: checkout + uses: actions/checkout@v3 + with: + submodules: 'recursive' + + - name: Set up Python + uses: actions/setup-python@v4 + with: + cache: 'pip' + python-version: '3.9' + + - name: Install pip dependencies + working-directory: ./src + run: | + python3 -m pip install requests + + - name: Try to restore update_deps cache + uses: actions/cache@v3 + with: + path: src/third_party_cache + key: update_deps-${{ runner.os }}-${{ hashFiles('src/build_tools/update_deps.py') }} + + - name: Install dependencies + working-directory: ./src + # This command uses src/third_party_cache as the download cache. + run: | + python3 build_tools/update_deps.py + + - name: Build Qt + working-directory: ./src + run: | + python3 build_tools/build_qt.py --release --confirm_license --macos_cpus=x86_64 + echo "MOZC_QT_PATH=${PWD}/third_party/qt" >> $GITHUB_ENV + + - name: bazel build + working-directory: ./src + run: | + bazel build --config oss_macos package --macos_cpus=x86_64 + + - name: upload artifacts + uses: actions/upload-artifact@v3 + with: + name: Mozc.pkg(intel64) + path: src/bazel-bin/mac/Mozc.pkg + if-no-files-found: warn + + build_fat_binary: + # https://github.com/actions/virtual-environments/blob/main/images/macos/macos-11-Readme.md + runs-on: macos-11 + timeout-minutes: 90 + + steps: + - name: checkout + uses: actions/checkout@v3 + with: + submodules: 'recursive' + + - name: Set up Python + uses: actions/setup-python@v4 + with: + cache: 'pip' + python-version: '3.9' + + - name: Install pip dependencies + working-directory: ./src + run: | + python3 -m pip install requests + + - name: Try to restore update_deps cache + uses: actions/cache@v3 + with: + path: src/third_party_cache + key: update_deps-${{ runner.os }}-${{ hashFiles('src/build_tools/update_deps.py') }} + + - name: Install dependencies + working-directory: ./src + # This command uses src/third_party_cache as the download cache. + run: | + python3 build_tools/update_deps.py + + - name: Build Qt + working-directory: ./src + run: | + python3 build_tools/build_qt.py --release --confirm_license --macos_cpus=x86_64,arm64 echo "MOZC_QT_PATH=${PWD}/third_party/qt" >> $GITHUB_ENV - name: bazel build working-directory: ./src run: | - bazel build --config oss_macos package + bazel build --config oss_macos package --macos_cpus=x86_64,arm64 - name: upload artifacts uses: actions/upload-artifact@v3 with: - name: Mozc.pkg + name: Mozc.pkg(fat_binary) path: src/bazel-bin/mac/Mozc.pkg if-no-files-found: warn diff --git a/docs/build_mozc_in_osx.md b/docs/build_mozc_in_osx.md index 9c9c148d93..a9e570b4d5 100644 --- a/docs/build_mozc_in_osx.md +++ b/docs/build_mozc_in_osx.md @@ -22,12 +22,13 @@ MOZC_QT_PATH=${PWD}/third_party/qt bazel build package --config oss_macos -c opt open bazel-bin/mac/Mozc.pkg ``` -Hint: With the above build steps, the target CPU architecture of the binaries in +💡 With the above build steps, the target CPU architecture of the binaries in `Mozc.pkg` is the same as the CPU architecture of the build environment. That is, if you build Mozc on arm64 environment, `Mozc.pkg` contains arm64 -binaries. +binaries. See the [build installer](#build-installer) section about how to do +cross build. -Hint: You can also download `Mozc.pkg` from GitHub Actions. Check [Build with GitHub Actions](#build-with-github-actions) for details. +💡 You can also download `Mozc.pkg` from GitHub Actions. Check [Build with GitHub Actions](#build-with-github-actions) for details. ## Setup @@ -110,6 +111,22 @@ MOZC_QT_PATH=${PWD}/third_party/qt bazel build package --config oss_macos -c opt open bazel-bin/mac/Mozc.pkg ``` +#### How to specify target CPU architectures + +To build arm64 binaries regardless of the host CPU architectue. +``` +python3 build_tools/build_qt.py --release --debug --confirm_license --macos_cpus=arm64 +MOZC_QT_PATH=${PWD}/third_party/qt bazel build package --config oss_macos -c opt --macos_cpus=arm64 +open bazel-bin/mac/Mozc.pkg +``` + +To build fat binaries for both arm64 and x86_64. +``` +python3 build_tools/build_qt.py --release --debug --confirm_license --macos_cpus=x86_64,arm64 +MOZC_QT_PATH=${PWD}/third_party/qt bazel build package --config oss_macos -c opt --macos_cpus=x86_64,arm64 +open bazel-bin/mac/Mozc.pkg +``` + ### Unit tests ```