Skip to content
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

Create XRT Windows SDK when base-dev component is built #8733

Merged
merged 8 commits into from
Feb 1, 2025
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
20 changes: 16 additions & 4 deletions build/build-win22.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ BUILDDIR=$(readlink -f $(dirname ${BASH_SOURCE[0]}))
CORE=`grep -c ^processor /proc/cpuinfo`

CMAKE="/mnt/c/Program Files/CMake/bin/cmake.exe"
CPACK="/mnt/c/Program Files/CMake/bin/cpack.exe"
EXT_DIR=/mnt/c/Xilinx/xrt/ext.new
BOOST=$EXT_DIR
KHRONOS=$EXT_DIR
Expand All @@ -28,6 +29,7 @@ usage()
echo "[-j <n>] Compile parallel (default: system cores)"
echo "[-dbg] Build debug library (default: optimized)"
echo "[-all] Build debug and optimized library (default: optimized)"
echo "[-sdk] Create NSIS XRT SDK NPU Installer (requires NSIS installed)."

exit 1
}
Expand All @@ -38,6 +40,7 @@ nocmake=0
noabi=0
dbg=0
release=1
sdk=0
alveo_build=0
npu_build=0
base_build=0
Expand Down Expand Up @@ -110,6 +113,12 @@ while [ $# -gt 0 ]; do
cmake_flags+=" -DDISABLE_ABI_CHECK=1"
shift
;;
-sdk)
shift
npu_build=1
cmake_flags+=" -DXRT_NPU=1"
sdk=1
;;
*)
echo "unknown option '$1'"
usage
Expand Down Expand Up @@ -139,17 +148,15 @@ cmake_flags+=" -DMSVC_PARALLEL_JOBS=$jcore"
cmake_flags+=" -DKHRONOS=$KHRONOS"
cmake_flags+=" -DBOOST_ROOT=$BOOST"

echo "${cmake_flags[@]}"

if [ $dbg == 1 ]; then
cmake_flags+=" -DCMAKE_BUILD_TYPE=Debug"
mkdir -p WDebug
cd WDebug

if [ $nocmake == 0 ]; then
echo "${cmake_flags[@]}"
"$CMAKE" -G "Visual Studio 17 2022" $cmake_flags ../../src
fi
"$CMAKE" --build . --verbose --config Debug
"$CMAKE" --build . --verbose --config Debug --target install
cd $BUILDDIR
fi
Expand All @@ -159,10 +166,15 @@ if [ $release == 1 ]; then
mkdir -p WRelease
cd WRelease
if [ $nocmake == 0 ]; then
echo "${cmake_flags[@]}"
"$CMAKE" -G "Visual Studio 17 2022" $cmake_flags ../../src
fi
"$CMAKE" --build . --verbose --config Release
"$CMAKE" --build . --verbose --config Release --target install

if [[ $sdk == 1 && $npu_build == 1 ]]; then
echo "Creating SDK installer ..."
"$CPACK" -G NSIS -C Release
fi
cd $BUILDDIR
fi

Expand Down
30 changes: 18 additions & 12 deletions build/build22.bat
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ set DEBUG=1
set RELEASE=1
set EXT_DIR=C:/Xilinx/XRT/ext.new
set CREATE_PACKAGE=0
set CREATE_SDK=0
set CMAKEFLAGS=
set NOCMAKE=0
set NOCTEST=0
Expand Down Expand Up @@ -39,6 +40,16 @@ IF DEFINED MSVC_PARALLEL_JOBS ( SET LOCAL_MSVC_PARALLEL_JOBS=%MSVC_PARALLEL_JOBS
if [%1] == [-opt] (
set DEBUG=0
) else (
if [%1] == [-npu] (
set CMAKEFLAGS=%CMAKEFLAGS% -DXRT_NPU=1
) else (
if [%1] == [-noabi] (
set CMAKEFLAGS=%CMAKEFLAGS% -DDISABLE_ABI_CHECK=1
) else (
if [%1] == [-sdk] (
set CREATE_SDK=1
set CMAKEFLAGS=%CMAKEFLAGS% -DXRT_NPU=1
) else (
if [%1] == [-pkg] (
set CREATE_PACKAGE=1
) else (
Expand Down Expand Up @@ -66,7 +77,7 @@ IF DEFINED MSVC_PARALLEL_JOBS ( SET LOCAL_MSVC_PARALLEL_JOBS=%MSVC_PARALLEL_JOBS
) else (
echo Unknown option: %1
goto Help
)))))))))))))
))))))))))))))))
shift
goto parseArgs

Expand Down Expand Up @@ -95,13 +106,16 @@ ECHO.
ECHO [-help] - List this help
ECHO [-clean] - Remove build directories
ECHO [-dbg] - Creates a debug build
ECHO [-noabi] - Do not compile with ABI version check (make incremental builds faster)
ECHO [-opt] - Creates a release build
ECHO [-sdk] - Create NSIS XRT SDK Installer for NPU (requires NSIS installed).
echo [-package] - Packages the release build to a MSI archive.
ECHO Note: Depends on the WIX application.
ECHO [-xclmgmt arg] - The directory to the xclmgmt drivers (used with [-package])
ECHO [-xocluser arg] - The directory to the xocluser drivers (used with [-package])
ECHO [-xclmgmt2 arg] - The directory to the xclmgmt2 drivers (used with [-package])
ECHO [-xocluser2 arg] - The directory to the xocluser2 drivers (used with [-package])
ECHO [-npu] - Build NPU component of XRT (deployment and development)
ECHO [-hip] - Enable hip library build
GOTO:EOF

Expand Down Expand Up @@ -133,9 +147,6 @@ if [%NOCMAKE%] == [0] (
IF errorlevel 1 (POPD & exit /B %errorlevel%)
)

cmake --build . --verbose --config Debug
IF errorlevel 1 (POPD & exit /B %errorlevel%)

cmake --build . --verbose --config Debug --target install
IF errorlevel 1 (POPD & exit /B %errorlevel%)

Expand Down Expand Up @@ -177,21 +188,16 @@ if [%NOCMAKE%] == [0] (
IF errorlevel 1 (POPD & exit /B %errorlevel%)
)

cmake --build . --verbose --config Release
IF errorlevel 1 (POPD & exit /B %errorlevel%)

cmake --build . --verbose --config Release --target install
IF errorlevel 1 (POPD & exit /B %errorlevel%)

ECHO ====================== Zipping up Installation Build ============================
cpack -G ZIP -C Release

if [%CREATE_PACKAGE%] == [1] (
ECHO ====================== Creating MSI Archive ============================
cpack -G WIX -C Release
if [%CREATE_SDK%] == [1] (
ECHO ====================== Creating SDK Installer ============================
cpack -G NSIS -C Release
)

popd
GOTO:EOF


33 changes: 14 additions & 19 deletions src/CMake/components.cmake
Original file line number Diff line number Diff line change
@@ -1,33 +1,28 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.

# Custom variables imported by this CMake stub which should be defined by parent CMake:
# LINUX_FLAVOR

if (NOT WIN32)
if (${LINUX_FLAVOR} MATCHES "^(ubuntu|debian)")
set (XRT_DEV_COMPONENT_SUFFIX "dev")
elseif (${LINUX_FLAVOR} MATCHES "^(rhel|centos|fedora)")
set (XRT_DEV_COMPONENT_SUFFIX "devel")
endif()
else()
set(LINUX_FLAVOR "none")
endif()
# Custom variables imported by this CMake stub which should be defined
# by parent CMake: LINUX_FLAVOR

# The default XRT build is legacy
if (NOT XRT_BASE AND NOT XRT_NPU AND NOT XRT_ALVEO)
message("-- Defaulting to legacy XRT build")
set(XRT_XRT 1)
endif()

if (NOT WIN32 AND ${LINUX_FLAVOR} MATCHES "^(ubuntu|debian|rhel|centos)")
if (NOT WIN32)
if (${LINUX_FLAVOR} MATCHES "^(ubuntu|debian)")
set (XRT_DEV_COMPONENT_SUFFIX "dev")
elseif (${LINUX_FLAVOR} MATCHES "^(rhel|centos)")
set (XRT_DEV_COMPONENT_SUFFIX "devel")
set (XRT_DEV_COMPONENT_SUFFIX "-dev")
elseif (${LINUX_FLAVOR} MATCHES "^(rhel|centos|fedora)")
set (XRT_DEV_COMPONENT_SUFFIX "-devel")
endif()
endif()

# NSIS packager cannot handle '-' in component names
if (WIN32)
set (XRT_DEV_COMPONENT_SUFFIX "_dev")
endif()

# Enable development package by specifying development component name
# If XRT_{PKG}_DEV_COMPONENT is same XRT_{PKG}_COMPONENT then only
# that package is created with both development and run-time content.
Expand Down Expand Up @@ -71,7 +66,7 @@ if (XRT_BASE)
# been explicitly marked for base
set (CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "base")
set (XRT_BASE_COMPONENT "base")
set (XRT_BASE_DEV_COMPONENT "base-${XRT_DEV_COMPONENT_SUFFIX}")
set (XRT_BASE_DEV_COMPONENT "base${XRT_DEV_COMPONENT_SUFFIX}")

# Tempoary fix for cpackLin conditionally adding dependencies for
# legacy XRT when XRT_DEV_COMPONENT equals "xrt". We don't want the
Expand All @@ -88,9 +83,9 @@ if (XRT_NPU)
# been explicitly marked alveo or npu
set (CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "npu")
set (XRT_COMPONENT "npu")
set (XRT_DEV_COMPONENT "npu-${XRT_DEV_COMPONENT_SUFFIX}")
set (XRT_DEV_COMPONENT "npu${XRT_DEV_COMPONENT_SUFFIX}")
set (XRT_BASE_COMPONENT "base")
set (XRT_BASE_DEV_COMPONENT "base-${XRT_DEV_COMPONENT_SUFFIX}")
set (XRT_BASE_DEV_COMPONENT "base${XRT_DEV_COMPONENT_SUFFIX}")
endif(XRT_NPU)

# Alveo builds one Alveo package for both deployment and development
Expand Down
44 changes: 44 additions & 0 deletions src/CMake/cpack-windows-sdk.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved.
cmake_minimum_required(VERSION 3.20)

set(CPACK_PACKAGE_VENDOR "Advanced Micro Devices, Inc.")
set(CPACK_PACKAGE_CONTACT "[email protected]")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "XDNA RunTime stack for use with AMD FPGA and NPU platforms")

set(CPACK_PACKAGE_NAME "XRT SDK")
set(CPACK_PACKAGE_VERSION_RELEASE "${XRT_VERSION_RELEASE}")
set(CPACK_PACKAGE_VERSION "${XRT_VERSION_MAJOR}.${XRT_VERSION_MINOR}.${XRT_VERSION_PATCH}")
set(CPACK_PACKAGE_VERSION_MAJOR "${XRT_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${XRT_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${XRT_VERSION_PATCH}")
set(CPACK_REL_VER "windows")
set(CPACK_ARCH "x86_64")

set(CPACK_ARCHIVE_COMPONENT_INSTALL 1)
set(CPACK_PACKAGE_FILE_NAME "xrtsdk-${CPACK_PACKAGE_VERSION}-${CPACK_REL_VER}-${CPACK_ARCH}")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/../LICENSE")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "XRT")
set(CPACK_NSIS_PACKAGE_NAME "XRT SDK ${CPACK_PACKAGE_VERSION}")
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
set(CPACK_NSIS_MENU_LINKS "")

# Initialize CPACK_COMPONENTS_ALL variable to just the SDK
# component, which is base-dev
set(CPACK_COMPONENTS_ALL "base_dev")
set(CPACK_ARCHIVE_FILE_NAME ${CPACK_PACKAGE_FILE_NAME})

message("-- ${CMAKE_BUILD_TYPE} ${PACKAGE_KIND} package")

include(CPack)

cpack_add_component(base_dev
DISPLAY_NAME "XRT SDK"
DESCRIPTION "XRT software development kit with header files and link libraries for application development."
GROUP Development
)

cpack_add_component_group(Development
EXPANDED
DESCRIPTION "XRT Software Development Kits"
)
12 changes: 9 additions & 3 deletions src/CMake/nativeWin.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ file(GLOB XRT_EULA
install (FILES ${XRT_SOURCE_DIR}/../LICENSE DESTINATION ${XRT_INSTALL_DIR}/license)
message("-- XRT EA eula files ${XRT_SOURCE_DIR}/../LICENSE")

# -- CPack
include(CMake/cpackWin.cmake)

# --- Create Version header and JSON file ---
include(CMake/version.cmake)

Expand All @@ -98,3 +95,12 @@ include(CMake/findpackage.cmake)

# --- Python bindings ---
xrt_add_subdirectory(python)

# -- CPack windows SDK if base component
if (${XRT_BASE_DEV_COMPONENT} STREQUAL "base_dev")
include(CMake/cpack-windows-sdk.cmake)
else()
# Legacy
include(CMake/cpackWin.cmake)
endif()

10 changes: 8 additions & 2 deletions src/runtime_src/core/tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ if (${XRT_BOOST_VERSION} VERSION_LESS 1.64.0)
endif()

xrt_add_subdirectory(xbutil2)
xrt_add_subdirectory(xbtracer)
xrt_add_subdirectory(xbreplay)
if(CMAKE_VERSION VERSION_LESS "3.18.0")
# CPackDeb.cmake does not support -l{dir} which is required
# when packaging plugin library libxrt_capture.so
message(WARNING "CMake version is less than 3.18.0, build of xbtracer/xbreplay disabled")
else()
xrt_add_subdirectory(xbtracer)
xrt_add_subdirectory(xbreplay)
endif()
if (${XRT_NATIVE_BUILD} STREQUAL "yes")
xrt_add_subdirectory(xbmgmt2)
if(NOT WIN32)
Expand Down
5 changes: 2 additions & 3 deletions src/runtime_src/core/tools/xbtracer/src/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ else()
target_link_libraries(xrt_capture PRIVATE xrt_coreutil uuid dl pthread)
endif()

# xrt_capture is a plug-in runtime loaded library
# it does not have a library or namelink component
install(TARGETS xrt_capture
EXPORT xrt-targets
RUNTIME DESTINATION ${XRT_INSTALL_BIN_DIR} COMPONENT ${XRT_BASE_COMPONENT}
LIBRARY DESTINATION ${XRT_INSTALL_LIB_DIR} COMPONENT ${XRT_BASE_COMPONENT} NAMELINK_COMPONENT ${XRT_BASE_DEV_COMPONENT}
ARCHIVE DESTINATION ${XRT_INSTALL_LIB_DIR} COMPONENT ${XRT_BASE_DEV_COMPONENT}
)
Loading