Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 55 additions & 2 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ jobs:
Build:
name: ${{ matrix.os }} - Vulkan ${{ matrix.vulkan }}
runs-on: ${{ matrix.os }}
env:
CODESIGN_IDENTITY: ${{ secrets.CODESIGN_IDENTITY }}
CERT_P12: ${{ secrets.CERT_P12 }}
CERT_PASSWORD: ${{ secrets.CERT_PASSWORD }}
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
APPLE_ID: ${{ secrets.APPLE_ID }}
TEAM_ID: ${{ secrets.TEAM_ID }}
APP_PASSWORD: ${{ secrets.APP_PASSWORD }}

strategy:
fail-fast: false
Expand Down Expand Up @@ -66,18 +74,63 @@ jobs:
with:
version: ${{ matrix.vulkan }}

- name: Import signing certificate
if: ${{ runner.os == 'macOS' }}
run: |
KEYCHAIN="$RUNNER_TEMP/novelrt-signing.keychain-db"
P12="$RUNNER_TEMP/novelrt-signing.p12"
echo "$CERT_P12" | base64 --decode > "$P12"
security create-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN"
security set-keychain-settings -lut 21600 "$KEYCHAIN"
security unlock-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN"
security import "$P12" -k "$KEYCHAIN" -P "$CERT_PASSWORD" -T /usr/bin/codesign
security set-key-partition-list -S apple-tool:,apple: -s -k "$KEYCHAIN_PASSWORD" "$KEYCHAIN"
security list-keychains -d user -s "$KEYCHAIN" $(security list-keychains -d user | tr -d '"')
security find-identity -v -p codesigning "$KEYCHAIN"

- name: Generate build system
run: cmake -G Ninja -S . -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_EXPORT_COMPILE_COMMANDS=ON --install-prefix "$(pwd)/artefacts"
run: cmake -G Ninja -S . -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_EXPORT_COMPILE_COMMANDS=ON --install-prefix "$(pwd)/artefacts" -UINC_INSTALL_DIR -ULIB_INSTALL_DIR -UBIN_INSTALL_DIR -UPKGCONFIG_INSTALL_DIR -DNOVELRT_CODESIGN_IDENTITY="${{ env.CODESIGN_IDENTITY }}"

- name: Build NovelRT
run: cmake --build build --config RelWithDebInfo --parallel

- name: Install NovelRT
run: cmake --install build --config RelWithDebInfo --prefix artefacts

- name: Publish build artefacts
- name: Notarize and staple VisualNovel.app
if: ${{ runner.os == 'macOS' }}
run: |
APP="artefacts/apps/VisualNovel.app"
xcrun notarytool submit "$APP" \
--apple-id "APPLE_ID" \
--team-id "TEAM_ID" \
--password "APP_PASSWORD" \
--wait
xcrun stapler staple "$APP"
xcrun stapler validate "$APP"
test -f "$APP/Contents/CodeResources"

- name: Create macOS release archive
if: ${{ runner.os == 'macOS' }}
run: |
ditto -c -k --keepParent artefacts/apps/VisualNovel.app \
"novelrt-${{ github.event.release.tag_name }}-${{ matrix.os }}.zip"

- name: Create release archive
if: ${{ runner.os != 'macOS' }}
shell: pwsh
run: |
Compress-Archive -Path $(Get-ChildItem artefacts/*) -DestinationPath "novelrt-${{ github.event.release.tag_name }}-${{ matrix.os }}.zip"

- name: Publish build artefacts
shell: pwsh
run: |
gh release upload ${{ github.event.release.tag_name }} "novelrt-${{ github.event.release.tag_name }}-${{ matrix.os }}.zip#${{ github.event.release.name }} - ${{ matrix.title }}" --repo "${{ github.repository }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Remove signing keychain
if: ${{ runner.os == 'macOS' && always() }}
run: |
security delete-keychain "$RUNNER_TEMP/novelrt-signing.keychain-db" || true
rm -f "$RUNNER_TEMP/novelrt-signing.p12"
75 changes: 75 additions & 0 deletions LuaOnlyTargets/VisualNovel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,78 @@ NovelRTBuildSystem_DeclareModule(EXECUTABLE NovelRT::LuaOnlyTargets::VisualNovel
Resources/VNConfig.json
Resources/Images/SampleBG.png
)

if(APPLE AND NOVELRT_INSTALL)
if(DEFINED ENV{CODESIGN_IDENTITY} AND NOT "$ENV{CODESIGN_IDENTITY}" STREQUAL "")
set(NOVELRT_CODESIGN_IDENTITY "$ENV{CODESIGN_IDENTITY}" CACHE STRING "" FORCE)
endif()

if(NOT DEFINED NOVELRT_CODESIGN_IDENTITY)
# this will cause ad-hoc signing... NOT distributable :/
# example of valid identity: "Developer ID Application: <Name> (<Team ID>)"
set(NOVELRT_CODESIGN_IDENTITY "-" CACHE STRING "")
endif()
install(CODE "set(novelrtCodesignIdentity [[${NOVELRT_CODESIGN_IDENTITY}]])")
install(CODE [[
set(novelrtBundle "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/apps/VisualNovel.app")

if(novelrtCodesignIdentity STREQUAL "")
message(FATAL_ERROR "NOVELRT_CODESIGN_IDENTITY is empty - cannot sign")
endif()
if(NOT EXISTS "${novelrtBundle}")
message(FATAL_ERROR "No bundle at '${novelrtBundle}'")
endif()

find_program(novelrtCodesign codesign REQUIRED)

set(novelrtCodesignArgs --force --sign "${novelrtCodesignIdentity}")
if(novelrtCodesignIdentity MATCHES "^Developer ID Application")
# we have the right identity to enable hardended runtime and timestamping
# the sig for notarization purposes.
list(APPEND novelrtCodesignArgs --options runtime --timestamp)
endif()

file(GLOB_RECURSE novelrtFrameworkItems LIST_DIRECTORIES false
"${novelrtBundle}/Contents/Frameworks/*")
foreach(novelrtItem IN LISTS novelrtFrameworkItems)
if(IS_SYMLINK "${novelrtItem}")
continue()
endif()
execute_process(
COMMAND file -b "${novelrtItem}"
OUTPUT_VARIABLE novelrtFileType
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT novelrtFileType MATCHES "Mach-O")
continue()
endif()
execute_process(
COMMAND "${novelrtCodesign}" ${novelrtCodesignArgs} "${novelrtItem}"
RESULT_VARIABLE codesignResult
OUTPUT_VARIABLE codesignOutput
ERROR_VARIABLE codesignOutput)
if(NOT codesignResult EQUAL 0)
message(WARNING "Signing failed - ${codesignOutput}")
endif()
endforeach()

execute_process(
COMMAND "${novelrtCodesign}" ${novelrtCodesignArgs} "${novelrtBundle}"
RESULT_VARIABLE codesignResult
OUTPUT_VARIABLE codesignOutput
ERROR_VARIABLE codesignOutput)
if(NOT codesignResult EQUAL 0)
message(WARNING "Signing failed - ${codesignOutput}")
endif()

execute_process(
COMMAND "${novelrtCodesign}" --verify --deep --strict "${novelrtBundle}"
RESULT_VARIABLE codesignResult
OUTPUT_VARIABLE codesignOutput
ERROR_VARIABLE codesignOutput)
if(NOT codesignResult EQUAL 0)
message(WARNING "Signature verification failed - ${codesignOutput}")
endif()

message(STATUS "Signed '${novelrtBundle}' with '${novelrtCodesignIdentity}' successfully!")
]])
endif()
Comment thread
RubyNova marked this conversation as resolved.
Resolved
4 changes: 2 additions & 2 deletions ResourceManagement/Core/ResourceLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace NovelRT::ResourceManagement
uuids::uuid ResourceLoader::RegisterAsset(const std::filesystem::path& filePath)
{
auto returnValue = RegisterAssetNoFileWrite(filePath);
WriteAssetDatabaseFile();
//WriteAssetDatabaseFile();
Comment thread
RubyNova marked this conversation as resolved.
Resolved
return returnValue;
}

Expand All @@ -24,7 +24,7 @@ namespace NovelRT::ResourceManagement
if (!_hasLoadedAssetDatabase)
{
_hasLoadedAssetDatabase = true;
LoadAssetDatabaseFile();
//LoadAssetDatabaseFile();
}

auto& pathGuidMap = GetFilePathsToGuidsMap();
Expand Down
4 changes: 2 additions & 2 deletions ResourceManagement/Desktop/DesktopResourceLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ namespace NovelRT::ResourceManagement::Desktop
{
auto filePath = _resourcesRootDirectory;

LoadAssetDatabaseFile();
//LoadAssetDatabaseFile();

std::vector<uuids::uuid> filesToUnregister{};

Expand Down Expand Up @@ -117,7 +117,7 @@ namespace NovelRT::ResourceManagement::Desktop
RegisterAsset(std::filesystem::relative(directoryEntry.path(), filePath));
}

WriteAssetDatabaseFile();
//WriteAssetDatabaseFile();

_isAssetDBInitialised = true;
}
Expand Down
4 changes: 2 additions & 2 deletions Utilities/Paths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ namespace NovelRT::Utilities
CFStringRef macPath = CFURLCopyFileSystemPath(bundleUrl, kCFURLPOSIXPathStyle);
if(macPath != nullptr)
{
//We've dunked into a bundle
//We've dunked into a bundle's "MacOS" folder
std::filesystem::path path = CFStringToStdString(macPath);
CFRelease(macPath);
CFRelease(bundleUrl);
return path;
return path.parent_path();
Comment thread
RubyNova marked this conversation as resolved.
Resolved
}
CFRelease(bundleUrl);
}
Expand Down
71 changes: 33 additions & 38 deletions cmake/NovelRTBuildSystem.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,12 @@ function(NovelRTBuildSystem_DeclareModule moduleKind moduleName)
target_link_libraries(${cmakeSafeName} ${declareModule_LINK_LIBRARIES})
endif()

if(APPLE AND declareModule_MACOSX_BUNDLE)
Comment thread
RubyNova marked this conversation as resolved.
Resolved
set(resourceRoot "$<TARGET_BUNDLE_CONTENT_DIR:${cmakeSafeName}>")
else()
set(resourceRoot "$<TARGET_FILE_DIR:${cmakeSafeName}>")
endif()

set(resourcesStr "cmake_policy(PUSH)\n")
string(APPEND resourcesStr [[ cmake_policy(SET CMP0007 NEW)]] "\n"
[[ set(resources "$<GENEX_EVAL:$<TARGET_PROPERTY:]] "${cmakeSafeName}" [[,NOVELRT_RESOURCES>>")]] "\n"
Expand All @@ -231,7 +237,7 @@ function(NovelRTBuildSystem_DeclareModule moduleKind moduleName)
[[ list(GET resources "${index}" resource)]] "\n"
[[ list(GET destinations "${index}" destination)]] "\n"
[[ if(NOT ("${resource}" STREQUAL "" OR "${destination}" STREQUAL ""))]] "\n"
[[ file(COPY "${resource}" DESTINATION "$<TARGET_FILE_DIR:]] "${cmakeSafeName}" [[>/${destination}" USE_SOURCE_PERMISSIONS)]] "\n"
[[ file(COPY "${resource}" DESTINATION "]] "${resourceRoot}" [[/${destination}" USE_SOURCE_PERMISSIONS)]] "\n"
[[ endif()]] "\n"
[[ endforeach()]] "\n"
[[ endif()]] "\n"
Expand All @@ -245,7 +251,8 @@ function(NovelRTBuildSystem_DeclareModule moduleKind moduleName)
if(NOVELRT_INSTALL)
if(APPLE AND declareModule_MACOSX_BUNDLE)
set(fixupStr "include(BundleUtilities)\n")
string(APPEND fixupStr [[ file(READ "]] "${CMAKE_CURRENT_BINARY_DIR}/NovelRT_DynamicLibraries.paths.txt" [[" dynamicLibPaths)]] "\n"
string(APPEND fixupStr [[ get_item_rpaths("$<TARGET_FILE:]] "${cmakeSafeName}" [[>" novelrtBundleRpaths)]] "\n"
[[ file(READ "]] "${CMAKE_CURRENT_BINARY_DIR}/NovelRT_DynamicLibraries.paths.txt" [[" dynamicLibPaths)]] "\n"
[[ set(dynamicLibs)]] "\n"
[[ foreach(dynamicLibPath IN LISTS dynamicLibPaths)]] "\n"
[[ if(EXISTS "${dynamicLibPath}")]] "\n"
Expand All @@ -263,7 +270,11 @@ function(NovelRTBuildSystem_DeclareModule moduleKind moduleName)
[[ get_filename_component(dynamicLibName "${dynamicLibPath}" NAME)]] "\n"
[[ list(APPEND installedDynamicLibs "$<TARGET_BUNDLE_CONTENT_DIR:]] "${cmakeSafeName}" [[>/Frameworks/${dynamicLibName}")]] "\n"
[[ endforeach()]] "\n"
[[ fixup_bundle("$<TARGET_BUNDLE_DIR:]] "${cmakeSafeName}" [[>" "${installedDynamicLibs}" "$<INSTALL_PREFIX>/lib;$<INSTALL_PREFIX>/bin")]])
[[ fixup_bundle("$<TARGET_BUNDLE_DIR:]] "${cmakeSafeName}" [[>" "${installedDynamicLibs}" "$<INSTALL_PREFIX>/lib;$<INSTALL_PREFIX>/bin")]] "\n"
[[ find_program(novelrtInstallNameTool install_name_tool REQUIRED)]] "\n"
[[ foreach(novelrtBundleRpath IN LISTS novelrtBundleRpaths)]] "\n"
[[ execute_process(COMMAND "${novelrtInstallNameTool}" -add_rpath "${novelrtBundleRpath}" "$<TARGET_FILE:]] "${cmakeSafeName}" [[>")]] "\n"
[[ endforeach()]])
install(CODE "${fixupStr}")

set(resourcesStr "cmake_policy(PUSH)\n")
Expand All @@ -277,59 +288,43 @@ function(NovelRTBuildSystem_DeclareModule moduleKind moduleName)
[[ list(GET resources "${index}" resource)]] "\n"
[[ list(GET destinations "${index}" destination)]] "\n"
[[ if(NOT ("${resource}" STREQUAL "" OR "${destination}" STREQUAL ""))]] "\n"
[[ file(INSTALL DESTINATION "$<TARGET_BUNDLE_CONTENT_DIR:]] "${cmakeSafeName}" [[>/${destination}" TYPE FILE FILES "${resource}" USE_SOURCE_PERMISSIONS)]] "\n"
[[ file(INSTALL DESTINATION "]] "${resourceRoot}" [[/${destination}" TYPE FILE FILES "${resource}" USE_SOURCE_PERMISSIONS)]] "\n"
[[ endif()]] "\n"
[[ endforeach()]] "\n"
[[ endif()]] "\n"
[[ cmake_policy(POP)]])
install(CODE "${resourcesStr}")
endif()

set(resourcesStr "cmake_policy(PUSH)\n")
string(APPEND resourcesStr [[ cmake_policy(SET CMP0007 NEW)]] "\n"
[[ set(resources "$<GENEX_EVAL:$<TARGET_PROPERTY:]] "${cmakeSafeName}" [[,NOVELRT_RESOURCES>>")]] "\n"
[[ set(destinations "$<GENEX_EVAL:$<TARGET_PROPERTY:]] "${cmakeSafeName}" [[,NOVELRT_RESOURCES_DESTINATIONS>>")]] "\n"
[[ list(LENGTH resources resourceCount)]] "\n"
[[ if("${resourceCount}" GREATER "0")]] "\n"
[[ math(EXPR resourceCount "${resourceCount} - 1")]] "\n"
[[ foreach(index RANGE "${resourceCount}")]] "\n"
[[ list(GET resources "${index}" resource)]] "\n"
[[ list(GET destinations "${index}" destination)]] "\n"
[[ if(NOT ("${resource}" STREQUAL "" OR "${destination}" STREQUAL ""))]] "\n"
[[ file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/bin/${destination}" TYPE FILE FILES "${resource}" USE_SOURCE_PERMISSIONS)]] "\n"
[[ endif()]] "\n"
[[ endforeach()]] "\n"
[[ endif()]] "\n"
[[ cmake_policy(POP)]])
install(CODE "${resourcesStr}")

install(
TARGETS ${cmakeSafeName}
EXPORT NovelRTConfig
ARCHIVE DESTINATION lib
BUNDLE DESTINATION apps
FILE_SET HEADERS DESTINATION include
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)

if(APPLE AND declareModule_MACOSX_BUNDLE)
if(NOT (APPLE AND declareModule_MACOSX_BUNDLE))
set(resourcesStr "cmake_policy(PUSH)\n")
string(APPEND resourcesStr [[ cmake_policy(SET CMP0007 NEW)]] "\n"
[[ set(resources "$<GENEX_EVAL:$<TARGET_PROPERTY:]] "${cmakeSafeName}" [[,NOVELRT_RESOURCES>>")]] "\n"
[[ set(destinations "$<GENEX_EVAL:$<TARGET_PROPERTY:]] "${cmakeSafeName}" [[,NOVELRT_RESOURCES_DESTINATIONS>>")]] "\n"
[[ list(LENGTH destinations destinationCount)]] "\n"
[[ if("${destinationCount}" GREATER "0")]] "\n"
[[ math(EXPR destinationCount "${destinationCount} - 1")]] "\n"
[[ foreach(index RANGE "${destinationCount}")]] "\n"
[[ list(LENGTH resources resourceCount)]] "\n"
[[ if("${resourceCount}" GREATER "0")]] "\n"
[[ math(EXPR resourceCount "${resourceCount} - 1")]] "\n"
[[ foreach(index RANGE "${resourceCount}")]] "\n"
[[ list(GET resources "${index}" resource)]] "\n"
[[ list(GET destinations "${index}" destination)]] "\n"
[[ if(NOT "${destination}" STREQUAL "")]] "\n"
[[ file(REMOVE_RECURSE "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/apps/$<TARGET_BUNDLE_DIR_NAME:]] "${cmakeSafeName}" [[>$<$<PLATFORM_ID:Darwin>:/Contents/MacOS>/${destination}")]] "\n"
[[ if(NOT ("${resource}" STREQUAL "" OR "${destination}" STREQUAL ""))]] "\n"
[[ file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/bin/${destination}" TYPE FILE FILES "${resource}" USE_SOURCE_PERMISSIONS)]] "\n"
[[ endif()]] "\n"
[[ endforeach()]] "\n"
[[ endif()]] "\n"
[[ cmake_policy(POP)]])
install(CODE "${resourcesStr}")
endif()

install(
TARGETS ${cmakeSafeName}
EXPORT NovelRTConfig
ARCHIVE DESTINATION lib
BUNDLE DESTINATION apps
FILE_SET HEADERS DESTINATION include
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)

if(WIN32 AND moduleKind STREQUAL "EXECUTABLE")
install(FILES $<TARGET_PDB_FILE:${cmakeSafeName}> DESTINATION bin OPTIONAL)
endif()
Expand Down
Loading