Switch Action and docs to use PowerShell

This commit is contained in:
sethg 2022-09-27 09:48:19 +02:00
commit 95d255e16e
2 changed files with 35 additions and 18 deletions

View file

@ -25,23 +25,30 @@ jobs:
submodules: recursive submodules: recursive
- name: Install Dependencies - name: Install Dependencies
shell: powershell
run: | run: |
nuget install CMake-win64 -Version 3.15.5 -OutputDirectory C:\Tools\CMake nuget install CMake-win64 -Version 3.15.5 -OutputDirectory C:\Tools\CMake
nuget install Bison -Version 3.7.4 -OutputDirectory C:\Tools\bison nuget install Bison -Version 3.7.4 -OutputDirectory C:\Tools\bison
nuget install PCRE2 -Version 10.39 -OutputDirectory C:\Tools\pcre2 nuget install PCRE2 -Version 10.39 -OutputDirectory C:\Tools\pcre2
- name: Build - name: Build
shell: cmd shell: powershell
run: | run: |
SET PATH=C:\Tools\CMake\CMake-win64.3.15.5\bin;C:\Tools\bison\Bison.3.7.4\bin;%PATH% $env:PATH="C:\Tools\CMake\CMake-win64.3.15.5\bin;C:\Tools\bison\Bison.3.7.4\bin;" + $env:PATH
SET PCRE_ROOT=C:\Tools\pcre2\PCRE2.10.39.0 $PCRE_ROOT="C:\Tools\pcre2\PCRE2.10.39.0"
SET PCRE_PLATFORM=x64 $PCRE_PLATFORM="x64"
cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_INSTALL_PREFIX="%CD:\=/%/install2" -DCMAKE_C_FLAGS="/DPCRE2_STATIC" ^ $WORKING_DIR=(Get-Location).ToString() -replace "\\","/"
-DCMAKE_CXX_FLAGS="/DPCRE2_STATIC" -DPCRE2_INCLUDE_DIR=%PCRE_ROOT%/include -DPCRE2_LIBRARY=%PCRE_ROOT%/lib/pcre2-8-static.lib -S . -B build cmake -G "Visual Studio 16 2019" -A "x64" `
-DCMAKE_INSTALL_PREFIX="$WORKING_DIR/install2" `
-DCMAKE_C_FLAGS="/DPCRE2_STATIC" `
-DCMAKE_CXX_FLAGS="/DPCRE2_STATIC" `
-DPCRE2_INCLUDE_DIR="$PCRE_ROOT/include" `
-DPCRE2_LIBRARY="$PCRE_ROOT/lib/pcre2-8-static.lib" `
-S . -B build
cmake --build build --config Release --target install cmake --build build --config Release --target install
- name: Test - name: Test
shell: cmd shell: powershell
working-directory: install2/bin working-directory: install2/bin
run: | run: |
swig.exe -version swig.exe -version

View file

@ -230,7 +230,7 @@ SWIG can also be compiled and run using <a href="https://www.msys2.org/">MSYS2</
<p> <p>
SWIG can be built using <a href="https://cmake.org/">CMake</a> and Visual Studio rather than autotools. As with the other approaches to SWIG can be built using <a href="https://cmake.org/">CMake</a> and Visual Studio rather than autotools. As with the other approaches to
building SWIG the dependencies need to be installed. The steps below are one of a number of ways of installing the dependencies without requiring Cygwin or MinGW. building SWIG the dependencies need to be installed. The steps below are one of a number of ways of installing the dependencies without requiring Cygwin or MinGW.
For fully working build steps always check the Continuous Integration (CI) setups currently detailed in the <a href="https://github.com/swig/swig/blob/master/appveyor.yml">Appveyor YAML file</a>. For fully working build steps always check the Continuous Integration (CI) setups currently detailed in the <a href="https://github.com/swig/swig/tree/master/.github/workflows/nuget.yml">GitHub Actions YAML file</a>.
</p> </p>
<ol> <ol>
@ -240,6 +240,7 @@ For fully working build steps always check the Continuous Integration (CI) setup
</li> </li>
<li> <li>
Install <a href="https://www.nuget.org/packages/CMake-win64/">CMake-win64 Nuget package</a> using the following command: <pre>C:\Tools\nuget install CMake-win64 -Version 3.15.5 -OutputDirectory C:\Tools\CMake</pre> Install <a href="https://www.nuget.org/packages/CMake-win64/">CMake-win64 Nuget package</a> using the following command: <pre>C:\Tools\nuget install CMake-win64 -Version 3.15.5 -OutputDirectory C:\Tools\CMake</pre>
Using PowerShell the equivalent syntax is: <pre>&"C:\Tools\nuget" install CMake-win64 -Version 3.15.5 -OutputDirectory C:\Tools\CMake</pre>
Alternatively you can download CMake from <a href="https://cmake.org/download/">https://cmake.org/download/</a>. Alternatively you can download CMake from <a href="https://cmake.org/download/">https://cmake.org/download/</a>.
</li> </li>
<li> <li>
@ -248,18 +249,18 @@ For fully working build steps always check the Continuous Integration (CI) setup
and save to a folder e.g. <tt>C:\Tools\Bison</tt> and save to a folder e.g. <tt>C:\Tools\Bison</tt>
</li> </li>
<li> <li>
Install the <a href="https://www.nuget.org/packages/pcre2/">PCRE2 Nuget package</a> using the following command: <pre>C:\Tools\nuget install PCRE2 -Version 10.39 -OutputDirectory C:\Tools\pcre2</pre>. Install the <a href="https://www.nuget.org/packages/pcre2/">PCRE2 Nuget package</a> using the following command: <pre>C:\Tools\nuget install PCRE2 -Version 10.39 -OutputDirectory C:\Tools\pcre2</pre>
Note this is a x64 build, if this is not suitable PCRE2 can be built from source using <a href="https://github.com/PhilipHazel/pcre2/">https://github.com/PhilipHazel/pcre2/</a>. Note this is a x64 build, if this is not suitable PCRE2 can be built from source using <a href="https://github.com/PhilipHazel/pcre2/">https://github.com/PhilipHazel/pcre2/</a>.
Alternatively, set <tt>WITH_PCRE=OFF</tt> to disable PCRE2 support if you are sure you do not require it. Alternatively, set <tt>WITH_PCRE=OFF</tt> to disable PCRE2 support if you are sure you do not require it.
</li> </li>
<li> <li>
We will also need the SWIG source code. Either download a zipped archive from GitHub, or if git is installed clone the latest codebase We will also need the SWIG source code. Either download a zipped archive from GitHub, or if git is installed clone the latest codebase
using <pre>git clone https://github.com/swig/swig.git</pre> using: <pre>git clone https://github.com/swig/swig.git</pre>
In this example we are assuming the source code is available at <tt>C:\swig</tt> In this example we are assuming the source code is available at <tt>C:\swig</tt>
</li> </li>
<li> <li>
<p> <p>
Now we have all the required dependencies we can build SWIG using the commands below. We are assuming Visual Studio 2019 is installed. For other versions of Visual Studio change <tt>"Visual Studio 16 2019 -A x64"</tt> to the relevant Now we have all the required dependencies we can build SWIG using PowerShell and the commands below. We are assuming Visual Studio 2019 is installed. For other versions of Visual Studio change <tt>"Visual Studio 16 2019 -A x64"</tt> to the relevant
<a href="https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html#visual-studio-generators">Visual Studio Generator</a> and <a href="https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html#visual-studio-generators">Visual Studio Generator</a> and
architecture. We add the required build tools to the system PATH, and then architecture. We add the required build tools to the system PATH, and then
build a Release version of SWIG. If all runs successfully a new swig.exe should be generated in the <tt>C:/swig/install2/bin</tt> folder. build a Release version of SWIG. If all runs successfully a new swig.exe should be generated in the <tt>C:/swig/install2/bin</tt> folder.
@ -268,16 +269,25 @@ For fully working build steps always check the Continuous Integration (CI) setup
</ol> </ol>
<div class="shell"><pre> <div class="shell"><pre>
cd C:\swig cd C:\swig
SET PATH=C:\Tools\CMake\CMake-win64.3.15.5\bin;C:\Tools\bison\Bison.3.7.4\bin;%PATH%
SET PCRE_ROOT=C:\Tools\pcre2\PCRE2.10.39.0 $env:PATH="C:\Tools\CMake\CMake-win64.3.15.5\bin;C:\Tools\bison\Bison.3.7.4\bin;" + $env:PATH
SET PCRE_PLATFORM=x64 $PCRE_ROOT="C:\Tools\pcre2\PCRE2.10.39.0"
cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_INSTALL_PREFIX="%CD:\=/%/install2" -DCMAKE_C_FLAGS="/DPCRE2_STATIC" ^ $PCRE_PLATFORM="x64"
-DCMAKE_CXX_FLAGS="/DPCRE2_STATIC" -DPCRE2_INCLUDE_DIR=%PCRE_ROOT%/include -DPCRE2_LIBRARY=%PCRE_ROOT%/lib/pcre2-8-static.lib -S . -B build
cmake -G "Visual Studio 16 2019" -A "x64" `
-DCMAKE_INSTALL_PREFIX="C:/swig/install2" `
-DCMAKE_C_FLAGS="/DPCRE2_STATIC" `
-DCMAKE_CXX_FLAGS="/DPCRE2_STATIC" `
-DPCRE2_INCLUDE_DIR="$PCRE_ROOT/include" `
-DPCRE2_LIBRARY="$PCRE_ROOT/lib/pcre2-8-static.lib" `
-S . -B build
cmake --build build --config Release --target install cmake --build build --config Release --target install
REM to test the exe # to test the exe built correctly
cd install2/bin cd install2/bin
swig.exe -help ./swig.exe -version
./swig.exe -help
</pre></div> </pre></div>
<p> <p>