Skip to content

Commit 70b54d8

Browse files
committed
feat: v0.1.1
1 parent 2b0e76a commit 70b54d8

7 files changed

Lines changed: 81 additions & 27 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## v0.1.1
4+
5+
- Relaxed `gleam_stdlib` constraint to support Gleam stdlib 1.x.
6+
- Windows: fixed dev bootstrap to prefer `.exe` assets and improved local builds via Makefile.
7+
- Port process now exits cleanly when the window is closed.
8+
39
## v0.1.0
410

511
- Toolchain-free installation: automatic port download from GitHub Releases, with per-user cache.

Makefile

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,19 @@ PRIV_DIR := priv
33
C_SRC := c_src/minigui_port.c
44

55
UNAME_S := $(shell uname -s 2>/dev/null || echo unknown)
6+
IS_WINDOWS := 0
7+
ifeq ($(OS),Windows_NT)
8+
IS_WINDOWS := 1
9+
endif
10+
ifneq (,$(findstring MINGW,$(UNAME_S)))
11+
IS_WINDOWS := 1
12+
endif
13+
ifneq (,$(findstring MSYS,$(UNAME_S)))
14+
IS_WINDOWS := 1
15+
endif
16+
ifneq (,$(findstring CYGWIN,$(UNAME_S)))
17+
IS_WINDOWS := 1
18+
endif
619

720
.PHONY: all port gleam demo clean
821

@@ -12,7 +25,16 @@ $(PRIV_DIR):
1225
mkdir -p $(PRIV_DIR)
1326

1427
port: $(PRIV_DIR)
15-
ifeq ($(UNAME_S),Linux)
28+
ifeq ($(IS_WINDOWS),1)
29+
@if command -v gcc >/dev/null 2>&1; then \
30+
gcc -O2 -Wall -Wextra -o $(PRIV_DIR)/$(PORT_NAME).exe $(C_SRC) -luser32 -lgdi32; \
31+
elif command -v cl >/dev/null 2>&1; then \
32+
MSYS2_ARG_CONV_EXCL="*" cl.exe /nologo /O2 /Fe:$(PRIV_DIR)/$(PORT_NAME).exe $(C_SRC) user32.lib gdi32.lib; \
33+
else \
34+
echo "Windows: install MSVC (cl) or MinGW (gcc) to build the port."; \
35+
exit 1; \
36+
fi
37+
else ifeq ($(UNAME_S),Linux)
1638
$(CC) -O2 -Wall -Wextra -o $(PRIV_DIR)/$(PORT_NAME) $(C_SRC) $$(pkg-config --cflags --libs gtk+-3.0) -pthread
1739
else ifeq ($(UNAME_S),Darwin)
1840
@echo "macOS: there is no native backend yet. Use headless mode (MINIGUI_HEADLESS=1) or implement Cocoa."
@@ -22,7 +44,8 @@ else
2244
endif
2345

2446
@# Compatibility with the previous name during development
25-
@if [ -f "$(PRIV_DIR)/minigui" ]; then cp -f "$(PRIV_DIR)/minigui" "$(PRIV_DIR)/minigui_port"; fi
47+
@if [ -f "$(PRIV_DIR)/minigui" ]; then cp -f "$(PRIV_DIR)/minigui" "$(PRIV_DIR)/minigui_port" 2>/dev/null || true; fi
48+
@if [ -f "$(PRIV_DIR)/minigui.exe" ]; then cp -f "$(PRIV_DIR)/minigui.exe" "$(PRIV_DIR)/minigui_port.exe" 2>/dev/null || true; fi
2649

2750
gleam:
2851
gleam build

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ Where `<version>` comes from the package `vsn` (e.g. `0.1.0`) and `<asset>` depe
4040
You can override the download base with:
4141

4242
```bash
43-
MINIGUI_RELEASE_BASE_URL="https://github.com/Aztekode/minigui/releases/download/v0.1.0"
43+
MINIGUI_RELEASE_BASE_URL="https://github.com/Aztekode/minigui/releases/download/v0.1.1"
4444
```
4545

4646
If you prefer an exact link like `.../minigui.exe`, you can set the full URL:
4747

4848
```bash
49-
MINIGUI_PORT_URL="https://github.com/Aztekode/minigui/releases/download/v0.1.0/minigui.exe"
49+
MINIGUI_PORT_URL="https://github.com/Aztekode/minigui/releases/download/v0.1.1/minigui.exe"
5050
```
5151

5252
Security/cache options:
@@ -103,7 +103,12 @@ MINIGUI_HEADLESS=1 make demo
103103

104104
## Build (Windows)
105105

106-
1. Compile `c_src/minigui_port.c` to `priv/minigui_port.exe` (MSVC or mingw).
106+
1. Compile the port:
107+
108+
```bash
109+
make port
110+
```
111+
107112
2. Run the demo:
108113

109114
```powershell

c_src/minigui_port.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,14 @@ static void send_closed(void) {
126126
send_packet(buf, 1);
127127
}
128128

129+
static void terminate_self(void) {
130+
#ifdef _WIN32
131+
ExitProcess(0);
132+
#else
133+
exit(0);
134+
#endif
135+
}
136+
129137
static void send_text_changed(const char* text) {
130138
size_t n = text ? strlen(text) : 0;
131139
if (n > 65000) n = 65000;
@@ -299,6 +307,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpara
299307
case WM_DESTROY:
300308
send_closed();
301309
PostQuitMessage(0);
310+
terminate_self();
302311
return 0;
303312
default:
304313
break;
@@ -392,6 +401,7 @@ static void on_entry_changed(GtkEditable* _editable, gpointer _data) {
392401
static void on_destroy(GtkWidget* _w, gpointer _data) {
393402
send_closed();
394403
gtk_main_quit();
404+
terminate_self();
395405
}
396406

397407
static gboolean apply_state_idle(gpointer _data) {

gleam.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name = "minigui"
2-
version = "0.1.0"
2+
version = "0.1.1"
33
description = "Basic GUI library for Gleam (Win32/GTK) using a C port with precompiled binaries."
44
licences = ["MIT"]
55
repository = { type = "github", user = "Aztekode", repo = "minigui" }
66
target = "erlang"
77

88
[dependencies]
9-
gleam_stdlib = "~> 0.45"
9+
gleam_stdlib = ">= 0.45.0 and < 2.0.0"

manifest.toml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
# This file was generated by Gleam
2-
# You typically do not need to edit this file
1+
# Do not manually edit this file, it is managed by Gleam.
2+
#
3+
# This file locks the dependency versions used, to make your build
4+
# deterministic and to prevent unexpected versions from being included
5+
# in your application.
6+
#
7+
# You should check this file into your source control repository.
38

49
packages = [
5-
{ name = "gleam_stdlib", version = "0.71.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "702F3BC2A14793906880B1078B19A6165F87323AEE8D0C4A34085846336FCAAE" },
10+
{ name = "gleam_stdlib", version = "1.0.3", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "1F543AFBA5D33DA493E6087F4E4C4F20D899411343512686C98A8ABB2963CF22" },
611
]
712

813
[requirements]
9-
gleam_stdlib = { version = "~> 0.45" }
14+
gleam_stdlib = { version = ">= 0.45.0 and < 2.0.0" }

src/minigui_bootstrap.erl

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ ensure_port() ->
2121
%% If it already exists in priv/, validate it as well (production policy).
2222
ok = ensure_http_started(),
2323
case maybe_verify_sha256(Url, Path) of
24-
ok -> Path;
24+
ok ->
25+
ok = maybe_chmod(Path),
26+
Path;
2527
{error, _} ->
2628
_ = file:delete(Path),
2729
ensure_port()
@@ -31,6 +33,7 @@ ensure_port() ->
3133
%% exist in "./priv". This avoids forcing a download during development.
3234
case local_repo_port() of
3335
{ok, Local} ->
36+
ok = maybe_chmod(Local),
3437
Local;
3538
error ->
3639
ok = ensure_http_started(),
@@ -44,7 +47,9 @@ ensure_port() ->
4447
%% If the download fails, try a typical dev fallback:
4548
%% priv/minigui_port or priv/minigui_port.exe (if present)
4649
case fallback_dev_port(PrivDir) of
47-
{ok, Fallback} -> Fallback;
50+
{ok, Fallback} ->
51+
ok = maybe_chmod(Fallback),
52+
Fallback;
4853
error -> erlang:error({minigui_port_download_failed, Url, Reason})
4954
end
5055
end
@@ -64,23 +69,23 @@ priv_dir() ->
6469
fallback_dev_port(PrivDir) ->
6570
%% Prefer release names (minigui/minigui.exe), but accept the historical
6671
%% minigui_port(/.exe) name for development.
67-
Candidates = [
68-
filename:join(PrivDir, "minigui"),
69-
filename:join(PrivDir, "minigui.exe"),
70-
filename:join(PrivDir, "minigui_port"),
71-
filename:join(PrivDir, "minigui_port.exe")
72-
],
72+
Candidates = dev_candidates(PrivDir),
7373
first_existing(Candidates).
7474

7575
local_repo_port() ->
76-
Candidates = [
77-
filename:absname(filename:join(["priv", "minigui"])),
78-
filename:absname(filename:join(["priv", "minigui.exe"])),
79-
filename:absname(filename:join(["priv", "minigui_port"])),
80-
filename:absname(filename:join(["priv", "minigui_port.exe"]))
81-
],
76+
Candidates = dev_candidates("priv"),
8277
first_existing(Candidates).
8378

79+
dev_candidates(Dir) ->
80+
Names =
81+
case os:type() of
82+
{win32, _} ->
83+
["minigui.exe", "minigui_port.exe", "minigui", "minigui_port"];
84+
_ ->
85+
["minigui", "minigui_port", "minigui.exe", "minigui_port.exe"]
86+
end,
87+
[filename:absname(filename:join([Dir, Name])) || Name <- Names].
88+
8489
first_existing([]) ->
8590
error;
8691
first_existing([Path | Rest]) ->
@@ -228,9 +233,9 @@ normalize_arch(Str) ->
228233

229234
release_base_url() ->
230235
%% Recommended: publish binaries by version, e.g.:
231-
%% https://github.com/Aztekode/minigui/releases/download/v0.1.0
236+
%% https://github.com/Aztekode/minigui/releases/download/v0.1.1
232237
%% Allows environment override:
233-
%% MINIGUI_RELEASE_BASE_URL="https://.../download/v0.1.0"
238+
%% MINIGUI_RELEASE_BASE_URL="https://.../download/v0.1.1"
234239
case os:getenv("MINIGUI_RELEASE_BASE_URL") of
235240
false ->
236241
DefaultRepo = "https://github.com/Aztekode/minigui/releases/download",

0 commit comments

Comments
 (0)