From a45c2350f8e8769f2b25c75beec8b354cb0c8bd1 Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 13 Jun 2019 22:43:02 +0800 Subject: update rule docs --- manual.md | 140 ++++++++++++++++++++++++++++++++++++++++++++--------------- zh/manual.md | 70 +++++++++++++++++++++++++++++- 2 files changed, 173 insertions(+), 37 deletions(-) diff --git a/manual.md b/manual.md index d4803311..cd124e18 100644 --- a/manual.md +++ b/manual.md @@ -4105,7 +4105,7 @@ Here the `main` is set to run the main entry module for the script. The file nam The directory structure is as follows: ``` -Projectdir +projectdir - xmake.lua - main.lua ``` @@ -4216,33 +4216,39 @@ A target can be superimposed to apply multiple rules to more customize its own b Rules specified by `add_files("*.md", {rule = "markdown"})`, with a higher priority than the rule set by `add_rules("markdown")`.

-| Interface | Description | Supported Versions | -| ----------------------------------------------- | -------------------------------------------- | -------- | -| [rule](#rule) | Defining Rules | >= 2.1.9 | -| [add_imports](#ruleadd_imports) | Pre-importing extension modules for all custom scripts | >= 2.1.9 | -| [set_extensions](#ruleset_extensions) | Setting the file extension type supported by the rule | >= 2.1.9 | -| [on_build](#ruleon_build) | Custom Compilation Script | >= 2.1.9 | -| [on_clean](#ruleon_clean) | Custom Cleanup Script | >= 2.1.9 | -| [on_package](#ruleon_package) | Custom Package Script | >= 2.1.9 | -| [on_install](#ruleon_install) | Custom Installation Script | >= 2.1.9 | -| [on_uninstall](#ruleon_uninstall) | Custom Uninstall Script | >= 2.1.9 | -| [on_build_file](#ruleon_build_file) | Customize the build script to implement single file build | >= 2.2.1 | -| [on_build_files](#ruleon_build_files) | Custom Compilation Scripts for Multi-File Construction | >= 2.2.1 | -| [before_build](#rulebefore_build) | Custom pre-compilation script | >= 2.2.1 | -| [before_clean](#rulebefore_clean) | Customizing the script before cleanup | >= 2.2.1 | -| [before_package](#rulebefore_package) | Customizing the script before packaging | >= 2.2.1 | -| [before_install](#rulebefore_install) | Custom Pre-Installation Scripts | >= 2.2.1 | -| [before_uninstall](#rulebefore_uninstall) | Customizing the script before uninstalling | >= 2.2.1 | -[before_build_file](#rulebefore_build_file) | Customize pre-compilation scripts to implement single file builds | >= 2.2.1 | -[before_build_files](#rulebefore_build_files) | Customizing pre-compilation scripts for multi-file build | >= 2.2.1 | -| [after_build](#ruleafter_build) | Custom Compiled Scripts | >= 2.2.1 | -| [after_clean](#ruleafter_clean) | Custom Cleanup Script | >= 2.2.1 | -| [after_package](#ruleafter_package) | Custom packaged scripts | >= 2.2.1 | -| [after_install](#ruleafter_install) | Custom Installed Scripts | >= 2.2.1 | -| [after_uninstall](#ruleafter_uninstall) | Custom Uninstalled Scripts | >= 2.2.1 | -| [after_build_file](#ruleafter_build_file) | Customize the compiled script to implement single file build | >= 2.2.1 | -| [after_build_files](#ruleafter_build_files) | Custom Compiled Scripts for Multi-File Construction | >= 2.2.1 | -| [rule_end](#rule_end) | End Definition Rule | >= 2.1.9 | +| Interface | Description | Supported Versions | +| ----------------------------------------------- | -------------------------------------------- | -------- | +| [rule](#rule) | Defining Rules | >= 2.1.9 | +| [add_imports](#ruleadd_imports) | Pre-importing extension modules for all custom scripts | >= 2.1.9 | +| [set_extensions](#ruleset_extensions) | Set the file extension type supported by the rule | >= 2.1.9 | +| [on_load](#ruleon_load) | Custom Load Script | >= 2.2.1 | +| [on_link](#ruleon_link) | Custom Link Script | >= 2.2.7 | +| [on_build](#ruleon_build) | Custom Compilation Script | >= 2.1.9 | +| [on_clean](#ruleon_clean) | Custom Cleanup Script | >= 2.1.9 | +| [on_package](#ruleon_package) | Custom Package Script | >= 2.1.9 | +| [on_install](#ruleon_install) | Custom Installation Script | >= 2.1.9 | +| [on_uninstall](#ruleon_uninstall) | Custom Uninstall Script | >= 2.1.9 | +| [on_build_file](#ruleon_build_file) | Custom the build script to implement single file build | >= 2.2.1 | +| [on_build_files](#ruleon_build_files) | Custom Compilation Scripts for Multi-File Construction | >= 2.2.1 | +| [before_load](#rulebefore_load) | Custom pre-load script | >= 2.2.1 | +| [before_link](#rulebefore_link) | Custom pre-link script | >= 2.2.7 | +| [before_build](#rulebefore_build) | Custom pre-compilation script | >= 2.2.1 | +| [before_clean](#rulebefore_clean) | Custom the script before cleanup | >= 2.2.1 | +| [before_package](#rulebefore_package) | Custom the script before packaging | >= 2.2.1 | +| [before_install](#rulebefore_install) | Custom Pre-Installation Scripts | >= 2.2.1 | +| [before_uninstall](#rulebefore_uninstall) | Custom the script before uninstalling | >= 2.2.1 | +| [before_build_file](#rulebefore_build_file) | Custom pre-compilation scripts to implement single file builds | >= 2.2.1 | +| [before_build_files](#rulebefore_build_files) | Custom pre-compilation scripts for multi-file build | >= 2.2.1 | +| [after_load](#ruleafter_load) | Custom script after loading | >= 2.2.1 | +| [after_link](#ruleafter_link) | Custom script after linking | >= 2.2.7 | +| [after_build](#ruleafter_build) | Custom script after compilation | >= 2.2.1 | +| [after_clean](#ruleafter_clean) | Custom script after cleaning | >= 2.2.1 | +| [after_package](#ruleafter_package) | Custom script after packaging | >= 2.2.1 | +| [after_install](#ruleafter_install) | Custom script after installing | >= 2.2.1 | +| [after_uninstall](#ruleafter_uninstall) | Custom script after uninstalling | >= 2.2.1 | +| [after_build_file](#ruleafter_build_file) | Custom script after compiling the single file | >= 2.2.1 | +| [after_build_files](#ruleafter_build_files) | Custom script after compiling the multiple file | >= 2.2.1 | +| [rule_end](#rule_end) | End Definition Rule | >= 2.1.9 | ##### Built-in rules @@ -4634,6 +4640,31 @@ target("test") add_files("src/*.markdown") ``` +##### rule:on_load + +###### Custom load script + +The load script used to implement the custom rules will be executed when the target is loaded. You can customize some target configurations in it, for example: + +```lua +rule("test") + on_load(function (target) + target:add("defines", "-DTEST") + end) +``` + +##### rule:on_link + +###### Custom link script + +The link script used to implement the custom rules overrides the default link behavior of the applied target, for example: + +```lua +rule("test") + on_link(function (target) + end) +``` + ##### rule:on_build ###### Custom compilation script @@ -4729,6 +4760,31 @@ rule("markdown") end) ``` +##### rule:before_load + +###### Custom pre-load script + +Used to implement the execution script before the custom target is loaded, for example: + +```lua +rule("test") + before_load(function (target) + target:add("defines", "-DTEST") + end) +``` + +##### rule:before_link + +###### Custom pre-link script + +Execution scripts used to implement custom target links, for example: + +```lua +rule("test") + before_link(function (target) + end) +``` + ##### rule:before_build ###### Custom pre-compilation script @@ -4755,7 +4811,7 @@ rule("markdown") ##### rule:before_package -###### Customizing the pre-package script +###### Custom the pre-package script Used to implement the execution script before the custom target is packaged, for example: @@ -4803,46 +4859,58 @@ Generally used to preprocess some source files before compiling. Similar to [rule:on_build_files](#ruleon_build_files), but the timing of this interface is called before compiling some source files. Generally used to preprocess some source files before compiling. +##### rule:after_load + +###### Custom post-loading script + +The execution script used to implement the custom target loading is similar to [rule:after_load](#ruleafter_load). + +##### rule:after_link + +###### Custom post-linking script + +The execution script used to implement the custom target link is similar to [rule:after_link](#ruleafter_link). + ##### rule:after_build -###### Custom pre-compilation script +###### Custom post-compilation script The execution script used to implement the custom target build is similar to [rule:before_build](#rulebefore_build). ##### rule:after_clean -###### Custom Cleanup Script +###### Custom post-cleaning script The execution script used to implement the custom target cleanup is similar to [rule:before_clean](#rulebefore_clean). ##### rule:after_package -###### Custom packaged script +###### Custom post-packaging script The execution script used to implement the custom target package is similar to [rule:before_package](#rulebefore_package). ##### rule:after_install -###### Custom Post-Installation Script +###### Custom post-installation script The execution script used to implement the custom target installation is similar to [rule:before_install](#rulebefore_install). ##### rule:after_uninstall -###### Custom Uninstallation Script +###### Custom post-uninstallation Script The execution script used to implement the custom target uninstallation is similar to [rule:before_uninstall](#rulebefore_uninstall). ##### rule:after_build_file -###### Customizing post-compilation scripts to process one source file at a time +###### Custom post-compilation scripts to process one source file at a time Similar to [rule:on_build_file](#ruleon_build_file), but the timing of this interface is called after compiling a source file. Generally used to post-process some compiled object files. ##### rule:after_build_files -###### Customizing post-compilation scripts to process multiple source files at once +###### Custom post-compilation scripts to process multiple source files at once Similar to [rule:on_build_files](#ruleon_build_files), but the timing of this interface is called after compiling some source files. Generally used to post-process some compiled object files. diff --git a/zh/manual.md b/zh/manual.md index a9652fe9..93151dc5 100644 --- a/zh/manual.md +++ b/zh/manual.md @@ -4300,6 +4300,8 @@ target("test") | [rule](#rule) | 定义规则 | >= 2.1.9 | | [add_imports](#ruleadd_imports) | 为所有自定义脚本预先导入扩展模块 | >= 2.1.9 | | [set_extensions](#ruleset_extensions) | 设置规则支持的文件扩展类型 | >= 2.1.9 | +| [on_load](#ruleon_load) | 自定义加载脚本 | >= 2.2.1 | +| [on_link](#ruleon_link) | 自定义链接脚本 | >= 2.2.7 | | [on_build](#ruleon_build) | 自定义编译脚本 | >= 2.1.9 | | [on_clean](#ruleon_clean) | 自定义清理脚本 | >= 2.1.9 | | [on_package](#ruleon_package) | 自定义打包脚本 | >= 2.1.9 | @@ -4307,6 +4309,8 @@ target("test") | [on_uninstall](#ruleon_uninstall) | 自定义卸载脚本 | >= 2.1.9 | | [on_build_file](#ruleon_build_file) | 自定义编译脚本, 实现单文件构建 | >= 2.2.1 | | [on_build_files](#ruleon_build_files) | 自定义编译脚本, 实现多文件构建 | >= 2.2.1 | +| [before_load](#rulebefore_load) | 自定义加载前的脚本 | >= 2.2.1 | +| [before_link](#rulebefore_link) | 自定义链接前的脚本 | >= 2.2.7 | | [before_build](#rulebefore_build) | 自定义编译前的脚本 | >= 2.2.1 | | [before_clean](#rulebefore_clean) | 自定义清理前的脚本 | >= 2.2.1 | | [before_package](#rulebefore_package) | 自定义打包前的脚本 | >= 2.2.1 | @@ -4314,6 +4318,8 @@ target("test") | [before_uninstall](#rulebefore_uninstall) | 自定义卸载前的脚本 | >= 2.2.1 | | [before_build_file](#rulebefore_build_file) | 自定义编译前的脚本, 实现单文件构建 | >= 2.2.1 | | [before_build_files](#rulebefore_build_files) | 自定义编译前的脚本, 实现多文件构建 | >= 2.2.1 | +| [after_load](#ruleafter_load) | 自定义加载后的脚本 | >= 2.2.1 | +| [after_link](#ruleafter_link) | 自定义链接后的脚本 | >= 2.2.7 | | [after_build](#ruleafter_build) | 自定义编译后的脚本 | >= 2.2.1 | | [after_clean](#ruleafter_clean) | 自定义清理后的脚本 | >= 2.2.1 | | [after_package](#ruleafter_package) | 自定义打包后的脚本 | >= 2.2.1 | @@ -4709,6 +4715,31 @@ target("test") add_files("src/*.markdown") ``` +##### rule:on_load + +###### 自定义加载脚本 + +用于实现自定规则的加载脚本,当加载target的时候,会被执行,可在里面自定义设置一些target配置,例如: + +```lua +rule("test") + on_load(function (target) + target:add("defines", "-DTEST") + end) +``` + +##### rule:on_link + +###### 自定义链接脚本 + +用于实现自定规则的链接脚本,会覆盖被应用的target的默认链接行为,例如: + +```lua +rule("test") + on_link(function (target) + end) +``` + ##### rule:on_build ###### 自定义编译脚本 @@ -4804,6 +4835,31 @@ rule("markdown") end) ``` +##### rule:before_load + +###### 自定义加载前脚本 + +用于实现自定义target加载前的执行脚本,例如: + +```lua +rule("test") + before_load(function (target) + target:add("defines", "-DTEST") + end) +``` + +##### rule:before_link + +###### 自定义链接前脚本 + +用于实现自定义target链接前的执行脚本,例如: + +```lua +rule("test") + before_link(function (target) + end) +``` + ##### rule:before_build ###### 自定义编译前脚本 @@ -4878,9 +4934,21 @@ rule("markdown") 跟[rule:on_build_files](#ruleon_build_files)用法类似,不过这个接口被调用的时机是在编译某些源文件之前, 一般用于对某些源文件进行编译前的预处理。 +##### rule:after_load + +###### 自定义加载后脚本 + +用于实现自定义target加载后的执行脚本,用法跟[rule:before_load](#rulebefore_load)类似。 + +##### rule:after_link + +###### 自定义链接后脚本 + +用于实现自定义target链接后的执行脚本,用法跟[rule:before_link](#rulebefore_link)类似。 + ##### rule:after_build -###### 自定义编译前脚本 +###### 自定义编译后脚本 用于实现自定义target构建后的执行脚本,用法跟[rule:before_build](#rulebefore_build)类似。 -- cgit v1.2.3