build-app: run the user entry's main submodule (packaged apps were no-ops) - #3
Open
turinglambdaai wants to merge 1 commit into
Open
turinglambdaai wants to merge 1 commit into
turinglambdaai wants to merge 1 commit into
Conversation
…thing The generated entry wrapper required the user's main as a plain library. Under `racket main.rkt` the (module+ main) submodule runs because the file is the program's top module; loaded via require from a wrapper, that submodule is never instantiated — so build-app's launcher exited 0 immediately without executing any user code (no output for --version, no usage error for unknown flags; the program body never started). The wrapper now mirrors the interpreter: it keeps the static require (so raco exe embeds the full dependency closure — dynamic-requires are invisible to it) and then explicitly instantiates (submod "main.rkt" main) when declared, falling back to the module body for top-level-style apps. Verified on Racket 9.3 CS / macOS arm64 with a real app using module+ main (window opens, server serves, SSE streams), a top-level-style script, and --version/--bogus flag semantics. glaze-test: 216 passed. Fixes #1
Owner
Author
|
CI 说明: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1
根因
build-app 生成的入口包装模块把用户 main 以 普通库 的方式
require进来。racket main.rkt之所以会跑(module+ main),是因为该文件本身就是程序的顶层模块;而包装模块自己是顶层模块,静态 require 进来的 main.rkt 只会被当库实例化——main 子模块永远不会执行。于是打包产物表现为:任何参数都立即 exit 0、无输出、程序体完全不启动(连 --version 都沉默)。修复
入口包装改为镜像解释器语义:
require "main.rkt"——raco exe 只嵌入静态可达的依赖闭包,dynamic-require 对它不可见;丢了它,运行时连racket/hash这类集合都找不到。(submod "main.rkt" main)(用module-declared?探测,声明了才跑);未声明 main 子模块的应用(顶层脚本风格)由第 1 步自然运行,不会双重执行。验证(Racket 9.3 CS / macOS arm64)
--version输出、未知 flag 走 usage 退出 1、GUI 窗口打开、HTTP 服务 200、SSE 事件流正常raco test glaze-test/:216 通过(含 macOS WebView e2e)注:gPTP Studio 此前用的手工组装 workaround(仓库内 scripts/package-macos.sh)现可弃用,回归 glaze build-app。