Skip to content

Commit

Permalink
cmake: fix and update packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
dagar committed Jan 19, 2023
1 parent 5eb13e4 commit 2b57227
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 52 deletions.
8 changes: 4 additions & 4 deletions .ci/Jenkinsfile-compile
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ pipeline {
script {
def build_nodes = [:]
def docker_images = [
armhf: "px4io/px4-dev-armhf:2021-09-08",
arm64: "px4io/px4-dev-aarch64:2021-09-08",
base: "px4io/px4-dev-base-bionic:2021-09-08",
nuttx: "px4io/px4-dev-nuttx-focal:2021-09-08",
armhf: "px4io/px4-dev-armhf:2022-08-12",
arm64: "px4io/px4-dev-aarch64:2022-08-12",
base: "px4io/px4-dev-ros2-foxy:2022-08-12",
nuttx: "px4io/px4-dev-nuttx-focal:2022-08-12",
]

def armhf_builds = [
Expand Down
19 changes: 18 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,21 @@ execute_process(
OUTPUT_STRIP_TRAILING_WHITESPACE
WORKING_DIRECTORY ${PX4_SOURCE_DIR}
)
message(STATUS "PX4 version: ${PX4_GIT_TAG}")

# git describe to X.Y.Z version
string(REPLACE "." ";" VERSION_LIST ${PX4_GIT_TAG})

# major version
list(GET VERSION_LIST 0 PX4_VERSION_MAJOR)
string(REPLACE "v" "" PX4_VERSION_MAJOR ${PX4_VERSION_MAJOR})
# minor version
list(GET VERSION_LIST 1 PX4_VERSION_MINOR)
# patch version
list(GET VERSION_LIST 2 PX4_VERSION_PATCH)
string(REPLACE "-" ";" PX4_VERSION_PATCH ${PX4_VERSION_PATCH})
list(GET PX4_VERSION_PATCH 0 PX4_VERSION_PATCH)

message(STATUS "PX4 version: ${PX4_GIT_TAG} (${PX4_VERSION_MAJOR}.${PX4_VERSION_MINOR}.${PX4_VERSION_PATCH})")

define_property(GLOBAL PROPERTY PX4_MODULE_LIBRARIES
BRIEF_DOCS "PX4 module libs"
Expand Down Expand Up @@ -456,6 +470,9 @@ add_custom_command(OUTPUT ${uorb_graph_config}
add_custom_target(uorb_graph DEPENDS ${uorb_graph_config})


include(bloaty)


include(doxygen)
include(metadata)
include(package)
Expand Down
22 changes: 12 additions & 10 deletions cmake/bloaty.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
############################################################################

find_program(BLOATY_PROGRAM bloaty)
if (BLOATY_PROGRAM)
if(BLOATY_PROGRAM)

set(BLOATY_OPTS --demangle=full --domain=vm -s vm -n 200 -w)

Expand Down Expand Up @@ -78,13 +78,15 @@ if (BLOATY_PROGRAM)
USES_TERMINAL
)

# bloaty compare with last master build
add_custom_target(bloaty_compare_master
COMMAND wget --continue --no-verbose https://s3.amazonaws.com/px4-travis/Firmware/master/${PX4_BOARD_VENDOR}_${PX4_BOARD_MODEL}_${PX4_BOARD_LABEL}.elf -O master.elf
COMMAND ${BLOATY_PROGRAM} -d symbols ${BLOATY_OPTS} $<TARGET_FILE:px4> -- master.elf
DEPENDS px4
WORKING_DIRECTORY ${PX4_BINARY_DIR}
VERBATIM
USES_TERMINAL
)
if(${PX4_PLATFORM} MATCHES "nuttx")
# bloaty compare with last master build
add_custom_target(bloaty_compare_master
COMMAND wget --continue --no-verbose https://s3.amazonaws.com/px4-travis/Firmware/master/${PX4_BOARD_VENDOR}_${PX4_BOARD_MODEL}_${PX4_BOARD_LABEL}.elf -O master.elf
COMMAND ${BLOATY_PROGRAM} -d symbols ${BLOATY_OPTS} $<TARGET_FILE:px4> -- master.elf
DEPENDS px4
WORKING_DIRECTORY ${PX4_BINARY_DIR}
VERBATIM
USES_TERMINAL
)
endif()
endif()
65 changes: 51 additions & 14 deletions cmake/package.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,30 +34,67 @@
# packaging

set(CPACK_PACKAGE_NAME ${PROJECT_NAME}-${PX4_CONFIG})
set(CPACK_PACKAGE_VERSION ${PX4_GIT_TAG})
set(CPACK_PACKAGE_CONTACT ${package-contact})
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS OFF) # TODO: review packaging for linux boards
set(CPACK_DEBIAN_PACKAGE_SECTION "devel")
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "The PX4 Pro autopilot.")

set(CPACK_PACKAGE_VENDOR "px4")

set(CPACK_PACKAGE_VERSION_MAJOR ${PX4_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PX4_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PX4_VERSION_PATCH})
#set(CPACK_PACKAGE_VERSION ${PX4_GIT_TAG})

set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PX4_CONFIG}-${PX4_GIT_TAG}")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PX4_GIT_TAG}")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PX4_CONFIG}-${PX4_GIT_TAG}-src")

set(CPACK_PACKAGE_CONTACT "[email protected]")

set(CPACK_RESOURCE_FILE_LICENSE "${PX4_SOURCE_DIR}/LICENSE")
set(CPACK_RESOURCE_FILE_README "${PX4_SOURCE_DIR}/README.md")

set(CPACK_COMPONENTS_GROUPING ALL_COMPONENTS_IN_ONE)#ONE_PER_GROUP)
# without this you won't be able to pack only specified component
set(CPACK_DEB_COMPONENT_INSTALL YES)

#set(CPACK_STRIP_FILES YES)

set(CPACK_SOURCE_GENERATOR "ZIP;TBZ2")
set(CPACK_PACKAGING_INSTALL_PREFIX "")
set(CPACK_SET_DESTDIR "OFF")

if ("${CMAKE_SYSTEM}" MATCHES "Linux")
if("${CMAKE_SYSTEM}" MATCHES "Linux")
set(CPACK_GENERATOR "TBZ2")

find_program(DPKG_PROGRAM dpkg)
if (EXISTS ${DPKG_PROGRAM})
list (APPEND CPACK_GENERATOR "DEB")
if(EXISTS ${DPKG_PROGRAM})
list(APPEND CPACK_GENERATOR "DEB")

set(CPACK_SET_DESTDIR true)
set(CPACK_PACKAGING_INSTALL_PREFIX "/tmp")

execute_process(COMMAND ${DPKG_PROGRAM} --print-architecture OUTPUT_VARIABLE DEB_ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE)
message("Architecture: " ${DEB_ARCHITECTURE})
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}_${DEB_ARCHITECTURE}")

set(CPACK_INSTALL_PREFIX @DEB_INSTALL_PREFIX@)
message ("==> CPACK_INSTALL_PREFIX = " ${CPACK_INSTALL_PREFIX})

################################################################################

set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Daniel Agar <${CPACK_PACKAGE_CONTACT}>")
set(CPACK_DEBIAN_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION})
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)

set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "PX4 autopilot")
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
set(CPACK_DEBIAN_PACKAGE_SECTION "misc")
set(CPACK_DEBIAN_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR})

# autogenerate dependency information
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
set(CPACK_DEBIAN_COMPRESSION_TYPE xz)

endif()
else()
set(CPACK_GENERATOR "ZIP")
endif()

include(CPack)

if(${PX4_PLATFORM} MATCHES "nuttx")
include(bloaty)
endif()
26 changes: 3 additions & 23 deletions platforms/posix/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -182,31 +182,11 @@ elseif("${PX4_BOARD}" MATCHES "sitl")
${PROJECT_NAME}/build/px4_sitl_default
)

# sitl_gazebo-classic built plugins
# gazebo dirs
install(
DIRECTORY
${PX4_BINARY_DIR}/build_gazebo-classic
DESTINATION
${PROJECT_NAME}/build/px4_sitl_default
FILES_MATCHING
PATTERN "CMakeFiles" EXCLUDE
PATTERN "*.so"
)

# sitl_gazebo-classic dirs
install(
DIRECTORY
${PROJECT_SOURCE_DIR}/Tools/simulation/gazebo-classic/sitl_gazebo-classic/models
${PROJECT_SOURCE_DIR}/Tools/simulation/gazebo-classic/sitl_gazebo-classic/worlds
DESTINATION
${PROJECT_NAME}/Tools/simulation/gazebo-classic/sitl_gazebo-classic
)

# sitl_gazebo-classic files
install(
FILES
${PROJECT_SOURCE_DIR}/Tools/simulation/gazebo-classic/sitl_gazebo-classic/CMakeLists.txt
${PROJECT_SOURCE_DIR}/Tools/simulation/gazebo-classic/sitl_gazebo-classic/package.xml
${PROJECT_SOURCE_DIR}/Tools/simulation/gz/models
${PROJECT_SOURCE_DIR}/Tools/simulation/gz/worlds
DESTINATION
${PROJECT_NAME}/Tools/simulation/gazebo-classic/sitl_gazebo-classic
)
Expand Down

0 comments on commit 2b57227

Please sign in to comment.