Skip to content

Custom Rule

We can use rule() to define custom build rules to handle specific file types or build logic.

Basic Example

EXPLORER
src
test.md
xmake.lua
Lua xmake.lua
12345678910
rule("markdown")
    set_extensions(".md")
    on_build_file(function (target, sourcefile, opt)
        print("processing %s", sourcefile)
    end)

target("test")
    set_kind("phony")
    add_files("src/*.md")
    add_rules("markdown")

Build and Run

bash
$ xmake