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
11 changes: 5 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.24")
cmake_policy(SET CMP0135 NEW)
endif()

set(STACK_VERSION 1.6.0 CACHE STRING "Main project version")
set(STACK_VERSION 1.8.0 CACHE STRING "Main project version")
project(npu-linux-driver VERSION ${STACK_VERSION})

set(BUILD_NUMBER "dev-0" CACHE STRING "Build number composed of name and unique number used as driver version")
Expand All @@ -34,12 +34,11 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

option(ENABLE_OPENVINO_PACKAGE "Enable building the OpenVINO + VPUX Plugin package" OFF)
option(ENABLE_VPUX_COMPILER_BUILD "Enable building compiler in driver" OFF)
option(ENABLE_VPUX_COMPILER_CACHE "Enable downloading compiler in driver" ON)
option(ENABLE_OPENVINO_PACKAGE "Enable building the OpenVINO + NPU Plugin package" OFF)
option(ENABLE_NPU_COMPILER_BUILD "Enable building compiler in driver" OFF)

message(STATUS "option ENABLE_OPENVINO_PACKAGE: ${ENABLE_OPENVINO_PACKAGE}")
message(STATUS "option ENABLE_VPUX_COMPILER_BUILD: ${ENABLE_VPUX_COMPILER_BUILD}")
message(STATUS "option ENABLE_NPU_COMPILER_BUILD: ${ENABLE_NPU_COMPILER_BUILD}")

include(GNUInstallDirs)

Expand All @@ -53,7 +52,7 @@ add_subdirectory(third_party)
add_subdirectory(umd)
add_subdirectory(validation)

include(cmake/packages.cmake)
include(cmake/packaging/setup.cmake)

# You may your custom commands in .local.cmake, i.e. driver compilation, running tests.
include(${CMAKE_CURRENT_SOURCE_DIR}/.local.cmake OPTIONAL)
2 changes: 1 addition & 1 deletion cmake/compiler_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ add_compile_options(
-fdebug-prefix-map=${CMAKE_SOURCE_DIR}=.
)

if(NOT ${LINUX_SYSTEM_NAME} STREQUAL "cros sdk")
if(NOT ${LINUX_SYSTEM_NAME} STREQUAL "cros_sdk")
add_compile_options(
# Enable macro security features
-D_FORTIFY_SOURCE=2
Expand Down
4 changes: 2 additions & 2 deletions cmake/detect_linux_system.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022-2023 Intel Corporation.
# Copyright 2022-2024 Intel Corporation.
#
# This software and the related documents are Intel copyrighted materials, and
# your use of them is governed by the express license under which they were
Expand Down Expand Up @@ -29,5 +29,5 @@ function(read_os_release ENTRY VAR_OUTPUT)
set(${VAR_OUTPUT} ${OUTPUT} PARENT_SCOPE)
endfunction()

read_os_release(NAME LINUX_SYSTEM_NAME)
read_os_release(ID LINUX_SYSTEM_NAME)
read_os_release(VERSION_ID LINUX_SYSTEM_VERSION_ID)
84 changes: 0 additions & 84 deletions cmake/packages.cmake

This file was deleted.

54 changes: 54 additions & 0 deletions cmake/packaging/generators/deb.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#
# Copyright (C) 2024 Intel Corporation
#
# SPDX-License-Identifier: MIT

find_program(DPKG_EXECUTABLE dpkg REQUIRED)

include(${CPACK_PROJECT_CONFIG_FILE})

set(CPACK_GENERATOR DEB)

# Create package per component
set(CPACK_DEB_COMPONENT_INSTALL ON)

# Enable detection of component dependencies
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
list(APPEND SHLIBDEPS_PRIVATE_DIRS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
list(APPEND SHLIBDEPS_PRIVATE_DIRS ${OPENVINO_LIBRARY_DIR})
list(APPEND SHLIBDEPS_PRIVATE_DIRS ${OPENCV_LIBRARY_DIR})
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS_PRIVATE_DIRS ${SHLIBDEPS_PRIVATE_DIRS})

# Component conflicts
set(CPACK_DEBIAN_LEVEL-ZERO_PACKAGE_CONFLICTS "level-zero, level-zero-devel")

# Get Debian architecture
execute_process(
COMMAND ${DPKG_EXECUTABLE} --print-architecture
OUTPUT_VARIABLE OUT_DPKG_ARCH
OUTPUT_STRIP_TRAILING_WHITESPACE
COMMAND_ERROR_IS_FATAL ANY)

set(PACKAGE_POSTFIX_NAME ${CPACK_PACKAGE_VERSION}_${LINUX_SYSTEM_NAME}${LINUX_SYSTEM_VERSION_ID}_${OUT_DPKG_ARCH}.deb)
foreach(COMPONENT ${CPACK_COMPONENTS_ALL})
string(TOUPPER ${COMPONENT} COMPONENT_UPPER)
set(CPACK_DEBIAN_${COMPONENT_UPPER}_FILE_NAME ${CPACK_PACKAGE_NAME}-${COMPONENT}_${PACKAGE_POSTFIX_NAME})
if (${COMPONENT_UPPER}_POSTINST)
list(APPEND CPACK_DEBIAN_${COMPONENT_UPPER}_PACKAGE_CONTROL_EXTRA ${${COMPONENT_UPPER}_POSTINST})
endif()
if (${COMPONENT_UPPER}_PRERM)
list(APPEND CPACK_DEBIAN_${COMPONENT_UPPER}_PACKAGE_CONTROL_EXTRA ${${COMPONENT_UPPER}_PRERM})
endif()
if (${COMPONENT_UPPER}_POSTRM)
list(APPEND CPACK_DEBIAN_${COMPONENT_UPPER}_PACKAGE_CONTROL_EXTRA ${${COMPONENT_UPPER}_POSTRM})
endif()
if (${COMPONENT_UPPER}_DEPENDS)
set(CPACK_DEBIAN_${COMPONENT_UPPER}_PACKAGE_DEPENDS ${${COMPONENT_UPPER}_DEPENDS})
endif()
endforeach()

set(CPACK_DEBIAN_DEBUGINFO_PACKAGE OFF)
set(CPACK_DEBIAN_LEVEL-ZERO_DEBUGINFO_PACKAGE ON)
set(CPACK_DEBIAN_LEVEL-ZERO-NPU_DEBUGINFO_PACKAGE ON)
set(CPACK_DEBIAN_DRIVER-COMPILER-NPU_DEBUGINFO_PACKAGE ON)
set(CPACK_DEBIAN_VALIDATION-NPU_DEBUGINFO_PACKAGE ON)
12 changes: 12 additions & 0 deletions cmake/packaging/generators/ebuild.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#
# Copyright (C) 2024 Intel Corporation
#
# SPDX-License-Identifier: MIT


find_program(EBUILD_EXECUTABLE ebuild REQUIRED)

set(CPACK_GENERATOR External)
set(CPACK_SET_DESTDIR ON)
set(CPACK_EXTERNAL_ENABLE_STAGING ON)
set(CPACK_EXTERNAL_PACKAGE_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/ebuild_package_script.cmake)
106 changes: 106 additions & 0 deletions cmake/packaging/generators/ebuild_package_script.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#
# Copyright (C) 2024 Intel Corporation
#
# SPDX-License-Identifier: MIT
#


function(strip_script SCRIPT_FILENAME OUTPUT_CONTENT)
# Remove comments, empty lines or lines like 'set -e..'
execute_process(COMMAND
sh -c "sed -e '/^#/d' -e '/^$/d' -e '/set -/d' ${SCRIPT_FILENAME}"
OUTPUT_VARIABLE TMP_OUTPUT_CONTENT
COMMAND_ERROR_IS_FATAL ANY)
set(${OUTPUT_CONTENT} ${TMP_OUTPUT_CONTENT} PARENT_SCOPE)
endfunction()


find_program(EBUILD_EXECUTABLE ebuild REQUIRED)

string(REPLACE "-" "." PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}")

set(PACKAGES_DESTINATION "${CPACK_PACKAGE_DIRECTORY}/packages")
set(REPO_NAME "intel-npu")
set(CATEGORY_NAME "intel-npu-drivers")

foreach(COMPONENT IN LISTS CPACK_COMPONENTS_ALL)
string(TOUPPER ${COMPONENT} COMPONENT_UPPER)
set(PACKAGE_NAME "${CPACK_PACKAGE_NAME}-${COMPONENT}")
set(PACKAGE_DATA "${CPACK_TEMPORARY_DIRECTORY}/${COMPONENT}")
set(PACKAGE_METADATA_DIR "${CPACK_TEMPORARY_DIRECTORY}/${REPO_NAME}/${CATEGORY_NAME}/${PACKAGE_NAME}")
set(PACKAGE_DESCRIPTION "${CPACK_COMPONENT_${COMPONENT_UPPER}_DESCRIPTION}")

file(MAKE_DIRECTORY "${PACKAGE_METADATA_DIR}")

set(EBUILD_FILE "${PACKAGE_METADATA_DIR}/${PACKAGE_NAME}-${PACKAGE_VERSION}.ebuild")

file(WRITE "${EBUILD_FILE}"
"EAPI=7\n"
"DESCRIPTION=\"${PACKAGE_DESCRIPTION}\"\n"
"SLOT=\"0\"\n"
"KEYWORDS=\"~amd64\"\n"
"S=\"${PACKAGE_DATA}\"\n")

if (${COMPONENT_UPPER}_DEPENDS)
file(APPEND "${EBUILD_FILE}"
"RDEPENDS=\"${${COMPONENT_UPPER}_DEPENDS}\"\n")
endif()

file(APPEND "${EBUILD_FILE}"
"\n"
"src_install() {\n"
" mkdir -p \${D}\n"
" cp -r \${S}/* \${D}\n"
"}\n")

if (${COMPONENT_UPPER}_POSTINST)
strip_script(${${COMPONENT_UPPER}_POSTINST} POSTINST)
file(APPEND "${EBUILD_FILE}"
"\n"
"pkg_postinst() {\n"
"${POSTINST}"
"}\n")
endif()

if (${COMPONENT_UPPER}_PRERM)
strip_script(${${COMPONENT_UPPER}_PRERM} PRERM)
file(APPEND "${EBUILD_FILE}"
"\n"
"pkg_prerm() {\n"
"${PRERM}"
"}\n")
endif()

if (${COMPONENT_UPPER}_POSTRM)
strip_script(${${COMPONENT_UPPER}_POSTRM} POSTRM)
file(APPEND "${EBUILD_FILE}"
"\n"
"pkg_postrm() {\n"
"${POSTRM}"
"}\n")
endif()

# Generate manifest
execute_process(COMMAND
${EBUILD_EXECUTABLE} ${EBUILD_FILE} manifest
COMMAND_ERROR_IS_FATAL ANY)

# Create temporary dir for portage
set(PORTAGE_TMPDIR "${CPACK_TEMPORARY_DIRECTORY}/portage_tmpdir")
file(MAKE_DIRECTORY "${PORTAGE_TMPDIR}")

if (${COMPONENT} IN_LIST EXTERNAL_COMPONENTS)
set(COMPONENT_TYPE "external")
else()
set(COMPONENT_TYPE "internal")
endif()

set(PKGDIR "${PACKAGES_DESTINATION}/${COMPONENT_TYPE}")
file(MAKE_DIRECTORY "${PKGDIR}")

# Create package
set(ENV_VARS "BINPKG_COMPRESS=zstd PORTAGE_USERNAME=$(id -un) PORTAGE_GRPNAME=$(id -gn) PORTAGE_TMPDIR=${PORTAGE_TMPDIR} PKGDIR=${PKGDIR}")
execute_process(COMMAND
sh -c "${ENV_VARS} ${EBUILD_EXECUTABLE} ${EBUILD_FILE} package"
COMMAND_ERROR_IS_FATAL ANY)
endforeach()
2 changes: 1 addition & 1 deletion cmake/packaging/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

set -e -o pipefail

if lsmod | grep intel_vpu > /dev/null; then
if lsmod | grep intel_vpu > /dev/null && [ -e "$(modinfo -n intel_vpu 2> /dev/null)" ]; then
rmmod intel_vpu
modprobe intel_vpu
fi
49 changes: 49 additions & 0 deletions cmake/packaging/setup.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#
# Copyright (C) 2022-2024 Intel Corporation
#
# SPDX-License-Identifier: MIT
#


if(${CMAKE_VERSION} VERSION_LESS "3.20")
# Using older version stucks on detecting the package dependencies
message(STATUS "CPack Debian in driver is not supported by cmake version less than 3.20.1")
return()
endif()

# Base information
set(CPACK_PACKAGE_NAME "intel")
set(CPACK_PACKAGE_VENDOR "Intel")
set(CPACK_PACKAGE_CONTACT "Intel Corporation")
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}.${BUILD_NUMBER})
set(CPACK_PROJECT_CONFIG_FILE ${CMAKE_BINARY_DIR}/CPackProjectConfigFile.cmake)

# Component descriptions
set(CPACK_COMPONENT_DRIVER-COMPILER-NPU_DESCRIPTION "Intel(R) Driver Compiler for NPU hardware\n\
The driver compiler enables compilation of OpenVINO IR models using Level Zero Graph Extension API.")
set(CPACK_COMPONENT_FW-NPU_DESCRIPTION "Intel(R) Firmware package for NPU hardware\n\
Firmware files required by IVPU kernel module.")
set(CPACK_COMPONENT_LEVEL-ZERO-NPU_DESCRIPTION "Intel(R) Level Zero Driver for NPU hardware\n\
Library implements Level Zero API to interract with NPU hardware.")
set(CPACK_COMPONENT_VALIDATION-NPU_DESCRIPTION "Intel(R) Validation applications for NPU\n\
Set of application required for testing of Intel(R) Level Zero Driver for NPU hardware.")

file(WRITE ${CPACK_PROJECT_CONFIG_FILE}
"set(FW-NPU_POSTINST ${CMAKE_CURRENT_LIST_DIR}/postinst)\n"
"set(EXTERNAL_COMPONENTS driver-compiler-npu;fw-npu;level-zero-npu)\n")

# Component list
get_cmake_property(CPACK_COMPONENTS_ALL COMPONENTS)
list(REMOVE_ITEM CPACK_COMPONENTS_ALL level-zero-devel)
list(REMOVE_ITEM CPACK_COMPONENTS_ALL openvino_standalone_package)

if (EXISTS "/etc/debian_version")
set(PACKAGE_TYPE "deb")
elseif(EXISTS "/etc/portage")
set(PACKAGE_TYPE "ebuild")
else()
message(FATAL_ERROR "Unable to detect package type for this system")
endif()

include(${CMAKE_CURRENT_LIST_DIR}/generators/${PACKAGE_TYPE}.cmake)
include(CPack)
4 changes: 2 additions & 2 deletions compiler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
# or implied warranties, other than those that are expressly stated in
# the License.

include(openvino_package.cmake)
include(vpux_compiler.cmake)
include(openvino.cmake)
include(npu_compiler.cmake)
Loading