From a6fc1625ea8f825a7161354eb9167a281542fa29 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Tue, 13 Oct 2026 05:13:32 +0000 Subject: build: package Windows releases as ZIP archives Co-Authored-By: Claude Fable 5.1 --- AGENTS/ARCH.md | 8 ++++++++ CMakeLists.txt | 7 ++++++- README.md | 27 ++++++++++++++++++++++++++- cmake/Release.cmake | 24 ++++++++++++++++++++---- 4 files changed, 60 insertions(+), 6 deletions(-) diff --git a/AGENTS/ARCH.md b/AGENTS/ARCH.md index fb33471..baa8a74 100644 --- a/AGENTS/ARCH.md +++ b/AGENTS/ARCH.md @@ -88,6 +88,14 @@ Windows `mingw32-make -C build install` builds the HTML manual and invokes `install.ps1` through Windows PowerShell with the build directory and `CMAKE_INSTALL_PREFIX`. The default Windows prefix is the per-user Programs directory above; explicit prefixes are preserved. Unix still invokes `install.sh`. +The release target explicitly passes the configured Windows flag to +`cmake/Release.cmake`, since a standalone CMake script otherwise describes the +host platform. Windows packages `cpsc.exe`, `doc/cpsc.html`, `install.ps1` and +`LICENSE` as `build/cpsc-VERSION-Windows-ARCH.zip` using CMake's default Deflate +compression. Unix retains `.tar.xz`, the POSIX installer and the man page. +Linux smoke tests can configure an isolated build with `-DWIN32=TRUE` to exercise +HTML/ZIP packaging; the resulting renamed Linux executable is only a test fixture, +not a usable Windows release. Build pin: developed and tested against **LLVM 18**. (The historical LLVM 19 breakage — `ArithmeticHandler.cc` touching `llvm::Module` through a transitive include — is gone diff --git a/CMakeLists.txt b/CMakeLists.txt index 508e61a..73ab34c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -101,12 +101,17 @@ add_custom_target(doc DEPENDS "${cpsc_manual_file}") configure_file(cmake/Install.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/Install.cmake" @ONLY) install(SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/Install.cmake") +set(cpsc_release_system "${CMAKE_SYSTEM_NAME}") +if(WIN32) + set(cpsc_release_system Windows) +endif() add_custom_target(release COMMAND "${CMAKE_COMMAND}" "-DCPSC_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}" "-DCPSC_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}" "-DCPSC_EXECUTABLE=$" - "-DCPSC_PLATFORM=${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}" + "-DCPSC_PLATFORM=${cpsc_release_system}-${CMAKE_SYSTEM_PROCESSOR}" + "-DCPSC_WINDOWS=${WIN32}" -P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Release.cmake" DEPENDS cpsc doc COMMENT "Packaging cpsc and its manual" diff --git a/README.md b/README.md index 35a856f..1155db2 100644 --- a/README.md +++ b/README.md @@ -183,7 +183,7 @@ You can also run `./install.sh --source-dir build --prefix "$HOME/.local"` directly after building `cpsc` and running `make -C build doc`. `DESTDIR` is supported for staging, for example `DESTDIR=/tmp/cpsc-stage make -C build install`. -Create an installation archive with: +On Unix, create an installation archive with: ```bash make -C build release @@ -232,6 +232,31 @@ or `-Help` for usage. Windows installation does not support `DESTDIR` staging. The PowerShell installer targets Windows PowerShell 5.1 or later and has only been reviewed statically; Windows installation still needs testing on Windows. +Create a Windows installation archive from the configured MinGW build with: + +```powershell +cmake --build build --target release +``` + +This is equivalent to `mingw32-make -C build release`. Windows produces +`build/cpsc-VERSION-Windows-ARCH.zip`, using the same UTC commit version as Unix +and retaining the configured execution mode. The ZIP contains `cpsc.exe`, +`doc/cpsc.html`, `install.ps1` and `LICENSE` under one top-level directory. +It uses CMake's default Deflate compression and needs no additional compression +tool; packaging requires Git and Pandoc, just as on Unix. + +Extract the ZIP using Windows Explorer, open PowerShell in the extracted package +directory, then run: + +```powershell +powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\install.ps1 +``` + +Recipients need neither CMake, Git nor Pandoc to install. To check installation, +open a new terminal, run `Get-Command cpsc` and compile a source with +`cpsc test.cps`; open Start Menu > cpsc > cpsc Help to check the manual. Running +the installer again should leave only one entry for its directory in the user PATH. + # Note DO NOT OPEN ANY ISSUES IF YOU COMPILE WITH VISUAL STUDIO OR ANYTHING EXCEPT MINGW-W64 (EVEN WITH MINGW-W64, WINDOWS IS LIKELY TO BE A PROBLEM MAKER) diff --git a/cmake/Release.cmake b/cmake/Release.cmake index be78088..fe78711 100644 --- a/cmake/Release.cmake +++ b/cmake/Release.cmake @@ -14,15 +14,31 @@ set(cpsc_short_id "${CMAKE_MATCH_2}") string(TIMESTAMP cpsc_commit_time "%Y-%m-%d-%H-%M-%S" UTC) set(cpsc_package_name "cpsc-${cpsc_commit_time}-${cpsc_short_id}-${CPSC_PLATFORM}") set(cpsc_package_dir "${CPSC_BINARY_DIR}/release/${cpsc_package_name}") -set(cpsc_archive "${CPSC_BINARY_DIR}/${cpsc_package_name}.tar.xz") +if(CPSC_WINDOWS) + set(cpsc_archive "${CPSC_BINARY_DIR}/${cpsc_package_name}.zip") + set(cpsc_binary_name cpsc.exe) + set(cpsc_installer install.ps1) + set(cpsc_manual cpsc.html) + set(cpsc_tar_flags cf) + set(cpsc_archive_format zip) +else() + set(cpsc_archive "${CPSC_BINARY_DIR}/${cpsc_package_name}.tar.xz") + set(cpsc_binary_name cpsc) + set(cpsc_installer install.sh) + set(cpsc_manual cpsc.1) + set(cpsc_tar_flags cJf) + set(cpsc_archive_format gnutar) +endif() file(REMOVE_RECURSE "${cpsc_package_dir}") file(MAKE_DIRECTORY "${cpsc_package_dir}/doc") -file(COPY "${CPSC_EXECUTABLE}" "${CPSC_SOURCE_DIR}/install.sh" "${CPSC_SOURCE_DIR}/LICENSE" +configure_file("${CPSC_EXECUTABLE}" "${cpsc_package_dir}/${cpsc_binary_name}" COPYONLY) +file(COPY "${CPSC_SOURCE_DIR}/${cpsc_installer}" "${CPSC_SOURCE_DIR}/LICENSE" DESTINATION "${cpsc_package_dir}") -file(COPY "${CPSC_BINARY_DIR}/doc/cpsc.1" DESTINATION "${cpsc_package_dir}/doc") +file(COPY "${CPSC_BINARY_DIR}/doc/${cpsc_manual}" DESTINATION "${cpsc_package_dir}/doc") execute_process( - COMMAND "${CMAKE_COMMAND}" -E tar cJf "${cpsc_archive}" --format=gnutar "${cpsc_package_name}" + COMMAND "${CMAKE_COMMAND}" -E tar "${cpsc_tar_flags}" "${cpsc_archive}" + "--format=${cpsc_archive_format}" "${cpsc_package_name}" WORKING_DIRECTORY "${CPSC_BINARY_DIR}/release" RESULT_VARIABLE cpsc_tar_result ) -- cgit v1.3.1-4-g156e