@bobfrankston/msger 0.1.133 → 0.1.134

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,254 @@
1
+ # msger Build System
2
+
3
+ ## Overview
4
+
5
+ The msger build system is unified and configuration-driven, supporting multiple platforms through a single entry point.
6
+
7
+ ## Build Configuration
8
+
9
+ Build targets are controlled via `msger-native/builder/build-config.json`:
10
+
11
+ ```json
12
+ {
13
+ "platforms": {
14
+ "windows": true, // Windows x64 binary
15
+ "wsl": false, // Linux x64 binary (via WSL)
16
+ "pi": false, // Raspberry Pi ARM64 (via SSH)
17
+ "arm64": false // Generic ARM64 (cross-compile in WSL)
18
+ },
19
+ "options": {
20
+ "release": true,
21
+ "verbose": false,
22
+ "piHost": "pi4c",
23
+ "piProjectPath": "/home/bob/projects/msger/msger-native"
24
+ }
25
+ }
26
+ ```
27
+
28
+ ## Build Commands
29
+
30
+ ### Standard Build
31
+ ```bash
32
+ npm run build # Build TypeScript + native binaries
33
+ npm run build:ts # Build TypeScript only
34
+ npm run build:native # Build native binaries only
35
+ ```
36
+
37
+ ### Release & Publish
38
+ ```bash
39
+ npm run release # Bump version, build, publish to npm
40
+ npm run installer # Release + install globally (Windows & WSL)
41
+ ```
42
+
43
+ ## Platform-Specific Details
44
+
45
+ ### Windows (x64)
46
+ - Built using native Rust toolchain
47
+ - Requires Visual Studio Build Tools or MSVC
48
+ - Output: `msger-native/bin/msgernative.exe`
49
+ - Auto-detects source changes to skip unnecessary rebuilds
50
+
51
+ ### WSL Linux (x64)
52
+ - Builds Linux binary inside WSL
53
+ - Runs `msger-native/builder/build-under-wsl.ts` via WSL
54
+ - Output: `msger-native/bin/msgernative`
55
+ - Requires WSL with Rust installed
56
+
57
+ ### Raspberry Pi (ARM64)
58
+ - Builds on remote Raspberry Pi via SSH
59
+ - Requires:
60
+ - SSH access to Pi (`piHost` in config)
61
+ - Project synced to Pi (`piProjectPath` in config)
62
+ - Rust installed on Pi
63
+ - Output: `msger-native/bin/msgernative-linux-aarch64`
64
+ - See [PI-RENDERING-NOTES.md](PI-RENDERING-NOTES.md) for Pi-specific details
65
+
66
+ ### Generic ARM64 (Cross-compile)
67
+ - Cross-compiles ARM64 binary in WSL
68
+ - Automatically installs dependencies:
69
+ 1. Rust (via `install-rust-wsl.sh`)
70
+ 2. ARM64 toolchain (via `setup-arm64-toolchain.sh`)
71
+ - Output: `msger-native/bin/msgernative-linux-aarch64`
72
+ - Uses `aarch64-unknown-linux-gnu` target
73
+
74
+ ## Build Scripts
75
+
76
+ ### Main Builder
77
+ **Location**: `msger-native/builder/builder.ts`
78
+
79
+ Unified build orchestrator that:
80
+ - Reads `build-config.json`
81
+ - Detects source changes
82
+ - Coordinates platform-specific builds
83
+ - Reports build summary
84
+
85
+ **Key Features**:
86
+ - `wslExec()`: Executes commands in WSL using spawn (avoids quoting issues)
87
+ - `toWSLPath()`: Converts Windows paths to WSL paths
88
+ - `needsRebuild()`: Checks if sources changed since last build
89
+ - Automatic Rust installation for ARM64 builds
90
+
91
+ ### WSL Builder
92
+ **Location**: `msger-native/builder/build-under-wsl.ts`
93
+
94
+ Runs natively inside WSL to build Linux binaries:
95
+ - Supports both x64 and ARM64 targets
96
+ - Auto-installs Rust toolchains
97
+ - Handles cross-compilation setup
98
+
99
+ ### Helper Scripts
100
+
101
+ #### `install-rust-wsl.sh`
102
+ Installs Rust in WSL if not present:
103
+ ```bash
104
+ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
105
+ ```
106
+
107
+ #### `setup-arm64-toolchain.sh`
108
+ Sets up ARM64 cross-compilation in WSL:
109
+ - Installs `aarch64-unknown-linux-gnu` Rust target
110
+ - Installs ARM64 cross-compiler (`gcc-aarch64-linux-gnu`)
111
+ - Configures cargo for cross-compilation
112
+
113
+ #### `build-on-pi.sh`
114
+ Helper for remote Pi builds (called via SSH)
115
+
116
+ ## Important Considerations
117
+
118
+ ### Line Endings
119
+ - All `.sh` scripts MUST use LF (Unix) line endings
120
+ - `.gitattributes` enforces this: `*.sh text eol=lf`
121
+ - Use `dos2unix` to fix if needed
122
+
123
+ ### Path Handling
124
+ - Use `wslExec()` and `toWSLPath()` for WSL operations
125
+ - Avoids shell quoting issues
126
+ - Properly converts Windows → WSL paths
127
+
128
+ ### Postinstall Hook
129
+ - **Location**: `msger-native/builder/postinstall.js`
130
+ - **Must be .js**: Node.js can't execute .ts in node_modules
131
+ - Sets executable permissions on Linux binaries
132
+ - Checks for system dependencies (webkit2gtk, gtk3)
133
+
134
+ ### TypeScript Compilation
135
+ - TypeScript source lives alongside compiled .js files
136
+ - Includes .map files for debugging
137
+ - All checked into git for production debugging
138
+
139
+ ## Troubleshooting
140
+
141
+ ### ARM64 Build Fails
142
+ 1. Check Rust installed in WSL: `wsl rustup --version`
143
+ 2. If not, run manually: `wsl bash msger-native/pibuild/install-rust-wsl.sh`
144
+ 3. Check toolchain: `wsl rustup target list --installed | grep aarch64`
145
+
146
+ ### WSL Path Conversion Fails
147
+ - Ensure WSL installed and accessible
148
+ - Test: `wsl wslpath "Y:\dev\utils\msger"`
149
+ - Should output: `/mnt/y/dev/utils/msger`
150
+
151
+ ### Pi Build Fails
152
+ 1. Test SSH: `ssh pi4c echo test`
153
+ 2. Check project exists on Pi: `ssh pi4c ls /home/bob/projects/msger`
154
+ 3. Verify Rust on Pi: `ssh pi4c rustc --version`
155
+
156
+ ## Build Flow Diagram
157
+
158
+ ```
159
+ npm run build
160
+
161
+ npm run build:ts (compile TypeScript)
162
+
163
+ npm run build:native
164
+
165
+ msger-native/builder/builder.ts
166
+
167
+ ├─→ Windows? → cargo build --release
168
+ ├─→ WSL? → wsl build-under-wsl.ts → cargo build (x64)
169
+ ├─→ Pi? → ssh pi4c "cargo build" → scp binary
170
+ └─→ ARM64? → install Rust → setup toolchain → cargo build (aarch64)
171
+ ```
172
+
173
+ ## Adding New Platforms
174
+
175
+ 1. Add platform flag to `build-config.json`
176
+ 2. Create build function in `builder.ts`
177
+ 3. Add case to `main()` function
178
+ 4. Update this documentation
179
+ 5. Test on target platform
180
+
181
+ ## ARM64 Build Debugging Notes (2025-11-17)
182
+
183
+ ### Issues Fixed
184
+
185
+ #### 1. Path Conversion (Y: to /mnt/y)
186
+ **Problem**: wslpath failed when given Windows paths with backslashes
187
+ **Fix**: `toWSLPath()` now converts backslashes to forward slashes
188
+ **Location**: builder.ts:74-83
189
+
190
+ #### 2. wslExec Function
191
+ **Problem**: Was double-wrapping bash commands causing syntax errors
192
+ **Fix**: Simplified to pass args directly to spawnSync
193
+ **Location**: builder.ts:58-69
194
+
195
+ #### 3. PATH with Parentheses
196
+ **Problem**: Windows PATH contains "Program Files (x86)" causing bash syntax errors
197
+ **Fix**: Quoted all PATH and directory references in bash commands
198
+ **Location**: builder.ts:217, 360
199
+
200
+ #### 4. Cargo Version Mismatch
201
+ **Problem**: System cargo in WSL (1.75) incompatible with Windows cargo (1.87) Cargo.lock v4
202
+ **Fix**: Always use rustup's cargo by setting `PATH="$HOME/.cargo/bin:$PATH"`
203
+
204
+ #### 5. Toolchain Detection After Install
205
+ **Problem**: `checkARM64Toolchain()` couldn't find rustup immediately after installation
206
+ **Fix**: Check now includes PATH setup
207
+ **Location**: builder.ts:288-293
208
+
209
+ #### 6. pkg-config Cross-Compilation
210
+ **Problem**: pkg-config not configured for ARM64 cross-compilation
211
+ **Fix**: Set `PKG_CONFIG_ALLOW_CROSS=1` and created `~/.cargo/config.toml` with linker
212
+ **Location**: setup-arm64-toolchain.sh:60-66
213
+
214
+ #### 7. Silent Compilation
215
+ **Problem**: Long compilation appeared stuck with no output
216
+ **Fix**: Added "Compiling ARM64 binary (this may take 2-5 minutes)..." message
217
+ **Location**: builder.ts:355
218
+
219
+ ### Key Implementation Details
220
+
221
+ #### Auto-Installation Flow
222
+ 1. `buildARM64()` calls `checkARM64Toolchain()`
223
+ 2. If false, calls `installARM64Toolchain()`
224
+ 3. `installARM64Toolchain()` checks for rustup:
225
+ - If missing: runs `install-rust-wsl.sh`
226
+ - Always runs `setup-arm64-toolchain.sh`
227
+ 4. Both scripts are idempotent (safe to run multiple times)
228
+
229
+ #### Build Command Structure
230
+ ```bash
231
+ export PATH="$HOME/.cargo/bin:$PATH" && \
232
+ export PKG_CONFIG_ALLOW_CROSS=1 && \
233
+ cd "/mnt/y/dev/utils/msger/msger-native" && \
234
+ cargo build --release --target aarch64-unknown-linux-gnu
235
+ ```
236
+
237
+ #### 8. ARM64 Cross-Compilation Not Viable
238
+ **Problem**: Cannot install ARM64 packages on x64 WSL - Ubuntu repos return 404 for ARM64 packages
239
+ **Root Cause**: `dpkg --add-architecture arm64` only works on native multi-arch systems, not WSL
240
+ **Attempted Fix**: Tried installing ARM64 library packages - repos don't exist for x64→ARM64
241
+ **Solution**: Use Pi build option instead - builds natively on ARM64 hardware via SSH
242
+ **Conclusion**: Cross-compiling GUI apps (webkit2gtk) from x64→ARM64 requires complex sysroot setup. Native Pi build is simpler and more reliable.
243
+
244
+ ### Important Notes
245
+ - System cargo (old 1.75) vs rustup cargo (new 1.91) - always use rustup
246
+ - Spawn with arg arrays avoids shell quoting issues with paths containing spaces/parentheses
247
+ - **Build process must be defensive**: Check for required tools/dependencies on every build, auto-install if missing
248
+ - Build checks every time, only installs if missing - not a one-time setup
249
+ - `PKG_CONFIG_ALLOW_CROSS` required for cross-compilation
250
+ - **ARM64 cross-compile from x64 WSL not supported** - use Pi build instead
251
+ - **Pi build must auto-install Rust if missing** - cannot assume Pi environment is configured
252
+ - Pi build copies only source files (src/, Cargo.toml, Cargo.lock, build.rs), copies back only binary
253
+ - No rsync on Windows - use scp for Pi file transfers
254
+ - Compilation takes 2-5 minutes on typical hardware
package/docs/README.md CHANGED
@@ -1,26 +1,27 @@
1
- # msger Documentation
2
-
3
- ## User Documentation
4
- - [README.md](../README.md) - Main project README (in root)
5
- - [MSGER-API.md](MSGER-API.md) - JavaScript API for message box content
6
- - [MSGER-API-SUMMARY.md](MSGER-API-SUMMARY.md) - Quick API reference
7
- - [CLOSE-API.md](CLOSE-API.md) - Programmatic close API
8
-
9
- ## Release Information
10
- - [CHANGELOG.md](CHANGELOG.md) - Version history and changes
11
- - [RELEASE-NOTES.md](RELEASE-NOTES.md) - User-facing release notes
12
- - [KNOWN-BUGS.md](KNOWN-BUGS.md) - Known issues and limitations
13
-
14
- ## Features
15
- - [DETACH-FEATURE.md](DETACH-FEATURE.md) - Detached window mode
16
- - [FULLSCREEN-FEATURE.md](FULLSCREEN-FEATURE.md) - Fullscreen mode
17
- - [MOUSE-ZOOM-FEATURE.md](MOUSE-ZOOM-FEATURE.md) - Mouse wheel zoom
18
-
19
- ## Developer Documentation
20
- - [DEVELOPERS.md](DEVELOPERS.md) - Developer guide
21
- - [IMPLEMENTATION-SUMMARY.md](IMPLEMENTATION-SUMMARY.md) - Implementation details
22
- - [PI-RENDERING-NOTES.md](PI-RENDERING-NOTES.md) - Raspberry Pi specific notes
23
- - [TODO.md](TODO.md) - Future plans and tasks
24
-
25
- ## Session Notes
26
- Development session notes are in [sessions/](sessions/)
1
+ # msger Documentation
2
+
3
+ ## User Documentation
4
+ - [README.md](../README.md) - Main project README (in root)
5
+ - [MSGER-API.md](MSGER-API.md) - JavaScript API for message box content
6
+ - [MSGER-API-SUMMARY.md](MSGER-API-SUMMARY.md) - Quick API reference
7
+ - [CLOSE-API.md](CLOSE-API.md) - Programmatic close API
8
+
9
+ ## Release Information
10
+ - [CHANGELOG.md](CHANGELOG.md) - Version history and changes
11
+ - [RELEASE-NOTES.md](RELEASE-NOTES.md) - User-facing release notes
12
+ - [KNOWN-BUGS.md](KNOWN-BUGS.md) - Known issues and limitations
13
+
14
+ ## Features
15
+ - [DETACH-FEATURE.md](DETACH-FEATURE.md) - Detached window mode
16
+ - [FULLSCREEN-FEATURE.md](FULLSCREEN-FEATURE.md) - Fullscreen mode
17
+ - [MOUSE-ZOOM-FEATURE.md](MOUSE-ZOOM-FEATURE.md) - Mouse wheel zoom
18
+
19
+ ## Developer Documentation
20
+ - [DEVELOPERS.md](DEVELOPERS.md) - Developer guide
21
+ - [BUILD-SYSTEM.md](BUILD-SYSTEM.md) - Build system and cross-platform compilation
22
+ - [IMPLEMENTATION-SUMMARY.md](IMPLEMENTATION-SUMMARY.md) - Implementation details
23
+ - [PI-RENDERING-NOTES.md](PI-RENDERING-NOTES.md) - Raspberry Pi specific notes
24
+ - [TODO.md](TODO.md) - Future plans and tasks
25
+
26
+ ## Session Notes
27
+ Development session notes are in [sessions/](sessions/)
@@ -1,14 +1,14 @@
1
- {
2
- "platforms": {
3
- "windows": true,
4
- "wsl": false,
5
- "pi": false,
6
- "arm64": false
7
- },
8
- "options": {
9
- "release": true,
10
- "verbose": false,
11
- "piHost": "pi4c",
12
- "piProjectPath": "/home/pi/dev/msger/msger-native"
13
- }
14
- }
1
+ {
2
+ "platforms": {
3
+ "windows": true,
4
+ "wsl": false,
5
+ "pi": true,
6
+ "arm64": false
7
+ },
8
+ "options": {
9
+ "release": true,
10
+ "verbose": true,
11
+ "piHost": "pi4c",
12
+ "piProjectPath": "/home/pi/msger/msger-native"
13
+ }
14
+ }