more_plugins.html 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>xmake</title>
  6. <link rel="icon" href="/assets/img/favicon.ico">
  7. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  8. <meta name="description" content="Description">
  9. <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  10. <link href="//cdn.jsdelivr.net/npm/[email protected]/github-markdown.min.css" rel="stylesheet">
  11. <style>
  12. .markdown-body {
  13. box-sizing: border-box;
  14. min-width: 200px;
  15. max-width: 980px;
  16. margin: 0 auto;
  17. padding: 45px;
  18. }
  19. @media (max-width: 767px) {
  20. .markdown-body {
  21. padding: 15px;
  22. }
  23. }
  24. </style>
  25. </head>
  26. <body>
  27. <article class="markdown-body">
  28. <h4>This is a mirror page, please see the original page: </h4><a href="https://xmake.io/#/plugin/more_plugins">https://xmake.io/#/plugin/more_plugins</a>
  29. </br>
  30. <script async type="text/javascript" src="//cdn.carbonads.com/carbon.js?serve=CE7I52QU&placement=xmakeio" id="_carbonads_js"></script>
  31. <style>
  32. #carbonads {
  33. font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu,
  34. Cantarell, "Helvetica Neue", Helvetica, Arial, sans-serif;
  35. }
  36. #carbonads {
  37. display: flex;
  38. max-width: 330px;
  39. background-color: hsl(0, 0%, 98%);
  40. box-shadow: 0 1px 4px 1px hsla(0, 0%, 0%, .1);
  41. }
  42. #carbonads a {
  43. color: inherit;
  44. text-decoration: none;
  45. }
  46. #carbonads a:hover {
  47. color: inherit;
  48. }
  49. #carbonads span {
  50. position: relative;
  51. display: block;
  52. overflow: hidden;
  53. }
  54. #carbonads .carbon-wrap {
  55. display: flex;
  56. }
  57. .carbon-img {
  58. display: block;
  59. margin: 0;
  60. line-height: 1;
  61. }
  62. .carbon-img img {
  63. display: block;
  64. }
  65. .carbon-text {
  66. font-size: 13px;
  67. padding: 10px;
  68. line-height: 1.5;
  69. text-align: left;
  70. }
  71. .carbon-poweredby {
  72. display: block;
  73. padding: 8px 10px;
  74. background: repeating-linear-gradient(-45deg, transparent, transparent 5px, hsla(0, 0%, 0%, .025) 5px, hsla(0, 0%, 0%, .025) 10px) hsla(203, 11%, 95%, .4);
  75. text-align: center;
  76. text-transform: uppercase;
  77. letter-spacing: .5px;
  78. font-weight: 600;
  79. font-size: 9px;
  80. line-height: 1;
  81. }
  82. </style>
  83. <h2 id="ide-editor-integration">IDE/Editor Integration</h2>
  84. <ul>
  85. <li><a href="https://github.com/xmake-io/xmake-vscode">xmake-vscode</a></li>
  86. </ul>
  87. <p><img src="https://raw.githubusercontent.com/xmake-io/xmake-vscode/master/res/problem.gif" width="650px" /></p>
  88. <ul>
  89. <li><a href="https://github.com/xmake-io/xmake-sublime">xmake-sublime</a></li>
  90. </ul>
  91. <p><img src="https://raw.githubusercontent.com/xmake-io/xmake-sublime/master/res/problem.gif" width="650px" /></p>
  92. <ul>
  93. <li><a href="https://github.com/xmake-io/xmake-idea">xmake-idea</a></li>
  94. </ul>
  95. <p><img src="https://raw.githubusercontent.com/xmake-io/xmake-idea/master/res/problem.gif" width="650px" /></p>
  96. <ul>
  97. <li><a href="https://github.com/luzhlon/xmake.vim">xmake.vim</a> (third-party, thanks <a href="https://github.com/luzhlon">@luzhlon</a>)</li>
  98. </ul>
  99. <h2 id="gradle-plugin-jni-">Gradle Plugin (JNI)</h2>
  100. <ul>
  101. <li><a href="https://github.com/xmake-io/xmake-gradle">xmake-gradle</a>: A gradle plugin that integrates xmake seamlessly</li>
  102. </ul>
  103. <h3 id="plugins-dsl">plugins DSL</h3>
  104. <pre><code>plugins {
  105. id &#39;org.tboox.gradle-xmake-plugin&#39; version &#39;1.0.9&#39;
  106. }
  107. </code></pre><h3 id="legacy-plugin-application">Legacy plugin application</h3>
  108. <pre><code>buildscript {
  109. repositories {
  110. maven {
  111. url "https://plugins.gradle.org/m2/"
  112. }
  113. }
  114. dependencies {
  115. classpath &#39;org.tboox:gradle-xmake-plugin:1.0.9&#39;
  116. }
  117. repositories {
  118. mavenCentral()
  119. }
  120. }
  121. apply plugin: "org.tboox.gradle-xmake-plugin"
  122. </code></pre><h3 id="simplest-example">Simplest Example</h3>
  123. <p>We add <code>xmake.lua</code> to <code>projectdir/jni/xmake.lua</code> and enable xmake in build.gradle.</p>
  124. <h4 id="build-gradle">build.gradle</h4>
  125. <pre><code>android {
  126. externalNativeBuild {
  127. xmake {
  128. path "jni/xmake.lua"
  129. }
  130. }
  131. }
  132. </code></pre><h4 id="jni">JNI</h4>
  133. <p>The JNI project structure:</p>
  134. <pre><code>projectdir
  135. - src
  136. - main
  137. - java
  138. - jni
  139. - xmake.lua
  140. - *.cpp
  141. </code></pre><p>xmake.lua:</p>
  142. <pre><code class="lang-lua">add_rules("mode.debug", "mode.release")
  143. target("nativelib")
  144. set_kind("shared")
  145. add_files("nativelib.cc")
  146. </code></pre>
  147. <h3 id="more-gradle-configuations">More Gradle Configuations</h3>
  148. <pre><code>android {
  149. defaultConfig {
  150. externalNativeBuild {
  151. xmake {
  152. // append the global cflags (optional)
  153. cFlags "-DTEST"
  154. // append the global cppflags (optional)
  155. cppFlags "-DTEST", "-DTEST2"
  156. // switch the build mode to `debug` for `xmake f -m debug` (optional)
  157. buildMode "debug"
  158. // set abi filters (optional), e.g. armeabi, armeabi-v7a, arm64-v8a, x86, x86_64
  159. // we can also get abiFilters from defaultConfig.ndk.abiFilters
  160. abiFilters "armeabi-v7a", "arm64-v8a"
  161. }
  162. }
  163. }
  164. externalNativeBuild {
  165. xmake {
  166. // enable xmake and set xmake.lua project file path
  167. path "jni/xmake.lua"
  168. // enable verbose output (optional), e.g. verbose, warning, normal
  169. logLevel "verbose"
  170. // set c++stl (optional), e.g. c++_static/c++_shared, gnustl_static/gnustl_shared, stlport_static/stlport_shared
  171. stl "c++_shared"
  172. // set the given xmake program path (optional)
  173. // program /usr/local/bin/xmake
  174. // disable stdc++ library (optional)
  175. // stdcxx false
  176. // set the given ndk directory path (optional)
  177. // ndk "/Users/ruki/files/android-ndk-r20b/"
  178. // set sdk version of ndk (optional)
  179. // sdkver 21
  180. }
  181. }
  182. }
  183. </code></pre><h3 id="build-jni-and-generate-apk">Build JNI and generate apk</h3>
  184. <p>The <code>xmakeBuild</code> will be injected to <code>assemble</code> task automatically if the gradle-xmake-plugin has been applied.</p>
  185. <pre><code class="lang-console">$ ./gradlew app:assembleDebug
  186. > Task :nativelib:xmakeConfigureForArm64
  187. > Task :nativelib:xmakeBuildForArm64
  188. >> xmake build
  189. [ 50%]: ccache compiling.debug nativelib.cc
  190. [ 75%]: linking.debug libnativelib.so
  191. [100%]: build ok!
  192. >> install artifacts to /Users/ruki/projects/personal/xmake-gradle/nativelib/libs/arm64-v8a
  193. > Task :nativelib:xmakeConfigureForArmv7
  194. > Task :nativelib:xmakeBuildForArmv7
  195. >> xmake build
  196. [ 50%]: ccache compiling.debug nativelib.cc
  197. [ 75%]: linking.debug libnativelib.so
  198. [100%]: build ok!
  199. >> install artifacts to /Users/ruki/projects/personal/xmake-gradle/nativelib/libs/armeabi-v7a
  200. > Task :nativelib:preBuild
  201. > Task :nativelib:assemble
  202. > Task :app:assembleDebug
  203. </code></pre>
  204. <h3 id="force-to-rebuild-jni">Force to rebuild JNI</h3>
  205. <pre><code class="lang-console">$ ./gradlew nativelib:xmakeRebuild
  206. </code></pre>
  207. </article>
  208. </body>
  209. </html>