Cmake 4. NdkBuild 5. Write at the end

One, foreword

Today, share the ExternalNativeBuild configuration that controls native compilation

2. Brief analysis of ExternalNativeBuild structure

1. ExternalNativeBuild exists

ExternalNativeBuild will map to com. Android. Build. Gradle. Internal. DSL. ExternalNativeBuild class, inheritance structure is as follows:

2. ExternalNativeBuild property

2.1 cmake

  • Type: CmakeOptions
  • See section 3 for details

2.2 ndkBuild

  • Type: NdkBuildOptions
  • See section 4 for details

3. Code structure

externalNativeBuild { ndkBuild { ... } cmake { ... }}Copy the code

Third, cmake

1. Existence location

Mapping for the com. Android. Build. Gradle. Internal. DSL. CmakeOptions, class structure

2. Cmake attribute

2.1 buildStagingDirectory

  • Type: String
  • Description: Configure the path for storing files after native build
  • Usage:
cmake {
	buildStagingDirectory "./outputs/cmake"
}
Copy the code

2.2 the path

  • Type: String
  • Description: Set the path to cmakelists.txt
  • Usage:
cmake {
	path "src/main/cpp/CMakeLists.txt"
}
Copy the code

Version 2.3

  • Type: String
  • Description: Set the version of CMake compiled for Android
  • Usage:
cmake {
	version "3.10.2"
}
Copy the code

Four, ndkBuild

1. Existence location

Mapping for the com. Android. Build. Gradle. Internal. DSL. NdkBuildOptions, class structure

2. NdkBuild attribute

2.1 buildStagingDirectory

  • Type: String
  • Description: Configure the path for storing files after native build
  • Usage:
ndkBuild {
	buildStagingDirectory "./outputs/ndk-build"
}
Copy the code

2.2 the path

  • Type: String
  • Description: Set the path to Android.mk
  • Usage:
ndkBuild {
	path 'Android.mk'
}
Copy the code

Write at the end

Github portal Gradle project address: Github portal

For this post’s ExternalNativeBuild configuration, enter the portal

If you find this post inspiring or confusing, give it a thumbs up or follow us, and kids will continue to share more great articles.

Or invite me to have a cup of coffee, children will be more confident to write