-
Notifications
You must be signed in to change notification settings - Fork 126
Add macOS ARM support for Thunderscope #3496
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
Changes from 12 commits
9d55cf0
a27eefc
16fff77
999a3e0
b8f3534
d32fb6d
11fcb39
068f212
4d2b6e9
42a0793
d6b303d
c85da81
49e0b0a
1ee0a58
6642aa2
34b2338
822d644
2e7f579
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| ansible-lint==24.12.2 | ||
| pyqtgraph==0.13.7 | ||
| thefuzz==0.19.0 | ||
| iterfzf==0.5.0.20.0 | ||
| python-Levenshtein==0.25.1 | ||
| psutil==5.9.0 | ||
| PyOpenGL==3.1.6 | ||
| ruff==0.5.5 | ||
| pyqt-toast-notification==1.3.2 | ||
| grpcio-tools==1.71.0 | ||
| platformio==6.1.18 | ||
| pyqt6==6.9.1 | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should make sure you're using the same c++ compuler version as Ubuntu (to minimize the number of c++ compatibility changes that are needed) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| #!/bin/bash | ||
| set -x | ||
| #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# | ||
| # UBC Thunderbots macOS Software Setup | ||
| # | ||
| # This script will install all required libraries and dependencies to build | ||
| # and run the Thunderbots codebase on macOS, including the AI and unit tests. | ||
| #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# | ||
|
|
||
| # Save the parent dir of this script | ||
| CURR_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) | ||
| cd "$CURR_DIR" || exit | ||
|
|
||
| source util.sh | ||
|
|
||
| arch=$(uname -m) | ||
| print_status_msg "Detected architecture: ${arch}" | ||
|
|
||
| # Check for Homebrew and install if missing | ||
| if ! command -v brew &>/dev/null; then | ||
| print_status_msg "Installing Homebrew..." | ||
| /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | ||
|
|
||
| # Configure Homebrew in current shell | ||
| if [ "$arch" = "arm64" ]; then | ||
| eval "$(/opt/homebrew/bin/brew shellenv)" | ||
| else | ||
| eval "$(/usr/local/bin/brew shellenv)" | ||
| fi | ||
|
Lmh-java marked this conversation as resolved.
Outdated
|
||
| fi | ||
|
|
||
| print_status_msg "Installing Utilities and Dependencies" | ||
|
|
||
| # Update Homebrew | ||
| brew update | ||
|
|
||
| # Install required packages | ||
| host_software_packages=( | ||
| cmake@4 | ||
| python@3.12 | ||
| bazelisk | ||
| openjdk@21 | ||
| pyqt@6 | ||
| qt@6 | ||
| node@20 | ||
| go@1.24 | ||
| clang-format@20 | ||
|
nycrat marked this conversation as resolved.
|
||
| ) | ||
|
|
||
| for pkg in "${host_software_packages[@]}"; do | ||
| if ! brew list "$pkg" &>/dev/null; then | ||
| print_status_msg "Installing $pkg..." | ||
| brew install "$pkg" | ||
| else | ||
| print_status_msg "$pkg already installed, skipping..." | ||
| fi | ||
| done | ||
|
|
||
| # Set up cache | ||
| mkdir /tmp/tbots_download_cache | ||
|
|
||
| # Set up Python | ||
| print_status_msg "Setting Up Python Environment" | ||
|
|
||
| # Create virtual environment | ||
| sudo python3.12 -m venv /opt/tbotspython | ||
| chmod | ||
| source /opt/tbotspython/bin/activate | ||
|
|
||
| # Install Python dependencies | ||
| sudo pip install --upgrade pip | ||
| sudo pip install -r macos_requirements.txt | ||
|
|
||
| print_status_msg "Done Setting Up Python Environment" | ||
|
|
||
| print_status_msg "Fetching game controller" | ||
| install_gamecontroller_macos | ||
|
|
||
| print_status_msg "Setting up TIGERS AutoRef" | ||
| install_java_macos | ||
| install_autoref_macos | ||
| sudo chmod +x "$CURR_DIR/../src/software/autoref/run_autoref.sh" | ||
| sudo cp "$CURR_DIR/../src/software/autoref/DIV_B.txt" "/opt/tbotspython/autoReferee/config/geometry/DIV_B.txt" | ||
| print_status_msg "Finished setting up AutoRef" | ||
|
|
||
| print_status_msg "Setting up cross compiler for robot software" | ||
| install_cross_compiler_mac | ||
| print_status_msg "Done setting up cross compiler for robot software" | ||
|
|
||
| print_status_msg "Setting Up Python Development Headers" | ||
| install_python_toolchain_headers | ||
| print_status_msg "Done Setting Up Python Development Headers" | ||
|
|
||
| print_status_msg "Granting Permissions to /opt/tbotspython" | ||
| sudo chown -R $(id -u):$(id -g) /opt/tbotspython | ||
| print_status_msg "Done Granting Permissions to /opt/tbotspython" | ||
|
|
||
| print_status_msg "Done Environment Configuration" | ||
|
|
||
|
Lmh-java marked this conversation as resolved.
|
||
| print_status_msg "Software Setup Complete" | ||
| print_status_msg "Note: Some changes require a new terminal session to take effect" | ||
|
|
||
|
nycrat marked this conversation as resolved.
nycrat marked this conversation as resolved.
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,15 @@ install_autoref() { | |
| rm -rf /tmp/tbots_download_cache/autoReferee.zip /tmp/tbots_download_cache/AutoReferee-${autoref_commit} | ||
| } | ||
|
|
||
| install_autoref_macos() { | ||
| autoref_version=1.5.5 | ||
| curl -L https://github.com/TIGERs-Mannheim/AutoReferee/releases/download/${autoref_version}/autoReferee.zip -o /tmp/tbots_download_cache/autoReferee.zip | ||
| unzip -q -o -d /tmp/tbots_download_cache/ /tmp/tbots_download_cache/autoReferee.zip | ||
|
|
||
| sudo mv /tmp/tbots_download_cache/autoReferee /opt/tbotspython/ | ||
| rm -rf /tmp/tbots_download_cache/autoReferee.zip | ||
| } | ||
|
|
||
| install_bazel() { | ||
| download=https://github.com/bazelbuild/bazelisk/releases/download/v1.26.0/bazelisk-linux-arm64 | ||
|
|
||
|
|
@@ -35,6 +44,16 @@ install_cross_compiler() { | |
| rm /tmp/tbots_download_cache/$full_file_name | ||
| } | ||
|
|
||
| install_cross_compiler_mac() { | ||
| file_name=aarch64-tbots-linux-gnu-for-aarch64 | ||
| full_file_name=$file_name.tar.xz | ||
| curl -L "https://raw.githubusercontent.com/UBC-Thunderbots/Software-External-Dependencies/refs/heads/main/toolchain/$full_file_name" \ | ||
| -o /tmp/tbots_download_cache/$full_file_name | ||
| tar -xf /tmp/tbots_download_cache/$full_file_name -C /tmp/tbots_download_cache/ | ||
| sudo mv /tmp/tbots_download_cache/aarch64-tbots-linux-gnu /opt/tbotspython | ||
| rm /tmp/tbots_download_cache/$full_file_name | ||
| } | ||
|
|
||
| install_gamecontroller () { | ||
| arch=arm64 | ||
| if is_x86 $1; then | ||
|
|
@@ -46,6 +65,19 @@ install_gamecontroller () { | |
| sudo chmod +x /opt/tbotspython/gamecontroller | ||
| } | ||
|
|
||
| install_gamecontroller_macos () { | ||
| curl -L https://github.com/RoboCup-SSL/ssl-game-controller/archive/refs/tags/v3.17.0.zip -o /tmp/tbots_download_cache/ssl-game-controller.zip | ||
| unzip -q -o -d /tmp/tbots_download_cache/ /tmp/tbots_download_cache/ssl-game-controller.zip | ||
| cd /tmp/tbots_download_cache/ssl-game-controller-3.17.0 | ||
| make install | ||
| go build cmd/ssl-game-controller/main.go | ||
| sudo mv main /opt/tbotspython/gamecontroller | ||
| sudo chmod +x /opt/tbotspython/gamecontroller | ||
|
|
||
| cd - | ||
| sudo rm -rf /tmp/tbots_download_cache/ssl-game-controller-3.17.0 /tmp/tbots_download_cache/go /tmp/tbots_download_cache/go.tar.gz /tmp/tbots_download_cache/ssl-game-controller.zip | ||
| } | ||
|
|
||
| install_java () { | ||
| java_home="" | ||
| java_download=https://download.oracle.com/java/21/latest/jdk-21_linux-aarch64_bin.tar.gz | ||
|
|
@@ -58,6 +90,17 @@ install_java () { | |
| rm /tmp/tbots_download_cache/jdk-21.tar.gz | ||
| } | ||
|
|
||
| install_java_macos () { | ||
| java_home="" | ||
| java_download=https://download.oracle.com/java/21/latest/jdk-21_macos-aarch64_bin.tar.gz | ||
| curl -L $java_download -o /tmp/tbots_download_cache/jdk-21.tar.gz | ||
| mkdir /tmp/tbots_download_cache/jdk | ||
| tar -xzf /tmp/tbots_download_cache/jdk-21.tar.gz -C /tmp/tbots_download_cache | ||
| sudo mv /tmp/tbots_download_cache/jdk-21*/Contents/Home /opt/tbotspython/bin/jdk | ||
| rm /tmp/tbots_download_cache/jdk-21.tar.gz | ||
| rm -rf /tmp/tbots_download_cache/jdk | ||
| } | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Java Installed already from brew, I don't think we need this
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need a specific version of Java for autoref (Java 21)
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suppose you're using the autoref binary package, so you can probably ignore this |
||
| install_python_dev_cross_compile_headers() { | ||
| mkdir -p /opt/tbotspython/cross_compile_headers | ||
| wget -N https://www.python.org/ftp/python/3.12.0/Python-3.12.0.tar.xz -O /tmp/tbots_download_cache/python-3.12.0.tar.xz | ||
|
|
@@ -90,6 +133,11 @@ install_python_dev_cross_compile_headers() { | |
| rm -rf /tmp/tbots_download_cache/python-3.12.0.tar.xz | ||
| } | ||
|
|
||
| install_python_toolchain_headers() { | ||
| sudo mkdir -p /opt/tbotspython/py_headers/include/ | ||
| sudo ln -sfn "$(python3.12-config --includes | awk '{for(i=1;i<=NF;++i) if ($i ~ /^-I/) print substr($i, 3)}' | head -n1)" /opt/tbotspython/py_headers/include/ | ||
| } | ||
|
|
||
| is_x86() { | ||
| if [[ $1 == "x86_64" ]]; then | ||
| return 0 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,8 +65,8 @@ common --enable_platform_specific_config | |
| build --incompatible_remove_legacy_whole_archive=False | ||
|
|
||
| # Escalate Warnings to fail Compile for Thunderbots code | ||
| build --features=external_include_paths | ||
| build --per_file_copt=proto/.*,proto/message_translation/.*,proto/primitive/.*,software/.*,shared/.*,-external/.*@-Wall,-Wextra,-Wno-unused-parameter,-Wno-deprecated,-Werror,-Wno-deprecated-declarations | ||
| build:linux --features=external_include_paths | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally these flags would also work on macos
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, ideally it should also work on macos, but because the macos clang compiler is stricter than linux and reports millions of new errors (converted from warnings). :( |
||
| build:linux --per_file_copt=proto/.*,proto/message_translation/.*,proto/primitive/.*,software/.*,shared/.*,-external/.*@-Wall,-Wextra,-Wno-unused-parameter,-Wno-deprecated,-Werror,-Wno-deprecated-declarations | ||
| # TODO: #3492 | ||
| # build --per_file_copt=software/.*,shared/.*,-external/.*@-Wconversion | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| #pragma once | ||
|
|
||
| #include <chrono> | ||
|
|
||
| #if defined(__APPLE__) | ||
| using Clock = std::chrono::system_clock; | ||
| #else | ||
| using Clock = std::chrono::_V2::system_clock; | ||
| #endif | ||
|
|
||
| #if __cplusplus > 201703L | ||
| #include <filesystem> | ||
| namespace fs = std::filesystem; | ||
| #else | ||
| #include <experimental/filesystem> | ||
| namespace fs = std::experimental::filesystem; | ||
| #endif | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of these can be removed pending #3542 I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will do a merge test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uhh I think bazel has no problem with your PR, everything compiles. But PyQt6 conflicts still exist with the current commit
9fce33a1727218c76ee0e1b37ee26bbbd1d0a1e1. I would guess this issue is normal because you have not resolved this PyQt lib conflict in your branch yet?Full Error message: