Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .github/workflows/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: since we're not using the multi-config genreator, do we need --config? Also, this is a debug build

Suggested change
cmake --install build --prefix build/install_artifact --config Release
cmake --install build --prefix build/install_artifact

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to be updated according to #679

- 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
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update github action pinned version.

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/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: since you downloaded build/package_linux, do you need to mkdir?

Suggested change
mkdir -p build/package_linux/

touch build/package_linux/dive_android_is_prebuilt
bash scripts/package_linux.sh
Comment on lines +502 to +503
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional: consider making dive_android_is_prebuilt an option for package_linux.sh so that it's more obvious to callers about the behavior they're going to get. It also lets the caller more easily choose behavior

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
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -354,3 +361,5 @@ if(NOT ANDROID)
)
endif()
endif()

add_subdirectory(packaging)
35 changes: 35 additions & 0 deletions packaging/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefer TODO with bugs so that future readers have more context

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()
7 changes: 7 additions & 0 deletions packaging/extras-example/extras/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Dive Packaging Extra artifacts

Extra artifacts can be bundled with CMake build:

```shell
cmake ... -DDIVE_INSTALL_EXTRAS=${EXTRA_ARTIFACT_ROOT}
```
28 changes: 28 additions & 0 deletions packaging/linux/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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 <dive-dev-team@google.com>"
)
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)
1 change: 1 addition & 0 deletions scripts/format_cmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ SRC_DIRS=(
"layer"
"lrz_validator"
"network"
"packaging"
"plugins"
"runtime_layer"
"trace_stats"
Expand Down
59 changes: 59 additions & 0 deletions scripts/package_linux.sh
Original file line number Diff line number Diff line change
@@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: set -u will halt for undefined variables. This can catch if e.g. ANDROID_NDK_HOME is not set

Suggested change
set -ex
set -eux


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" \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Given that the generator is Ninja, I don't think we need to explicitly set the make program as well

Suggested change
-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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: is -j necessary with ninja? I think "all the jobs!" is the ninja default

Also since we're not using a multi-config generator, do we need --config?

Suggested change
cmake --build . --config=Debug -j
cmake --build .

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
Comment on lines +50 to +51
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we're not using the multi-config generator, do we need --config?

Suggested change
cmake --build . --config Release
cmake --install . --prefix ../dive_linux --config Release
cmake --build .
cmake --install . --prefix ../dive_linux

cpack -G DEB
popd

pushd "${DIVE_BUILD_ROOT}/package_linux"
cp host/*.deb .
dpkg -I *.deb
dpkg -c *.deb
popd