From eceef54f5898181d6171945febc66cd7084b75dc Mon Sep 17 00:00:00 2001 From: fruffy Date: Tue, 3 Dec 2024 10:38:53 -0500 Subject: [PATCH] CI installation refactoring. Signed-off-by: fruffy --- .github/workflows/ci-lint.yaml | 12 +- .github/workflows/ci-p4tools.yml | 2 +- .github/workflows/ci-ptf-kernels-weekly.yml | 2 +- .github/workflows/ci-ptf.yml | 2 +- .github/workflows/ci-static-build-test.yml | 2 +- .github/workflows/ci-test-debian.yml | 36 ++- .github/workflows/ci-test-fedora.yml | 8 +- .github/workflows/ci-test-mac.yml | 6 +- .github/workflows/ci-ubuntu-18-nightly.yml | 2 +- .../ci-ubuntu-20-sanitizer-nightly.yml | 2 +- .github/workflows/ci-validation-nightly.yml | 2 +- .gitignore | 3 + Dockerfile | 1 + pyproject.toml | 49 ++++ requirements.txt | 18 -- tools/ci-build.sh | 21 +- tools/install.sh | 214 ++++++++++++++++++ tools/install_fedora_deps.sh | 7 +- tools/install_mac_deps.sh | 9 +- 19 files changed, 344 insertions(+), 54 deletions(-) delete mode 100644 requirements.txt create mode 100755 tools/install.sh diff --git a/.github/workflows/ci-lint.yaml b/.github/workflows/ci-lint.yaml index c938f577185..7791c7a064f 100644 --- a/.github/workflows/ci-lint.yaml +++ b/.github/workflows/ci-lint.yaml @@ -35,12 +35,16 @@ jobs: tools/ci-build.sh - name: Run cpplint on C/C++ files. - run: cmake --build build --target cpplint + run: poetry run cmake --build build --target cpplint - name: Run clang-format on C/C++ files. - run: cmake --build build --target clang-format + run: | + poetry run clang-format --version + poetry run cmake --build build --target clang-format - name: Run black and isort on Python files. run: | - cmake --build build --target black - cmake --build build --target isort + poetry run black --version + poetry run cmake --build build --target black + poetry run isort --version + poetry run cmake --build build --target isort diff --git a/.github/workflows/ci-p4tools.yml b/.github/workflows/ci-p4tools.yml index de2fe523c5d..57277b7834f 100644 --- a/.github/workflows/ci-p4tools.yml +++ b/.github/workflows/ci-p4tools.yml @@ -40,5 +40,5 @@ jobs: - name: Run tests (Ubuntu 22.04) # Need to use sudo for the eBPF kernel tests. - run: sudo -E ctest -R "testgen|smith" --output-on-failure --schedule-random + run: sudo -E env PATH="$PATH" poetry run ctest -R "testgen|smith" --output-on-failure --schedule-random working-directory: ./build diff --git a/.github/workflows/ci-ptf-kernels-weekly.yml b/.github/workflows/ci-ptf-kernels-weekly.yml index 9073f755a7c..85dab9d387a 100644 --- a/.github/workflows/ci-ptf-kernels-weekly.yml +++ b/.github/workflows/ci-ptf-kernels-weekly.yml @@ -119,4 +119,4 @@ jobs: - name: Install VM and run PTF tests for eBPF backend run: | - sudo -E ./tools/ci-ptf/run_test.sh sudo docker run --privileged -v /sys/fs/bpf:/sys/fs/bpf -w /p4c/backends/ebpf/tests p4c ./test.sh + sudo -E ./tools/ci-ptf/run_test.sh sudo docker run --privileged -v /sys/fs/bpf:/sys/fs/bpf -w /p4c/backends/ebpf/tests p4c poetry run ./test.sh diff --git a/.github/workflows/ci-ptf.yml b/.github/workflows/ci-ptf.yml index 3304f705ae4..b057c899a1b 100644 --- a/.github/workflows/ci-ptf.yml +++ b/.github/workflows/ci-ptf.yml @@ -53,5 +53,5 @@ jobs: tools/ci-build.sh - name: Run PTF tests for eBPF backend (Ubuntu 20.04) - run: sudo -E ./test.sh + run: sudo -E env PATH="$PATH" poetry run ./test.sh working-directory: ./backends/ebpf/tests diff --git a/.github/workflows/ci-static-build-test.yml b/.github/workflows/ci-static-build-test.yml index 230a11d9cbf..a0c63d31a0b 100644 --- a/.github/workflows/ci-static-build-test.yml +++ b/.github/workflows/ci-static-build-test.yml @@ -48,6 +48,6 @@ jobs: - shell: bash name: Build (Ubuntu 20.04) run: | - sudo -E tools/ci-build.sh + tools/ci-build.sh ./tools/ci-check-static.sh ./build/p4c-bm2-ss ./build/p4c-dpdk ./build/p4c-ebpf \ ./build/p4c-pna-p4tc ./build/p4c-ubpf ./build/p4test ./build/p4testgen diff --git a/.github/workflows/ci-test-debian.yml b/.github/workflows/ci-test-debian.yml index ac2b2d5e4be..aa212045358 100644 --- a/.github/workflows/ci-test-debian.yml +++ b/.github/workflows/ci-test-debian.yml @@ -14,6 +14,36 @@ concurrency: cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} jobs: + + # Build with GCC and test P4C on Ubuntu 24.04. + test-ubuntu24: + runs-on: ubuntu-24.04 + env: + CTEST_PARALLEL_LEVEL: 4 + IMAGE_TYPE: test + BUILD_GENERATOR: Ninja + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + fetch-depth: 0 + + - name: ccache + uses: hendrikmuhs/ccache-action@v1 + with: + key: test-${{ runner.os }}-gcc + max-size: 1000M + + - name: Build (Ubuntu 24.04, GCC) + run: | + tools/ci-build.sh + + - name: Run tests (Ubuntu 24.04) + # Need to use sudo for the eBPF kernel tests. + run: | + sudo -E env PATH="$PATH" poetry run ctest --output-on-failure --schedule-random + working-directory: ./build + # Build with GCC and test P4C on Ubuntu 22.04. test-ubuntu22: runs-on: ubuntu-22.04 @@ -39,7 +69,8 @@ jobs: - name: Run tests (Ubuntu 22.04) # Need to use sudo for the eBPF kernel tests. - run: sudo -E ctest --output-on-failure --schedule-random + run: | + sudo -E env PATH="$PATH" poetry run ctest --output-on-failure --schedule-random working-directory: ./build # Build with GCC and test Tofino backend on Ubuntu 22.04. @@ -112,6 +143,7 @@ jobs: - name: Run tests (Ubuntu 20.04) # Need to use sudo for the eBPF kernel tests. - run: sudo -E ctest --output-on-failure --schedule-random + run: | + sudo -E env PATH="$PATH" poetry run ctest --output-on-failure --schedule-random working-directory: ./build if: matrix.unity == 'ON' && matrix.gtest == 'ON' diff --git a/.github/workflows/ci-test-fedora.yml b/.github/workflows/ci-test-fedora.yml index 2b4a4d95287..d818acaa6f1 100644 --- a/.github/workflows/ci-test-fedora.yml +++ b/.github/workflows/ci-test-fedora.yml @@ -35,7 +35,9 @@ jobs: submodules: recursive - name: Install dependencies (Fedora Linux) - run: tools/install_fedora_deps.sh + run: | + export PATH="$HOME/.local/bin:$PATH" + tools/install_fedora_deps.sh - name: ccache uses: hendrikmuhs/ccache-action@v1 @@ -45,10 +47,12 @@ jobs: - name: Build p4c (Fedora Linux) run: | + export PATH="$HOME/.local/bin:$PATH" ./bootstrap.sh -DCMAKE_BUILD_TYPE=Release -DCMAKE_UNITY_BUILD=ON --build-generator "Ninja" cmake --build build -- -j $(nproc) - name: Run p4c tests (Fedora Linux) run: | - export PATH="$HOME/.local/bin:$PATH"; ctest --output-on-failure --schedule-random + export PATH="$HOME/.local/bin:$PATH" + poetry run ctest --output-on-failure --schedule-random working-directory: ./build diff --git a/.github/workflows/ci-test-mac.yml b/.github/workflows/ci-test-mac.yml index 4c8845dbe07..fb2d693c064 100644 --- a/.github/workflows/ci-test-mac.yml +++ b/.github/workflows/ci-test-mac.yml @@ -46,6 +46,7 @@ jobs: - name: Install dependencies (MacOS) run: | + source ~/.bash_profile tools/install_mac_deps.sh - name: Build (MacOS) @@ -58,7 +59,7 @@ jobs: - name: Run tests (MacOS) run: | source ~/.bash_profile - ctest --output-on-failure --schedule-random -E "bpf|ubpf|testgen|smith" + poetry run ctest --output-on-failure --schedule-random -E "bpf|ubpf|testgen|smith" working-directory: ./build # Build and test p4c on MacOS 13 on x86. @@ -93,6 +94,7 @@ jobs: - name: Install dependencies (MacOS) run: | + source ~/.bash_profile tools/install_mac_deps.sh - name: Build (MacOS) @@ -105,5 +107,5 @@ jobs: - name: Run tests (MacOS) run: | source ~/.bash_profile - ctest --output-on-failure --schedule-random -E "bpf|ubpf|testgen|smith" + poetry run ctest --output-on-failure --schedule-random -E "bpf|ubpf|testgen|smith" working-directory: ./build diff --git a/.github/workflows/ci-ubuntu-18-nightly.yml b/.github/workflows/ci-ubuntu-18-nightly.yml index 68ada935503..b4fe85f17cd 100644 --- a/.github/workflows/ci-ubuntu-18-nightly.yml +++ b/.github/workflows/ci-ubuntu-18-nightly.yml @@ -39,4 +39,4 @@ jobs: # this is needed to create network namespaces for the ebpf tests. - name: Run tests (Ubuntu 18.04) run: | - sudo -E docker run --privileged -w /p4c/build -e $CTEST_PARALLEL_LEVEL p4c ctest --output-on-failure --schedule-random + sudo -E docker run --privileged -w /p4c/build -e $CTEST_PARALLEL_LEVEL p4c poetry run --output-on-failure --schedule-random diff --git a/.github/workflows/ci-ubuntu-20-sanitizer-nightly.yml b/.github/workflows/ci-ubuntu-20-sanitizer-nightly.yml index 830ddade2cd..665764af7c1 100644 --- a/.github/workflows/ci-ubuntu-20-sanitizer-nightly.yml +++ b/.github/workflows/ci-ubuntu-20-sanitizer-nightly.yml @@ -40,5 +40,5 @@ jobs: - name: Run tests (Ubuntu 20.04) # Need to use sudo for the eBPF kernel tests. - run: sudo -E ctest --output-on-failure --schedule-random + run: sudo -E env PATH="$PATH" poetry run ctest --output-on-failure --schedule-random working-directory: ./build diff --git a/.github/workflows/ci-validation-nightly.yml b/.github/workflows/ci-validation-nightly.yml index b947f603d63..47d985f1a67 100644 --- a/.github/workflows/ci-validation-nightly.yml +++ b/.github/workflows/ci-validation-nightly.yml @@ -38,5 +38,5 @@ jobs: - name: Validate run: | - ctest -R toz3-validate-p4c --output-on-failure --schedule-random + poetry run ctest -R toz3-validate-p4c --output-on-failure --schedule-random working-directory: ./build diff --git a/.gitignore b/.gitignore index 7772b8a5d40..e9bf002d74f 100644 --- a/.gitignore +++ b/.gitignore @@ -52,3 +52,6 @@ docs/doxygen/awesome_css/ # thirdparty backends/tofino/third_party/ + +# Poetry +poetry.lock diff --git a/Dockerfile b/Dockerfile index 50a34e25158..92215d07ad2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -46,6 +46,7 @@ ARG BUILD_AUTO_VAR_INIT_PATTERN=OFF # - Disable leaks detector as p4c uses GC. ENV UBSAN_OPTIONS=print_stacktrace=1 ENV ASAN_OPTIONS=print_stacktrace=1:detect_leaks=0 +ENV PATH="/root/.local/bin:$PATH" # Delegate the build to tools/ci-build. COPY . /p4c/ diff --git a/pyproject.toml b/pyproject.toml index 368e195d59e..3354a2ecf16 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,3 +51,52 @@ disable = [ "missing-function-docstring", "too-few-public-methods", ] + +[tool.poetry] +name = "p4c" +version = "1.2.5.1" +description = "" +authors = ["Your Name "] +license = "Apache" +readme = "README.md" +package-mode = false + +[tool.poetry.dependencies] +# Fixme: This restriction is because of pyinstaller +python = "<3.14,>=3.8" +# General testing utilties. +pyroute2 = "0.7.3" +ply = "3.11" +scapy = "2.5.0" +# Utilities for BMv2 and PTF tests. +ptf = "0.10.0" +googleapis-common-protos = "1.53.0" +grpcio = [ + {version = "1.67.0", python = ">3.6"}, + {version = "1.48.2", python = "<=3.6"} +] +thrift = "0.21.0 " +protobuf = [ + {version = "3.20.2", python = ">3.6"}, + {version = "3.19.2", python = "<=3.6"} +] +# Linters and formatters. +clang-format = "18.1.0" +black = [ + {version = "24.3.0", python = ">3.6"}, + {version = "22.8.0", python = "<=3.6"} +] +isort = [ + {version = "5.13.2", python = ">3.6"}, + {version = "5.10.1", python = "<=3.6"} +] +# FIXME: Remove and replace with local FetchContent version. +p4runtime = "1.4.1" +# FIXME: The Tofino back end should vendor these tools or use them locally. +jsl= "0.2.4" +pyinstaller= "6.11.0" +jsonschema= "4.23.0" + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 7df5e9fb622..00000000000 --- a/requirements.txt +++ /dev/null @@ -1,18 +0,0 @@ -###### Python3 dependencies with version specifiers ###### -# Install with pip3 install --user -r requirements.txt -pyroute2==0.7.3 -ply==3.11 -ptf==0.10.0 -scapy==2.5.0 -clang-format==18.1.0 -isort==5.13.2; python_version > '3.6' -black==24.3.0; python_version > '3.6' -protobuf==3.20.2; python_version > '3.6' -grpcio==1.67.0; python_version > '3.6' -googleapis-common-protos==1.53.0; python_version > '3.6' -# Ubuntu 18.04 uses Python 3.6, which is not supported by recent versions of Protobuf and Black. -protobuf==3.19.2; python_version <= '3.6' -googleapis-common-protos==1.53.0; python_version <= '3.6' -grpcio==1.48.2; python_version <= '3.6' -isort==5.10.1; python_version <= '3.6' -black==22.8.0; python_version <= '3.6' diff --git a/tools/ci-build.sh b/tools/ci-build.sh index 40549580f2d..489dc6aa4f4 100755 --- a/tools/ci-build.sh +++ b/tools/ci-build.sh @@ -104,8 +104,10 @@ fi sudo apt-get update sudo apt-get install -y --no-install-recommends ${P4C_DEPS} -sudo pip3 install --upgrade pip -sudo pip3 install -r ${P4C_DIR}/requirements.txt +# Set up poetry. +sudo apt-get install -y python3-venv curl +curl -sSL https://install.python-poetry.org | python3 - +poetry install -C ${P4C_DIR} if [ "${BUILD_GENERATOR,,}" == "ninja" ] && [ ! $(command -v ninja) ] then @@ -128,8 +130,6 @@ function build_bmv2() { # TODO: Remove this check once 18.04 is deprecated. if [[ "${DISTRIB_RELEASE}" == "18.04" ]] ; then P4C_RUNTIME_DEPS_BOOST="libboost-graph1.65.1 libboost-iostreams1.65.1" - else - P4C_RUNTIME_DEPS_BOOST="libboost-graph1.7* libboost-iostreams1.7*" fi P4C_RUNTIME_DEPS="cpp \ @@ -146,7 +146,7 @@ function build_bmv2() { P4C_RUNTIME_DEPS+=" gcc-9 g++-9" export CC=gcc-9 export CXX=g++-9 - else + elif [[ "${DISTRIB_RELEASE}" != "24.04" ]] ; then sudo apt-get install -y wget ca-certificates # Add the p4lang opensuse repository. echo "deb http://download.opensuse.org/repositories/home:/p4lang/xUbuntu_${DISTRIB_RELEASE}/ /" | sudo tee /etc/apt/sources.list.d/home:p4lang.list @@ -155,11 +155,6 @@ function build_bmv2() { fi sudo apt-get update && sudo apt-get install -y --no-install-recommends ${P4C_RUNTIME_DEPS} - - if [[ "${DISTRIB_RELEASE}" != "18.04" ]] ; then - # To run PTF nanomsg tests. Not available on 18.04. - sudo pip3 install nnpy - fi } if [[ "${ENABLE_BMV2}" == "ON" ]] ; then @@ -292,12 +287,12 @@ fi if [ -e build ]; then /bin/rm -rf build; fi mkdir -p ${P4C_DIR}/build cd ${P4C_DIR}/build -cmake ${CMAKE_FLAGS} -G "${BUILD_GENERATOR}" .. +poetry run cmake ${CMAKE_FLAGS} -G "${BUILD_GENERATOR}" .. # If CMAKE_ONLY is active, only run CMake. Do not build. if [ "$CMAKE_ONLY" == "OFF" ]; then - cmake --build . -- -j $(nproc) - sudo cmake --install . + poetry run cmake --build . -- -j $(nproc) + sudo -E env PATH="$PATH" cmake --install . # Print ccache statistics after building ccache -p -s fi diff --git a/tools/install.sh b/tools/install.sh new file mode 100755 index 00000000000..fbb656c9443 --- /dev/null +++ b/tools/install.sh @@ -0,0 +1,214 @@ +#!/bin/bash + +THIS_DIR=$( cd -- "$( dirname -- "${0}" )" &> /dev/null && pwd ) +P4C_DIR=$(readlink -f ${THIS_DIR}/..) + +# Get distribution info +DISTRO=$(lsb_release -i | awk -F: '{print $2}' | xargs) +VERSION=$(lsb_release -r | awk -F: '{print $2}' | xargs) + +# Define supported distributions and versions +SUPPORTED_DISTROS=("Ubuntu" "Pop") +SUPPORTED_UBUNTU_VERSIONS=("20.04" "22.04" "24.04") + +# Function to check if an element exists in an array +contains() { + local element + for element in "${@:2}"; do + if [[ "$element" == "$1" ]]; then + return 0 + fi + done + return 1 +} + +# Check distribution and version +if contains "$DISTRO" "${SUPPORTED_DISTROS[@]}"; then + if [[ "$DISTRO" == "Ubuntu" ]]; then + if contains "$VERSION" "${SUPPORTED_UBUNTU_VERSIONS[@]}"; then + echo "Supported distribution: $DISTRO $VERSION" + exit 0 + else + echo "Error: Unsupported Ubuntu version: $VERSION" + exit 1 + fi + else + # Assume all versions of Pop!_OS and Linux Mint are supported + echo "Supported distribution: $DISTRO $VERSION" + fi +else + echo "Error: Unsupported distribution: $DISTRO" + exit 1 +fi + +# Whether to install dependencies required to run PTF-ebpf tests +: "${INSTALL_PTF_EBPF_DEPENDENCIES:=OFF}" +# The build generator to use. Defaults to Make. +: "${BUILD_GENERATOR:="ninja"}" +# BMv2 is enable by default. +: "${ENABLE_BMV2:=ON}" +# eBPF is enabled by default. +: "${ENABLE_EBPF:=ON}" +# This is the list of back ends that can be enabled. +# Back ends can be enabled from the command line with "ENABLE_[backend]=TRUE/FALSE" +ENABLE_BACKENDS=("TOFINO" "BMV2" "EBPF" "UBPF" "DPDK" + "P4TC" "P4FMT" "P4TEST" "P4C_GRAPHS" + "TEST_TOOLS" +) +function build_cmake_enabled_backend_string() { + CMAKE_ENABLE_BACKENDS="" + for backend in "${ENABLE_BACKENDS[@]}"; + do + enable_var=ENABLE_${backend} + if [ -n "${!enable_var}" ]; then + echo "${enable_var}=${!enable_var} is set." + CMAKE_ENABLE_BACKENDS+="-D${enable_var}=${!enable_var} " + fi + done +} + + +. /etc/lsb-release + +# In Docker builds, sudo is not available. So make it a noop. +if [ "$IN_DOCKER" == "TRUE" ]; then + echo "Executing within docker container." + function sudo() { command "$@"; } +fi + + +# ! ------ BEGIN CORE ----------------------------------------------- +P4C_DEPS="bison \ + flex \ + cmake \ + build-essential \ + ccache \ + ninja-build \ + g++ \ + git \ + lld \ + libboost-graph-dev \ + libboost-iostreams-dev \ + libfl-dev \ + python3 \ + python3-pip \ + python3-setuptools" + +sudo apt-get update +sudo apt-get install -y --no-install-recommends ${P4C_DEPS} + +sudo apt-get install -y python3-poetry python3-venv +poetry install +poetry shell + +if [ "${BUILD_GENERATOR,,}" == "ninja" ] && [ ! $(command -v ninja) ] +then + echo "Selected ninja as build generator, but ninja could not be found." + exit 1 +fi + +# ! ------ END CORE ----------------------------------------------- + +ccache --set-config max_size=1G + +# ! ------ BEGIN BMV2 ----------------------------------------------- +function build_bmv2() { + P4C_RUNTIME_DEPS_BOOST="libboost-graph1.7* libboost-iostreams1.7*" + + P4C_RUNTIME_DEPS="cpp \ + ${P4C_RUNTIME_DEPS_BOOST} \ + libgc1* \ + libgmp-dev \ + libnanomsg-dev" + + sudo apt-get install -y wget ca-certificates + # Add the p4lang opensuse repository. + echo "deb http://download.opensuse.org/repositories/home:/p4lang/xUbuntu_${DISTRIB_RELEASE}/ /" | sudo tee /etc/apt/sources.list.d/home:p4lang.list + curl -fsSL https://download.opensuse.org/repositories/home:p4lang/xUbuntu_${DISTRIB_RELEASE}/Release.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/home_p4lang.gpg > /dev/null + P4C_RUNTIME_DEPS+=" p4lang-bmv2" + + sudo apt-get update && sudo apt-get install -y --no-install-recommends ${P4C_RUNTIME_DEPS} + +} + +if [[ "${ENABLE_BMV2}" == "ON" ]] ; then + build_bmv2 +fi +# ! ------ END BMV2 ----------------------------------------------- + +# ! ------ BEGIN EBPF ----------------------------------------------- +function build_ebpf() { + P4C_EBPF_DEPS="libpcap-dev \ + libelf-dev \ + zlib1g-dev \ + llvm \ + clang \ + tcpdump \ + iproute2 \ + iptables \ + net-tools" + + sudo apt-get install -y --no-install-recommends ${P4C_EBPF_DEPS} +} + +function install_ptf_ebpf_test_deps() ( + P4C_PTF_PACKAGES="gcc-multilib \ + python3-six \ + libgmp-dev \ + libjansson-dev" + sudo apt-get install -y --no-install-recommends ${P4C_PTF_PACKAGES} + + git clone --depth 1 --recursive --branch v0.3.1 https://github.com/NIKSS-vSwitch/nikss /tmp/nikss + pushd /tmp/nikss + ./build_libbpf.sh + mkdir build + cd build + cmake -DCMAKE_BUILD_TYPE=Release -G "${BUILD_GENERATOR}" .. + cmake --build . -- -j $(nproc) + sudo cmake --install . + + # install bpftool + git clone --recurse-submodules --branch v7.3.0 https://github.com/libbpf/bpftool.git /tmp/bpftool + cd /tmp/bpftool/src + make "-j$(nproc)" + sudo make install + popd +) + +if [[ "${ENABLE_EBPF}" == "ON" ]] ; then + build_ebpf + if [[ "${INSTALL_PTF_EBPF_DEPENDENCIES}" == "ON" ]] ; then + install_ptf_ebpf_test_deps + fi +fi +# ! ------ END EBPF ----------------------------------------------- + +# ! ------ BEGIN DPDK ----------------------------------------------- +function build_dpdk() { + # Replace existing Protobuf with one that works. + # TODO: Debug protobuf mismatch. + sudo -E pip3 uninstall -y protobuf + sudo pip3 install protobuf==3.20.3 netaddr==0.9.0 +} + +if [[ "${ENABLE_DPDK}" == "ON" ]]; then + build_dpdk +fi +# ! ------ END DPDK ----------------------------------------------- + +# ! ------ BEGIN TOFINO -------------------------------------------- + +function build_tofino() { + P4C_TOFINO_PACKAGES="rapidjson-dev" + sudo apt-get install -y --no-install-recommends ${P4C_TOFINO_PACKAGES} + sudo pip3 install jsl==0.2.4 pyinstaller==6.11.0 +} + +if [[ "${ENABLE_TOFINO}" == "ON" ]]; then + echo "Installing Tofino dependencies" + build_tofino +fi +# ! ------ END TOFINO ---------------------------------------------- + +echo "Test image ready" + diff --git a/tools/install_fedora_deps.sh b/tools/install_fedora_deps.sh index 0788268af09..f079456c933 100755 --- a/tools/install_fedora_deps.sh +++ b/tools/install_fedora_deps.sh @@ -51,6 +51,8 @@ sudo dnf install -y -q \ procps-ng \ python3 \ python3-pip \ + python3-virtualenv \ + curl \ python3-thrift \ readline-devel \ tcpdump \ @@ -59,8 +61,9 @@ sudo dnf install -y -q \ zlib-devel \ ninja-build -pip3 install --upgrade pip -pip3 install -r ${P4C_DIR}/requirements.txt +# Set up poetry. +curl -sSL https://install.python-poetry.org | python3 - +poetry install MAKEFLAGS="-j$(nproc)" export MAKEFLAGS diff --git a/tools/install_mac_deps.sh b/tools/install_mac_deps.sh index 09a93ff31e5..87d55817a9d 100755 --- a/tools/install_mac_deps.sh +++ b/tools/install_mac_deps.sh @@ -41,7 +41,7 @@ brew update BOOST_LIB="boost@1.85" REQUIRED_PACKAGES=( autoconf automake ccache cmake libtool - openssl coreutils bison grep ninja + openssl coreutils bison grep ninja virtualenv curl ${BOOST_LIB} ) for package in "${REQUIRED_PACKAGES[@]}"; do @@ -60,8 +60,9 @@ fi if ! grep -q "$HOMEBREW_PREFIX/opt/grep/libexec/gnubin" ~/.bash_profile; then echo 'export PATH="$HOMEBREW_PREFIX/opt/grep/libexec/gnubin:$PATH"' >> ~/.bash_profile fi +echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bash_profile source ~/.bash_profile -# Install required pip packages -# TODO: Should we use --break-system-packages or should we set up a venv? -pip3 install --user --break-system-packages -r requirements.txt +# Set up poetry. +curl -sSL https://install.python-poetry.org | python3 - +poetry install