diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 0bdb0478..b4c94c77 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -126,6 +126,264 @@ jobs: name: archives-${{ matrix.config.os }}-${{ matrix.config.arch }} path: new_release/* + windows-build: + strategy: + fail-fast: false + matrix: + config: + - { name: "windows", os: "windows-2022", arch: "x86_64", target: "x64" } + ocaml-compiler: + - 4.14.x + runs-on: ${{ matrix.config.os }} + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Fetch tags + run: git fetch --tags --force origin + + - uses: actions/cache@v5 + id: wincache + with: + path: | + ~/.opam + _opam + key: windows-${{ hashFiles('*.opam') }} + + - name: Install OCaml ${{ matrix.ocaml-compiler }} + uses: ocaml/setup-ocaml@v3 + with: + cache-prefix: v3 + ocaml-compiler: 4.14 + opam-pin: false + opam-repositories: | + default: https://github.com/punchagan/opam-repository.git#f1c70a26b442142ba1c3bd040bf8621060c94912 + + # - name: Install something that triggers mingw-w64-shims recompilation + # run: opam install conf-mingw-w64-gmp-x86_64 conf-mingw-w64-libffi-x86_64 conf-mingw-w64-openssl-x86_64 -y + + - name: Install system dependencies + run: | + opam depext conf-openssl conf-zlib -y + # On s'assure que les paquets sont bien là pour la compilation + opam install conf-openssl conf-zlib -y + + - name: Install dependencies + if: steps.wincache.outputs.cache-hit != 'true' + run: opam install --deps-only --with-test --with-doc -y . + + - name: Install dependencies + if: steps.wincache.outputs.cache-hit + run: opam install --deps-only --with-test --depext-only --with-doc -y . && opam upgrade + + - name: Build installable artifacts + run: opam exec -- dune build --profile release @install --ignore-promoted-rules + + - name: Install into relocatable bundle + run: opam exec -- dune install --relocatable --prefix ${{ github.workspace }}/bundle slipshow + + - name: Debug - Verify "${{ github.workspace }}\bundle" + run: | + Write-Output "Test ${{ github.workspace }}/bundle : $(Test-Path ${{ github.workspace }}/bundle)" + Get-ChildItem -Path ${{ github.workspace }}/bundle + + - name: Copy required DLLs into "${{ github.workspace }}\bundle\bin" + shell: pwsh + run: | + $bundleBin = "${{ github.workspace }}\bundle\bin" + $exe = "$bundleBin\slipshow.exe" + + # Retrieve Cygwin folder + $cygwinpath = "$env:LOCALAPPDATA\opam\.cygwin" + Write-host "cygwinpath = $cygwinpath" + + # Searches for DLLs in the typical Cygwin locations managed by OPAM + $searchRoots = @( + "C:\cygwin64\bin", + "C:\msys64\usr\bin", + "C:\msys64\mingw64\bin" + ) + ($env:PATH -split ";") + + # List of DLLs to copy + $dlls = @( + "libcrypto-3.dll", + "libssl-3.dll", + "zlib1.dll" + ) + + foreach ($dll in $dlls) { + $found = $false + + # Try to find the dll into typical Cygwin locations + if (Test-Path $cygwinpath) { + $sourceFile = Get-ChildItem $cygwinpath -Recurse -Filter $dll | + Select-Object -First 1 -ExpandProperty FullName + if (($null -ne $sourceFile) -and (Test-Path $sourceFile)) { + Copy-Item $sourceFile $bundleBin -Force + Write-Host "Library $dll copied from $sourceFile to $bundleBin" + $found = $true + } + } + + if (-not $found) { + # Try to find the dll into the Cygwin folder + foreach ($root in $searchRoots) { + $sourceFile = Join-Path $root $dll + if (Test-Path $sourceFile) { + Copy-Item $sourceFile $bundleBin -Force + Write-Host "Library $dll copied from $sourceFile to $bundleBin" + $found = $true + break + } + } + } + + if (-not $found) { + Write-Warning "Could not find library $dll" + } + } + + # - name: Prepare release directory + # run: | + # New-Item -ItemType Directory -Force -Path new_release + + # - name: Create ZIP archive slipshow-${{ matrix.config.name }}-${{ matrix.config.target }}.zip + # run: Compress-Archive -Path ${{ github.workspace }}/bundle/* -DestinationPath new_release/slipshow-${{ matrix.config.name }}-${{ matrix.config.target }}.zip + + # - name: Upload archives + # uses: actions/upload-artifact@v4 + # with: + # name: archives-windows-${{ matrix.config.arch }} + # path: new_release/*.zip + + - name: Install WiX 6 (required by OUI for Windows MSI) + shell: pwsh + run: | + dotnet tool install --global wix --version 6.0.2 + + # Ajouter le dossier des outils .NET globaux au PATH + $dotnetToolsPath = "$env:USERPROFILE\.dotnet\tools" + echo "$dotnetToolsPath" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + Write-Host "WiX installed, tools path: $dotnetToolsPath" + + # - name: Install OUI via opam + # run: opam install oui -y + # - name: Install OUI via opam (depuis les sources) + # run: opam pin add oui https://github.com/OCamlPro/ocaml-universal-installer.git#master --no-action -y && opam install oui -y + + # - name: Write oui.json + # shell: pwsh + # run: | + # # Récupérer la version depuis le tag git (ex: v1.2.3 → 1.2.3) + WiX exige major.minor.patch strictement numériques ; fallback sur 0.0.1 + # $version = (git describe --tags --abbrev=0 2>$null) -replace '^v', '' + # if (($version -eq $null) -ot ($version -notmatch '^\d+\.\d+\.\d+$')) { $version = "0.0.1" } + # Write-host "version = $version" + + # $config = @{ + # name = "slipshow" + # fullname = "Slipshow" + # version = $version + # unique_id = "com.slipshow.slipshow" + # wix_manufacturer = "Paul-Elliot" + # wix_description = "Slipshow is an engine to write slips, a concept evolved from slides." + # exec_files = @("bin/slipshow.exe") + # } + # $config | ConvertTo-Json -Depth 5 | Set-Content oui.json -Encoding UTF8 + # Write-Host "oui.json generated:" + # Get-Content oui.json + + # - name: Lint oui.json + # run: opam exec -- oui lint oui.json ${{ github.workspace }}/bundle + + # - name: Generate MSI installer with OUI + # run: | + # New-Item -ItemType Directory -Force -Path new_release + # opam exec -- oui build oui.json ${{ github.workspace }}/bundle --output-dir ${{ github.workspace }}/new_release + # shell: pwsh + + # - name: Debug - Verify "${{ github.workspace }}/new_release" + # run: | + # Write-Output "Test ${{ github.workspace }}/new_release : $(Test-Path ${{ github.workspace }}/new_release)" + # Get-ChildItem -Path ${{ github.workspace }}/new_release + + - name: Prepare release directory + shell: pwsh + run: New-Item -ItemType Directory -Force -Path new_release + + - name: Get version from git tag + continue-on-error: true + id: version + shell: pwsh + run: | + # $version = (git describe --tags --abbrev=0 2>$null) -replace '^v', '' + # if ($version -notmatch '^\d+\.\d+\.\d+$') { $version = "0.0.1" } + $version = "0.0.1" + echo "VERSION=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append + Write-Host "Version: $version" + + - name: Write WiX source file (slipshow.wxs) + shell: pwsh + run: | + $version = "${{ steps.version.outputs.VERSION }}" + $bundle = "${{ github.workspace }}\bundle" + + # Générer la liste des fichiers du bundle + $files = Get-ChildItem -Path "$bundle\bin" -File + $fileEntries = ($files | ForEach-Object { + $id = $_.Name -replace '[^a-zA-Z0-9]', '_' + " " + }) -join "`n" + + $wxs = @" + + + + + + + + + + + + + + + $fileEntries + + + + + + + + "@ + + $wxs | Set-Content slipshow.wxs -Encoding UTF8 + Write-Host "slipshow.wxs generated" + Get-Content slipshow.wxs + + - name: Build MSI with WiX + shell: pwsh + run: | + $version = "${{ steps.version.outputs.VERSION }}" + wix build slipshow.wxs -o "new_release\slipshow-windows-x64-${version}.msi" + Write-Host "MSI generated:" + Get-ChildItem new_release + + - name: Upload installer + uses: actions/upload-artifact@v4 + with: + name: archives-windows-${{ matrix.config.arch }} + path: new_release/*.msi + release: if: startsWith(github.ref, 'refs/tags/') needs: [linux-build, mac-build] diff --git a/dune-project b/dune-project index de9ef062..d8c7d7b9 100644 --- a/dune-project +++ b/dune-project @@ -32,7 +32,6 @@ bos lwt (inotify (= :os "linux")) - (cf-lwt (>="0.4")) astring fmt logs diff --git a/slipshow.opam b/slipshow.opam index 0cf4858b..5c00dea2 100644 --- a/slipshow.opam +++ b/slipshow.opam @@ -21,7 +21,6 @@ depends: [ "bos" "lwt" "inotify" {os = "linux"} - "cf-lwt" {>= "0.4"} "astring" "fmt" "logs" diff --git a/vendor/github.com/panglesd/lwd/lib/lwd/lwd_infix.ml b/vendor/github.com/panglesd/lwd/lib/lwd/lwd_infix.ml index 28f12a63..12935894 100644 --- a/vendor/github.com/panglesd/lwd/lib/lwd/lwd_infix.ml +++ b/vendor/github.com/panglesd/lwd/lib/lwd/lwd_infix.ml @@ -1,8 +1,6 @@ -(*BEGIN LETOP*) let (let$) : 'a Lwd.t -> ('a -> 'b) -> 'b Lwd.t = Lwd.Infix.(>|=) let (and$) : 'a Lwd.t -> 'b Lwd.t -> ('a * 'b) Lwd.t = Lwd.pair let (let$*) : 'a Lwd.t -> ('a -> 'b Lwd.t) -> 'b Lwd.t = Lwd.Infix.(>>=) -(*END*) let ($=) : 'a Lwd.var -> 'a -> unit = Lwd.set let ($<-) : 'a Lwd_table.row -> 'a -> unit = Lwd_table.set diff --git a/vendor/github.com/panglesd/lwd/lib/lwd/lwd_infix.mli b/vendor/github.com/panglesd/lwd/lib/lwd/lwd_infix.mli index a0757107..9d6fbbb8 100644 --- a/vendor/github.com/panglesd/lwd/lib/lwd/lwd_infix.mli +++ b/vendor/github.com/panglesd/lwd/lib/lwd/lwd_infix.mli @@ -1,4 +1,3 @@ -(*BEGIN LETOP*) val (let$) : 'a Lwd.t -> ('a -> 'b) -> 'b Lwd.t (** Alias to {!Lwd.map'} suitable for let-op bindings *) @@ -7,7 +6,6 @@ val (let$*) : 'a Lwd.t -> ('a -> 'b Lwd.t) -> 'b Lwd.t val (and$) : 'a Lwd.t -> 'b Lwd.t -> ('a * 'b) Lwd.t (** Alias to {!Lwd.pair} suitable for let-op bindings *) -(*END*) val ($=) : 'a Lwd.var -> 'a -> unit (** Infix alias to {!Lwd.set} *) diff --git a/vendor/github.com/panglesd/lwd/lib/lwd/lwd_seq.ml b/vendor/github.com/panglesd/lwd/lib/lwd/lwd_seq.ml index cbd48065..c6773aa5 100644 --- a/vendor/github.com/panglesd/lwd/lib/lwd/lwd_seq.ml +++ b/vendor/github.com/panglesd/lwd/lib/lwd/lwd_seq.ml @@ -1,8 +1,4 @@ -(*BEGIN INJECTIVITY*) type !+'a t = -(*ELSE*) -type +'a t = -(*END*) | Nil | Leaf of { mutable mark: int; v: 'a; } | Join of { mutable mark: int; l: 'a t; r: 'a t; } diff --git a/vendor/github.com/panglesd/lwd/lib/lwd/lwd_seq.mli b/vendor/github.com/panglesd/lwd/lib/lwd/lwd_seq.mli index f7607033..a5be682a 100644 --- a/vendor/github.com/panglesd/lwd/lib/lwd/lwd_seq.mli +++ b/vendor/github.com/panglesd/lwd/lib/lwd/lwd_seq.mli @@ -12,13 +12,8 @@ element. *) -(*BEGIN INJECTIVITY*) type !+'a t type !+'a seq = 'a t -(*ELSE*) -type +'a t -type +'a seq = 'a t -(*END*) (** The type of sequences *)