| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>xmake</title>
- <link rel="icon" href="/assets/img/favicon.ico">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
- <meta name="description" content="Description">
- <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
- <link href="//cdn.jsdelivr.net/npm/[email protected]/github-markdown.min.css" rel="stylesheet">
- <style>
- .markdown-body {
- box-sizing: border-box;
- min-width: 200px;
- max-width: 980px;
- margin: 0 auto;
- padding: 45px;
- }
- @media (max-width: 767px) {
- .markdown-body {
- padding: 15px;
- }
- }
- </style>
- </head>
- <body>
- <article class="markdown-body">
- <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>
- </br>
- <script async type="text/javascript" src="//cdn.carbonads.com/carbon.js?serve=CE7I52QU&placement=xmakeio" id="_carbonads_js"></script>
- <style>
- #carbonads {
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu,
- Cantarell, "Helvetica Neue", Helvetica, Arial, sans-serif;
- }
- #carbonads {
- display: flex;
- max-width: 330px;
- background-color: hsl(0, 0%, 98%);
- box-shadow: 0 1px 4px 1px hsla(0, 0%, 0%, .1);
- }
- #carbonads a {
- color: inherit;
- text-decoration: none;
- }
- #carbonads a:hover {
- color: inherit;
- }
- #carbonads span {
- position: relative;
- display: block;
- overflow: hidden;
- }
- #carbonads .carbon-wrap {
- display: flex;
- }
- .carbon-img {
- display: block;
- margin: 0;
- line-height: 1;
- }
- .carbon-img img {
- display: block;
- }
- .carbon-text {
- font-size: 13px;
- padding: 10px;
- line-height: 1.5;
- text-align: left;
- }
- .carbon-poweredby {
- display: block;
- padding: 8px 10px;
- 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);
- text-align: center;
- text-transform: uppercase;
- letter-spacing: .5px;
- font-weight: 600;
- font-size: 9px;
- line-height: 1;
- }
- </style>
- <h2 id="ide-editor-integration">IDE/Editor Integration</h2>
- <ul>
- <li><a href="https://github.com/xmake-io/xmake-vscode">xmake-vscode</a></li>
- </ul>
- <p><img src="https://raw.githubusercontent.com/xmake-io/xmake-vscode/master/res/problem.gif" width="650px" /></p>
- <ul>
- <li><a href="https://github.com/xmake-io/xmake-sublime">xmake-sublime</a></li>
- </ul>
- <p><img src="https://raw.githubusercontent.com/xmake-io/xmake-sublime/master/res/problem.gif" width="650px" /></p>
- <ul>
- <li><a href="https://github.com/xmake-io/xmake-idea">xmake-idea</a></li>
- </ul>
- <p><img src="https://raw.githubusercontent.com/xmake-io/xmake-idea/master/res/problem.gif" width="650px" /></p>
- <ul>
- <li><a href="https://github.com/luzhlon/xmake.vim">xmake.vim</a> (third-party, thanks <a href="https://github.com/luzhlon">@luzhlon</a>)</li>
- </ul>
- <h2 id="gradle-plugin-jni-">Gradle Plugin (JNI)</h2>
- <ul>
- <li><a href="https://github.com/xmake-io/xmake-gradle">xmake-gradle</a>: A gradle plugin that integrates xmake seamlessly</li>
- </ul>
- <h3 id="plugins-dsl">plugins DSL</h3>
- <pre><code>plugins {
- id 'org.tboox.gradle-xmake-plugin' version '1.0.9'
- }
- </code></pre><h3 id="legacy-plugin-application">Legacy plugin application</h3>
- <pre><code>buildscript {
- repositories {
- maven {
- url "https://plugins.gradle.org/m2/"
- }
- }
- dependencies {
- classpath 'org.tboox:gradle-xmake-plugin:1.0.9'
- }
- repositories {
- mavenCentral()
- }
- }
- apply plugin: "org.tboox.gradle-xmake-plugin"
- </code></pre><h3 id="simplest-example">Simplest Example</h3>
- <p>We add <code>xmake.lua</code> to <code>projectdir/jni/xmake.lua</code> and enable xmake in build.gradle.</p>
- <h4 id="build-gradle">build.gradle</h4>
- <pre><code>android {
- externalNativeBuild {
- xmake {
- path "jni/xmake.lua"
- }
- }
- }
- </code></pre><h4 id="jni">JNI</h4>
- <p>The JNI project structure:</p>
- <pre><code>projectdir
- - src
- - main
- - java
- - jni
- - xmake.lua
- - *.cpp
- </code></pre><p>xmake.lua:</p>
- <pre><code class="lang-lua">add_rules("mode.debug", "mode.release")
- target("nativelib")
- set_kind("shared")
- add_files("nativelib.cc")
- </code></pre>
- <h3 id="more-gradle-configuations">More Gradle Configuations</h3>
- <pre><code>android {
- defaultConfig {
- externalNativeBuild {
- xmake {
- // append the global cflags (optional)
- cFlags "-DTEST"
- // append the global cppflags (optional)
- cppFlags "-DTEST", "-DTEST2"
- // switch the build mode to `debug` for `xmake f -m debug` (optional)
- buildMode "debug"
- // set abi filters (optional), e.g. armeabi, armeabi-v7a, arm64-v8a, x86, x86_64
- // we can also get abiFilters from defaultConfig.ndk.abiFilters
- abiFilters "armeabi-v7a", "arm64-v8a"
- }
- }
- }
- externalNativeBuild {
- xmake {
- // enable xmake and set xmake.lua project file path
- path "jni/xmake.lua"
- // enable verbose output (optional), e.g. verbose, warning, normal
- logLevel "verbose"
- // set c++stl (optional), e.g. c++_static/c++_shared, gnustl_static/gnustl_shared, stlport_static/stlport_shared
- stl "c++_shared"
- // set the given xmake program path (optional)
- // program /usr/local/bin/xmake
- // disable stdc++ library (optional)
- // stdcxx false
- // set the given ndk directory path (optional)
- // ndk "/Users/ruki/files/android-ndk-r20b/"
- // set sdk version of ndk (optional)
- // sdkver 21
- }
- }
- }
- </code></pre><h3 id="build-jni-and-generate-apk">Build JNI and generate apk</h3>
- <p>The <code>xmakeBuild</code> will be injected to <code>assemble</code> task automatically if the gradle-xmake-plugin has been applied.</p>
- <pre><code class="lang-console">$ ./gradlew app:assembleDebug
- > Task :nativelib:xmakeConfigureForArm64
- > Task :nativelib:xmakeBuildForArm64
- >> xmake build
- [ 50%]: ccache compiling.debug nativelib.cc
- [ 75%]: linking.debug libnativelib.so
- [100%]: build ok!
- >> install artifacts to /Users/ruki/projects/personal/xmake-gradle/nativelib/libs/arm64-v8a
- > Task :nativelib:xmakeConfigureForArmv7
- > Task :nativelib:xmakeBuildForArmv7
- >> xmake build
- [ 50%]: ccache compiling.debug nativelib.cc
- [ 75%]: linking.debug libnativelib.so
- [100%]: build ok!
- >> install artifacts to /Users/ruki/projects/personal/xmake-gradle/nativelib/libs/armeabi-v7a
- > Task :nativelib:preBuild
- > Task :nativelib:assemble
- > Task :app:assembleDebug
- </code></pre>
- <h3 id="force-to-rebuild-jni">Force to rebuild JNI</h3>
- <pre><code class="lang-console">$ ./gradlew nativelib:xmakeRebuild
- </code></pre>
- </article>
- </body>
- </html>
|