diff --git a/.github/workflows/presubmit.yml b/.github/workflows/presubmit.yml index f6535171b..749f6de06 100644 --- a/.github/workflows/presubmit.yml +++ b/.github/workflows/presubmit.yml @@ -452,3 +452,62 @@ jobs: - name: Ninja log run: | cat build/.ninja_log + - name: Produce install artifacts + run: | + cmake --install build --prefix build/install_artifact --config Release + - name: Upload test output + uses: actions/upload-artifact@v6 + with: + name: install_artifact_android + path: | + build/install_artifact + + build_dpkg: + name: "Build Debian Package" + runs-on: ubuntu-24.04 + needs: build_Android_from_Linux_Debug + steps: + - name: Set up Java 17 + uses: actions/setup-java@v3 + id: setup-java + with: + java-version: '17' + distribution: 'temurin' + - name: Check out code + uses: actions/checkout@v3 + with: + submodules: recursive + - name: Install Dependencies + run: | + sudo apt-get update --yes + # Build Dependencies + sudo apt-get install --yes cmake ninja-build clang-19 python3-mako + # Dive Dependencies + sudo apt-get install --yes qtbase5-dev libarchive-dev libtinfo-dev + - uses: nttld/setup-ndk@v1 + id: setup-ndk + with: + ndk-version: r25 + add-to-path: true + - name: Download Android Artifacts + uses: actions/download-artifact@v5 + with: + name: install_artifact_android + path: build/package_linux/dive_android + - name: Android Artifacts + run: ls -R build/package_linux/dive_android + - name: Build + run: | + mkdir -p build/package_linux/ + touch build/package_linux/dive_android_is_prebuilt + bash scripts/package_linux.sh + env: + ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} + JAVA_HOME: ${{ steps.setup-java.outputs.java-home }} + - name: Upload debian package + uses: actions/upload-artifact@v4 + with: + name: package_linux + path: | + build/package_linux/dive_linux/ + build/package_linux/*.deb diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a52dd7e1..a963c4d3e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,6 +46,13 @@ option(DIVE_BUILD_WITH_SANITIZER "Build Dive with sanitizers" OFF) set(DIVE_INSTALL_DESTINATION ".") set(DIVE_PLUGINS_INSTALL_DESTINATION "plugins") +set(DIVE_ANDROID_PREBUILT "" CACHE STRING "Prebuilt Dive Android binaries") +set(DIVE_INSTALL_EXTRAS + "" + CACHE STRING + "Extra files to include with dive build" +) + # Disable gtest for install set(INSTALL_GTEST OFF) @@ -354,3 +361,5 @@ if(NOT ANDROID) ) endif() endif() + +add_subdirectory(packaging) diff --git a/packaging/CMakeLists.txt b/packaging/CMakeLists.txt new file mode 100644 index 000000000..1c42a1681 --- /dev/null +++ b/packaging/CMakeLists.txt @@ -0,0 +1,35 @@ +# +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +if(EXISTS "${DIVE_ANDROID_PREBUILT}") + install( + DIRECTORY "${DIVE_ANDROID_PREBUILT}/" + # TODO: fix device resources location. + DESTINATION "${DIVE_INSTALL_DESTINATION}/install" + ) +endif() + +# Extra resources, e.g. private plugins +if(EXISTS "${DIVE_INSTALL_EXTRAS}") + install( + DIRECTORY "${DIVE_INSTALL_EXTRAS}/" + DESTINATION "${DIVE_INSTALL_DESTINATION}/" + ) +endif() + +if(CMAKE_HOST_LINUX) + add_subdirectory(linux) +endif() diff --git a/packaging/extras-example/extras/README.md b/packaging/extras-example/extras/README.md new file mode 100644 index 000000000..4f4d67a67 --- /dev/null +++ b/packaging/extras-example/extras/README.md @@ -0,0 +1,7 @@ +# Dive Packaging Extra artifacts + +Extra artifacts can be bundled with CMake build: + +```shell +cmake ... -DDIVE_INSTALL_EXTRAS=${EXTRA_ARTIFACT_ROOT} +``` diff --git a/packaging/linux/CMakeLists.txt b/packaging/linux/CMakeLists.txt new file mode 100644 index 000000000..7b75628f8 --- /dev/null +++ b/packaging/linux/CMakeLists.txt @@ -0,0 +1,28 @@ +# +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +set(CPACK_DEBIAN_PACKAGE_NAME "dive-profiler") +set(CPACK_DEBIAN_PACKAGE_MAINTAINER + "Dive Profiler Developers " +) +set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "Dive is a GPU Profiler.") +set(CPACK_DEBIAN_PACKAGE_SECTION "devel") +set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional") +set(CPACK_DEBIAN_PACKAGE_DEPENDS "") +set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) +set(CPACK_PACKAGING_INSTALL_PREFIX "/opt/dive-profiler") + +include(CPack) diff --git a/scripts/format_cmake.sh b/scripts/format_cmake.sh index 7c7f9b616..7822de54b 100755 --- a/scripts/format_cmake.sh +++ b/scripts/format_cmake.sh @@ -27,6 +27,7 @@ SRC_DIRS=( "layer" "lrz_validator" "network" + "packaging" "plugins" "runtime_layer" "trace_stats" diff --git a/scripts/package_linux.sh b/scripts/package_linux.sh new file mode 100644 index 000000000..4d28c2eee --- /dev/null +++ b/scripts/package_linux.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -ex + +readonly DIVE_ROOT="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )/.." &> /dev/null && pwd )" +readonly DIVE_BUILD_ROOT="${DIVE_BUILD_ROOT:-build}" +mkdir -p "${DIVE_BUILD_ROOT}/package_linux/device" +mkdir -p "${DIVE_BUILD_ROOT}/package_linux/host" + +if [ ! -e "${DIVE_BUILD_ROOT}/package_linux/dive_android_is_prebuilt" ]; then + pushd "${DIVE_BUILD_ROOT}/package_linux/device" + cmake -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake \ + -G "Ninja" \ + -DCMAKE_MAKE_PROGRAM="ninja" \ + -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_SYSTEM_NAME=Android \ + -DANDROID_ABI=arm64-v8a \ + -DANDROID_PLATFORM=android-26 \ + -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=NEVER \ + -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=NEVER \ + -DDIVE_GFXR_GRADLE_CONSOLE=plain \ + ${DIVE_ROOT} + cmake --build . --config=Debug -j + cmake --install . --prefix ../dive_android + popd +fi + +pushd "${DIVE_BUILD_ROOT}/package_linux/host" + cmake -G "Ninja" \ + -DCMAKE_BUILD_TYPE=Release \ + -DDIVE_ANDROID_PREBUILT="`pwd`/../dive_android" \ + -DDIVE_INSTALL_EXTRAS="${DIVE_ROOT}/packaging/extras-example" \ + -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/clang-19 \ + -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/clang++-19 \ + ${DIVE_ROOT} + cmake --build . --config Release + cmake --install . --prefix ../dive_linux --config Release + cpack -G DEB +popd + +pushd "${DIVE_BUILD_ROOT}/package_linux" + cp host/*.deb . + dpkg -I *.deb + dpkg -c *.deb +popd