Skip to content

Custom Rule

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

For a custom rules tutorial, see Custom Rules Guide. For the complete API, see Custom Rule API. For built-in rules, see Built-in Rules.

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