We write a small .bat file wrapper and then force CMake
to use that.

Note that we need to specify the path with / instead of \
as path separator because otherwise run-cmake action will
mangle it.

Change-Id: I05d3f7f3f7f7418d1977e523c6dcfb6fa5feb604
Signed-off-by: Frank Lichtenheld <fr...@lichtenheld.com>
---
 .github/workflows/build.yaml | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

This is an alternate patch to "CMake: Support doc builds on
Windows machines that do not have .py file association" since
there was some doubt on IRC whether we want to have the complexity
inside of CMake or should delegate that to the caller.

Let me know your opinions.

diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index da2a427c..72edb089 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -286,8 +286,25 @@ jobs:
       - uses: actions/checkout@v3
       - uses: lukka/get-cmake@latest
 
+      # since we can't execute .py files directly, do a workaround for 
rst2html,rst2man
+      - name: Determine Python script path
+        run: |
+          import os
+          import sysconfig
+          scripts_path = sysconfig.get_path("scripts",f"{os.name}")
+          with open(os.environ["GITHUB_ENV"], "a") as env:
+            print(f"PYTHON_SCRIPTS_DIR={scripts_path}", file=env)
+        shell: python
       - name: Install rst2html
-        run: python -m pip install --upgrade pip docutils
+        run: |
+          python -m pip install --upgrade pip docutils
+          $install_dir = "${{ runner.workspace }}\docutils"
+          mkdir $install_dir
+          echo "python $Env:PYTHON_SCRIPTS_DIR\rst2html.py %*" > 
$install_dir\rst2html.bat
+          cat $install_dir\rst2html.bat
+          echo "python $Env:PYTHON_SCRIPTS_DIR\rst2man.py %*" > 
$install_dir\rst2man.bat
+          $safe_path = $install_dir.replace("\", "/")
+          echo "DOCUTILS=$safe_path" >> "$Env:GITHUB_ENV"
 
       - name: Restore artifacts, or setup vcpkg (do not install any package)
         uses: lukka/run-vcpkg@v11
@@ -300,6 +317,7 @@ jobs:
         if: ${{ matrix.arch == 'arm64' }}
         with:
           configurePreset: win-${{ matrix.arch }}-release
+          configurePresetAdditionalArgs: "[`-DRST2HTML=${{ env.DOCUTILS 
}}/rst2html.bat`, `-DRST2MAN=${{ env.DOCUTILS }}/rst2man.bat`]"
           buildPreset: win-${{ matrix.arch }}-release
 
       - name: Run CMake with vcpkg.json manifest
@@ -307,6 +325,7 @@ jobs:
         if: ${{ matrix.arch != 'arm64' }}
         with:
           configurePreset: win-${{ matrix.arch }}-release
+          configurePresetAdditionalArgs: "[`-DRST2HTML=${{ env.DOCUTILS 
}}/rst2html.bat`, `-DRST2MAN=${{ env.DOCUTILS }}/rst2man.bat`]"
           buildPreset: win-${{ matrix.arch }}-release
           testPreset: win-${{ matrix.arch }}-release
 
-- 
2.34.1



_______________________________________________
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to