diff --git a/.bazelrc b/.bazelrc new file mode 100644 index 0000000..b9d8ee5 --- /dev/null +++ b/.bazelrc @@ -0,0 +1,8 @@ +# Enable logging rc options. +common --announce_rc + +############################################################################### +# Put user-specific options in user.bazelrc +# See https://bazel.build/configure/best-practices#bazelrc-file +################################################################################ +try-import %workspace%/user.bazelrc diff --git a/.github/workflows/amd64_linux_bazel.yml b/.github/workflows/amd64_linux_bazel.yml new file mode 100644 index 0000000..0695aa8 --- /dev/null +++ b/.github/workflows/amd64_linux_bazel.yml @@ -0,0 +1,74 @@ +# ref: https://github.com/actions/runner-images +name: amd64 Linux Bazel + +on: [push, pull_request, workflow_dispatch] + +# Building using the github runner environement directly. +jobs: + native: + strategy: + matrix: + bazel: [ + {compilation_mode: opt}, + {compilation_mode: dbg}, + ] + cpp: [ + {version: 14, flags: "-std=c++14"}, + {version: 17, flags: "-std=c++17"}, + {version: 20, flags: "-std=c++20"}, + ] + python: [ + {version: '3.11'}, + ] + exclude: + # only test `-c dbg` build with C++17 + - cpp: {version: 14} + bazel: {compilation_mode: dbg} + - cpp: {version: 20} + bazel: {compilation_mode: dbg} + fail-fast: false + name: Linux•Bazel(${{ matrix.bazel.compilation_mode }})•C++${{ matrix.cpp.version }}•Python${{ matrix.python.version }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Check Java + run: java -version + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python.version }} + - name: Check Python + run: | + python --version + python -m platform + - uses: bazel-contrib/setup-bazel@0.8.4 + with: + bazelisk-cache: true + disk-cache: ${{ github.workflow }} + repository-cache: true + - name: Check Bazel + run: bazel version + - name: Build + run: > + cd examples/basic && + bazel build + -c ${{ matrix.bazel.compilation_mode }} + --cxxopt=${{ matrix.cpp.flags }} --host_cxxopt=${{ matrix.cpp.flags }} + --subcommands=pretty_print + --enable_bzlmod + //... + - name: Test + run: > + cd examples/basic && + bazel test + -c ${{ matrix.bazel.compilation_mode }} + --cxxopt=${{ matrix.cpp.flags }} --host_cxxopt=${{ matrix.cpp.flags }} + --subcommands=pretty_print + --enable_bzlmod + //... + + amd64_linux_bazel: + runs-on: ubuntu-latest + needs: native + steps: + - uses: actions/checkout@v4 diff --git a/.github/workflows/amd64_macos_bazel.yml b/.github/workflows/amd64_macos_bazel.yml new file mode 100644 index 0000000..1de301c --- /dev/null +++ b/.github/workflows/amd64_macos_bazel.yml @@ -0,0 +1,72 @@ +# ref: https://github.com/actions/runner-images +name: amd64 MacOS Bazel + +on: [push, pull_request, workflow_dispatch] + +# Building using the github runner environement directly. +jobs: + native: + strategy: + matrix: + bazel: [ + {compilation_mode: opt}, + {compilation_mode: dbg}, + ] + cpp: [ + #{version: 14, flags: "-std=c++14"}, + {version: 17, flags: "-std=c++17"}, + #{version: 20, flags: "-std=c++20"}, + ] + python: [ + {version: '3.11'}, + ] + exclude: + # only test `-c dbg` build with C++17 + - cpp: {version: 14} + bazel: {compilation_mode: dbg} + - cpp: {version: 20} + bazel: {compilation_mode: dbg} + fail-fast: false + name: MacOS•Bazel(${{ matrix.bazel.compilation_mode }})•C++${{ matrix.cpp.version }}•Python${{ matrix.python.version }} + runs-on: macos-13 # last macos intel based runner + steps: + - uses: actions/checkout@v4 + - name: Set Java to OpenJDK 17 (Temurin) + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '17' + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python.version }} + - name: Check Python + run: | + python --version + python -m platform + - name: Check Bazel + run: bazel version + - name: Build + run: > + cd examples/basic && + bazel build + -c ${{ matrix.bazel.compilation_mode }} + --cxxopt=${{ matrix.cpp.flags }} --host_cxxopt=${{ matrix.cpp.flags }} + --subcommands=pretty_print + --enable_bzlmod + //... + - name: Test + run: > + cd examples/basic && + bazel test + -c ${{ matrix.bazel.compilation_mode }} + --cxxopt=${{ matrix.cpp.flags }} --host_cxxopt=${{ matrix.cpp.flags }} + --subcommands=pretty_print + --enable_bzlmod + //... + + amd64_macos_bazel: + runs-on: ubuntu-latest + needs: native + steps: + - uses: actions/checkout@v4 diff --git a/.github/workflows/amd64_windows_bazel.yml b/.github/workflows/amd64_windows_bazel.yml new file mode 100644 index 0000000..09abdd0 --- /dev/null +++ b/.github/workflows/amd64_windows_bazel.yml @@ -0,0 +1,77 @@ +# ref: https://github.com/actions/runner-images +name: amd64 Windows Bazel + +on: [push, pull_request, workflow_dispatch] + +# Building using the github runner environement directly. +jobs: + native: + strategy: + matrix: + runner: [ + windows-2022, + #windows-2019, + ] + bazel: [ + {compilation_mode: opt}, + {compilation_mode: dbg}, + ] + cpp: [ + {version: 14, flags: "/std:c++14"}, + {version: 17, flags: "/std:c++17"}, + #{version: 20, flags: "/std:c++20"}, + ] + python: [ + {version: '3.11'}, + ] + exclude: + - runner: windows-2019 + cpp: {version: 20} + # only test -c dbg with VS 2022 version 17 to save compute time + - runner: windows-2019 + bazel: {compilation_mode: dbg} + - cpp: {version: 14} + bazel: {compilation_mode: dbg} + - cpp: {version: 20} + bazel: {compilation_mode: dbg} + fail-fast: false # Don't cancel all jobs if one fails. + name: ${{ matrix.runner }}•Bazel(${{ matrix.bazel.compilation_mode }})•C++${{ matrix.cpp.version }}•Python${{ matrix.python.version }} + runs-on: ${{ matrix.runner }} + steps: + - uses: actions/checkout@v4 + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python.version }} + - name: Check Python + run: | + python --version + python -m platform + - name: Install Bazel + run: choco install bazel + - name: Check Bazel + run: bazel version + - name: Build + run: > + cd examples/basic && + bazel build + -c ${{ matrix.bazel.compilation_mode }} + --cxxopt=${{ matrix.cpp.flags }} --host_cxxopt=${{ matrix.cpp.flags }} + --subcommands=pretty_print + --enable_bzlmod + //... + - name: Test + run: > + cd examples/basic && + bazel test + -c ${{ matrix.bazel.compilation_mode }} + --cxxopt=${{ matrix.cpp.flags }} --host_cxxopt=${{ matrix.cpp.flags }} + --subcommands=pretty_print + --enable_bzlmod + //... + + amd64_windows_bazel: + runs-on: ubuntu-latest + needs: native + steps: + - uses: actions/checkout@v4 diff --git a/.github/workflows/arm64_macos_bazel.yml b/.github/workflows/arm64_macos_bazel.yml new file mode 100644 index 0000000..4ce8696 --- /dev/null +++ b/.github/workflows/arm64_macos_bazel.yml @@ -0,0 +1,72 @@ +# ref: https://github.com/actions/runner-images +name: arm64 MacOS Bazel + +on: [push, pull_request, workflow_dispatch] + +# Building using the github runner environement directly. +jobs: + native: + strategy: + matrix: + bazel: [ + {compilation_mode: opt}, + {compilation_mode: dbg}, + ] + cpp: [ + #{version: 14, flags: "-std=c++14"}, + {version: 17, flags: "-std=c++17"}, + #{version: 20, flags: "-std=c++20"}, + ] + python: [ + {version: '3.11'}, + ] + exclude: + # only test `-c dbg` build with C++17 + - cpp: {version: 14} + bazel: {compilation_mode: dbg} + - cpp: {version: 20} + bazel: {compilation_mode: dbg} + fail-fast: false + name: MacOS•Bazel(${{ matrix.bazel.compilation_mode }})•C++${{ matrix.cpp.version }}•Python${{ matrix.python.version }} + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + - name: Set Java to OpenJDK 17 (Temurin) + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '17' + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python.version }} + - name: Check Python + run: | + python --version + python -m platform + - name: Check Bazel + run: bazel version + - name: Build + run: > + cd examples/basic && + bazel build + -c ${{ matrix.bazel.compilation_mode }} + --cxxopt=${{ matrix.cpp.flags }} --host_cxxopt=${{ matrix.cpp.flags }} + --subcommands=pretty_print + --enable_bzlmod + //... + - name: Test + run: > + cd examples/basic && + bazel test + -c ${{ matrix.bazel.compilation_mode }} + --cxxopt=${{ matrix.cpp.flags }} --host_cxxopt=${{ matrix.cpp.flags }} + --subcommands=pretty_print + --enable_bzlmod + //... + + arm64_macos_bazel: + runs-on: ubuntu-latest + needs: native + steps: + - uses: actions/checkout@v4 diff --git a/.gitignore b/.gitignore index 0d4fed2..8b0cf67 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ bazel-* MODULE.bazel.lock + +user.bazelrc +.*.swp diff --git a/examples/basic/MODULE.bazel b/examples/basic/MODULE.bazel index ddbc411..9a3dc37 100644 --- a/examples/basic/MODULE.bazel +++ b/examples/basic/MODULE.bazel @@ -1,3 +1,4 @@ +bazel_dep(name = "platforms", version = "0.0.10") bazel_dep(name = "rules_python", version = "0.34.0") bazel_dep(name = "pybind11_bazel") local_path_override(