diff options
| author | ruki <waruqi@gmail.com> | 2019-08-22 23:09:57 +0800 |
|---|---|---|
| committer | ruki <waruqi@gmail.com> | 2019-08-22 12:59:42 +0800 |
| commit | d090863ba070ecfc6659f27b1450f7870c8b9c01 (patch) | |
| tree | 3db52fb89c003720d0f54b5fa8fccdc9377e78bb | |
| parent | 2952258322e3dbbbdd77bd86bb93ad23d9e1dd5c (diff) | |
| download | xmake-docs-d090863ba070ecfc6659f27b1450f7870c8b9c01.tar.gz xmake-docs-d090863ba070ecfc6659f27b1450f7870c8b9c01.zip | |
update vsxmake docs
| -rw-r--r-- | assets/img/manual/property_page_vsxmake.png | bin | 0 -> 32431 bytes | |||
| -rw-r--r-- | plugin/builtin_plugins.md | 357 | ||||
| -rw-r--r-- | zh-cn/plugin/builtin_plugins.md | 379 |
3 files changed, 373 insertions, 363 deletions
diff --git a/assets/img/manual/property_page_vsxmake.png b/assets/img/manual/property_page_vsxmake.png Binary files differnew file mode 100644 index 00000000..e67e9b18 --- /dev/null +++ b/assets/img/manual/property_page_vsxmake.png diff --git a/plugin/builtin_plugins.md b/plugin/builtin_plugins.md index c0eb430b..93357330 100644 --- a/plugin/builtin_plugins.md +++ b/plugin/builtin_plugins.md @@ -1,4 +1,185 @@ + +## Generate IDE Project Files + +### Generate Makefile + +```bash +$ xmake project -k makefile +``` + +### Generate CMakelists.txt + +```console +$ xmake project -k cmakelists +``` + +### Generate compiler_flags + +```console +$ xmake project -k compiler_flags +``` + +### Generate compiler_commands + +We can export the compilation commands info of all source files and it is JSON compilation database format. + +```console +$ xmake project -k compile_commands +``` + +The the content of the output file: + +``` +[ + { "directory": "/home/user/llvm/build", + "command": "/usr/bin/clang++ -Irelative -DSOMEDEF=\"With spaces, quotes and \\-es.\" -c -o file.o file.cc", + "file": "file.cc" }, + ... +] + +``` + +Please see [JSONCompilationDatabase](#https://clang.llvm.org/docs/JSONCompilationDatabase.html) if need known more info about `compile_commands`. + +### Generate VisualStudio Project + +#### Compile with xmake integration + +v2.2.8 or later, provides a new version of the vs project generation plugin extension, which is very different from the previous plugin processing mode for generating vs. The previously generated vs project is the compilation of all files and then transferred to vs. To handle compilation. + +But this mode, there is no way to support the rules of xmake. Because xmake's rules use a lot of custom scripts like `on_build`, they can't be expanded, so projects like qt, wdk can't support exporting to vs. compile. + +Therefore, in order to solve this problem, the new version of the vs. build plugin performs the compile operation by directly calling the xmake command under vs, and also supports intellsence and definition jumps, as well as breakpoint debugging. + +The specific use is similar to the old version: + +```console +$ xmake project -k [vsxmake2010|vsxmake2013|vsxmake2015|..] -m "debug,release" +``` + + + +In addition, the vsxmake plugin will additionally generate a custom configuration property page for easy and flexible modification and appending some xmake compilation configuration in the vs., and even switch to other cross toolchains in the configuration to achieve the vs. vs. Cross-compilation of other platforms such as android, linux. + + + +#### Using vs built-in compilation mechanism + +!> It is recommended to use the new version of the vs. plugin provided after v2.2.8 mentioned above. The support is more complete. The generation method here does not support the rules of xmake, and the generation of projects such as qt. + +```bash +$ xmake project -k [vs2008|vs2013|vs2015|..] +``` + +v2.1.2 or later, it supports multi-mode and multi-architecture generation for vs201x project. + +For example: + +```bash +$ xmake project -k vs2017 -m "debug,release" +``` + +It will generate four project configurations: `debug|x86`, `debug|x64`, `release|x86`, `release|x64`. + +Or you can set modes to `xmake.lua`: + +```lua +set_modes("debug", "release") +``` + +Then, we run the following command: + +```bash +$ xmake project -k vs2017 +``` + +The effect is same. + +## Run the Custom Lua Script + +### Run the given script + +Write a simple lua script: + +```lua +function main() + print("hello xmake!") +end +``` + +Run this lua script. + +```bash +$ xmake lua /tmp/test.lua +``` + +<p class="tip"> + You can also use `import` api to write a more advance lua script. +</p> + +### Run the builtin script + +You can run `xmake lua -l` to list all builtin script name, for example: + +```bash +$ xmake lua -l +scripts: + cat + cp + echo + versioninfo + ... +``` + +And run them: + +```bash +$ xmake lua cat ~/file.txt +$ xmake lua echo "hello xmake" +$ xmake lua cp /tmp/file /tmp/file2 +$ xmake lua versioninfo +``` + +### Run interactive commands (REPL) + +Enter interactive mode: + +```bash +$ xmake lua +> 1 + 2 +3 + +> a = 1 +> a +1 + +> for _, v in pairs({1, 2, 3}) do +>> print(v) +>> end +1 +2 +3 +``` + +And we can `import` modules: + +```bash +> task = import("core.project.task") +> task.run("hello") +hello xmake! +``` + +If you want to cancel multiline input, please input character `q`, for example: + +```bash +> for _, v in ipairs({1, 2}) do +>> print(v) +>> q <-- cancel multiline and clear previous input +> 1 + 2 +3 +``` + ## Macros Recording and Playback ### Introduction @@ -232,182 +413,6 @@ end If you want to known more options, please run: `xmake macro --help` </p> -## Run the Custom Lua Script - -### Run the given script - -Write a simple lua script: - -```lua -function main() - print("hello xmake!") -end -``` - -Run this lua script. - -```bash -$ xmake lua /tmp/test.lua -``` - -<p class="tip"> - You can also use `import` api to write a more advance lua script. -</p> - -### Run the builtin script - -You can run `xmake lua -l` to list all builtin script name, for example: - -```bash -$ xmake lua -l -scripts: - cat - cp - echo - versioninfo - ... -``` - -And run them: - -```bash -$ xmake lua cat ~/file.txt -$ xmake lua echo "hello xmake" -$ xmake lua cp /tmp/file /tmp/file2 -$ xmake lua versioninfo -``` - -### Run interactive commands (REPL) - -Enter interactive mode: - -```bash -$ xmake lua -> 1 + 2 -3 - -> a = 1 -> a -1 - -> for _, v in pairs({1, 2, 3}) do ->> print(v) ->> end -1 -2 -3 -``` - -And we can `import` modules: - -```bash -> task = import("core.project.task") -> task.run("hello") -hello xmake! -``` - -If you want to cancel multiline input, please input character `q`, for example: - -```bash -> for _, v in ipairs({1, 2}) do ->> print(v) ->> q <-- cancel multiline and clear previous input -> 1 + 2 -3 -``` - -## Generate IDE Project Files - -### Generate Makefile - -```bash -$ xmake project -k makefile -``` - -### Generate CMakelists.txt - -```console -$ xmake project -k cmakelists -``` - -### Generate compiler_flags - -```console -$ xmake project -k compiler_flags -``` - -### Generate compiler_commands - -We can export the compilation commands info of all source files and it is JSON compilation database format. - -```console -$ xmake project -k compile_commands -``` - -The the content of the output file: - -``` -[ - { "directory": "/home/user/llvm/build", - "command": "/usr/bin/clang++ -Irelative -DSOMEDEF=\"With spaces, quotes and \\-es.\" -c -o file.o file.cc", - "file": "file.cc" }, - ... -] - -``` - -Please see [JSONCompilationDatabase](#https://clang.llvm.org/docs/JSONCompilationDatabase.html) if need known more info about `compile_commands`. - -### Generate VisualStudio Project - -#### Compile with xmake integration - -v2.2.8 or later, provides a new version of the vs project generation plugin extension, which is very different from the previous plugin processing mode for generating vs. The previously generated vs project is the compilation of all files and then transferred to vs. To handle compilation. - -But this mode, there is no way to support the rules of xmake. Because xmake's rules use a lot of custom scripts like `on_build`, they can't be expanded, so projects like qt, wdk can't support exporting to vs. compile. - -Therefore, in order to solve this problem, the new version of the vs. build plugin performs the compile operation by directly calling the xmake command under vs, and also supports intellsence and definition jumps, as well as breakpoint debugging. - -The specific use is similar to the old version: - -```console -$ xmake project -k [vsxmake2010|vsxmake2013|vsxmake2015|..] -m "debug,release" -``` - - - -#### Using vs built-in compilation mechanism - -!> It is recommended to use the new version of the vs. plugin provided after v2.2.8 mentioned above. The support is more complete. The generation method here does not support the rules of xmake, and the generation of projects such as qt. - -```bash -$ xmake project -k [vs2008|vs2013|vs2015|..] -``` - -v2.1.2 or later, it supports multi-mode and multi-architecture generation for vs201x project. - -For example: - -```bash -$ xmake project -k vs2017 -m "debug,release" -``` - -It will generate four project configurations: `debug|x86`, `debug|x64`, `release|x86`, `release|x64`. - -Or you can set modes to `xmake.lua`: - -```lua -set_modes("debug", "release") -``` - -Then, we run the following command: - -```bash -$ xmake project -k vs2017 -``` - -The effect is same. - ## Generate Doxygen Document Please ensure that the doxygen tool has been installed first. diff --git a/zh-cn/plugin/builtin_plugins.md b/zh-cn/plugin/builtin_plugins.md index ea81ec29..ee7a4fa3 100644 --- a/zh-cn/plugin/builtin_plugins.md +++ b/zh-cn/plugin/builtin_plugins.md @@ -1,4 +1,196 @@ +## 生成IDE工程文件 + +### 简介 + +XMake跟`cmake`, `premake`等其他一些构建工具的区别在于: + +<p class="warn"> +`xmake`默认是直接构建运行的,生成第三方的IDE的工程文件仅仅作为`插件`来提供。 +</p> + +这样做的一个好处是:插件更加容易扩展,维护也更加独立和方便。 + +### 生成Makefile + +```console +$ xmake project -k makefile +``` + +### 生成CMakelists.txt + +```console +$ xmake project -k cmakelists +``` + +### 生成compiler_flags + +```console +$ xmake project -k compiler_flags +``` + +### 生成compiler_commands + +导出每个源文件的编译信息,生成基于clang的编译数据库文件,json格式,可用于跟ide,编辑器,静态分析工具进行交互。 + +```console +$ xmake project -k compile_commands +``` + +输出的内容格式如下: + +``` +[ + { "directory": "/home/user/llvm/build", + "command": "/usr/bin/clang++ -Irelative -DSOMEDEF=\"With spaces, quotes and \\-es.\" -c -o file.o file.cc", + "file": "file.cc" }, + ... +] + +``` + +对于`compile_commands`的详细说明见:[JSONCompilationDatabase](#https://clang.llvm.org/docs/JSONCompilationDatabase.html) + +### 生成VisualStudio工程 + +#### 使用xmake集成编译 + +v2.2.8以上版本,提供了新版本的vs工程生成插件扩展,跟之前的生成vs的插件处理模式上有很大的不同,之前生成的vs工程是吧所有文件的编译展开后,转交给vs来处理编译。 + +但是这种模式,对xmake的rules是没法支持的。因为xmake的rules里面用了很多的`on_build`此类自定义脚本,无法展开,所以像qt, wdk此类的项目就没法支持导出到vs里面进行编译了。 + +因此,为了解决这个问题,新版本的vs生成插件通过在vs下直接调用xmake命令,去执行编译操作,并且对intellsence和定义跳转,还有断点调试也做了支持。 + +具体使用方式跟老版本类似: + +```console +$ xmake project -k [vsxmake2010|vsxmake2013|vsxmake2015|..] -m "debug,release" +``` + + + +另外,vsxmake插件还会额外生成一个自定义的配置属性页,用于在vs里面,方便灵活的修改和追加一些xmake编译配置,甚至可以在里面配置切换到其他交叉工具链,实现在vs中对android, linux等其他平台的交叉编译。 + + + +#### 使用vs内置编译机制 + +!> 建议尽量使用上文提到的v2.2.8之后提供的新版的vs生成插件,支持更加完善,此处的生成方式不支持xmake的rules,以及对qt等工程的生成。 + +```console +$ xmake project -k [vs2008|vs2013|vs2015|..] +``` + +v2.1.2以上版本,增强了vs201x版本工程的生成,支持多模式+多架构生成,生成的时候只需要指定: + +```console +$ xmake project -k vs2017 -m "debug,release" +``` + +生成后的工程文件,同时支持`debug|x86`, `debug|x64`, `release|x86`, `release|x64`四种配置模式。 + +如果不想每次生成的时候,指定模式,可以把模式配置加到`xmake.lua`的中,例如: + +```lua +-- 配置当前的工程,支持哪些编译模式 +add_rules("mode.debug", "mode.release") +``` + +## 运行自定义lua脚本 + +这个跟宏脚本类似,只是省去了导入导出操作,直接指定lua脚本来加载运行,这对于想要快速测试一些接口模块,验证自己的某些思路,都是一个不错的方式。 + +### 运行指定的脚本文件 + +我们先写个简单的lua脚本: + +```lua +function main() + print("hello xmake!") +end +``` + +然后直接运行它就行了: + +```console +$ xmake lua /tmp/test.lua +``` + +<p class="tip"> + 当然,你也可以像宏脚本那样,使用`import`接口导入扩展模块,实现复杂的功能。 +</p> + +### 运行内置的脚本命令 + +你可以运行 `xmake lua -l` 来列举所有内置的脚本名,例如: + +```console +$ xmake lua -l +scripts: + cat + cp + echo + versioninfo + ... +``` + +并且运行它们: + +```console +$ xmake lua cat ~/file.txt +$ xmake lua echo "hello xmake" +$ xmake lua cp /tmp/file /tmp/file2 +$ xmake lua versioninfo +``` + +### 运行交互命令 (REPL) + +有时候在交互模式下,运行命令更加的方便测试和验证一些模块和api,也更加的灵活,不需要再去额外写一个脚本文件来加载。 + +我们先看下,如何进入交互模式: + +```console +# 不带任何参数执行,就可以进入 +$ xmake lua +> + +# 进行表达式计算 +> 1 + 2 +3 + +# 赋值和打印变量值 +> a = 1 +> a +1 + +# 多行输入和执行 +> for _, v in pairs({1, 2, 3}) do +>> print(v) +>> end +1 +2 +3 +``` + +我们也能够通过 `import` 来导入扩展模块: + +```console +> task = import("core.project.task") +> task.run("hello") +hello xmake! +``` + +如果要中途取消多行输入,只需要输入字符:`q` 就行了 + +```console +> for _, v in ipairs({1, 2}) do +>> print(v) +>> q <-- 取消多行输入,清空先前的输入数据 +> 1 + 2 +3 +``` + + ## 宏记录和回放 ### 简介 @@ -242,193 +434,6 @@ end 如果你想要获取更多宏参数选项信息,请运行: `xmake macro --help` </p> -## 运行自定义lua脚本 - -这个跟宏脚本类似,只是省去了导入导出操作,直接指定lua脚本来加载运行,这对于想要快速测试一些接口模块,验证自己的某些思路,都是一个不错的方式。 - -### 运行指定的脚本文件 - -我们先写个简单的lua脚本: - -```lua -function main() - print("hello xmake!") -end -``` - -然后直接运行它就行了: - -```console -$ xmake lua /tmp/test.lua -``` - -<p class="tip"> - 当然,你也可以像宏脚本那样,使用`import`接口导入扩展模块,实现复杂的功能。 -</p> - -### 运行内置的脚本命令 - -你可以运行 `xmake lua -l` 来列举所有内置的脚本名,例如: - -```console -$ xmake lua -l -scripts: - cat - cp - echo - versioninfo - ... -``` - -并且运行它们: - -```console -$ xmake lua cat ~/file.txt -$ xmake lua echo "hello xmake" -$ xmake lua cp /tmp/file /tmp/file2 -$ xmake lua versioninfo -``` - -### 运行交互命令 (REPL) - -有时候在交互模式下,运行命令更加的方便测试和验证一些模块和api,也更加的灵活,不需要再去额外写一个脚本文件来加载。 - -我们先看下,如何进入交互模式: - -```console -# 不带任何参数执行,就可以进入 -$ xmake lua -> - -# 进行表达式计算 -> 1 + 2 -3 - -# 赋值和打印变量值 -> a = 1 -> a -1 - -# 多行输入和执行 -> for _, v in pairs({1, 2, 3}) do ->> print(v) ->> end -1 -2 -3 -``` - -我们也能够通过 `import` 来导入扩展模块: - -```console -> task = import("core.project.task") -> task.run("hello") -hello xmake! -``` - -如果要中途取消多行输入,只需要输入字符:`q` 就行了 - -```console -> for _, v in ipairs({1, 2}) do ->> print(v) ->> q <-- 取消多行输入,清空先前的输入数据 -> 1 + 2 -3 -``` - -## 生成IDE工程文件 - -### 简介 - -XMake跟`cmake`, `premake`等其他一些构建工具的区别在于: - -<p class="warn"> -`xmake`默认是直接构建运行的,生成第三方的IDE的工程文件仅仅作为`插件`来提供。 -</p> - -这样做的一个好处是:插件更加容易扩展,维护也更加独立和方便。 - -### 生成Makefile - -```console -$ xmake project -k makefile -``` - -### 生成CMakelists.txt - -```console -$ xmake project -k cmakelists -``` - -### 生成compiler_flags - -```console -$ xmake project -k compiler_flags -``` - -### 生成compiler_commands - -导出每个源文件的编译信息,生成基于clang的编译数据库文件,json格式,可用于跟ide,编辑器,静态分析工具进行交互。 - -```console -$ xmake project -k compile_commands -``` - -输出的内容格式如下: - -``` -[ - { "directory": "/home/user/llvm/build", - "command": "/usr/bin/clang++ -Irelative -DSOMEDEF=\"With spaces, quotes and \\-es.\" -c -o file.o file.cc", - "file": "file.cc" }, - ... -] - -``` - -对于`compile_commands`的详细说明见:[JSONCompilationDatabase](#https://clang.llvm.org/docs/JSONCompilationDatabase.html) - -### 生成VisualStudio工程 - -#### 使用xmake集成编译 - -v2.2.8以上版本,提供了新版本的vs工程生成插件扩展,跟之前的生成vs的插件处理模式上有很大的不同,之前生成的vs工程是吧所有文件的编译展开后,转交给vs来处理编译。 - -但是这种模式,对xmake的rules是没法支持的。因为xmake的rules里面用了很多的`on_build`此类自定义脚本,无法展开,所以像qt, wdk此类的项目就没法支持导出到vs里面进行编译了。 - -因此,为了解决这个问题,新版本的vs生成插件通过在vs下直接调用xmake命令,去执行编译操作,并且对intellsence和定义跳转,还有断点调试也做了支持。 - -具体使用方式跟老版本类似: - -```console -$ xmake project -k [vsxmake2010|vsxmake2013|vsxmake2015|..] -m "debug,release" -``` - - - -#### 使用vs内置编译机制 - -!> 建议尽量使用上文提到的v2.2.8之后提供的新版的vs生成插件,支持更加完善,此处的生成方式不支持xmake的rules,以及对qt等工程的生成。 - -```console -$ xmake project -k [vs2008|vs2013|vs2015|..] -``` - -v2.1.2以上版本,增强了vs201x版本工程的生成,支持多模式+多架构生成,生成的时候只需要指定: - -```console -$ xmake project -k vs2017 -m "debug,release" -``` - -生成后的工程文件,同时支持`debug|x86`, `debug|x64`, `release|x86`, `release|x64`四种配置模式。 - -如果不想每次生成的时候,指定模式,可以把模式配置加到`xmake.lua`的中,例如: - -```lua --- 配置当前的工程,支持哪些编译模式 -add_rules("mode.debug", "mode.release") -``` - ## 生成doxygen文档 请先确保本机已安装`doxygen`工具,然后在工程目录下运行: |
