Skip to content

Commit 39b34cb

Browse files
authored
Nanopb Compiplation Refactor & Protobuf Cleanup (UBC-Thunderbots#3525)
1 parent 208c927 commit 39b34cb

8 files changed

Lines changed: 263 additions & 128 deletions

File tree

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
multiplatform-build:
1515
strategy:
1616
matrix:
17-
platform: [ ubuntu-22.04, ubuntu-24.04-arm ]
17+
platform: [ ubuntu-24.04-arm ]
1818

1919
name: Ubuntu Alternate Builds
2020
runs-on: ${{ matrix.platform }}

.github/workflows/pre-commit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ concurrency:
1414
jobs:
1515
formatting-check:
1616
name: Formatting and FSM diagram generation with pre-commit-ci-lite
17-
runs-on: ubuntu-22.04
17+
runs-on: ubuntu-24.04
1818
if: github.event.pull_request.draft == false
1919
steps:
2020
- uses: actions/checkout@v4

environment_setup/setup_software.sh

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ source util.sh
2323
g_arch=$(uname -m) # Global variable. No function should use this name.
2424
print_status_msg "Detected architecture: ${g_arch}"
2525

26+
if [[ $(lsb_release -rs) == "20.04" ]] || [[ $(lsb_release -rs) == "22.04" ]]; then
27+
print_status_msg "This version of ubuntu is not supported anymore, please upgrade your OS version"
28+
exit 1
29+
fi
30+
2631
print_status_msg "Installing Utilities and Dependencies"
2732

2833
sudo apt-get update
@@ -55,20 +60,13 @@ host_software_packages=(
5560
g++-10
5661
kcachegrind # This lets us view the profiles output by callgrind
5762
libeigen3-dev # A math / numerical library used for things like linear regression
58-
libprotobuf-dev
5963
libudev-dev
6064
libusb-1.0-0-dev
6165
libxcb-cursor0 # This is used as the Linux platform abstraction by Qt
62-
protobuf-compiler # This is required for the "NanoPb" library, which does not
63-
# properly manage this as a bazel dependency, so we have
64-
# to manually install it ourselves
6566
python3.12 # Python 3
6667
python3.12-dev # Python 3 headers
6768
python3.12-venv # Virtual Environment
6869
python3-pip # Required for bazel to install python dependencies for build targets
69-
python3-protobuf # This is required for the "NanoPb" library, which does not
70-
# properly manage this as a bazel dependency, so we have
71-
# to manually install it ourselves
7270
python3-yaml # Load dynamic parameter configuration files
7371
valgrind # Checks for memory leaks
7472
libsqlite3-dev # needed to build Python 3 with sqlite support
@@ -80,36 +78,16 @@ host_software_packages=(
8078
xvfb # used for CI to run GUI applications
8179
)
8280

83-
if [[ $(lsb_release -rs) == "20.04" ]]; then
84-
# This is required for bazel, we've seen some issues where
85-
# the bazel install hasn't installed it properly
86-
host_software_packages+=(python-is-python3)
87-
88-
# This is to setup the toolchain for bazel to run
89-
host_software_packages+=(clang)
90-
host_software_packages+=(llvm-6.0)
91-
host_software_packages+=(libclang-6.0-dev)
92-
host_software_packages+=(libncurses5)
93-
94-
# This fixes missing headers by notifying the linker
95-
sudo ldconfig
96-
fi
97-
9881
# Clear the download cache
9982
sudo rm -rf /tmp/tbots_download_cache
10083
mkdir /tmp/tbots_download_cache
10184

102-
if [[ $(lsb_release -rs) == "22.04" ]] || [[ $(lsb_release -rs) == "24.04" ]]; then
85+
if [[ $(lsb_release -rs) == "24.04" ]]; then
10386
# This is required because a Braille TTY device that Linux provides a driver for conflicts with the ESP32
10487
wget -nc https://github.com/UBC-Thunderbots/Software-External-Dependencies/blob/main/85-brltty.rules -O /tmp/tbots_download_cache/85-brltty.rules
10588
sudo mv /tmp/tbots_download_cache/85-brltty.rules /usr/lib/udev/rules.d/85-brltty.rules
10689
fi
10790

108-
if [[ $(lsb_release -rs) == "22.04" ]]; then
109-
# This is required for clang-format
110-
host_software_packages+=(libtinfo5)
111-
fi
112-
11391
virtualenv_opt_args=""
11492
if [[ $(lsb_release -rs) == "24.04" ]]; then
11593
host_software_packages+=(python3-pyqt6)
@@ -135,20 +113,11 @@ if ! sudo /usr/bin/python3.12 -m venv /opt/tbotspython $virtualenv_opt_args ; th
135113
exit 1
136114
fi
137115

138-
if [[ $(lsb_release -rs) == "20.04" ]] || [[ $(lsb_release -rs) == "22.04" ]]; then
139-
# Install pip if it is not a system-managed package
140-
sudo /usr/bin/python3.12 -m ensurepip
141-
fi
142-
143116
if ! sudo /opt/tbotspython/bin/python3 -m pip install --upgrade pip ; then
144117
print_status_msg "Error: Upgrading pip version in venv failed"
145118
exit 1
146119
fi
147120

148-
if [[ $(lsb_release -rs) == "22.04" ]]; then
149-
sudo /opt/tbotspython/bin/pip3 install -r ubuntu22_requirements.txt
150-
fi
151-
152121
if [[ $(lsb_release -rs) == "24.04" ]]; then
153122
sudo /opt/tbotspython/bin/pip3 install -r ubuntu24_requirements.txt
154123
fi

src/.bazelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ common --features=external_include_paths
4242
build --disk_cache=~/.cache/thunderbots_bazel_disk_cache
4343

4444
build --experimental_remote_merkle_tree_cache # partial repo caching optimization
45-
build --incompatible_enable_proto_toolchain_resolution # protoc caching
45+
common --incompatible_enable_proto_toolchain_resolution # protoc caching
4646

4747
# Ensure that we don't accidentally build gRPC
4848
common --per_file_copt=external/.*grpc.*@--GRPC_WAS_NOT_SUPPOSED_TO_BE_BUILT

src/MODULE.bazel

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,17 @@ module(
77
##############################################################
88
# Import Dependencies available in the Bazel Central Registry
99
##############################################################
10-
1110
bazel_dep(name = "googletest", version = "1.15.2")
1211
bazel_dep(name = "platforms", version = "0.0.11")
1312
bazel_dep(name = "pybind11_bazel", version = "2.13.6")
1413
bazel_dep(name = "bazel_skylib", version = "1.7.1")
1514
bazel_dep(name = "rules_pkg", version = "1.1.0")
1615
bazel_dep(name = "rules_foreign_cc", version = "0.14.0")
1716
bazel_dep(name = "rules_python", version = "1.4.1")
18-
bazel_dep(name = "protobuf", version = "31.1")
1917
bazel_dep(name = "eigen", version = "3.4.0.bcr.3")
20-
bazel_dep(name = "zlib", version = "1.3.1.bcr.5")
21-
bazel_dep(name = "nanopb", version = "0.4.9.1")
22-
bazel_dep(name = "toolchains_protoc", version = "0.4.1")
18+
bazel_dep(name = "zlib", version = "1.3.1.bcr.6")
19+
bazel_dep(name = "nanopb", version = "0.4.9.1.bcr.2")
20+
bazel_dep(name = "protobuf", version = "31.1")
2321
bazel_dep(name = "rules_proto", version = "7.1.0")
2422
bazel_dep(name = "yaml-cpp", version = "0.8.0")
2523
bazel_dep(name = "buildifier_prebuilt", version = "8.0.3")
@@ -79,18 +77,6 @@ use_repo(pip, "nanopb_deps")
7977
pybind11_configure = use_extension("@pybind11_bazel//:internal_configure.bzl", "internal_configure_extension")
8078
use_repo(pybind11_configure, "pybind11")
8179

82-
# Configure proto compiler optimization
83-
# Optional: choose a version of protoc rather than the latest.
84-
protoc = use_extension("@toolchains_protoc//protoc:extensions.bzl", "protoc")
85-
protoc.toolchain(
86-
# Creates a repository to satisfy well-known-types dependencies such as
87-
# deps=["@com_google_protobuf//:any_proto"]
88-
google_protobuf = "com_google_protobuf",
89-
# Pin to any version of protoc
90-
version = "v31.1",
91-
)
92-
use_repo(protoc, "com_google_protobuf", "toolchains_protoc_hub")
93-
9480
###########################################################################
9581
# Setup non Bazel Central Registry dependencies & Non MODULE supported deps
9682
###########################################################################

src/MODULE.bazel.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)