diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f1cf9ef..04c28ad 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -138,6 +138,7 @@ jobs: - uses: actions/setup-python@v7 with: python-version: '3.12' + cache: 'pip' - name: Install mbedTLS codegen deps run: pip install -r deps/mbedtls/scripts/basic.requirements.txt @@ -145,33 +146,27 @@ jobs: - name: Build and pack Iris run: | git fetch --all --tags - cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release + cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release "-DCMAKE_OSX_ARCHITECTURES=x86_64;arm64" cmake --build build - sudo cmake --install build + cmake --install build --prefix dist - name: Replace bundled symlinks and re-sign run: | # Artifact zips flatten symlinks into copies, which breaks the # bundle's code signature, so bundle real files and sign those ( - cd ./build/iris.app/Contents/Frameworks + cd dist/iris.app/Contents/Frameworks for f in *; do if [ -L "$f" ]; then target=$(readlink "$f") - sudo rm "$f" - sudo cp "$target" "$f" + rm "$f" + cp "$target" "$f" fi done ) - sudo codesign --force --deep --sign - ./build/iris.app - codesign --verify --deep --strict ./build/iris.app - - - name: Stage artifact - run: | - mkdir -p ./build/dist - cp -R ./build/iris.app ./build/dist + codesign --force --deep --sign - dist/iris.app - uses: actions/upload-artifact@v7 with: name: iris-latest-macos-universal - path: ./build/dist + path: ./dist diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ddc3c2e..b631a54 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -161,6 +161,7 @@ jobs: - uses: actions/setup-python@v7 with: python-version: '3.12' + cache: 'pip' - name: Install mbedTLS codegen deps run: pip install -r deps/mbedtls/scripts/basic.requirements.txt @@ -168,26 +169,25 @@ jobs: - name: Build and pack Iris run: | git fetch --all --tags - cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release + cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release "-DCMAKE_OSX_ARCHITECTURES=x86_64;arm64" cmake --build build - sudo cmake --install build + cmake --install build --prefix dist - name: Replace bundled symlinks and re-sign run: | # Artifact zips flatten symlinks into copies, which breaks the # bundle's code signature, so bundle real files and sign those ( - cd ./build/iris.app/Contents/Frameworks + cd dist/iris.app/Contents/Frameworks for f in *; do if [ -L "$f" ]; then target=$(readlink "$f") - sudo rm "$f" - sudo cp "$target" "$f" + rm "$f" + cp "$target" "$f" fi done ) - sudo codesign --force --deep --sign - ./build/iris.app - codesign --verify --deep --strict ./build/iris.app + codesign --force --deep --sign - dist/iris.app - name: Generate artifact name id: generate-name @@ -196,7 +196,7 @@ jobs: - name: Zip artifact run: | - cd build; zip -r ../${{ steps.generate-name.outputs.artifact }}.zip ./iris.app; cd .. + zip -r ${{ steps.generate-name.outputs.artifact }}.zip ./dist/ - name: Upload to release uses: softprops/action-gh-release@v3 diff --git a/.gitignore b/.gitignore index 5506882..d9b89c9 100644 --- a/.gitignore +++ b/.gitignore @@ -5,10 +5,12 @@ tools/ elf/ roms/ .vs/ +.venv/ ac/ screens/ imgui.ini iris.res +*.app *.AppImage *.expected *.dump diff --git a/CMakeLists.txt b/CMakeLists.txt index c4da37b..3e7d1ab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,12 +2,16 @@ cmake_minimum_required(VERSION 3.25) project(iris LANGUAGES C CXX) set(WIN_ICON ${CMAKE_CURRENT_SOURCE_DIR}/res/iris.rc) -set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64") -set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15") +set(CMAKE_OSX_DEPLOYMENT_TARGET "12") set(OSX_ICON ${CMAKE_CURRENT_SOURCE_DIR}/res/iris.icns) set_source_files_properties(${OSX_ICON} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources") +# Normalizing destinations good +if(POLICY CMP0177) + cmake_policy(SET CMP0177 NEW) +endif() + # Statically link SDL3 for Linux targets set(SDL_STATIC ON) set(ASMJIT_STATIC ON) @@ -469,7 +473,7 @@ if (CMAKE_SYSTEM_NAME MATCHES "Darwin") find_library(MOLTENVK_LIBRARY NAMES libMoltenVK.dylib - PATHS ENV VULKAN_SDK + PATHS /usr/local/lib ENV VULKAN_SDK PATH_SUFFIXES /lib ) @@ -520,50 +524,35 @@ set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT " message(STATUS "CMake System Name: ${CMAKE_SYSTEM_NAME}") if (CMAKE_SYSTEM_NAME MATCHES "Darwin") - # tell Install about the target, otherwise fixup won't know about the transitive dependencies - install(TARGETS iris - BUNDLE DESTINATION ./install COMPONENT Runtime - RUNTIME DESTINATION ./install/bin COMPONENT Runtime - ) - - set(BUNDLE_PATH "${CMAKE_BINARY_DIR}/iris.app") # where to look for dependencies when fixing up - file(GLOB VULKAN_DYLIBS $ENV{VULKAN_SDK}/lib/libvulkan.*.dylib) - set(VULKAN_DYLIBS ${VULKAN_DYLIBS} $ENV{VULKAN_SDK}/lib/libMoltenVK.dylib) + set(DIRS "/usr/local/lib") + if(DEFINED ENV{VULKAN_SDK}) + list(APPEND DIRS $ENV{VULKAN_SDK}/lib) + endif() + + # Install prefixes are passed through unnormalized, and fixup_bundle requires a complete path, therefore we need to clobber the bundle in the build folder. + # There's also no way to normalize a path given as a generator expression, like INSTALL_PREFIX. install(CODE " - execute_process(COMMAND echo \"Preparing to bundle iris...\") - execute_process(COMMAND echo \"Bundle path: ${BUNDLE_PATH}\") - execute_process(COMMAND echo \"Vulkan dylibs: ${VULKAN_DYLIBS}\") - execute_process(COMMAND echo \"Adding local RPATH...\") - execute_process( - COMMAND install_name_tool -add_rpath - \"@executable_path/../Frameworks\" - \"${BUNDLE_PATH}/Contents/MacOS/iris\" - ) - execute_process(COMMAND echo \"Creating ICD JSON directory...\") - make_directory(${BUNDLE_PATH}/Contents/Resources/vulkan/icd.d) - execute_process(COMMAND echo \"Creating Frameworks directory...\") - make_directory(${BUNDLE_PATH}/Contents/Frameworks) - execute_process(COMMAND echo \"Copying files...\") - file(COPY - ${CMAKE_CURRENT_SOURCE_DIR}/MoltenVK_icd.json - DESTINATION ${BUNDLE_PATH}/Contents/Resources/vulkan/icd.d/ - ) - file(COPY - ${VULKAN_DYLIBS} - DESTINATION ${BUNDLE_PATH}/Contents/Frameworks/ - ) - execute_process(COMMAND echo \"Signing app bundle...\") - execute_process(COMMAND - codesign --force --deep --sign - ${BUNDLE_PATH} - RESULT_VARIABLE codesign_result - OUTPUT_VARIABLE codesign_output - ) + include(BundleUtilities) + + make_directory($/Contents/Resources/vulkan/icd.d) + file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/MoltenVK_icd.json DESTINATION $/Contents/Resources/vulkan/icd.d/) + + fixup_bundle($ \"\" \"${DIRS}\") + + execute_process(COMMAND codesign --force --deep --sign - $ RESULT_VARIABLE codesign_result OUTPUT_VARIABLE codesign_output) if (codesign_result) execute_process(COMMAND echo \"${codesign_output}\") endif() ") + + # BUNDLE installs will try modify the rpath of the bundle, which won't work as fixup_bundle already does so. + install(FILES $ DESTINATION .) + + # FILES installs do not retain the executable flag on binaries. + install(CODE "execute_process(COMMAND /bin/sh -c \"chmod +x $/iris.app/Contents/Frameworks/* $/iris.app/Contents/MacOS/*\")") + set(CPACK_GENERATOR "DragNDrop") - include(CPack) + include(CPack) endif() if (CMAKE_SYSTEM_NAME MATCHES "Linux") diff --git a/README.md b/README.md index cf2947a..13ea4e1 100644 --- a/README.md +++ b/README.md @@ -91,14 +91,30 @@ cmake --build build ``` ### macOS - +Install the dependencies, for example with Homebrew: +```sh +brew install cmake ninja python ``` +Then clone: +```sh git clone https://github.com/allkern/iris --recursive cd iris -cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release +``` +mbedTLS uses a Python source generator, which requires some dependencies. You can use a virtual environment to install these locally: +```sh +python3 -m venv .venv +./.venv/bin/pip install -r deps/mbedtls/scripts/basic.requirements.txt +``` +Finally, configure and build: +```sh +cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DPython3_EXECUTABLE=$PWD/.venv/bin/python cmake --build build ``` -Optionally run `sudo cmake --install build` to generate a macOS App Bundle +You can also generate a proper Bundle if you'd like: +```sh +cmake --install build --prefix . +``` +You'll then find a full `iris.app` in the project directory. ## Progress/Insights Iris can boot/run a fairly large number of commercial games, playability may be all over the place though, some games run fairly smoothly, while others can't break the 1 digit FPS mark, this is due to the lack of EE/VU JITs which will be addressed soon.