Android Gradle语法(Android Gradle DSL)

Google关于Android Gradle DSL的官方文档:
Android Gradle DSL

一、cmake

下面由两个cmake语句,但其类型不同,所以其属性不同

1、CmakeOptions类型的cmake

路径:
(AppExtension) android->
(ExternalNativeBuild) externalNativeBuild ->
(CmakeOptions) cmake

android {
		externalNativeBuild {
				cmake {
						buildStagingDirectory "./outputs/cmake"
						path "CMakeLists.txt"
						version "3.7.1"
				}
		}
}

AppExtension :The android extension for application plugins.
即,android{ 这里使用 }

PropertyDescription
buildStagingDirectorySpecifies the path to your external native build output directory.
pathSpecifies the relative path to your CMakeLists.txt build script.
versionThe version of CMake that the Android plugin should use when building your CMake project.

2、ExternalNativeCmakeOptions类型的cmake

路径:
(AppExtension) android->
(DefaultConfig) defaultConfig->
(ExternalNativeBuildOptions) externalNativeBuild->
(ExternalNativeCmakeOptions) cmake

android {
		defaultConfig {
				externalNativeBuild {
						cmake {
								arguments "-DANDROID_ARM_NEON=TRUE", "-DANDROID_TOOLCHAIN=clang"
								cFlags "-D__STDC_FORMAT_MACROS"
								cppFlags "-fexceptions", "-frtti"
								targets "libexample-one"
						}
				}
		}
}
PropertyDescription
abiFiltersSpecifies the Application Binary Interfaces (ABI) that Gradle should build outputs for. The ABIs that Gradle packages into your APK are determined by NdkOptions.abiFilter()
argumentsSpecifies arguments for CMake.
cFlagsSpecifies flags for the C compiler.
cppFlagsSpecifies flags for the C++ compiler.
targetsSpecifies the library and executable targets from your CMake project that Gradle should build. If you don’t configure this property, Gradle builds all executables and shared object libraries that you define in your ndk-build project. However, by default, Gradle packages only the shared libraries in your APK.

通过targets属性的描述可知,默认只打包“动态库文件”,即.so文件。
如果希望生成“静态库文件”,即.a文件,则需要加上targets属性来指明静态库名。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值