Skip to content

Commit 69a2efb

Browse files
committed
fix: revert to dynlib on Windows
1 parent 392751e commit 69a2efb

13 files changed

+192
-175
lines changed

.github/snippets/get-cargo-os.yml

+38-89
Original file line numberDiff line numberDiff line change
@@ -6,50 +6,20 @@ value:
66
- name: Install MacOS dependencies
77
if: matrix.os == 'macos-latest'
88
run: brew update; brew install gpgme
9-
- name: Setup Msys2 on Windows
10-
if: matrix.os == 'windows-latest'
11-
uses: msys2/setup-msys2@v2
12-
with:
13-
update: true
14-
msystem: mingw64
15-
path-type: inherit
16-
install: >-
17-
base-devel
18-
git
19-
mingw-w64-x86_64-toolchain
209
- name: Install Windows dependencies
2110
if: matrix.os == 'windows-latest'
22-
env:
23-
RUNNER_TEMP: ${{ runner.temp }}
24-
working-directory: ${{ runner.temp }}
25-
shell: msys2 {0}
26-
# Short version, the choco install only provideds 32-bit dynamic
27-
# libraries for some reason. We want to try 64-bit static links, so
28-
# we have to build all the deps ourselves. Also, the gpgme python
29-
# install scripts use subprocess.Popen and friends, which are all
30-
# horked in msys2, so we'll stick to only C and C++ libs.
11+
# Use choco to install gnupg; directly downloading + running the
12+
# gnupg.exe installer silently fails somehow after setting the
13+
# registry, but before/during writing to the `C:\Program Files
14+
# (x86)\gnupg` filesystem. Also see
15+
# https://github.com/actions/virtual-environments/issues/2876 to
16+
# ensure that the $env:PATH doesn't run out of characters when
17+
# running choco.
3118
run: |
32-
curl https://gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-1.42.tar.bz2 -o libgpg-error-1.42.tar.bz2
33-
tar -jxf libgpg-error-1.42.tar.bz2
34-
curl https://gnupg.org/ftp/gcrypt/libassuan/libassuan-2.5.5.tar.bz2 -o libassuan-2.5.5.tar.bz2
35-
tar -jxf libassuan-2.5.5.tar.bz2
36-
curl https://gnupg.org/ftp/gcrypt/gpgme/gpgme-1.16.0.tar.bz2 -o gpgme-1.16.0.tar.bz2
37-
tar -jxf gpgme-1.16.0.tar.bz2
38-
pushd libgpg-error-1.42
39-
./configure --enable-static
40-
make
41-
make install
42-
popd
43-
pushd libassuan-2.5.5
44-
./configure --enable-static
45-
make
46-
make install
47-
popd
48-
pushd gpgme-1.16.0
49-
./configure --enable-static --enable-languages=cl,cpp
50-
make
51-
make install
52-
popd
19+
$env:PATH = "C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\ProgramData\chocolatey\bin"
20+
[Environment]::SetEnvironmentVariable("Path", $env:PATH, "Machine")
21+
choco install -y gnupg
22+
echo "C:\Program Files (x86)\GnuPG\bin" >> $env:GITHUB_PATH
5323
- name: Get cargo stable
5424
if: matrix.os != 'windows-latest'
5525
uses: actions-rs/toolchain@v1
@@ -63,69 +33,48 @@ value:
6333
toolchain: nightly
6434
components: rustfmt
6535
- name: Get Windows cargo stable
66-
# After dozens of stabs at this, we have decided to build the gpgme
67-
# dependencies ourselves, in order to provide a 64-bit statically
68-
# linked binary. (On windows, the gpgme pre-built packages from
69-
# chocolatey etc only provide 32-bit dynamic libs.) There are still
70-
# plenty of issues on this route, though, including:
71-
#
72-
# 1. You can't use the msvc target to build gnupg; the gpg libraries
73-
# are built with the GNU toolchain, and are apparently nigh-on
74-
# impossible to build in Studio.
75-
# 2. The GNU toolchain included in the Windows runner is
76-
# different than the builtin rust installation. That *shouldn't*
77-
# be a problem (as of 2020-02, rust is supposed to by favor the
78-
# system toolchain), but somehow it is.
79-
# 3. The GNU runner toolchain still seems to be half-baked, and is
80-
# missing libraries. Also, its compiler isn't even on the PATH,
81-
# making it impossible for cargo to find, and thus to include its
82-
# associated libs. You can't even build GNU C programs
83-
# without explicitly adding it yourself before you compile. See
84-
# https://github.com/actions/virtual-environments/issues/2549
36+
# I give up. We are going to distribute Windows Versio as a 32-bit
37+
# dynamic-link to gpgme, and include documentation that gpgme is
38+
# required to run.
8539
#
86-
# However, there is a `msys2/setup-msys2@v2` action available, which
87-
# provides a more complete dev environment for building gnu-based
88-
# windows applications, and handles many (but not quite all) of the
89-
# path problems.
40+
# Commit `88e4066` (v0.5.3, 20210818023324Z) of this repo contains a
41+
# static-link for all three platforms build on GitHub Actions. This
42+
# is a big step over the previous successful build `d0d3533`
43+
# (20210803124432T-0600) which inadvertantly dynamically linked the
44+
# gpgme libraries on all platforms.
9045
#
91-
# So, it looks like the best way to build this is to use the msvc
92-
# toolchain to cross-compile to the gnu target inside the msys2
93-
# shell. This was actually recommended by various reputable internet
94-
# sources (none of which I can find right now). Also, we need to
95-
# ensure that the correct target is selected on Windows builds, and
96-
# that the cross-compile toolchain can be found. So for Windows
97-
# builds, we need to
46+
# For Windows especially, `88e4066` was the culmination of a lot
47+
# of effort: we downloaded and built the gpg-error, assuan, and
48+
# gpgme dependencies manually, since the publically-available
49+
# pre-built dependencies (via chocolatey, et al) only contain
50+
# dynamic 32-bit libs, and had to use the msys2 shell to incorporate
51+
# the gnu toolchain. However, even then the resulting Windows
52+
# executable couldn't bind to `gpg-agent` or fork `gpgme-w32spawn`,
53+
# likely as a result of the static linkage that the gpgme system was
54+
# not designed to accomodate.
9855
#
99-
# - install the msys2 shell and development tools. (see the `uses:
100-
# msys2/setup-msys2@v2` up above)
101-
# - ensure that the stable- or nightly-x86_64-pc-windows-msvc
102-
# cargo toolchain is installed and selected.
103-
# - ensure that the cross-compile x86_64-pc-windows-gnu target is
104-
# installed for that cargo toolchain.
105-
# - ensure that the cross-compile toolchain tools are actually
106-
# available (`windows-latest` does satisfy this with msys2/mingw)
107-
# - use the msys2 shell and `--release --target
108-
# x86_64-pc-windows-gnu` for all cargo commands.
109-
# - remember that this will build to the
110-
# `target/i686-pc-windows-gnu/release` directory.
56+
# So, we've reverted the Windows build steps back to their dynamic
57+
# 32-bit instructions, which are still somewhat convoluted: we need
58+
# to use the 32-bit-msvc toolchain to cross-compile to the
59+
# 32-bit-gnu target, and explicitly add the 32-bit compiler on PATH
60+
# a la https://github.com/actions/virtual-environments/issues/2549.
11161
if: matrix.os == 'windows-latest'
11262
uses: actions-rs/toolchain@v1
11363
with:
114-
toolchain: stable-x86_64-pc-windows-msvc
115-
target: x86_64-pc-windows-gnu
64+
toolchain: stable-i686-pc-windows-msvc
65+
target: i686-pc-windows-gnu
11666
components: clippy
11767
default: true
11868
- name: Get Windows cargo nightly
11969
if: matrix.os == 'windows-latest'
12070
uses: actions-rs/toolchain@v1
12171
with:
122-
toolchain: nightly-x86_64-pc-windows-msvc
123-
target: x86_64-pc-windows-gnu
72+
toolchain: nightly-i686-pc-windows-msvc
73+
target: i686-pc-windows-gnu
12474
components: rustfmt
12575
- name: Update Windows target configuration
12676
if: matrix.os == 'windows-latest'
127-
shell: msys2 {0}
128-
run: rustup set default-host x86_64-pc-windows-gnu
77+
run: rustup set default-host i686-pc-windows-gnu
12978
- name: Find paths
13079
id: cargo-find-paths
13180
run: 'echo ::set-output name=cargo-lock-glob::"${{ matrix.root }}"/**/Cargo.lock'

.github/snippets/job-publish-versio.yml

+14-14
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ value:
1515
rustflags: '-D warnings'
1616
bin_name: 'versio'
1717
- os: windows-latest
18-
target: 'x86_64-pc-windows-gnu.exe'
18+
target: 'x86_64-pc-win32.exe'
1919
root: '.'
2020
rustflags: '-D warnings'
2121
bin_name: 'versio.exe'
@@ -62,23 +62,23 @@ value:
6262
GPGME_INCLUDE: /usr/local/opt/libassuan/include:/usr/local/opt/gpgme/include
6363
GPGME_LIB_DIR: /usr/local/opt/libassuan/lib:/usr/local/opt/gpgme/lib
6464
GPGME_LIBS: static=gpgme:static=assuan
65+
- name: Add mingw32 to PATH
66+
# See comments in `../snippets/get-cargo-os.yml`
67+
if: matrix.os == 'windows-latest'
68+
run: |
69+
echo "C:\msys64\mingw32\bin" >> $env:GITHUB_PATH
6570
- name: Build Windows binary
71+
# We're not going to try to statically link for Windows; see
72+
# comments in `../snippets/get-cargo-os.yml`. Because we aren't
73+
# statically linking, we don't have to specify the build locations
74+
# in the environment; the build scripts will find them via the
75+
# registry and/or the `gpgme-config` / `gpg-error-config`
76+
# programs.
6677
if: matrix.os == 'windows-latest'
67-
shell: msys2 {0}
68-
run: cargo build --release --target x86_64-pc-windows-gnu
78+
run: cargo build --release --target i686-pc-windows-gnu
6979
working-directory: ${{ matrix.root }}
7080
env:
7181
RUSTFLAGS: ${{ matrix.rustflags }}
72-
# See comments in the above "Build Ubuntu binary" step to
73-
# explain these env. Now that we're building the gpg libs
74-
# ourselves, we need to use the locations of where `make
75-
# install` in the `Install Windows dependencies` step puts them.
76-
LIBGPG_ERROR_INCLUDE: '/mingw64/include'
77-
LIBGPG_ERROR_LIB_DIR: '/mingw64/lib'
78-
LIBGPG_ERROR_LIBS: 'static=gpg-error'
79-
GPGME_INCLUDE: '/mingw64/include'
80-
GPGME_LIB_DIR: '/mingw64/lib'
81-
GPGME_LIBS: 'static=gpgme;static=assuan'
8282
- name: Upload binary
8383
if: matrix.os != 'windows-latest'
8484
uses: actions/upload-release-asset@v1
@@ -92,6 +92,6 @@ value:
9292
uses: actions/upload-release-asset@v1
9393
with:
9494
upload_url: ${{ needs.github-publish.outputs.upload_url }}
95-
asset_path: target/x86_64-pc-windows-gnu/release/${{ matrix.bin_name }}
95+
asset_path: target/i686-pc-windows-gnu/release/${{ matrix.bin_name }}
9696
asset_name: versio__${{ matrix.target }}
9797
asset_content_type: application/octet-stream

.github/snippets/steps-github-publish.yml

+10
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ value:
2121
2222
New to Versio? The [repository](https://github.com/chaaz/versio) is the best place to learn about Versio and what it can do. If you want to report a bug or request a feature, you can do so at our [Issues](https://github.com/chaaz/versio/issues) link, but we ask you first read the [Troubleshooting](https://github.com/chaaz/versio/blob/main/docs/troubleshooting.md) page learn about problems and their solutions.
2323
24+
DEPENDENCIES:
25+
26+
On MacOS and Linux, you must have GPG tools installed. These tools are installed by default on most distributions of Linux and MacOS. If you can run `git`, then you probably have the necessary tools already installed.
27+
28+
On Windows, you need to install the GpgME package, which is available [here](https://gnupg.org/ftp/gcrypt/binary/gnupg-w32-2.3.1_20210420.exe) (Signature and checksum available from its [parent directory](https://gnupg.org/ftp/gcrypt/binary/)).
29+
30+
If you have any questions, you should view the [Dependency page](https://github.com/chaaz/versio/blob/main/docs/dependencies.md) for information about installing and testing dependencies.
31+
32+
INSTALLATION:
33+
2434
To install, follow the instructions for your platform; some files might be zipped for improved download speed. For example, on MacOS you can do something like this (assuming `~/bin` exists and is in your PATH):
2535
2636
```sh

.github/workflows/github-publish.yml

+13-30
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ jobs:
102102
with:
103103
tag_name: "${{ steps.find-version.outputs.version }}"
104104
release_name: "(TODO) RELEASE FOR ${{ steps.find-version.outputs.version }}"
105-
body: "(TODO) SUMMARY\n- (TODO) FEATURE1\n\nNew to Versio? The [repository](https://github.com/chaaz/versio) is the best place to learn about Versio and what it can do. If you want to report a bug or request a feature, you can do so at our [Issues](https://github.com/chaaz/versio/issues) link, but we ask you first read the [Troubleshooting](https://github.com/chaaz/versio/blob/main/docs/troubleshooting.md) page learn about problems and their solutions.\n\nTo install, follow the instructions for your platform; some files might be zipped for improved download speed. For example, on MacOS you can do something like this (assuming `~/bin` exists and is in your PATH):\n\n```sh\ncurl -L https://github.com/chaaz/versio/releases/download/${{ steps.find-version.outputs.version }}/versio__x86_64-apple-darwin -o ~/bin/versio\nchmod +x ~/bin/versio\n```\n\n**MacOS:** download `versio__x86_64-apple-darwin`, copy to `versio` in your PATH.\n**GNU Linux 64:** download `versio__x86_64-unknown-linux-gnu`, copy to `versio` in your PATH.\n**Windows:** download `versio__x86_64-pc-win32.exe`, copy to `versio.exe` in your %PATH.\n"
105+
body: "(TODO) SUMMARY\n- (TODO) FEATURE1\n\nNew to Versio? The [repository](https://github.com/chaaz/versio) is the best place to learn about Versio and what it can do. If you want to report a bug or request a feature, you can do so at our [Issues](https://github.com/chaaz/versio/issues) link, but we ask you first read the [Troubleshooting](https://github.com/chaaz/versio/blob/main/docs/troubleshooting.md) page learn about problems and their solutions.\n\nDEPENDENCIES:\n\nOn MacOS and Linux, you must have GPG tools installed. These tools are installed by default on most distributions of Linux and MacOS. If you can run `git`, then you probably have the necessary tools already installed.\n\nOn Windows, you need to install the GpgME package, which is available [here](https://gnupg.org/ftp/gcrypt/binary/gnupg-w32-2.3.1_20210420.exe) (Signature and checksum available from its [parent directory](https://gnupg.org/ftp/gcrypt/binary/)).\n\nIf you have any questions, you should view the [Dependency page](https://github.com/chaaz/versio/blob/main/docs/dependencies.md) for information about installing and testing dependencies.\n\nINSTALLATION: \n\nTo install, follow the instructions for your platform; some files might be zipped for improved download speed. For example, on MacOS you can do something like this (assuming `~/bin` exists and is in your PATH):\n\n```sh\ncurl -L https://github.com/chaaz/versio/releases/download/${{ steps.find-version.outputs.version }}/versio__x86_64-apple-darwin -o ~/bin/versio\nchmod +x ~/bin/versio\n```\n\n**MacOS:** download `versio__x86_64-apple-darwin`, copy to `versio` in your PATH.\n**GNU Linux 64:** download `versio__x86_64-unknown-linux-gnu`, copy to `versio` in your PATH.\n**Windows:** download `versio__x86_64-pc-win32.exe`, copy to `versio.exe` in your %PATH.\n"
106106
draft: true
107107
prerelease: false
108108
commitish: main
@@ -122,7 +122,7 @@ jobs:
122122
rustflags: "-D warnings"
123123
bin_name: versio
124124
- os: windows-latest
125-
target: x86_64-pc-windows-gnu.exe
125+
target: x86_64-pc-win32.exe
126126
root: "."
127127
rustflags: "-D warnings"
128128
bin_name: versio.exe
@@ -139,21 +139,9 @@ jobs:
139139
- name: Install MacOS dependencies
140140
if: "matrix.os == 'macos-latest'"
141141
run: brew update; brew install gpgme
142-
- name: Setup Msys2 on Windows
143-
if: "matrix.os == 'windows-latest'"
144-
uses: msys2/setup-msys2@v2
145-
with:
146-
update: true
147-
msystem: mingw64
148-
path-type: inherit
149-
install: base-devel git mingw-w64-x86_64-toolchain
150142
- name: Install Windows dependencies
151143
if: "matrix.os == 'windows-latest'"
152-
env:
153-
RUNNER_TEMP: "${{ runner.temp }}"
154-
working-directory: "${{ runner.temp }}"
155-
shell: "msys2 {0}"
156-
run: "curl https://gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-1.42.tar.bz2 -o libgpg-error-1.42.tar.bz2\ntar -jxf libgpg-error-1.42.tar.bz2\ncurl https://gnupg.org/ftp/gcrypt/libassuan/libassuan-2.5.5.tar.bz2 -o libassuan-2.5.5.tar.bz2\ntar -jxf libassuan-2.5.5.tar.bz2\ncurl https://gnupg.org/ftp/gcrypt/gpgme/gpgme-1.16.0.tar.bz2 -o gpgme-1.16.0.tar.bz2\ntar -jxf gpgme-1.16.0.tar.bz2\npushd libgpg-error-1.42\n./configure --enable-static\nmake\nmake install\npopd\npushd libassuan-2.5.5\n./configure --enable-static\nmake\nmake install\npopd\npushd gpgme-1.16.0\n./configure --enable-static --enable-languages=cl,cpp\nmake\nmake install\npopd\n"
144+
run: "$env:PATH = \"C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\ProgramData\\chocolatey\\bin\"\n[Environment]::SetEnvironmentVariable(\"Path\", $env:PATH, \"Machine\")\nchoco install -y gnupg\necho \"C:\\Program Files (x86)\\GnuPG\\bin\" >> $env:GITHUB_PATH\n"
157145
- name: Get cargo stable
158146
if: "matrix.os != 'windows-latest'"
159147
uses: actions-rs/toolchain@v1
@@ -170,21 +158,20 @@ jobs:
170158
if: "matrix.os == 'windows-latest'"
171159
uses: actions-rs/toolchain@v1
172160
with:
173-
toolchain: stable-x86_64-pc-windows-msvc
174-
target: x86_64-pc-windows-gnu
161+
toolchain: stable-i686-pc-windows-msvc
162+
target: i686-pc-windows-gnu
175163
components: clippy
176164
default: true
177165
- name: Get Windows cargo nightly
178166
if: "matrix.os == 'windows-latest'"
179167
uses: actions-rs/toolchain@v1
180168
with:
181-
toolchain: nightly-x86_64-pc-windows-msvc
182-
target: x86_64-pc-windows-gnu
169+
toolchain: nightly-i686-pc-windows-msvc
170+
target: i686-pc-windows-gnu
183171
components: rustfmt
184172
- name: Update Windows target configuration
185173
if: "matrix.os == 'windows-latest'"
186-
shell: "msys2 {0}"
187-
run: rustup set default-host x86_64-pc-windows-gnu
174+
run: rustup set default-host i686-pc-windows-gnu
188175
- name: Find paths
189176
id: cargo-find-paths
190177
run: "echo ::set-output name=cargo-lock-glob::\"${{ matrix.root }}\"/**/Cargo.lock"
@@ -217,19 +204,15 @@ jobs:
217204
GPGME_INCLUDE: "/usr/local/opt/libassuan/include:/usr/local/opt/gpgme/include"
218205
GPGME_LIB_DIR: "/usr/local/opt/libassuan/lib:/usr/local/opt/gpgme/lib"
219206
GPGME_LIBS: "static=gpgme:static=assuan"
207+
- name: Add mingw32 to PATH
208+
if: "matrix.os == 'windows-latest'"
209+
run: "echo \"C:\\msys64\\mingw32\\bin\" >> $env:GITHUB_PATH\n"
220210
- name: Build Windows binary
221211
if: "matrix.os == 'windows-latest'"
222-
shell: "msys2 {0}"
223-
run: cargo build --release --target x86_64-pc-windows-gnu
212+
run: cargo build --release --target i686-pc-windows-gnu
224213
working-directory: "${{ matrix.root }}"
225214
env:
226215
RUSTFLAGS: "${{ matrix.rustflags }}"
227-
LIBGPG_ERROR_INCLUDE: /mingw64/include
228-
LIBGPG_ERROR_LIB_DIR: /mingw64/lib
229-
LIBGPG_ERROR_LIBS: static=gpg-error
230-
GPGME_INCLUDE: /mingw64/include
231-
GPGME_LIB_DIR: /mingw64/lib
232-
GPGME_LIBS: static=gpgme;static=assuan
233216
- name: Upload binary
234217
if: "matrix.os != 'windows-latest'"
235218
uses: actions/upload-release-asset@v1
@@ -243,6 +226,6 @@ jobs:
243226
uses: actions/upload-release-asset@v1
244227
with:
245228
upload_url: "${{ needs.github-publish.outputs.upload_url }}"
246-
asset_path: "target/x86_64-pc-windows-gnu/release/${{ matrix.bin_name }}"
229+
asset_path: "target/i686-pc-windows-gnu/release/${{ matrix.bin_name }}"
247230
asset_name: "versio__${{ matrix.target }}"
248231
asset_content_type: application/octet-stream

0 commit comments

Comments
 (0)