跳至正文
OpenAgentSkill
浏览已开放 · 目录记录日期 2026-11-21 · 自动更新和账户服务暂时关闭。
搜索与研究

xmake-pascal

Use when building Pascal projects with xmake — `.pas`/`.pp`/`.lpr` sources, FreePascal (`fpc`) / Delphi toolchain, binary and shared-library targets.

xmake-io · 已有静态检查记录

安装与使用

运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。

npx skills add xmake-io/xmake-skills --skill xmake-pascal

技能说明


name: xmake-pascal description: Use when building Pascal projects with xmake — .pas/.pp/.lpr sources, FreePascal (fpc) / Delphi toolchain, binary and shared-library targets.

Building Pascal with Xmake

Xmake supports Pascal (via FreePascal fpc) since v2.5.8.

1. Minimal project

add_rules("mode.debug", "mode.release")

target("hello")
    set_kind("binary")
    add_files("src/main.pas")

Recognized extensions: .pas, .pp, .lpr.

2. Target kinds

target("app")       set_kind("binary")
target("mylib")     set_kind("shared")       -- .so / .dll
target("staticlib") set_kind("static")       -- .a / .lib

Shared library example:

target("mylib")
    set_kind("shared")
    add_files("src/lib.pas")

3. Flags

target("app")
    add_files("src/*.pas")
    add_pcflags("-O3", "-Xs")            -- fpc flags (strip symbols)

4. Toolchain

xmake f --toolchain=fpc                   # FreePascal
xmake f --toolchain=fpc --sdk=/opt/fpc-3.2

Pitfalls

  • Project file format. .lpr is the standard program entry for Lazarus projects — use it as the add_files entry, not unit files.
  • Unit dependency ordering. fpc handles unit deps itself; don't enumerate dependencies manually unless you have a reason.
  • Cross-compile. FreePascal supports many targets but the config is fpc-specific; see FreePascal docs for -T<target> / -P<arch>.

When to branch out

  • Target basics → xmake-targets
  • Cross-compile → xmake-cross-compilation