Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xmake-io/xmake-gradle
A gradle plugin that integrates xmake seamlessly
https://github.com/xmake-io/xmake-gradle
android-studio gradle-plugin xmake xmake-gradle
Last synced: 1 day ago
JSON representation
A gradle plugin that integrates xmake seamlessly
- Host: GitHub
- URL: https://github.com/xmake-io/xmake-gradle
- Owner: xmake-io
- License: apache-2.0
- Created: 2020-04-03T15:09:49.000Z (over 4 years ago)
- Default Branch: dev
- Last Pushed: 2024-09-11T01:41:05.000Z (about 2 months ago)
- Last Synced: 2024-09-11T06:20:39.030Z (about 2 months ago)
- Topics: android-studio, gradle-plugin, xmake, xmake-gradle
- Language: Groovy
- Homepage: https://xmake.io
- Size: 270 KB
- Stars: 48
- Watchers: 4
- Forks: 3
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-xmake - xmake-gradle
README
## Introduction ([中文](/README_zh.md))
xmake-gradle is a gradle plugin that integrates xmake seamlessly.
If you want to know more, please refer to:
* [Documents](https://xmake.io/#/home)
* [HomePage](https://xmake.io)
* [Github](https://github.com/xmake-io/xmake-gradle)
* [Gitee](https://gitee.com/tboox/xmake-gradle)
* [GradlePlugin](https://plugins.gradle.org/plugin/org.tboox.gradle-xmake-plugin)## Prerequisites
XMake installed on the system. Available [here](https://github.com/xmake-io/xmake).
## Apply the plugin
### plugins DSL
```
plugins {
id 'org.tboox.gradle-xmake-plugin' version '1.1.9'
}
```### Legacy plugin application
```
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'org.tboox:gradle-xmake-plugin:1.1.9'
}
repositories {
mavenCentral()
}
}apply plugin: "org.tboox.gradle-xmake-plugin"
```## Configuation
### Simplest Example
We add `xmake.lua` to `projectdir/jni/xmake.lua` and enable xmake in build.gradle.
#### build.gradle
```
android {
externalNativeBuild {
xmake {
path "jni/xmake.lua"
}
}
}
```#### JNI
The JNI project structure:
```
projectdir
- src
- main
- java
- jni
- xmake.lua
- *.cpp
```xmake.lua:
```lua
add_rules("mode.debug", "mode.release")
target("nativelib")
set_kind("shared")
add_files("nativelib.cc")
```### More Gradle Configuations
```
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"// set the built targets
//targets "xxx", "yyy"
}
}
}externalNativeBuild {
xmake {
// enable xmake and set xmake.lua project file path
path "jni/xmake.lua"// enable verbose output (optional), e.g. verbose, 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
}
}
}
```## Build
### Build JNI and generate apk
The `xmakeBuild` will be injected to `assemble` task automatically if the gradle-xmake-plugin has been applied.
```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
```### Force to rebuild JNI
```console
$ ./gradlew nativelib:xmakeRebuild
```## Development
### Build Plugins
```console
$ ./gradlew gradle-xmake-plugin:assemble
```### Publish Plugins
see [https://guides.gradle.org/publishing-plugins-to-gradle-plugin-portal/](https://guides.gradle.org/publishing-plugins-to-gradle-plugin-portal/)
```console
$ ./gradlew gradle-xmake-plugin:publishPlugins
```## Contacts
* Email:[[email protected]](mailto:[email protected])
* Homepage:[tboox.org](https://tboox.org)
* Community:[/r/tboox on reddit](https://www.reddit.com/r/tboox/)
* ChatRoom:[Char on telegram](https://t.me/tbooxorg), [Chat on gitter](https://gitter.im/tboox/tboox?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
* QQ Group: 343118190(full), 662147501
* Wechat Public: tboox-os## Backers
Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/xmake#backer)]
## Sponsors
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/xmake#sponsor)]