Skip to content

Commit

Permalink
windows-build: Get a C compiler to work again (#1105)
Browse files Browse the repository at this point in the history
  • Loading branch information
Akuli authored Jul 31, 2022
1 parent 2a96237 commit 66e3bf7
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ jobs:
with:
python-version: "3.8" # last version supporting windows 7
- run: pip install -r requirements.txt -r requirements-dev.txt
# FIXME: recompile launcher when this is fixed: https://github.com/egor-tensin/setup-mingw/issues/6
# - uses: egor-tensin/setup-mingw@v2
# with:
# platform: x64
- uses: egor-tensin/setup-clang@v1
with:
platform: x64
# -u makes print show in real time
- run: python -u scripts/build-exe-installer.py
- uses: actions/upload-artifact@v2
Expand Down
9 changes: 2 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,17 +259,12 @@ Other people shouldn't need them.
2. Make a pull request of your changelog edits. Review carefully:
changing the changelog afterwards is difficult, as the text gets copied into the releases page.
3. Merge the pull request and pull the merge commit to your local `master` branch.
4. On a Windows computer (or VM), install Resource Hacker and change the version number in `launcher/Porcupine.exe`.
Hopefully I will eventually get a C compiler to work again,
so that this step can be skipped (see [#1086](https://github.com/Akuli/porcupine/pull/1086)).
![resource-hacker.png](resource-hacker.png)
Push the new `.exe` file directly to master.
5. Run `python3 scripts/release.py` from the `master` branch.
4. Run `python3 scripts/release.py` from the `master` branch.
The script pushes a tag named e.g. `v2022.07.29`,
which triggers the parts of `.github/workflows/build.yml`
that have `if: startsWith(github.ref, 'refs/tags/v')` in them.
They build and deploy docs, copy the changelog to the releases page, and so on.
6. Update `porcupine.wiki` if you added new features that are likely not obvious to users.
5. Update `porcupine.wiki` if you added new features that are likely not obvious to users.

If you want, you can also do a release from a branch named `bugfix-release` instead of `master`.
This is useful if you fixed a bug that made Porcupine unusable for someone,
Expand Down
Binary file removed launcher/Porcupine.exe
Binary file not shown.
8 changes: 6 additions & 2 deletions launcher/main.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <stdnoreturn.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
#include <windows.h>
#include <stdnoreturn.h>

static noreturn void fatal_error(const wchar_t *msg)
{
Expand All @@ -13,8 +13,12 @@ static noreturn void fatal_error(const wchar_t *msg)

typedef int(WINAPI *PyMainProc)(int argc, wchar_t **argv);

int wmain(int argc, wchar_t **argv)
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
{
// this is basically what cpython's PC/WinMain.c does
int argc = __argc;
wchar_t **argv = __wargv;

wchar_t *launcherpath = calloc(sizeof(launcherpath[0]), MAX_PATH);
if (!launcherpath)
fatal_error(L"allocating memory failed");
Expand Down
12 changes: 7 additions & 5 deletions scripts/build-exe-installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,8 @@
print("Converting logo to .ico format")
PIL.Image.open("porcupine/images/logo-200x200.gif").save("build/porcupine-logo.ico")

# FIXME: Currently I can't get C compiler to work on github actions.
# I have committed a copy of the Porcupine.exe launcher here.
# Unfortunately the launcher contains an old version number that I can't update...
# If you can't get a C compiler to work, you can install an older version of Porcupine and copy
# its Porcupine.exe to launcher/Porcupine.exe
if os.path.exists("build/launcher/Porcupine.exe"):
print("Found launcher/Porcupine.exe, no C compiler needed")
else:
Expand All @@ -108,14 +107,17 @@
)
subprocess.check_call(
[
"gcc.exe",
"clang.exe",
"-municode",
"-mwindows",
"-o",
"Porcupine.exe",
"main.c",
"icon.res",
"metadata.res",
"-luser32",
# https://stackoverflow.com/a/37409970
# https://stackoverflow.com/q/64911334
"-Wl,/subsystem:windows",
],
cwd="build/launcher",
)
Expand Down

0 comments on commit 66e3bf7

Please sign in to comment.