···77 GIT_TAG 2ed382a15566b267c32fae440b065f7844b15bfb
88)
99FetchContent_MakeAvailable(ghostty)
1010+1111+# Cross-compilation targets for CI and multi-platform builds.
1212+# Each call produces ghostty-vt-static-<NAME> and ghostty-vt-<NAME>
1313+# IMPORTED targets whose output lands under build/ghostty-<NAME>/.
1414+ghostty_vt_add_target(NAME linux-amd64 ZIG_TARGET x86_64-linux-gnu)
1515+ghostty_vt_add_target(NAME linux-arm64 ZIG_TARGET aarch64-linux-gnu)
1616+ghostty_vt_add_target(NAME macos-amd64 ZIG_TARGET x86_64-macos)
1717+ghostty_vt_add_target(NAME macos-arm64 ZIG_TARGET aarch64-macos)
1818+ghostty_vt_add_target(NAME windows-amd64 ZIG_TARGET x86_64-windows-gnu)
1919+ghostty_vt_add_target(NAME windows-arm64 ZIG_TARGET aarch64-windows-gnu)
+49-1
Makefile
···99# Stamp file to track whether the cmake build has run.
1010STAMP := $(BUILD_DIR)/.ghostty-built
11111212-.PHONY: build test clean
1212+# Cross-compilation target definitions.
1313+# Each entry maps a make target suffix to GOOS, GOARCH, zig target triple,
1414+# and the CC/CXX target flag for zig cc.
1515+CROSS_TARGETS := linux-amd64 linux-arm64 macos-amd64 macos-arm64 windows-amd64 windows-arm64
1616+1717+linux-amd64_GOOS := linux
1818+linux-amd64_GOARCH := amd64
1919+linux-amd64_ZIG := x86_64-linux-gnu
2020+2121+linux-arm64_GOOS := linux
2222+linux-arm64_GOARCH := arm64
2323+linux-arm64_ZIG := aarch64-linux-gnu
2424+2525+macos-amd64_GOOS := darwin
2626+macos-amd64_GOARCH := amd64
2727+macos-amd64_ZIG := x86_64-macos
2828+2929+macos-arm64_GOOS := darwin
3030+macos-arm64_GOARCH := arm64
3131+macos-arm64_ZIG := aarch64-macos
3232+3333+windows-amd64_GOOS := windows
3434+windows-amd64_GOARCH := amd64
3535+windows-amd64_ZIG := x86_64-windows-gnu
3636+3737+windows-arm64_GOOS := windows
3838+windows-arm64_GOARCH := arm64
3939+windows-arm64_ZIG := aarch64-windows-gnu
4040+4141+.PHONY: build test clean cross $(addprefix cross-,$(CROSS_TARGETS))
13421443$(STAMP):
1544 cmake -B $(BUILD_DIR) -DCMAKE_BUILD_TYPE=Release
···21502251test: $(STAMP)
2352 PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) DYLD_LIBRARY_PATH=$(DYLD_LIBRARY_PATH) LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) go test ./...
5353+5454+# cross builds all cross-compilation targets.
5555+cross: $(addprefix cross-,$(CROSS_TARGETS))
5656+5757+# cross-<target> cross-compiles the Go package for the given target using
5858+# zig cc and the libghostty-vt static library built by CMake.
5959+define CROSS_RULE
6060+cross-$(1): $(STAMP)
6161+ CGO_ENABLED=1 \
6262+ CC="zig cc -target $$($(1)_ZIG)" \
6363+ CXX="zig c++ -target $$($(1)_ZIG)" \
6464+ GOOS=$$($(1)_GOOS) \
6565+ GOARCH=$$($(1)_GOARCH) \
6666+ CGO_CFLAGS="-I$(CURDIR)/$(BUILD_DIR)/ghostty-$(1)/include -DGHOSTTY_STATIC" \
6767+ CGO_LDFLAGS="-L$(CURDIR)/$(BUILD_DIR)/ghostty-$(1)/lib -lghostty-vt" \
6868+ go build . ./sys/...
6969+endef
7070+7171+$(foreach t,$(CROSS_TARGETS),$(eval $(call CROSS_RULE,$(t))))
24722573clean:
2674 rm -rf $(BUILD_DIR)
+41
README.md
···7979See the [Ghostty docs](https://ghostty.org/docs/install/build) for
8080building `libghostty-vt` from source.
81818282+### Cross-Compilation
8383+8484+Because `libghostty-vt` only depends on libc, cross-compilation is
8585+straightforward using [Zig](https://ziglang.org/) as the C compiler.
8686+Zig is already required to build `libghostty-vt`, so no extra tooling
8787+is needed. You don't need to write any Zig code, we're just using
8888+Zig as a C/C++ compiler.
8989+9090+First, build `libghostty-vt` for your target (from the ghostty source tree):
9191+9292+```shell
9393+zig build -Demit-lib-vt -Dtarget=x86_64-linux-gnu --prefix /tmp/ghostty-linux-amd64
9494+```
9595+9696+Then cross-compile your Go project with `zig cc`:
9797+9898+```shell
9999+CGO_ENABLED=1 \
100100+GOOS=linux GOARCH=amd64 \
101101+CC="zig cc -target x86_64-linux-gnu" \
102102+CXX="zig c++ -target x86_64-linux-gnu" \
103103+CGO_CFLAGS="-I/tmp/ghostty-linux-amd64/include -DGHOSTTY_STATIC" \
104104+CGO_LDFLAGS="-L/tmp/ghostty-linux-amd64/lib -lghostty-vt" \
105105+go build ./...
106106+```
107107+108108+Supported targets include `x86_64-linux-gnu`, `aarch64-linux-gnu`,
109109+`x86_64-macos`, `aarch64-macos`, `x86_64-windows-gnu`, and
110110+`aarch64-windows-gnu`.
111111+112112+If you are using ghostty's CMake integration via `FetchContent`, the
113113+`ghostty_vt_add_target()` function handles the zig build for you:
114114+115115+```cmake
116116+FetchContent_MakeAvailable(ghostty)
117117+ghostty_vt_add_target(NAME linux-amd64 ZIG_TARGET x86_64-linux-gnu)
118118+```
119119+120120+See the [ghostty CMakeLists.txt](https://github.com/ghostty-org/ghostty/blob/main/CMakeLists.txt)
121121+for full documentation of `ghostty_vt_add_target()`.
122122+82123## Development
8312484125CMake fetches and builds `libghostty-vt` automatically. CMake is only