diff options
Diffstat (limited to 'manual.md')
| -rw-r--r-- | manual.md | 225 |
1 files changed, 138 insertions, 87 deletions
@@ -686,93 +686,99 @@ target("test2") `target()' interface can be repeatedly invoked in different places to set the same target. </p> -| Interfaces | Description | Support version | -| --------------------------------------------- | ------------------------------------------------------ | --------------------------- | -| [target](#target) | Define a project target | >= 1.0.1 | -| [target_end](#target_end) | End target definition | >= 2.1.1 | -| [set_kind](#targetset_kind) | Set target kind | >= 1.0.1 | -| [set_strip](#targetset_strip) | Strip target symbols | >= 1.0.1 | -| [set_enabled](#targetset_enabled) | Enable or disable target | >= 2.2.2 | -| [set_default](#targetset_default) | Mark as default target | >= 2.1.3 | -| [set_options](#targetset_options) | Set configuartion options | >= 1.0.1 | -| [set_symbols](#targetset_symbols) | Set symbol info | >= 1.0.1 | -| [set_basename](#targetset_basename) | Set the base name of target file | >= 2.1.2 | -| [set_filename](#targetset_filename) | Set the full name of target file | >= 2.1.2 | -| [set_warnings](#targetset_warnings) | Set compilation warning level | >= 1.0.1 | -| [set_optimize](#targetset_optimize) | Set compilation optimization level | >= 1.0.1 | -| [set_languages](#targetset_languages) | Set source code language standards | >= 1.0.1 | -| [set_headerdir](#targetset_headerdir) | Set output directories for header files | >= 1.0.1 | -| [set_targetdir](#targetset_targetdir) | Set output directories for target file | >= 1.0.1 | -| [set_objectdir](#targetset_objectdir) | Set output directories for object files | >= 1.0.1 | -| [set_dependir](#targetset_dependir) | Set output directories for dependent files | >= 2.2.2 | -| [add_imports](#targetadd_imports) | Add imported modules for the custom script | >= 2.1.7 | -| [add_rules](#targetadd_rules) | Add custom compilation rule to target | >= 2.1.9 | -| [on_load](#targeton_load) | Run custom load target configuartion script | >= 2.1.5 | -| [on_build](#targeton_build) | Run custom build target script | >= 2.0.1 | -| [on_clean](#targeton_clean) | Run custom clean files script | >= 2.0.1 | -| [on_package](#targeton_package) | Run custom package target script | >= 2.0.1 | -| [on_install](#targeton_install) | Run custom install target file script | >= 2.0.1 | -| [on_uninstall](#targeton_uninstall) | Run custom uninstall target file script | >= 2.0.1 | -| [on_run](#targeton_run) | Run custom run target script | >= 2.0.1 | -| [before_build](#targetbefore_build) | Run custom script before building target | >= 2.0.1 | -| [before_clean](#targetbefore_clean) | Run custom script before cleaning target | >= 2.0.1 | -| [before_package](#targetbefore_package) | Run custom script before packaging target | >= 2.0.1 | -| [before_install](#targetbefore_install) | Run custom script before installing target | >= 2.0.1 | -| [before_uninstall](#targetbefore_uninstall) | Run custom script before uninstalling target | >= 2.0.1 | -| [before_run](#targetbefore_run) | Run custom script before running target | >= 2.0.1 | -| [after_build](#targetafter_build) | Run custom script after building target | >= 2.0.1 | -| [after_clean](#targetafter_clean) | Run custom script after cleaning target | >= 2.0.1 | -| [after_package](#targetafter_package) | Run custom script after packaging target | >= 2.0.1 | -| [after_install](#targetafter_install) | Run custom script after installing target | >= 2.0.1 | -| [after_uninstall](#targetafter_uninstall) | Run custom script after uninstalling target | >= 2.0.1 | -| [after_run](#targetafter_run) | Run custom script after running target | >= 2.0.1 | -| [set_config_h](#targetset_config_h) | Set auto-generated config header file | >= 1.0.1 < 2.1.5 deprecated | -| [set_config_h_prefix](#targetset_config_h) | Set macro prefix in auto-generated config header | >= 1.0.1 < 2.1.5 deprecated | -| [set_config_header](#targetset_config_header) | Set auto-generated config header file (new) | >= 2.1.5 | -| [set_pcheader](#targetset_pcheader) | Set pre-compiled c header file | >= 2.1.5 | -| [set_pcxxheader](#targetset_pcxxheader) | Set pre-compiled c++ header file | >= 2.1.5 | -| [add_deps](#targetadd_deps) | Add target dependencies | >= 1.0.1 | -| [add_links](#targetadd_links) | Add link libraries | >= 1.0.1 | -| [add_syslinks](#targetadd_syslinks) | Add system link libraries | >= 2.2.3 | -| [add_files](#targetadd_files) | Add source files | >= 1.0.1 | -| [del_files](#targetdel_files) | Remove source files | >= 2.1.9 | -| [add_headers](#targetadd_headers) | Add installed header files | >= 1.0.1 | -| [add_linkdirs](#targetadd_linkdirs) | Add link search directories | >= 1.0.1 | -| [add_rpathdirs](#targetadd_rpathdirs) | Add load search directories for dynamic library | >= 2.1.3 | -| [add_includedirs](#targetadd_includedirs) | Add include search directories | >= 1.0.1 | -| [add_defines](#targetadd_defines) | Add macro definition | >= 1.0.1 | -| [add_undefines](#targetadd_undefines) | Add macro undefinition | >= 1.0.1 | -| [add_defines_h](#targetadd_defines_h) | Add macro definition to auto-generated config header | >= 1.0.1 | -| [add_undefines_h](#targetadd_undefines_h) | Add macro undefinition to auto-generated config header | >= 1.0.1 | -| [add_cflags](#targetadd_cflags) | Add c compilation flags | >= 1.0.1 | -| [add_cxflags](#targetadd_cxflags) | Add c/c++ compilation flags | >= 1.0.1 | -| [add_cxxflags](#targetadd_cxxflags) | Add c++ compilation flags | >= 1.0.1 | -| [add_mflags](#targetadd_mflags) | Add objc compilation flags | >= 1.0.1 | -| [add_mxflags](#targetadd_mxflags) | Add objc/objc++ compilation flags | >= 1.0.1 | -| [add_mxxflags](#targetadd_mxxflags) | Add objc++ compilation flags | >= 1.0.1 | -| [add_scflags](#targetadd_scflags) | Add swift compilation flags | >= 2.0.1 | -| [add_asflags](#targetadd_asflags) | Add asm compilation flags | >= 2.0.1 | -| [add_gcflags](#targetadd_gcflags) | Add go compilation flags | >= 2.1.1 | -| [add_dcflags](#targetadd_dcflags) | Add dlang compilation flags | >= 2.1.1 | -| [add_rcflags](#targetadd_rcflags) | Add rust compilation flags | >= 2.1.1 | -| [add_cuflags](#targetadd_cuflags) | Add cuda compilation flags | >= 2.1.1 | -| [add_ldflags](#targetadd_ldflags) | Add static library link flags | >= 1.0.1 | -| [add_arflags](#targetadd_arflags) | Add archive library flags | >= 1.0.1 | -| [add_shflags](#targetadd_shflags) | Add dynamic library link flags | >= 1.0.1 | -| [add_cfunc](#targetadd_cfunc) | Add single c function for checking | >= 2.0.1 | -| [add_cxxfunc](#targetadd_cxxfunc) | Add single c++ function for checking | >= 2.0.1 | -| [add_cfuncs](#targetadd_cfuncs) | Add c functions for checking | >= 2.0.1 | -| [add_cxxfuncs](#targetadd_cxxfuncs) | Add c++ functions for checking | >= 2.0.1 | -| [add_packages](#targetadd_packages) | Add package dependencies | >= 2.0.1 | -| [add_options](#targetadd_options) | Add options dependencies | >= 2.0.1 | -| [add_languages](#targetadd_languages) | Add language standards | >= 1.0.1 | -| [add_vectorexts](#targetadd_vectorexts) | Add vector extensions | >= 1.0.1 | -| [add_frameworks](#targetadd_frameworks) | Add frameworks | >= 2.1.1 | -| [add_frameworkdirs](#targetadd_frameworkdirs) | Add framework search directories | >= 2.1.5 | -| [set_tools](#targetset_tools) | Set toolchains | >= 2.2.1 | -| [add_tools](#targetadd_tools) | Add toolchains | >= 2.2.1 | -| [set_values](#targetset_values) | Set custom configuartion values | >= 2.2.1 | -| [add_values](#targetadd_values) | Add custom configuartion values | >= 2.2.1 | +| Interfaces | Description | Support version | +| --------------------------------------------- | ------------------------------------------------------ | --------------------------- | +| [target](#target) | Define a project target | >= 1.0.1 | +| [target_end](#target_end) | End target definition | >= 2.1.1 | +| [set_kind](#targetset_kind) | Set target kind | >= 1.0.1 | +| [set_strip](#targetset_strip) | Strip target symbols | >= 1.0.1 | +| [set_enabled](#targetset_enabled) | Enable or disable target | >= 2.2.2 | +| [set_default](#targetset_default) | Mark as default target | >= 2.1.3 | +| [set_options](#targetset_options) | Set configuartion options | >= 1.0.1 | +| [set_symbols](#targetset_symbols) | Set symbol info | >= 1.0.1 | +| [set_basename](#targetset_basename) | Set the base name of target file | >= 2.1.2 | +| [set_filename](#targetset_filename) | Set the full name of target file | >= 2.1.2 | +| [set_warnings](#targetset_warnings) | Set compilation warning level | >= 1.0.1 | +| [set_optimize](#targetset_optimize) | Set compilation optimization level | >= 1.0.1 | +| [set_languages](#targetset_languages) | Set source code language standards | >= 1.0.1 | +| [set_headerdir](#targetset_headerdir) | Set output directories for header files | >= 1.0.1 | +| [set_targetdir](#targetset_targetdir) | Set output directories for target file | >= 1.0.1 | +| [set_objectdir](#targetset_objectdir) | Set output directories for object files | >= 1.0.1 | +| [set_dependir](#targetset_dependir) | Set output directories for dependent files | >= 2.2.2 | +| [add_imports](#targetadd_imports) | Add imported modules for the custom script | >= 2.1.7 | +| [add_rules](#targetadd_rules) | Add custom compilation rule to target | >= 2.1.9 | +| [on_load](#targeton_load) | Run custom load target configuartion script | >= 2.1.5 | +| [on_build](#targeton_build) | Run custom build target script | >= 2.0.1 | +| [on_build_file](#targeton_build_file) | Run custom build single file script | >= 2.2.3 | +| [on_build_files](#targeton_build_files) | Run custom build files script | >= 2.2.3 | +| [on_clean](#targeton_clean) | Run custom clean files script | >= 2.0.1 | +| [on_package](#targeton_package) | Run custom package target script | >= 2.0.1 | +| [on_install](#targeton_install) | Run custom install target file script | >= 2.0.1 | +| [on_uninstall](#targeton_uninstall) | Run custom uninstall target file script | >= 2.0.1 | +| [on_run](#targeton_run) | Run custom run target script | >= 2.0.1 | +| [before_build](#targetbefore_build) | Run custom script before building target | >= 2.0.1 | +| [before_build_file](#targetbefore_build_file) | Run custom script before building single file | >= 2.2.3 | +| [before_build_files](#targetbefore_build_files) | Run custom script before building files | >= 2.2.3 | +| [before_clean](#targetbefore_clean) | Run custom script before cleaning target | >= 2.0.1 | +| [before_package](#targetbefore_package) | Run custom script before packaging target | >= 2.0.1 | +| [before_install](#targetbefore_install) | Run custom script before installing target | >= 2.0.1 | +| [before_uninstall](#targetbefore_uninstall) | Run custom script before uninstalling target | >= 2.0.1 | +| [before_run](#targetbefore_run) | Run custom script before running target | >= 2.0.1 | +| [after_build](#targetafter_build) | Run custom script after building target | >= 2.0.1 | +| [after_build_file](#targetafter_build_file) | Run custom script after building single file | >= 2.2.3 | +| [after_build_files](#targetafter_build_files) | Run custom script after building files | >= 2.2.3 | +| [after_clean](#targetafter_clean) | Run custom script after cleaning target | >= 2.0.1 | +| [after_package](#targetafter_package) | Run custom script after packaging target | >= 2.0.1 | +| [after_install](#targetafter_install) | Run custom script after installing target | >= 2.0.1 | +| [after_uninstall](#targetafter_uninstall) | Run custom script after uninstalling target | >= 2.0.1 | +| [after_run](#targetafter_run) | Run custom script after running target | >= 2.0.1 | +| [set_config_h](#targetset_config_h) | Set auto-generated config header file | >= 1.0.1 < 2.1.5 deprecated | +| [set_config_h_prefix](#targetset_config_h) | Set macro prefix in auto-generated config header | >= 1.0.1 < 2.1.5 deprecated | +| [set_config_header](#targetset_config_header) | Set auto-generated config header file (new) | >= 2.1.5 | +| [set_pcheader](#targetset_pcheader) | Set pre-compiled c header file | >= 2.1.5 | +| [set_pcxxheader](#targetset_pcxxheader) | Set pre-compiled c++ header file | >= 2.1.5 | +| [add_deps](#targetadd_deps) | Add target dependencies | >= 1.0.1 | +| [add_links](#targetadd_links) | Add link libraries | >= 1.0.1 | +| [add_syslinks](#targetadd_syslinks) | Add system link libraries | >= 2.2.3 | +| [add_files](#targetadd_files) | Add source files | >= 1.0.1 | +| [del_files](#targetdel_files) | Remove source files | >= 2.1.9 | +| [add_headers](#targetadd_headers) | Add installed header files | >= 1.0.1 | +| [add_linkdirs](#targetadd_linkdirs) | Add link search directories | >= 1.0.1 | +| [add_rpathdirs](#targetadd_rpathdirs) | Add load search directories for dynamic library | >= 2.1.3 | +| [add_includedirs](#targetadd_includedirs) | Add include search directories | >= 1.0.1 | +| [add_defines](#targetadd_defines) | Add macro definition | >= 1.0.1 | +| [add_undefines](#targetadd_undefines) | Add macro undefinition | >= 1.0.1 | +| [add_defines_h](#targetadd_defines_h) | Add macro definition to auto-generated config header | >= 1.0.1 | +| [add_undefines_h](#targetadd_undefines_h) | Add macro undefinition to auto-generated config header | >= 1.0.1 | +| [add_cflags](#targetadd_cflags) | Add c compilation flags | >= 1.0.1 | +| [add_cxflags](#targetadd_cxflags) | Add c/c++ compilation flags | >= 1.0.1 | +| [add_cxxflags](#targetadd_cxxflags) | Add c++ compilation flags | >= 1.0.1 | +| [add_mflags](#targetadd_mflags) | Add objc compilation flags | >= 1.0.1 | +| [add_mxflags](#targetadd_mxflags) | Add objc/objc++ compilation flags | >= 1.0.1 | +| [add_mxxflags](#targetadd_mxxflags) | Add objc++ compilation flags | >= 1.0.1 | +| [add_scflags](#targetadd_scflags) | Add swift compilation flags | >= 2.0.1 | +| [add_asflags](#targetadd_asflags) | Add asm compilation flags | >= 2.0.1 | +| [add_gcflags](#targetadd_gcflags) | Add go compilation flags | >= 2.1.1 | +| [add_dcflags](#targetadd_dcflags) | Add dlang compilation flags | >= 2.1.1 | +| [add_rcflags](#targetadd_rcflags) | Add rust compilation flags | >= 2.1.1 | +| [add_cuflags](#targetadd_cuflags) | Add cuda compilation flags | >= 2.1.1 | +| [add_ldflags](#targetadd_ldflags) | Add static library link flags | >= 1.0.1 | +| [add_arflags](#targetadd_arflags) | Add archive library flags | >= 1.0.1 | +| [add_shflags](#targetadd_shflags) | Add dynamic library link flags | >= 1.0.1 | +| [add_cfunc](#targetadd_cfunc) | Add single c function for checking | >= 2.0.1 | +| [add_cxxfunc](#targetadd_cxxfunc) | Add single c++ function for checking | >= 2.0.1 | +| [add_cfuncs](#targetadd_cfuncs) | Add c functions for checking | >= 2.0.1 | +| [add_cxxfuncs](#targetadd_cxxfuncs) | Add c++ functions for checking | >= 2.0.1 | +| [add_packages](#targetadd_packages) | Add package dependencies | >= 2.0.1 | +| [add_options](#targetadd_options) | Add options dependencies | >= 2.0.1 | +| [add_languages](#targetadd_languages) | Add language standards | >= 1.0.1 | +| [add_vectorexts](#targetadd_vectorexts) | Add vector extensions | >= 1.0.1 | +| [add_frameworks](#targetadd_frameworks) | Add frameworks | >= 2.1.1 | +| [add_frameworkdirs](#targetadd_frameworkdirs) | Add framework search directories | >= 2.1.5 | +| [set_tools](#targetset_tools) | Set toolchains | >= 2.2.1 | +| [add_tools](#targetadd_tools) | Add toolchains | >= 2.2.1 | +| [set_values](#targetset_values) | Set custom configuartion values | >= 2.2.1 | +| [add_values](#targetadd_values) | Add custom configuartion values | >= 2.2.1 | ##### target @@ -1311,6 +1317,51 @@ target("test") 一旦对这个target目标设置了自己的build过程,那么xmake默认的构建过程将不再被执行。 </p> +##### target:on_build_file + +###### Run custom build single file script + +通过此接口,可以用来hook指定target内置的构建过程,替换每个源文件编译过程: + +```lua +target("test") + set_kind("binary") + add_files("src/*.c") + on_build_file(function (target, sourcefile, opt) + opt.origin(target, sourcefile, opt) + end) +``` + +上面代码中的`opt.origin`存有内置的构建脚本,如果hook后还是想调用内置的构建脚本去编译源文件,那么直接继续调用`opt.origin`就行了。 + +如果不想重写内置的编译脚本,仅仅只是在编译前后添加一些自己的处理,其实用:[target.before_build_file](#targetbefore_build_file)和[target.after_build_file](#targetafter_build_file)会更加方便,不需要调用`opt.origin`。 + +##### target:on_build_files + +###### Run custom build files script + +通过此接口,可以用来hook指定target内置的构建过程,替换一批同类型源文件编译过程: + +```lua +target("test") + set_kind("binary") + add_files("src/*.c") + on_build_files(function (target, sourcebatch, opt) + opt.origin(target, sourcebatch, opt) + end) +``` + +设置此接口后,对应源文件列表中文件,就不会出现在自定义的[target.on_build_file](#targeton_build_file)了,因为这个是包含关系。 + +其中sourcebatch描述了这批同类型源文件: + +* `sourcebatch.sourcekind`: 获取这批源文件的类型,比如:cc, as, .. +* `sourcebatch.sourcefiles()`: 获取源文件列表 +* `sourcebatch.objectfiles()`: 获取对象文件列表 +* `sourcebatch.dependfiles()`: 获取对应依赖文件列表,存有源文件中编译依赖信息,例如:xxx.d + +上面代码中的`opt.origin`存有内置的构建脚本,如果hook后还是想调用内置的构建脚本去编译源文件,那么直接继续调用`opt.origin`就行了。 + ##### target:on_clean ###### Run custom clean files script |
