@@ -215,6 +215,7 @@ The global interface affects the whole project description scope and all sub-pro
215215
216216| Interfaces | Description | Version |
217217| ------------------------------------- | ----------------------------- | -------- |
218+ | [ set_modes] ( #set_modes ) | Set project compilation modes | >= 2.1.2 |
218219| [ set_project] ( #set_project ) | Set project name | >= 2.0.1 |
219220| [ set_version] ( #set_version ) | Set project version | >= 2.0.1 |
220221| [ set_xmakever] ( #set_xmakever ) | Set minimal xmake version | >= 2.1.1 |
@@ -223,6 +224,32 @@ The global interface affects the whole project description scope and all sub-pro
223224| [ add_plugindirs] ( #add_plugindirs ) | Add plugin directories | >= 2.0.1 |
224225| [ add_packagedirs] ( #add_packagedirs ) | Add package directories | >= 2.0.1 |
225226
227+ ##### set_modes
228+
229+ ###### Set project compilation modes
230+
231+ This is an optional api, just to make it easy for the plugin to get mode configuration information now.
232+
233+ ``` lua
234+ set_modes (" debug" , " release" )
235+ ```
236+
237+ If you set this configuration, you need not set them manually when generating vs201x project.
238+
239+ ``` bash
240+ $ xmake project -k vs2017
241+ ```
242+
243+ Otherwise, you need to run:
244+
245+ ``` bash
246+ $ xmake project -k vs2017 -m " debug,release"
247+ ```
248+
249+ <p class =" tip " >
250+ If you do not set this configuration, [ is_mode] ( #is_mode ) can also be used normally.
251+ </p >
252+
226253##### set_project
227254
228255###### Set project name
@@ -410,6 +437,7 @@ target("test2")
410437| [set_strip](#targetset_strip) | 设置是否strip信息 | >= 1.0.1 |
411438| [set_options](#targetset_options) | 设置关联选项 | >= 1.0.1 |
412439| [set_symbols](#targetset_symbols) | 设置符号信息 | >= 1.0.1 |
440+ | [set_basename](#targetset_basename) | 设置目标文件名 | >= 2.1.2 |
413441| [set_warnings](#targetset_warnings) | 设置警告级别 | >= 1.0.1 |
414442| [set_optimize](#targetset_optimize) | 设置优化级别 | >= 1.0.1 |
415443| [set_languages](#targetset_languages) | 设置代码语言标准 | >= 1.0.1 |
@@ -630,6 +658,38 @@ set_symbols("debug", "hidden")
630658
631659如果没有调用这个api,默认是禁用调试符号的。。
632660
661+ ##### target:set_basename
662+
663+ ###### 设置目标文件名
664+
665+ 默认情况下,生成的目标文件名基于`target("name")`中配置的值,例如:
666+
667+ ```lua
668+ -- 目标文件名为:libxxx.a
669+ target("xxx")
670+ set_kind("static")
671+
672+ -- 目标文件名为:libxxx2.so
673+ target("xxx2")
674+ set_kind("shared")
675+ ```
676+
677+ 默认的命名方式,基本上可以满足大部分情况下的需求,但是如果有时候想要更加定制化目标文件名
678+
679+ 例如,按编译模式和架构区分目标名,这个时候可以使用这个接口,来设置:
680+
681+ ```lua
682+ target("xxx")
683+ set_kind("static")
684+ set_basename("xxx_$(mode)_$(arch)")
685+ ```
686+
687+ 如果这个时候,编译配置为:`xmake f -m debug -a armv7`,那么生成的文件名为:`libxxx_debug_armv7.a`
688+
689+ 如果还想进一步定制目标文件的目录名,可参考:[set_targetdir](#targetset_targetdir)。
690+
691+ 或者通过编写自定义脚本,实现更高级的逻辑,具体见:[after_build](#targetafter_build)和[os.mv](#os-mv)。
692+
633693##### target:set_warnings
634694
635695###### 设置警告级别
0 commit comments