@@ -16,25 +16,46 @@ tasks.register('conanProfile', Copy) {
1616 filter(ReplaceTokens , tokens : [" NDK_PATH" : android. ndkDirectory. toString()])
1717}
1818
19- tasks. register(' conanInstall' ) {
20- dependsOn(tasks. named(" conanProfile" ))
21- doFirst {
22- [" armv7" , " armv8" , " x86" , " x86_64" ]. each { String arch ->
23- exec {
24- commandLine(
25- " conan" , " install" , " ." ,
26- " --output-folder=build/conan/" + arch,
27- " --build=missing" ,
28- " --profile:host=build/conanprofile.txt" ,
29- " -s" , " arch=" + arch,
30- " -s" , " build_type=Release" ,
31- " -s" , " &:build_type=RelWithDebInfo" ,
32- " -s" , " odrcore/*:build_type=RelWithDebInfo" ,
33- )
34- }
35- }
19+ abstract class ConanInstallTask extends Exec {
20+ @Input
21+ abstract Property<String > getArch ()
22+
23+ // Cannot read project.layout.buildDirectory when configuration-cache is enabled
24+ @Input
25+ abstract Property<String > getArchBuildDirPath ()
26+
27+ @OutputDirectory
28+ final Provider<Directory > outputDirectory = archBuildDirPath.map { new File (it ) }
29+
30+ @Override
31+ protected void exec () {
32+ commandLine(
33+ " conan" , " install" , " ." ,
34+ " --output-folder=" + archBuildDirPath. get(),
35+ " --build=missing" ,
36+ " --profile:host=build/conanprofile.txt" ,
37+ " -s" , " arch=" + arch. get(),
38+ " -s" , " build_type=Release" ,
39+ " -s" , " &:build_type=RelWithDebInfo" ,
40+ " -s" , " odrcore/*:build_type=RelWithDebInfo" ,
41+ )
42+ super . exec()
43+ }
44+ }
45+
46+ [" armv7" , " armv8" , " x86" , " x86_64" ]. each { architecture ->
47+ tasks. register(' conanInstall-' + architecture, ConanInstallTask ) {
48+ setArch(architecture)
49+ setArchBuildDirPath(new File (project. layout. buildDirectory. get(). toString(), ' conan/' + architecture). absolutePath)
50+ dependsOn(tasks. named(" conanProfile" ))
3651 }
3752}
53+ tasks. register(" conanInstall" ) {
54+ [" armv7" , " armv8" , " x86" , " x86_64" ]. each { arch ->
55+ dependsOn tasks. named(' conanInstall-' + arch)
56+ }
57+ }
58+
3859tasks. named(" preBuild" ). configure { preBuildTask ->
3960 preBuildTask. dependsOn(tasks. named(" conanInstall" ))
4061}
0 commit comments