Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add simple packaging #6

Merged
merged 15 commits into from Nov 9, 2022
190 changes: 190 additions & 0 deletions .github/nsis/FileAssociation.nsh
@@ -0,0 +1,190 @@
/*
_____________________________________________________________________________

File Association
_____________________________________________________________________________

Based on code taken from http://nsis.sourceforge.net/File_Association

Usage in script:
1. !include "FileAssociation.nsh"
2. [Section|Function]
${FileAssociationFunction} "Param1" "Param2" "..." $var
[SectionEnd|FunctionEnd]

FileAssociationFunction=[RegisterExtension|UnRegisterExtension]

_____________________________________________________________________________

${RegisterExtension} "[executable]" "[extension]" "[description]"

"[executable]" ; executable which opens the file format
;
"[extension]" ; extension, which represents the file format to open
;
"[description]" ; description for the extension. This will be display in Windows Explorer.
;


${UnRegisterExtension} "[extension]" "[description]"

"[extension]" ; extension, which represents the file format to open
;
"[description]" ; description for the extension. This will be display in Windows Explorer.
;

_____________________________________________________________________________

Macros
_____________________________________________________________________________

Change log window verbosity (default: 3=no script)

Example:
!include "FileAssociation.nsh"
!insertmacro RegisterExtension
${FileAssociation_VERBOSE} 4 # all verbosity
!insertmacro UnRegisterExtension
${FileAssociation_VERBOSE} 3 # no script
*/


!ifndef FileAssociation_INCLUDED
!define FileAssociation_INCLUDED

!include Util.nsh

!verbose push
!verbose 3
!ifndef _FileAssociation_VERBOSE
!define _FileAssociation_VERBOSE 3
!endif
!verbose ${_FileAssociation_VERBOSE}
!define FileAssociation_VERBOSE `!insertmacro FileAssociation_VERBOSE`
!verbose pop

!macro FileAssociation_VERBOSE _VERBOSE
!verbose push
!verbose 3
!undef _FileAssociation_VERBOSE
!define _FileAssociation_VERBOSE ${_VERBOSE}
!verbose pop
!macroend



!macro RegisterExtensionCall _EXECUTABLE _EXTENSION _DESCRIPTION
!verbose push
!verbose ${_FileAssociation_VERBOSE}
Push `${_DESCRIPTION}`
Push `${_EXTENSION}`
Push `${_EXECUTABLE}`
${CallArtificialFunction} RegisterExtension_
!verbose pop
!macroend

!macro UnRegisterExtensionCall _EXTENSION _DESCRIPTION
!verbose push
!verbose ${_FileAssociation_VERBOSE}
Push `${_EXTENSION}`
Push `${_DESCRIPTION}`
${CallArtificialFunction} UnRegisterExtension_
!verbose pop
!macroend



!define RegisterExtension `!insertmacro RegisterExtensionCall`
!define un.RegisterExtension `!insertmacro RegisterExtensionCall`

!macro RegisterExtension
!macroend

!macro un.RegisterExtension
!macroend

!macro RegisterExtension_
!verbose push
!verbose ${_FileAssociation_VERBOSE}

Exch $R2 ;exe
Exch
Exch $R1 ;ext
Exch
Exch 2
Exch $R0 ;desc
Exch 2
Push $0
Push $1

ReadRegStr $1 HKCR $R1 "" ; read current file association
StrCmp "$1" "" NoBackup ; is it empty
StrCmp "$1" "$R0" NoBackup ; is it our own
WriteRegStr HKCR $R1 "backup_val" "$1" ; backup current value
NoBackup:
WriteRegStr HKCR $R1 "" "$R0" ; set our file association

ReadRegStr $0 HKCR $R0 ""
StrCmp $0 "" 0 Skip
WriteRegStr HKCR "$R0" "" "$R0"
WriteRegStr HKCR "$R0\shell" "" "open"
WriteRegStr HKCR "$R0\DefaultIcon" "" "$R2,0"
Skip:
WriteRegStr HKCR "$R0\shell\open\command" "" '"$R2" "%1"'
WriteRegStr HKCR "$R0\shell\edit" "" "Edit $R0"
WriteRegStr HKCR "$R0\shell\edit\command" "" '"$R2" "%1"'

Pop $1
Pop $0
Pop $R2
Pop $R1
Pop $R0

!verbose pop
!macroend



!define UnRegisterExtension `!insertmacro UnRegisterExtensionCall`
!define un.UnRegisterExtension `!insertmacro UnRegisterExtensionCall`

!macro UnRegisterExtension
!macroend

!macro un.UnRegisterExtension
!macroend

!macro UnRegisterExtension_
!verbose push
!verbose ${_FileAssociation_VERBOSE}

Exch $R1 ;desc
Exch
Exch $R0 ;ext
Exch
Push $0
Push $1

ReadRegStr $1 HKCR $R0 ""
StrCmp $1 $R1 0 NoOwn ; only do this if we own it
ReadRegStr $1 HKCR $R0 "backup_val"
StrCmp $1 "" 0 Restore ; if backup="" then delete the whole key
DeleteRegKey HKCR $R0
Goto NoOwn

Restore:
WriteRegStr HKCR $R0 "" $1
DeleteRegValue HKCR $R0 "backup_val"
DeleteRegKey HKCR $R1 ;Delete key with association name settings

NoOwn:

Pop $1
Pop $0
Pop $R1
Pop $R0

!verbose pop
!macroend

!endif # !FileAssociation_INCLUDED
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -39,6 +39,11 @@ jobs:
path: 'source'
submodules: 'true'

- name: Setup NSIS Windows
if: matrix.os == 'windows-latest'
working-directory: ${{github.workspace}}
run: cp source\.github\nsis\FileAssociation.nsh "C:/Program Files (x86)/NSIS/Include"
mwestphal marked this conversation as resolved.
Show resolved Hide resolved

- name: Setup Directories
working-directory: ${{github.workspace}}
run: mkdir build
Expand All @@ -53,3 +58,13 @@ jobs:
- name: Build
working-directory: ${{github.workspace}}/build
run: cmake --build . --parallel 2 --config Release

- name: Package
working-directory: ${{github.workspace}}/build
run: ctest -R cpack -VV
Meakk marked this conversation as resolved.
Show resolved Hide resolved

- name: Upload Artifacts
uses: actions/upload-artifact@v2
with:
path: ./build/F3D-*
name: f3d-${{matrix.os}}
31 changes: 30 additions & 1 deletion CMakeLists.txt
Expand Up @@ -44,6 +44,35 @@ function (superbuild_find_projects var)
PARENT_SCOPE)
endfunction ()

function (superbuild_add_packaging)
# Packaging tests
mwestphal marked this conversation as resolved.
Show resolved Hide resolved
if (WIN32)
set(generators
ZIP
NSIS)
elseif (APPLE)
set(generators
DragNDrop)
else ()
set(generators
TGZ
TXZ
DEB)
endif ()
foreach (generator IN LISTS generators)
superbuild_add_extra_package_test(f3d "${generator}"
LABELS "F3D"
TIMEOUT 6400)
endforeach ()

endfunction ()

function (superbuild_add_tests)
# Declaring this CMake function, even empty, is needed to trigger BUILD_TESTING
# in the superbuild logic.
# TODO add actual testing here
endfunction ()

list(APPEND superbuild_version_files
"${CMAKE_CURRENT_LIST_DIR}/versions.cmake")
list(APPEND superbuild_project_roots
Expand All @@ -58,7 +87,7 @@ set(_superbuild_default_alembic ON)
set(_superbuild_default_assimp ON)
set(_superbuild_default_occt ON)
set(_superbuild_default_ospray ON)
set(_superbuild_default_pybind11 ON)
set(_superbuild_default_pybind11 OFF)

if (NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/superbuild/CMakeLists.txt")
message(FATAL_ERROR "It appears as though the superbuild infrastructure "
Expand Down
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -5,3 +5,4 @@ see LICENSE

# Acknowledgments
Inspired by/Copied from paraview-superbuild, Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc.
Uses FileAssociation.nsh, Copyright (c) Vytautas Krivickas from https://nsis.sourceforge.io/File_Association.
6 changes: 6 additions & 0 deletions projects/alembic.cmake
@@ -1,8 +1,14 @@
set(alembic_lib_install_dir lib)
if (WIN32)
set(alembic_lib_install_dir bin)
endif (WIN32)
mwestphal marked this conversation as resolved.
Show resolved Hide resolved

superbuild_add_project(alembic
LICENSE_FILES
LICENSE.txt
DEPENDS imath
CMAKE_ARGS
-DALEMBIC_LIB_INSTALL_DIR:PATH=${alembic_lib_install_dir}
-DUSE_BINARIES=OFF
-DBUILD_TESTING=OFF
-DCMAKE_BUILD_TYPE=Release
Expand Down
39 changes: 39 additions & 0 deletions projects/apple/f3d.bundle.cmake
@@ -0,0 +1,39 @@
include(f3d.bundle.common)
set(f3d_appname "${f3d_name}-${f3d_version}.app") # TODO

set(additional_libraries)
if (ospray_enabled)
set(osprayextra_libraries
openvkl_module_cpu_device
openvkl_module_cpu_device_4
openvkl_module_cpu_device_8
openvkl_module_cpu_device_16
ospray_module_denoiser
ospray_module_ispc)

foreach (osprayextra_library IN LISTS osprayextra_libraries)
if (EXISTS "${superbuild_install_location}/lib/lib${osprayextra_library}.dylib")
list(APPEND additional_libraries
"${superbuild_install_location}/lib/lib${osprayextra_library}.dylib")
endif ()
endforeach ()
endif ()

## TODO impossible to implement without a MacOS, will be handled in another PR

#superbuild_apple_create_app(
# "\${CMAKE_INSTALL_PREFIX}"
# "${f3d_appname}"
# "${superbuild_install_location}/Applications/f3d.app/Contents/MacOS/f3d"
# CLEAN
# SEARCH_DIRECTORIES "${superbuild_install_location}/lib"
# ADDITIONAL_LIBRARIES ${additional_libraries})
#
#install(
# FILES "${superbuild_install_location}/../superbuild/f3d/src/logo.icns" # TODO
# DESTINATION "${f3d_appname}/Contents/Resources"
# COMPONENT superbuild) # TODO
#install(
# FILES "${superbuild_install_location}/Applications/f3d.app/Contents/Info.plist"
# DESTINATION "${f3d_appname}/Contents"
# COMPONENT superbuild) # TODO
20 changes: 20 additions & 0 deletions projects/f3d.bundle.common.cmake
@@ -0,0 +1,20 @@
# TODO Recover from somewhere ?
Meakk marked this conversation as resolved.
Show resolved Hide resolved
set(f3d_name F3D)
set(f3d_version 1.3.1)
set(f3d_description "F3D - A fast and minimalist 3D viewer")
set(f3d_url "https://f3d-app.github.io/f3d/")

set(CPACK_PACKAGE_NAME "${f3d_name}")
set(CPACK_PACKAGE_VERSION "${f3d_version}")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${f3d_name}")
set(CPACK_PACKAGE_VENDOR "${f3d_name}-app")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${f3d_description}")
set(CPACK_PACKAGE_DESCRIPTION_FILE ${readme_path})
set(CPACK_PACKAGE_HOMEPAGE_URL ${f3d_url})
set(CPACK_PACKAGE_CHECKSUM MD5)
set(CPACK_PACKAGE_EXECUTABLES f3d f3d)
set(CPACK_RESOURCE_FILE_README ${readme_path}) # Rework this and add a WELCOME
set(CPACK_RESOURCE_FILE_LICENSE "${superbuild_install_location}/share/licenses/f3d/LICENSE")
set(CPACK_CREATE_DESKTOP_LINKS f3d)
set(CPACK_STRIP_FILES TRUE)
set(CPACK_THREADS 0)
20 changes: 19 additions & 1 deletion projects/f3d.cmake
@@ -1,6 +1,18 @@
set(f3d_build_for_linux FALSE)
set(f3d_build_for_windows FALSE)
set(f3d_build_for_macos FALSE)
if (WIN32)
set(f3d_build_for_windows TRUE)
elseif (APPLE)
set(f3d_build_for_macos TRUE)
elseif (UNIX)
set(f3d_build_for_linux TRUE)
endif ()

superbuild_add_project(f3d
LICENSE_FILES
LICENSE
THIRD_PARTY_LICENSES.md
DEPENDS vtk
DEPENDS_OPTIONAL pybind11 alembic assimp occt
CMAKE_ARGS
Expand All @@ -14,7 +26,13 @@ superbuild_add_project(f3d
-DF3D_MODULE_ALEMBIC:BOOL=${alembic_enabled}
-DF3D_MODULE_RAYTRACING:BOOL=${ospray_enabled}
-DF3D_PYTHON_BINDINGS:BOOL=${pybind11_enabled}
-DF3D_INSTALL_SDK=ON
-DCMAKE_BUILD_TYPE=Release
-DF3D_INSTALL_DEFAULT_CONFIGURATION_FILE=ON
-DF3D_INSTALL_DEFAULT_CONFIGURATION_FILE_IN_PREFIX=ON
-DF3D_INSTALL_DEFAULT_CONFIGURATION_FILE_IN_PREFIX:BOOL=${f3d_build_for_linux}
-DF3D_GENERATE_MAN:BOOL=${f3d_build_for_linux}
-DF3D_INSTALL_MIME_TYPES_FILE:BOOL=${f3d_build_for_linux} # XXX: This change in master
-DF3D_INSTALL_THUMBNAILER_FILES:BOOL=${f3d_build_for_linux}
-DF3D_MACOS_BUNDLE:BOOL=${f3d_build_for_macos}
-DF3D_WINDOWS_GUI:BOOL=${f3d_build_for_windows}
)
1 change: 1 addition & 0 deletions projects/occt.cmake
Expand Up @@ -7,6 +7,7 @@ superbuild_add_project(occt
LICENSE_LGPL_21.txt
OCCT_LGPL_EXCEPTION.txt
CMAKE_ARGS
-DINSTALL_DIR_BIN:PATH=bin
-DBUILD_ADDITIONAL_TOOLKITS=${occt_toolkits_escaped}
-DBUILD_MODULE_ApplicationFramework=OFF
-DBUILD_MODULE_DataExchange=OFF
Expand Down