diff --git a/.gitignore b/.gitignore index 197cd865..4f7d42c5 100644 --- a/.gitignore +++ b/.gitignore @@ -47,4 +47,5 @@ Starship.log *.sav *.lib *.pdb -dumps/ \ No newline at end of file +dumps/ +_packages/* diff --git a/CMakeLists.txt b/CMakeLists.txt index e14777e0..e3b99acf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -555,4 +555,40 @@ add_custom_target( WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND ${TORCH_EXECUTABLE} pack port starship.otr COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/starship.otr" "${CMAKE_BINARY_DIR}/starship.otr" -) \ No newline at end of file +) + +if(CMAKE_SYSTEM_NAME MATCHES "Darwin") +add_custom_target(CreateOSXIcons + COMMAND mkdir -p ${CMAKE_BINARY_DIR}/macosx/starship.iconset + COMMAND sips -z 16 16 logo.png --out ${CMAKE_BINARY_DIR}/macosx/starship.iconset/icon_16x16.png + COMMAND sips -z 32 32 logo.png --out ${CMAKE_BINARY_DIR}/macosx/starship.iconset/icon_16x16@2x.png + COMMAND sips -z 32 32 logo.png --out ${CMAKE_BINARY_DIR}/macosx/starship.iconset/icon_32x32.png + COMMAND sips -z 64 64 logo.png --out ${CMAKE_BINARY_DIR}/macosx/starship.iconset/icon_32x32@2x.png + COMMAND sips -z 128 128 logo.png --out ${CMAKE_BINARY_DIR}/macosx/starship.iconset/icon_128x128.png + COMMAND sips -z 256 256 logo.png --out ${CMAKE_BINARY_DIR}/macosx/starship.iconset/icon_128x128@2x.png + COMMAND sips -z 256 256 logo.png --out ${CMAKE_BINARY_DIR}/macosx/starship.iconset/icon_256x256.png + COMMAND sips -z 512 512 logo.png --out ${CMAKE_BINARY_DIR}/macosx/starship.iconset/icon_256x256@2x.png + COMMAND sips -z 512 512 logo.png --out ${CMAKE_BINARY_DIR}/macosx/starship.iconset/icon_512x512.png + COMMAND cp logo.png ${CMAKE_BINARY_DIR}/macosx/starship.iconset/icon_512x512@2x.png + COMMAND iconutil -c icns -o ${CMAKE_BINARY_DIR}/macosx/starship.icns ${CMAKE_BINARY_DIR}/macosx/starship.iconset + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + COMMENT "Creating OSX icons ..." + ) + add_dependencies(${PROJECT_NAME} CreateOSXIcons) + configure_file("${CMAKE_SOURCE_DIR}/Info.plist" "${CMAKE_BINARY_DIR}/Info.plist" COPYONLY) +endif() + +set_property(TARGET ${PROJECT_NAME} PROPERTY APPIMAGE_DESKTOP_FILE_TERMINAL YES) +set_property(TARGET ${PROJECT_NAME} PROPERTY APPIMAGE_DESKTOP_FILE "${CMAKE_SOURCE_DIR}/Starship.desktop") +set_property(TARGET ${PROJECT_NAME} PROPERTY APPIMAGE_ICON_FILE "${CMAKE_SOURCE_DIR}/logo.png") + +if(CMAKE_SYSTEM_NAME MATCHES "Linux") + set(CPACK_GENERATOR "External") +elseif(CMAKE_SYSTEM_NAME MATCHES "Windows|NintendoSwitch|CafeOS") + set(CPACK_GENERATOR "ZIP") +elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin") + set(CPACK_GENERATOR "Bundle") +endif() + +set(CPACK_PROJECT_CONFIG_FILE ${CMAKE_SOURCE_DIR}/cmake/configure-packaging.cmake) +include(cmake/packaging.cmake) \ No newline at end of file diff --git a/Info.plist b/Info.plist new file mode 100644 index 00000000..39fb6bc1 --- /dev/null +++ b/Info.plist @@ -0,0 +1,42 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleName + Starship + CFBundleExecutable + Starship + CFBundleGetInfoString + 0.1.0 + CFBundleIconFile + Starship.icns + CFBundleIdentifier + com.Starship.Starship + CFBundleDocumentTypes + + + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + APPL + CFBundleShortVersionString + 0.1.0 + CFBundleSignature + ZMM + CFBundleVersion + 0.1.0 + NSHumanReadableCopyright + Copyright 2024 HarbourMasters. + LSApplicationCategoryType + public.app-category.games + LSMinimumSystemVersion + 10.15 + LSArchitecturePriority + + arm64 + x86_64 + + + \ No newline at end of file diff --git a/Starship.desktop b/Starship.desktop new file mode 100644 index 00000000..566ac94f --- /dev/null +++ b/Starship.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Version=1.0 +Name=2SHIP +Exec=Starship +Terminal=false +Icon=logo +Type=Application +Categories=Game; +X-AppImage-Integrate=false \ No newline at end of file diff --git a/cmake/configure-packaging.cmake b/cmake/configure-packaging.cmake new file mode 100644 index 00000000..f3d2c115 --- /dev/null +++ b/cmake/configure-packaging.cmake @@ -0,0 +1,29 @@ +set(CPACK_ARCHIVE_COMPONENT_INSTALL ON) +set(CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY 0) +set(CPACK_COMPONENTS_ALL "Starship") + +if (CPACK_GENERATOR STREQUAL "External") + list(APPEND CPACK_COMPONENTS_ALL "extractor" "appimage") +endif() + +if (CPACK_GENERATOR MATCHES "DEB|RPM") +# https://unix.stackexchange.com/a/11552/254512 +set(CPACK_PACKAGING_INSTALL_PREFIX "/opt/ship/bin")#/${CMAKE_PROJECT_VERSION}") +set(CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY 0) +elseif (CPACK_GENERATOR MATCHES "ZIP") +set(CPACK_PACKAGING_INSTALL_PREFIX "") +endif() + +if (CPACK_GENERATOR MATCHES "External") +set(CPACK_ARCHIVE_COMPONENT_INSTALL ON) +SET(CPACK_MONOLITHIC_INSTALL 1) +set(CPACK_PACKAGING_INSTALL_PREFIX "/usr/bin") +endif() + +if (CPACK_GENERATOR MATCHES "Bundle") + set(CPACK_BUNDLE_NAME "Starship") + set(CPACK_BUNDLE_PLIST "macosx/Info.plist") + set(CPACK_BUNDLE_ICON "macosx/Starship.icns") + # set(CPACK_BUNDLE_STARTUP_COMMAND "macosx/Starship-macos.sh") + set(CPACK_BUNDLE_APPLE_CERT_APP "-") +endif() \ No newline at end of file diff --git a/cmake/packaging.cmake b/cmake/packaging.cmake new file mode 100644 index 00000000..be0fb315 --- /dev/null +++ b/cmake/packaging.cmake @@ -0,0 +1,90 @@ +# these are cache variables, so they could be overwritten with -D, + +set(CPACK_PACKAGE_NAME "${PROJECT_NAME}" + CACHE STRING "The resulting package name" +) + +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Simple C++ application" + CACHE STRING "Package description for the package metadata" +) +set(CPACK_PACKAGE_VENDOR "Some Company") + +set(CPACK_VERBATIM_VARIABLES YES) + +set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME}) +SET(CPACK_OUTPUT_FILE_PREFIX "${CMAKE_SOURCE_DIR}/_packages") + +set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) +set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR}) +set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH}) +set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") + +set(CPACK_PACKAGE_CONTACT "YOUR@E-MAIL.net") +set(CPACK_DEBIAN_PACKAGE_MAINTAINER "YOUR NAME") + +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md") +set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md") + +if (CMAKE_SYSTEM_NAME STREQUAL "Linux") +set(CPACK_SYSTEM_NAME ${LSB_RELEASE_CODENAME_SHORT}) +# package name for deb +# if set, then instead of some-application-0.9.2-Linux.deb +# you'll get some-application_0.9.2_amd64.deb (note the underscores too) +#set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT) +execute_process(COMMAND dpkg --print-architecture OUTPUT_VARIABLE ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE) +set( CPACK_DEBIAN_FILE_NAME ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}-${ARCHITECTURE}.deb ) +# if you want every group to have its own package, +# although the same happens if this is not sent (so it defaults to ONE_PER_GROUP) +# and CPACK_DEB_COMPONENT_INSTALL is set to YES +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_EXTERNAL_ENABLE_STAGING YES) +set(CPACK_EXTERNAL_PACKAGE_SCRIPT "${PROJECT_BINARY_DIR}/appimage-generate.cmake") + +file(GENERATE + OUTPUT "${PROJECT_BINARY_DIR}/appimage-generate.cmake" + CONTENT [[ +include(CMakePrintHelpers) +cmake_print_variables(CPACK_TEMPORARY_DIRECTORY) +cmake_print_variables(CPACK_TOPLEVEL_DIRECTORY) +cmake_print_variables(CPACK_PACKAGE_DIRECTORY) +cmake_print_variables(CPACK_PACKAGE_FILE_NAME) + +find_program(LINUXDEPLOY_EXECUTABLE + NAMES linuxdeploy linuxdeploy-x86_64.AppImage + PATHS ${CPACK_PACKAGE_DIRECTORY}/linuxdeploy) + +if (NOT LINUXDEPLOY_EXECUTABLE) + message(STATUS "Downloading linuxdeploy") + set(LINUXDEPLOY_EXECUTABLE ${CPACK_PACKAGE_DIRECTORY}/linuxdeploy/linuxdeploy) + file(DOWNLOAD + https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage + ${LINUXDEPLOY_EXECUTABLE} + INACTIVITY_TIMEOUT 10 + LOG ${CPACK_PACKAGE_DIRECTORY}/linuxdeploy/download.log + STATUS LINUXDEPLOY_DOWNLOAD) + execute_process(COMMAND chmod +x ${LINUXDEPLOY_EXECUTABLE} COMMAND_ECHO STDOUT) +endif() + +execute_process( + COMMAND + ${CMAKE_COMMAND} -E env + OUTPUT=${CPACK_PACKAGE_FILE_NAME}.appimage + VERSION=$,${CPACK_PACKAGE_VERSION},0.1.0> + NO_STRIP=true + ${LINUXDEPLOY_EXECUTABLE} + --appimage-extract-and-run + --appdir=${CPACK_TEMPORARY_DIRECTORY} + --executable=$ + $<$>:--desktop-file=$> + $<$>:--icon-file=$> + --output=appimage + --verbosity=2 +) +]]) + +endif() + +include(CPack) \ No newline at end of file diff --git a/logo.png b/logo.png new file mode 100644 index 00000000..56ddadf1 Binary files /dev/null and b/logo.png differ