Skip to content
Merged
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
3 changes: 2 additions & 1 deletion .github/workflows/build_linux_packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ jobs:
amdgpu_families: ${{ inputs.amdgpu_families }}
package_version: ${{ inputs.package_version }}
extra_cmake_options: ${{ inputs.extra_cmake_options }}
BUILD_DIR: build
run: |
python3 build_tools/github_actions/build_linux_configure.py
python3 build_tools/github_actions/build_configure.py

- name: Build therock-dist
run: cmake --build build --target therock-dist
Expand Down
47 changes: 15 additions & 32 deletions .github/workflows/build_windows_packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ on:
default: gfx110X-dgpu
extra_cmake_options:
type: string
default: "-DBUILD_TESTING=ON"

workflow_call:
inputs:
Expand All @@ -22,7 +21,6 @@ on:
type: string
extra_cmake_options:
type: string
default: "-DBUILD_TESTING=ON"

permissions:
contents: read
Expand Down Expand Up @@ -54,7 +52,7 @@ jobs:
mkdir "$buildDir"
Write-Host "Generated Build Directory: $buildDir"
$bashBuildDir = $buildDir -replace '\\', '/' -replace '^B:', '/b'
echo "BUILD_DIR_BASH=$bashBuildDir" >> $env:GITHUB_ENV
echo "BUILD_DIR=$bashBuildDir" >> $env:GITHUB_ENV
Write-Host "Converted Build Directory For Bash: $bashBuildDir"
$fs = Get-PSDrive -PSProvider "FileSystem"
$fsout = $fs | Select-Object -Property Name,Used,Free,Root
Expand Down Expand Up @@ -134,48 +132,33 @@ jobs:
lfs: true

- name: Configure Projects
env:
amdgpu_families: ${{ inputs.amdgpu_families }}
package_version: ${{ inputs.package_version }}
extra_cmake_options: ${{ inputs.extra_cmake_options }}
run: |
# clear cache before build and after download
ccache -z

# Generate a new build id.
package_version="${{ inputs.package_version }}"
amdgpu_families="${{ inputs.amdgpu_families }}"
extra_cmake_options="${{ inputs.extra_cmake_options }}"
echo "Building package ${package_version}"

# Build.
cmake -B "${{ env.BUILD_DIR_BASH }}" -GNinja . \
-DCMAKE_C_COMPILER="${{ env.VCToolsInstallDir }}/bin/Hostx64/x64/cl.exe" \
-DCMAKE_CXX_COMPILER="${{ env.VCToolsInstallDir }}/bin/Hostx64/x64/cl.exe" \
-DCMAKE_LINKER="${{ env.VCToolsInstallDir }}/bin/Hostx64/x64/link.exe" \
-DTHEROCK_BACKGROUND_BUILD_JOBS=4 \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded \
-DTHEROCK_AMDGPU_FAMILIES=${amdgpu_families} \
-DTHEROCK_PACKAGE_VERSION="${package_version}" \
-DTHEROCK_AMDGPU_WINDOWS_INTEROP_DIR=${GITHUB_WORKSPACE}/amdgpu-windows-interop \
${extra_cmake_options}
python3 build_tools/github_actions/build_configure.py

- name: Build therock-dist
run: cmake --build "${{ env.BUILD_DIR_BASH }}" --target therock-dist
run: cmake --build "${{ env.BUILD_DIR }}" --target therock-dist

- name: Build therock-archives
run: cmake --build "${{ env.BUILD_DIR_BASH }}" --target therock-archives
run: cmake --build "${{ env.BUILD_DIR }}" --target therock-archives

- name: Report
if: ${{ !cancelled() }}
run: |
echo "Build dir:"
echo "------------"
ls -lh "${{ env.BUILD_DIR_BASH }}"
ls -lh "${{ env.BUILD_DIR }}"
echo "Artifact Archives:"
echo "------------------"
ls -lh "${{ env.BUILD_DIR_BASH }}"/artifacts/*.tar.xz
ls -lh "${{ env.BUILD_DIR }}"/artifacts/*.tar.xz
echo "Artifacts:"
echo "----------"
du -h -d 1 "${{ env.BUILD_DIR_BASH }}"/artifacts
du -h -d 1 "${{ env.BUILD_DIR }}"/artifacts
echo "CCache Stats:"
echo "-------------"
ccache -s
Expand All @@ -200,7 +183,7 @@ jobs:
if: always()
run: |
python3 build_tools/github_actions/create_log_index.py \
--build-dir=${{ env.BUILD_DIR_BASH }} \
--build-dir=${{ env.BUILD_DIR }} \
--amdgpu-family=${{ env.AMDGPU_FAMILIES }}

- name: Upload artifacts
Expand All @@ -209,13 +192,13 @@ jobs:
python build_tools/github_actions/upload_build_artifacts.py \
--run-id ${{ github.run_id }} \
--amdgpu-family ${{ env.AMDGPU_FAMILIES }} \
--build-dir ${{ env.BUILD_DIR_BASH }}
--build-dir ${{ env.BUILD_DIR }}

- name: Upload Logs
if: always()
run: |
python3 build_tools/github_actions/upload_build_logs_to_s3.py \
--build-dir=${{ env.BUILD_DIR_BASH }} \
--build-dir=${{ env.BUILD_DIR }} \
--run-id ${{ github.run_id }} \
--amdgpu-family ${{ env.AMDGPU_FAMILIES }}

Expand All @@ -225,7 +208,7 @@ jobs:
python build_tools/github_actions/upload_build_summary.py \
--run-id ${{ github.run_id }} \
--amdgpu-family ${{ env.AMDGPU_FAMILIES }} \
--build-dir ${{ env.BUILD_DIR_BASH }}
--build-dir ${{ env.BUILD_DIR }}

- name: Save cache
uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
Expand Down
81 changes: 81 additions & 0 deletions build_tools/github_actions/build_configure.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
"""
This script runs the Linux build configuration

Required environment variables:
- amdgpu_families
- package_version
- extra_cmake_options
"""
Comment on lines +1 to +8
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please update this docstring (works on both Windows and Linux, then document which env vars are required on each platform)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

unfortunate. let me update this in the next PR


import logging
import os
from pathlib import Path
import platform
import shlex
import subprocess

logging.basicConfig(level=logging.INFO)
THIS_SCRIPT_DIR = Path(__file__).resolve().parent
THEROCK_DIR = THIS_SCRIPT_DIR.parent.parent

PLATFORM = platform.system().lower()

amdgpu_families = os.getenv("amdgpu_families")
package_version = os.getenv("package_version")
extra_cmake_options = os.getenv("extra_cmake_options")
build_dir = os.getenv("BUILD_DIR")
vctools_install_dir = os.getenv("VCToolsInstallDir")
github_workspace = os.getenv("GITHUB_WORKSPACE")

platform_options = {
"windows": [
f"-DCMAKE_C_COMPILER={vctools_install_dir}/bin/Hostx64/x64/cl.exe",
f"-DCMAKE_CXX_COMPILER={vctools_install_dir}/bin/Hostx64/x64/cl.exe",
f"-DCMAKE_LINKER={vctools_install_dir}/bin/Hostx64/x64/link.exe",
"-DTHEROCK_BACKGROUND_BUILD_JOBS=4",
],
}


def build_configure():
logging.info(f"Building package {package_version}")

cmd = [
"cmake",
"-B",
build_dir,
"-GNinja",
".",
f"-DTHEROCK_AMDGPU_FAMILIES={amdgpu_families}",
f"-DTHEROCK_PACKAGE_VERSION='{package_version}'",
"-DCMAKE_C_COMPILER_LAUNCHER=ccache",
"-DCMAKE_CXX_COMPILER_LAUNCHER=ccache",
"-DTHEROCK_VERBOSE=ON",
"-DBUILD_TESTING=ON",
]

# Adding platform specific options
cmd += platform_options.get(PLATFORM, [])

if PLATFORM == "windows":
# VCToolsInstallDir is required for build. Throwing an error if environment variable doesn't exist
if not vctools_install_dir:
raise Exception(
"Environment variable VCToolsInstallDir is not set. Please see https://github.com/ROCm/TheRock/blob/main/docs/development/windows_support.md#important-tool-settings about Windows tool configurations. Exiting."
)

if os.path.isdir(f"{github_workspace}/amdgpu-windows-interop"):
cmd.append(
f"-DTHEROCK_AMDGPU_WINDOWS_INTEROP_DIR={github_workspace}/amdgpu-windows-interop"
)

# Splitting cmake options into an array (ex: "-flag X" -> ["-flag", "X"]) for subprocess.run
cmake_options_arr = extra_cmake_options.split()
cmd += cmake_options_arr

logging.info(shlex.join(cmd))
subprocess.run(cmd, cwd=THEROCK_DIR, check=True)


if __name__ == "__main__":
build_configure()
49 changes: 0 additions & 49 deletions build_tools/github_actions/build_linux_configure.py

This file was deleted.

Loading