Parcourir la source

chore(windows): PaoTin++ for Windows

dzp il y a 2 ans
Parent
commit
32d8fe69c7
2 fichiers modifiés avec 322 ajouts et 0 suppressions
  1. 154 0
      .github/workflows/windows-publish.yml
  2. 168 0
      install.nsi

+ 154 - 0
.github/workflows/windows-publish.yml

@@ -0,0 +1,154 @@
+name: Windows build and publish
+
+# This workflow uses actions that are not certified by GitHub.
+# They are provided by a third-party and are governed by
+# separate terms of service, privacy policy, and support
+# documentation.
+
+on:
+  push:
+    branches: [ "beta" ]
+    # Publish semver tags as releases.
+    tags: [ 'v*.*.*' ]
+  pull_request:
+    branches: [ "master" ]
+
+env:
+  # Use docker.io for Docker Hub if empty
+  REGISTRY: docker.io
+  # github.repository as <account>/<repo>
+  IMAGE_NAME: ${{ github.repository }}
+
+
+jobs:
+  build:
+    runs-on: windows-2019
+
+    outputs:
+      name: ${{ steps.exe-name.outputs.EXENAME }}
+
+    defaults:
+      run:
+        shell: C:\tools\cygwin\bin\bash.exe --login --norc -eo pipefail -o igncr '{0}'
+
+    steps:
+      - name: Set up Cygwin
+        uses: egor-tensin/setup-cygwin@v4
+        with:
+          packages: make gcc-g++ zlib-devel
+
+      - name: Set git to use LF
+        shell: pwsh
+        run: |
+          git config --global core.autocrlf false
+          git config --global core.eol lf
+
+      - name: Check out code
+        uses: actions/checkout@v1
+        with:
+          submodules: true
+
+      - name: Get current time
+        id: time1
+        uses: Kaven-Universe/github-action-current-date-time@v1
+        with:
+          format: "YYYYMMDD-HHmmss"
+          timezone-offset: -480
+
+      - uses: benjlevesque/short-sha@v2.2
+        id: short-sha
+        with:
+          length: 6
+
+      - name: Generate artifact name
+        id: exe-name
+        run: |
+          echo "$GITHUB_OUTPUT"
+          echo "EXENAME=$EXENAME" >> "$GITHUB_OUTPUT"
+        env:
+          EXENAME: paotin-for-windows-setup-${{ steps.time1.outputs.time }}-B${{ github.run_number }}-g${{ steps.short-sha.outputs.sha }}.exe
+
+      - name: Install PCRE
+        run: |
+          cd $(cygpath $GITHUB_WORKSPACE)
+          curl -sL https://sourceforge.net/projects/pcre/files/pcre/8.45/pcre-8.45.tar.bz2/download | tar jxvf -
+          (cd pcre-8.45 && ./configure --enable-unicode-properties --prefix=$(pwd)/usr LDFLAGS=-static && make && make install)
+
+      - name: Compile
+        env:
+          CFLAGS: -I../../pcre-8.45/usr/include
+          CPPFLAGS: -I../../pcre-8.45/usr/include
+          LDFLAGS: -static -L../../pcre-8.45/usr/lib
+        run: |
+          cd $(cygpath $GITHUB_WORKSPACE)
+          (cd tintin/src && ./configure && make && strip tt++ || cat config.log)
+
+      - name: Check TinTin++
+        run: |
+          cd $(cygpath $GITHUB_WORKSPACE)
+          ls -lh tintin/src/tt++
+          file tintin/src/tt++
+          ldd tintin/src/tt++
+          tintin/src/tt++ -V || true
+
+      - name: Packaging
+        run: |
+          cd $(cygpath $GITHUB_WORKSPACE)
+          cp tintin/src/tt++.exe bin/
+          cp /bin/cygwin1.dll bin/
+          rm -rf .git
+          rm -rf .github
+          rm -rf tintin
+          rm -rf pcre-8.45
+
+      - name: Create installer
+        uses: joncloud/makensis-action@v4
+        with:
+          script-file: install.nsi
+          arguments: "/V3"
+
+      - name: Rename installer
+        run: |
+          cd $(cygpath $GITHUB_WORKSPACE)
+          mv setup.exe ${{ steps.exe-name.outputs.EXENAME }}
+
+      - name: Create artifact -- PaoTin++ Installer
+        uses: actions/upload-artifact@v3
+        with:
+          name: ${{ steps.exe-name.outputs.EXENAME }}
+          path: ${{ steps.exe-name.outputs.EXENAME }}
+
+      - name: Create artifact -- WinTin++
+        uses: actions/upload-artifact@v3
+        with:
+          name: WinTin++
+          path: |
+            ${{ github.workspace }}/bin/tt++.exe
+            ${{ github.workspace }}/bin/cygwin1.dll
+
+      - name: Release
+        uses: softprops/action-gh-release@v1
+        if: startsWith(github.ref, 'refs/tags/')
+        with:
+          files: |
+            ${{ github.workspace }}/tintin/src/tt++.exe
+            ${{ github.workspace }}/README.md
+
+  publish:
+    runs-on: ubuntu-latest
+    needs: build
+    steps:
+      - name: Retrieve artifact files
+        uses: actions/download-artifact@v3
+        with:
+          name: ${{ needs.build.outputs.name }}
+
+      - name: Send to file server
+        uses: appleboy/scp-action@v0.1.4
+        with:
+          host: ${{ secrets.FILE_SERVER_HOST }}
+          port: ${{ secrets.FILE_SERVER_PORT }}
+          username: ${{ secrets.FILE_SERVER_USER }}
+          key: ${{ secrets.FILE_SERVER_KEY }}
+          source: ${{ needs.build.outputs.name }}
+          target: ${{ secrets.FILE_SERVER_ROOT }}/Windows/

+ 168 - 0
install.nsi

@@ -0,0 +1,168 @@
+Name "PaoTin++ for Windows"
+OutFile setup.exe
+ShowInstDetails show
+AllowRootDirInstall true
+
+!include "FileFunc.nsh"
+!include "nsDialogs.nsh"
+!include "winmessages.nsh"
+
+Page custom SelectDriver
+Page instfiles
+
+var dialog
+var hctrl
+var drive
+
+Function getDrivesCallback
+    ${NSD_CB_AddString} $hctrl "$9"
+	Push $0
+FunctionEnd
+
+Function changeSelect
+    ${NSD_GetText} $hctrl $0
+    StrCpy $drive $0
+FunctionEnd
+
+Function SelectDriver
+	nsDialogs::Create 1018
+	Pop $dialog
+
+    ${NSD_CreateLabel} 0 10u 100% 20u "Select which disk you want to install to:"
+    Pop $hctrl
+    ${NSD_CreateDropList} 0 30u 100% 80u "Select"
+    Pop $hctrl
+
+	${GetDrives} "HDD" "getDrivesCallback"
+    StrCpy $drive "C:\"
+    ${NSD_CB_SelectString} $hctrl "$drive"
+
+    ${NSD_OnChange} $hctrl "changeSelect"
+
+	nsDialogs::Show
+FunctionEnd
+
+var file
+var dir
+
+Section
+    StrCpy $drive $drive 2
+    StrCpy $file "$TEMP\settings.json"
+	FileOpen $R3 $file w
+	FileWrite $R3 "{$\r$\n"
+    FileWrite $R3 "    $\"profiles$\": $\r$\n"
+    FileWrite $R3 "    {$\r$\n"
+    FileWrite $R3 "        $\"defaults$\": {},$\r$\n"
+    FileWrite $R3 "        $\"list$\": $\r$\n"
+    FileWrite $R3 "        [$\r$\n"
+    FileWrite $R3 "            {$\r$\n"
+    FileWrite $R3 "                $\"commandline$\": $\"$drive\\paotin\\bin\\tt++.exe ids/tintin$\",$\r$\n"
+    FileWrite $R3 "                $\"guid$\": $\"{0b778637-b3ef-410d-b678-3f825e2cdef1}$\",$\r$\n"
+    FileWrite $R3 "                $\"hidden$\": false,$\r$\n"
+    FileWrite $R3 "                $\"name$\": $\"WinTin++$\",$\r$\n"
+    FileWrite $R3 "                $\"startingDirectory$\": $\"$drive\\paotin$\"$\r$\n"
+    FileWrite $R3 "            },$\r$\n"
+    FileWrite $R3 "            {$\r$\n"
+    FileWrite $R3 "                $\"commandline$\": $\"$drive\\paotin\\bin\\tt++.exe ids/paotin$\",$\r$\n"
+    FileWrite $R3 "                $\"guid$\": $\"{0b778637-b3ef-410d-b678-3f825e2cdef2}$\",$\r$\n"
+    FileWrite $R3 "                $\"hidden$\": false,$\r$\n"
+    FileWrite $R3 "                $\"name$\": $\"PaoTin++ for Windows$\",$\r$\n"
+    FileWrite $R3 "                $\"startingDirectory$\": $\"$drive\\paotin$\"$\r$\n"
+    FileWrite $R3 "            },$\r$\n"
+    FileWrite $R3 "            {$\r$\n"
+    FileWrite $R3 "                $\"commandline$\": $\"$drive\\paotin\\bin\\tt++.exe ids/pkuxkx$\",$\r$\n"
+    FileWrite $R3 "                $\"guid$\": $\"{0b778637-b3ef-410d-b678-3f825e2cdef3}$\",$\r$\n"
+    FileWrite $R3 "                $\"hidden$\": false,$\r$\n"
+    FileWrite $R3 "                $\"name$\": $\"\u5317\u5927\u4fa0\u5ba2\u884c$\",$\r$\n"
+    FileWrite $R3 "                $\"startingDirectory$\": $\"$drive\\paotin$\"$\r$\n"
+    FileWrite $R3 "            },$\r$\n"
+    FileWrite $R3 "            {$\r$\n"
+    FileWrite $R3 "                $\"commandline$\": $\"$drive\\paotin\\bin\\tt++.exe ids/thuxyj$\",$\r$\n"
+    FileWrite $R3 "                $\"guid$\": $\"{0b778637-b3ef-410d-b678-3f825e2cdef4}$\",$\r$\n"
+    FileWrite $R3 "                $\"hidden$\": false,$\r$\n"
+    FileWrite $R3 "                $\"name$\": $\"\u6e05\u534e\u897f\u6e38\u8bb0$\",$\r$\n"
+    FileWrite $R3 "                $\"startingDirectory$\": $\"$drive\\paotin$\"$\r$\n"
+    FileWrite $R3 "            }$\r$\n"
+    FileWrite $R3 "        ]$\r$\n"
+    FileWrite $R3 "    }$\r$\n"
+    FileWrite $R3 "}$\r$\n"
+    FileClose $R3
+
+    StrCpy $dir "$LocalAppData\Microsoft\Windows Terminal\Fragments\PaoTin++"
+    CreateDirectory "$dir"
+    CopyFiles /SILENT "$file" "$dir"
+    StrCpy $dir "$LocalAppData\Microsoft\Windows Terminal Preview\Fragments\PaoTin++"
+    CreateDirectory "$dir"
+    CopyFiles /SILENT "$file" "$dir"
+SectionEnd
+
+Section
+    StrCpy $INSTDIR "$drive\paotin"
+    StrCpy $OUTDIR "$drive\paotin"
+    SetOutPath "$INSTDIR"
+    RMDir "$INSTDIR"
+    File /r *
+SectionEnd
+
+!define CreateJunction "!insertmacro CreateJunction"
+
+Function CreateJunction
+    Exch $4
+    Exch
+    Exch $5
+    Push $1
+    Push $2
+    Push $3
+    Push $6
+    CreateDirectory "$5"
+    System::Call "kernel32::CreateFileW(w `$5`, i 0x40000000, i 0, i 0, i 3, i 0x02200000, i 0) i .r6"
+
+    ${If} $0 = "-1"
+        StrCpy $0 "0"
+        RMDir "$5"
+        goto create_junction_end
+    ${EndIf}
+
+    CreateDirectory "$4"  ; Windows XP requires that the destination exists
+    StrCpy $4 "\??\$4"
+    StrLen $0 $4
+    IntOp $0 $0 * 2
+    IntOp $1 $0 + 2
+    IntOp $2 $1 + 10
+    IntOp $3 $1 + 18
+    System::Call "*(i 0xA0000003, &i4 $2, &i2 0, &i2 $0, &i2 $1, &i2 0, &w$1 `$4`, &i2 0)i.r2"
+    System::Call "kernel32::DeviceIoControl(i r6, i 0x900A4, i r2, i r3, i 0, i 0, *i r4r4, i 0) i.r0"
+    System::Call "kernel32::CloseHandle(i r6) i.r1"
+
+    ${If} $0 == "0"
+        RMDir "$5"
+    ${EndIf}
+
+    create_junction_end:
+    Pop $6
+    Pop $3
+    Pop $2
+    Pop $1
+    Pop $5
+    Pop $4
+FunctionEnd
+
+!macro CreateJunction Junction Target outVar
+    Push $0
+    Push "${Junction}"
+    Push "${Target}"
+    Call CreateJunction
+    StrCpy ${outVar} $0
+    Pop $0
+!macroend
+
+Section
+    CreateDirectory "$drive\my-paotin"
+    CreateDirectory "$drive\my-paotin\ids"
+    CreateDirectory "$drive\my-paotin\etc"
+    CreateDirectory "$drive\my-paotin\data"
+    CreateDirectory "$drive\my-paotin\log"
+    CreateDirectory "$drive\my-paotin\plugins"
+
+    ${CreateJunction} "$drive\paotin\var" "$drive\my-paotin" $0
+SectionEnd