diff --git a/.github/workflows/appstream_parser.yaml b/.github/workflows/appstream_parser.yaml new file mode 100644 index 0000000..a13fc75 --- /dev/null +++ b/.github/workflows/appstream_parser.yaml @@ -0,0 +1,66 @@ +name: appstream-parser + +on: + pull_request: + types: [ opened, synchronize, reopened, closed ] + release: + types: [ published, created, edited ] + workflow_dispatch: + +jobs: + + appstream-parser: + + env: + VERSION: 0.0.1 + + strategy: + matrix: + os: [ ubuntu-20.04, ubuntu-22.04, ubuntu-24.04 ] + + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + persist-credentials: false + fetch-depth: 1 + + - name: Install packages + run: | + sudo apt-get update + sudo apt-get -y install libflatpak-dev libxml2-dev zlib1g-dev flatpak + echo "flatpak list" + flatpak list + + - name: Configure Debug + run: | + mkdir -p ${{github.workspace}}/build/debug + cmake ${{github.workspace}} -B ${{github.workspace}}/build/debug + + - name: Build Debug + working-directory: ${{github.workspace}}/build/debug + run: | + rm -rf _packages || true + make package -j + ls -la _packages + + - name: Configure Release + run: | + mkdir -p ${{github.workspace}}/build/release + cmake ${{github.workspace}} -B ${{github.workspace}}/build/release + + - name: Build Release Package + working-directory: ${{github.workspace}}/build/release + run: | + rm -rf _packages || true + make package -j + ls -la _packages + echo "Release Info" + ls -la appstream_parser + echo "Strip executable" + strip appstream_parser + ls -la appstream_parser + echo "List Dependencies" + ldd appstream_parser diff --git a/CMakeLists.txt b/CMakeLists.txt index e2966a8..58691bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,17 @@ cmake_minimum_required(VERSION 3.14) -project(appstream_sax) + +if (NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug, Release, RelWithDebInfo, or MinSizeRel." FORCE) + message(STATUS "CMAKE_BUILD_TYPE not set, defaulting to Release.") +endif () + +list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) + +project(appstream_parser + VERSION 0.0.1 + DESCRIPTION "Appstream Parser" + LANGUAGES CXX +) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -24,4 +36,11 @@ FetchContent_Declare( FetchContent_MakeAvailable(spdlog) -target_link_libraries(${PROJECT_NAME} PRIVATE spdlog::spdlog LibXml2::LibXml2) \ No newline at end of file +target_link_libraries(${PROJECT_NAME} PRIVATE spdlog::spdlog LibXml2::LibXml2) + +# +# Packaging +# +if (NOT CMAKE_CROSSCOMPILING) + include(packaging) +endif () diff --git a/cmake/packaging.cmake b/cmake/packaging.cmake new file mode 100644 index 0000000..89e6195 --- /dev/null +++ b/cmake/packaging.cmake @@ -0,0 +1,61 @@ +# +# Copyright 2020 Toyota Connected North America +# Copyright 2024 Joel Winarske +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +set(CPACK_GENERATOR "TGZ;RPM;DEB") + +if (${CMAKE_BUILD_TYPE} STREQUAL "Debug") + set(CPACK_PACKAGE_NAME ${EXE_OUTPUT_NAME}-dbg) +else () + set(CPACK_PACKAGE_NAME ${EXE_OUTPUT_NAME}) +endif () + +set(CPACK_DEFAULT_PACKAGE_DESCRIPTION_SUMMARY "${EXE_OUTPUT_NAME} - ${CMAKE_BUILD_TYPE}") +set(CPACK_PACKAGE_VENDOR "Joel Winarske") +set(CPACK_PACKAGE_CONTACT "joel.winarske@gmail.com") + +set(CPACK_VERBATIM_VARIABLES YES) + +set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME}) +set(CPACK_OUTPUT_FILE_PREFIX "${CMAKE_BINARY_DIR}/_packages") + +set(CPACK_COMPONENTS_GROUPING ALL_COMPONENTS_IN_ONE) + +set(CPACK_DEB_COMPONENT_INSTALL YES) + +set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Joel Winarske ") +set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS NO) +set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT) + +set(CPACK_RPM_COMPONENT_INSTALL YES) +set(CPACK_RPM_FILE_NAME RPM-DEFAULT) +set(CPACK_RPM_PACKAGE_LICENSE "Apache-2.0") +set(CPACK_RPM_PACKAGE_VENDOR "${CPACK_PACKAGE_VENDOR}") +set(CPACK_RPM_PACKAGE_DESCRIPTION "${CPACK_DEFAULT_PACKAGE_DESCRIPTION_SUMMARY}") + +set(CPACK_TGZ_FILE_NAME TGZ-DEFAULT) + +if (${CMAKE_BUILD_TYPE} STREQUAL "Release") + set(CPACK_STRIP_FILES ${EXE_OUTPUT_NAME}) +endif () + +if (${CMAKE_BUILD_TYPE} STREQUAL "Debug") + set(CPACK_DEBIAN_DEBUGINFO_PACKAGE ON) + set(CMAKE_RPM_DEBUGINFO_PACKAGE ON) + set(CMAKE_TGZ_DEBUGINFO_PACKAGE ON) +endif () + +include(CPack)