Skip to content

Commit

Permalink
Merge pull request #672 from rradjabi/aws-pegasus-build
Browse files Browse the repository at this point in the history
AWS Pegasus RPM build and AWS-F1 Developer Flow support
  • Loading branch information
sonals authored Nov 15, 2018
2 parents a656ee8 + 41c42e0 commit 512252e
Show file tree
Hide file tree
Showing 15 changed files with 260 additions and 45 deletions.
21 changes: 17 additions & 4 deletions build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,18 @@

set -e

OSDIST=`lsb_release -i |awk -F: '{print tolower($2)}' | tr -d ' \t'`
BUILDDIR=$(readlink -f $(dirname ${BASH_SOURCE[0]}))
CORE=`grep -c ^processor /proc/cpuinfo`
CMAKE=cmake

if [[ $OSDIST == "centos" ]]; then
CMAKE=cmake3
if [[ ! -x "$(command -v $CMAKE)" ]]; then
echo "$CMAKE is not installed, please run xrtdeps.sh"
exit 1
fi
fi

usage()
{
Expand Down Expand Up @@ -103,20 +113,23 @@ if [[ $covbuild == 1 ]]; then
fi
mkdir -p Coverity
cd Coverity
cmake -DCMAKE_BUILD_TYPE=Release ../../src
make -j $CORE COVUSER=$covuser COVPW=$covpw DATE="`git rev-parse --short HEAD`" coverity
$CMAKE -DCMAKE_BUILD_TYPE=Release ../../src
make COVUSER=$covuser COVPW=$covpw DATE="`git rev-parse --short HEAD`" coverity
cd $here
exit 0
fi

mkdir -p Debug Release
cd Debug
time cmake -DRDI_CCACHE=$ccache -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ../../src
echo "$CMAKE -DRDI_CCACHE=$ccache -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ../../src"
time $CMAKE -DRDI_CCACHE=$ccache -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ../../src
time make -j $jcore $verbose DESTDIR=$PWD install
cd $BUILDDIR

cd Release
time cmake -DRDI_CCACHE=$ccache -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ../../src
echo "$CMAKE -DRDI_CCACHE=$ccache -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ../../src"
time $CMAKE -DRDI_CCACHE=$ccache -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ../../src
time make -j $jcore $verbose DESTDIR=$PWD install
#time make xrtpkg
time make package
cd $here
8 changes: 8 additions & 0 deletions src/CMake/config/dkms-awsmgmt/dkms.conf.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
PACKAGE_NAME="xrt-awsmgmt"
PACKAGE_VERSION="@XRT_VERSION_STRING@"
MAKE[0]="cd driver/aws/kernel/mgmt; make; cd ../../../.."
CLEAN="cd driver/aws/kernel/mgmt; make clean; cd ../../../.."
BUILT_MODULE_NAME[0]="awsmgmt"
BUILT_MODULE_LOCATION[0]="driver/aws/kernel/mgmt"
DEST_MODULE_LOCATION[0]="/kernel/extras"
AUTOINSTALL="yes"
File renamed without changes.
34 changes: 34 additions & 0 deletions src/CMake/config/postinst-aws.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/sh

if [ -n "`dkms status -m xrt-aws -v @XRT_VERSION_STRING@`" ]; then
echo "Unloading old XRT Linux kernel modules"
modprobe -r awsmgmt

echo "Unregistering old XRT Linux kernel module sources @XRT_VERSION_STRING@ from dkms"
dkms remove -m xrt-aws -v @XRT_VERSION_STRING@ --all
find /lib/modules -type f -name awsmgmt.ko -delete
find /lib/modules -type f -name awsmgmt.ko.kz -delete
depmod -A
fi

if [ -z "`dkms status -m xrt-aws -v @XRT_VERSION_STRING@`" ]; then
echo "Registering new XRT Linux kernel module sources @XRT_VERSION_STRING@ with dkms"
dkms add -m xrt-aws -v "@XRT_VERSION_STRING@"
fi

if [ -e /lib/modules/`uname -r`/build/include ]; then
echo "Building XRT Linux kernel modules sources with dkms"
dkms build -m xrt-aws -v "@XRT_VERSION_STRING@"
echo "Installing XRT Linux kernel modules sources with dkms"
dkms install -m xrt-aws -v "@XRT_VERSION_STRING@" --force
install -m 644 /usr/src/xrt-aws-@XRT_VERSION_STRING@/driver/aws/kernel/mgmt/10-awsmgmt.rules /etc/udev/rules.d

echo "Loading new XRT Linux kernel modules"
udevadm control --reload-rules
modprobe awsmgmt
udevadm trigger
else
echo "Build/Install of XRT Linux kernel modules skipped since Linux kernel headers are not installed"
fi

exit 0
14 changes: 14 additions & 0 deletions src/CMake/config/prerm-aws.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

echo "Unloading old XRT Linux kernel modules"
modprobe -r awsmgmt

echo "Unregistering XRT Linux kernel module sources @XRT_VERSION_STRING@ from dkms"
dkms remove -m xrt-aws -v @XRT_VERSION_STRING@ --all
find /lib/modules -type f -name awsmgmt.ko -delete
find /lib/modules -type f -name awsmgmt.ko.kz -delete
depmod -A

rm -f /etc/udev/rules.d/10-awsmgmt.rules

exit 0
11 changes: 11 additions & 0 deletions src/CMake/config/xrt-aws.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
prefix=@XRT_INSTALL_DIR@
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include

Name: libxrt-aws
Description: Xilinx AWS HAL Library
Version: 2.1.0
Requires: xrt >= 2.1.0
Libs: -L${libdir} -lxrt-aws
Cflags: -I${includedir}
35 changes: 33 additions & 2 deletions src/CMake/cpack.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ SET(CPACK_PACKAGE_VERSION_MINOR "${XRT_VERSION_MINOR}")
SET(CPACK_PACKAGE_VERSION_PATCH "${XRT_VERSION_PATCH}")
SET(CPACK_PACKAGE_NAME "xrt")

SET(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
SET(CPACK_DEB_COMPONENT_INSTALL ON)
SET(CPACK_RPM_COMPONENT_INSTALL ON)

execute_process(
COMMAND lsb_release -r -s
OUTPUT_VARIABLE CPACK_REL_VER
Expand All @@ -21,16 +25,34 @@ SET(PACKAGE_KIND "TGZ")
if (${LINUX_FLAVOR} STREQUAL Ubuntu)
SET(CPACK_GENERATOR "DEB;TGZ")
SET(PACKAGE_KIND "DEB")
# Modify the package name for the xrt component
# Syntax is set(CPACK_<GENERATOR>_<COMPONENT>_PACKAGE_NAME "<name">)
SET(CPACK_DEBIAN_XRT_PACKAGE_NAME "xrt")

SET(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_BINARY_DIR}/postinst;${CMAKE_CURRENT_BINARY_DIR}/prerm")
SET(CPACK_DEBIAN_AWS_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_BINARY_DIR}/postinst-aws;${CMAKE_CURRENT_BINARY_DIR}/prerm-aws")
SET(CPACK_DEBIAN_PACKAGE_SHLIBDEPS "OFF")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "ocl-icd-opencl-dev (>= 2.2.0), libboost-dev (>=1.58), libboost-filesystem-dev (>=1.58), uuid-dev (>= 2.27.1), dkms (>= 2.2.0), libprotoc-dev (>=2.6.1), protobuf-compiler (>=2.6.1), libncurses5-dev (>=6.0), lsb-release, libxml2-dev (>=2.9.1), libyaml-dev (>= 0.1.6)")
# aws component dependencies
SET(CPACK_DEBIAN_AWS_PACKAGE_DEPENDS "xrt (>= ${XRT_VERSION_MAJOR}.${XRT_VERSION_MINOR}.${XRT_VERSION_PATCH})")
# xrt component dependencies
SET(CPACK_DEBIAN_XRT_PACKAGE_DEPENDS "ocl-icd-opencl-dev (>= 2.2.0), libboost-dev (>=1.58), libboost-filesystem-dev (>=1.58), uuid-dev (>= 2.27.1), dkms (>= 2.2.0), libprotoc-dev (>=2.6.1), protobuf-compiler (>=2.6.1), libncurses5-dev (>=6.0), lsb-release, libxml2-dev (>=2.9.1), libyaml-dev (>= 0.1.6)")

elseif (${LINUX_FLAVOR} MATCHES "^(RedHat|CentOS)")
SET(CPACK_GENERATOR "RPM;TGZ")
SET(PACKAGE_KIND "RPM")
# Modify the package name for the xrt component
# Syntax is set(CPACK_<GENERATOR>_<COMPONENT>_PACKAGE_NAME "<name">)
set(CPACK_RPM_XRT_PACKAGE_NAME "xrt")

SET(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/postinst")
SET(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/prerm")
SET(CPACK_RPM_AWS_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/postinst-aws")
SET(CPACK_RPM_AWS_PRE_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/prerm-aws")
SET(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/usr/local" "/usr/src" "/opt" "/etc/OpenCL" "/etc/OpenCL/vendors" "/usr/lib" "/usr/lib/pkgconfig" "/usr/lib64/pkgconfig")
set(CPACK_RPM_PACKAGE_REQUIRES "ocl-icd-devel >= 2.2, boost-devel >= 1.53, boost-filesystem >= 1.53, libuuid-devel >= 2.23.2, dkms >= 2.5.0, protobuf-devel >= 2.5.0, protobuf-compiler >= 2.5.0, ncurses-devel >= 5.9, redhat-lsb-core, libxml2-devel >= 2.9.1, libyaml-devel >= 0.1.4 ")
# aws component dependencies
SET(CPACK_RPM_AWS_PACKAGE_REQUIRES "xrt >= ${XRT_VERSION_MAJOR}.${XRT_VERSION_MINOR}.${XRT_VERSION_PATCH}")
# xrt component dependencies
SET(CPACK_RPM_XRT_PACKAGE_REQUIRES "ocl-icd-devel >= 2.2, boost-devel >= 1.53, boost-filesystem >= 1.53, libuuid-devel >= 2.23.2, dkms >= 2.5.0, protobuf-devel >= 2.5.0, protobuf-compiler >= 2.5.0, ncurses-devel >= 5.9, redhat-lsb-core, libxml2-devel >= 2.9.1, libyaml-devel >= 0.1.4 ")
else ()
SET (CPACK_GENERATOR "TGZ")
endif()
Expand All @@ -44,4 +66,13 @@ SET(CPACK_PACKAGE_CONTACT "[email protected]")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Xilinx RunTime stack for use with Xilinx FPGA platforms")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/../LICENSE")

add_custom_target(xrtpkg
echo "COMMAND ${CMAKE_CPACK_COMMAND}"
COMMAND ${CMAKE_CPACK_COMMAND}
COMMAND -mv -f ${CPACK_PACKAGE_FILE_NAME}-xrt.deb ${CPACK_PACKAGE_FILE_NAME}.deb 2> /dev/null
COMMAND -mv -f ${CPACK_PACKAGE_FILE_NAME}-xrt.rpm ${CPACK_PACKAGE_FILE_NAME}.rpm 2> /dev/null
COMMAND -mv -f ${CPACK_PACKAGE_FILE_NAME}-xrt.tar.gz ${CPACK_PACKAGE_FILE_NAME}.tar.gz 2> /dev/null

)

INCLUDE(CPack)
59 changes: 59 additions & 0 deletions src/CMake/dkms-aws.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Custom variables imported by this CMake stub which should be defined by parent CMake:
# XRT_DKMS_DRIVER_SRC_BASE_DIR

set(XRT_DKMS_INSTALL_DIR_aws "/usr/src/xrt-aws-${XRT_VERSION_STRING}")

message("-- XRT DRIVER SRC BASE DIR ${XRT_DKMS_DRIVER_SRC_BASE_DIR}")

set(DKMS_FILE_NAME "dkms.conf")
set(DKMS_POSTINST "postinst-aws")
set(DKMS_PRERM "prerm-aws")

configure_file(
"${CMAKE_SOURCE_DIR}/CMake/config/dkms-awsmgmt/${DKMS_FILE_NAME}.in"
"dkms-awsmgmt/${DKMS_FILE_NAME}"
)

configure_file(
"${CMAKE_SOURCE_DIR}/CMake/config/${DKMS_POSTINST}.in"
"${DKMS_POSTINST}"
)

configure_file(
"${CMAKE_SOURCE_DIR}/CMake/config/${DKMS_PRERM}.in"
"${DKMS_PRERM}"
)

set(XRT_DKMS_SRCS_aws
driver/aws/kernel/mgmt/mgmt-bit.c
driver/aws/kernel/mgmt/mgmt-bit.h
driver/aws/kernel/mgmt/mgmt-core.c
driver/aws/kernel/mgmt/mgmt-core.h
driver/aws/kernel/mgmt/mgmt-cw.c
driver/aws/kernel/mgmt/mgmt-cw.h
driver/aws/kernel/mgmt/mgmt-firewall.c
driver/aws/kernel/mgmt/mgmt-sysfs.c
driver/aws/kernel/mgmt/mgmt-thread.c
driver/aws/kernel/mgmt/10-awsmgmt.rules
driver/aws/kernel/mgmt/Makefile
driver/xclng/include/xocl_ioctl.h
driver/xclng/include/mgmt-reg.h
driver/xclng/include/mgmt-ioctl.h
driver/xclng/include/qdma_ioctl.h
driver/xclng/include/devices.h
driver/include/ert.h
driver/include/xclfeatures.h
driver/include/xclbin.h
driver/include/xclerr.h
)

set(XRT_DKMS_ABS_SRCS_aws)

foreach(DKMS_FILE ${XRT_DKMS_SRCS_aws})
get_filename_component(DKMS_DIR ${DKMS_FILE} DIRECTORY)
install(FILES ${XRT_DKMS_DRIVER_SRC_BASE_DIR}/${DKMS_FILE} DESTINATION ${XRT_DKMS_INSTALL_DIR_aws}/${DKMS_DIR} COMPONENT aws)
list(APPEND XRT_DKMS_ABS_SRCS_aws ${XRT_DKMS_DRIVER_SRC_BASE_DIR}/${DKMS_FILE})
endforeach()

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/dkms-awsmgmt/${DKMS_FILE_NAME} DESTINATION ${XRT_DKMS_INSTALL_DIR_aws} COMPONENT aws)

2 changes: 1 addition & 1 deletion src/CMake/dkms.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SET (DKMS_POSTINST "postinst")
SET (DKMS_PRERM "prerm")

configure_file (
"${CMAKE_SOURCE_DIR}/CMake/config/${DKMS_FILE_NAME}.in"
"${CMAKE_SOURCE_DIR}/CMake/config/dkms-xocl/${DKMS_FILE_NAME}.in"
${DKMS_FILE_NAME}
)

Expand Down
62 changes: 46 additions & 16 deletions src/CMake/pkgconfig.cmake
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
SET (PKG_CONFIG_FILE_NAME "xrt.pc")

message("-- Preparing XRT pkg-config ${PKG_CONFIG_FILE_NAME}")

configure_file (
"${CMAKE_SOURCE_DIR}/CMake/config/${PKG_CONFIG_FILE_NAME}.in"
${PKG_CONFIG_FILE_NAME}
@ONLY
)
message("-- Preparing XRT pkg-config")

if (${LINUX_FLAVOR} STREQUAL Ubuntu)
set(XRT_PKG_CONFIG_DIR "/usr/lib/pkgconfig")
Expand All @@ -16,12 +8,50 @@ else ()
set(XRT_PKG_CONFIG_DIR "/usr/share/pkgconfig")
endif ()

install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${PKG_CONFIG_FILE_NAME} DESTINATION ${XRT_PKG_CONFIG_DIR})
configure_file (
${CMAKE_SOURCE_DIR}/CMake/config/xrt.pc.in
xrt.pc
@ONLY
)
install (
FILES
${CMAKE_CURRENT_BINARY_DIR}/xrt.pc
DESTINATION
${XRT_PKG_CONFIG_DIR}
)

configure_file (
${CMAKE_SOURCE_DIR}/CMake/config/xrt-aws.pc.in
xrt-aws.pc
@ONLY
)
install (
FILES
${CMAKE_CURRENT_BINARY_DIR}/xrt-aws.pc
DESTINATION
${XRT_PKG_CONFIG_DIR}
)

configure_file(${CMAKE_SOURCE_DIR}/CMake/config/libxmaapi.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libxmaapi.pc @ONLY)
#install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libxmaapi.pc DESTINATION ${XMA_INSTALL_DIR}/lib/pkgconfig)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libxmaapi.pc DESTINATION ${XRT_PKG_CONFIG_DIR})
configure_file (
${CMAKE_SOURCE_DIR}/CMake/config/libxmaapi.pc.in
${CMAKE_CURRENT_BINARY_DIR}/libxmaapi.pc
@ONLY
)
install (
FILES
${CMAKE_CURRENT_BINARY_DIR}/libxmaapi.pc
DESTINATION
${XRT_PKG_CONFIG_DIR}
)

configure_file(${CMAKE_SOURCE_DIR}/CMake/config/libxmaplugin.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libxmaplugin.pc @ONLY)
#install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libxmaplugin.pc DESTINATION ${XMA_INSTALL_DIR}/lib/pkgconfig)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libxmaplugin.pc DESTINATION ${XRT_PKG_CONFIG_DIR})
configure_file (
${CMAKE_SOURCE_DIR}/CMake/config/libxmaplugin.pc.in
${CMAKE_CURRENT_BINARY_DIR}/libxmaplugin.pc
@ONLY
)
install (
FILES
${CMAKE_CURRENT_BINARY_DIR}/libxmaplugin.pc
DESTINATION
${XRT_PKG_CONFIG_DIR}
)
8 changes: 6 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PROJECT(XRT)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11)
CMAKE_MINIMUM_REQUIRED(VERSION 3.0.0)

SET(PROJECT_DESCRIPTION "https://github.com/Xilinx/XRT")

Expand Down Expand Up @@ -78,6 +78,9 @@ if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
endif()
set (CMAKE_INSTALL_PREFIX "/opt/xilinx")

# Default component name for any install() command without the COMPONENT argument
set (CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "xrt")

set (XRT_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set (XRT_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/xrt")

Expand Down Expand Up @@ -132,15 +135,16 @@ set(XMA_SOVERSION ${XRT_SOVERSION})
add_subdirectory(xma)
#XMA settings END


message("-- XRT version: ${XRT_VERSION_STRING}")

include (CMake/cpack.cmake)

include (CMake/lint.cmake)

set (XRT_DKMS_DRIVER_SRC_BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/runtime_src")

include (CMake/dkms.cmake)
include (CMake/dkms-aws.cmake)

include (CMake/icd.cmake)

Expand Down
6 changes: 3 additions & 3 deletions src/runtime_src/driver/xclng/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Set INTERNAL_TESTING variable by setting the shell environment
# variable "AWS_F1_TARGET" when invoking build.sh or cmake. If it
# is not defined, default to INTERNAL_TESTING = 1.
if( $ENV{AWS_F1_TARGET} )
if( $ENV{AWS_FPGA_REPO_DIR} )
set(INTERNAL_TESTING 0)
else()
set(INTERNAL_TESTING 1) #AWS_INTERNAL_TESTING
set(INTERNAL_TESTING 1)
endif()

add_subdirectory(xrt)
add_subdirectory(tools/xbflash)
add_subdirectory(tools/xbutil)
add_subdirectory(tools/awssak)

5 changes: 4 additions & 1 deletion src/runtime_src/driver/xclng/tools/awssak/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ else()
)
endif()

install (TARGETS awssak RUNTIME DESTINATION ${XRT_INSTALL_DIR}/bin)
install(TARGETS awssak
RUNTIME
DESTINATION ${XRT_INSTALL_DIR}/bin
COMPONENT aws)

endif (NOT ${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm")
Loading

0 comments on commit 512252e

Please sign in to comment.