comparison mupdf-source/thirdparty/zxing-cpp/wrappers/kn/build.gradle.kts @ 2:b50eed0cc0ef upstream

ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4. The directory name has changed: no version number in the expanded directory now.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:43:07 +0200
parents
children
comparison
equal deleted inserted replaced
1:1d09e1dec1d9 2:b50eed0cc0ef
1 import io.github.isning.gradle.plugins.cmake.params.CustomCMakeParams
2 import io.github.isning.gradle.plugins.cmake.params.entries.CustomCMakeCacheEntries
3 import io.github.isning.gradle.plugins.cmake.params.entries.asCMakeParams
4 import io.github.isning.gradle.plugins.cmake.params.entries.platform.ModifiablePlatformEntriesImpl
5 import io.github.isning.gradle.plugins.cmake.params.entries.plus
6 import io.github.isning.gradle.plugins.cmake.params.plus
7 import io.github.isning.gradle.plugins.kn.krossCompile.invoke
8 import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
9 import java.util.*
10
11 plugins {
12 alias(libs.plugins.kotlinMultiplatform)
13 alias(libs.plugins.krossCompile)
14 `maven-publish`
15 signing
16 }
17
18 group = "io.github.zxing-cpp"
19 version = "2.3.0-SNAPSHOT"
20
21 Properties().apply {
22 rootProject.file("local.properties").takeIf { it.exists() && it.isFile }?.let { load(it.reader()) }
23 }.onEach { (key, value) ->
24 if (key is String) ext[key] = value
25 }
26
27 val hostOs = System.getProperty("os.name")
28
29 repositories {
30 mavenCentral()
31 google()
32 }
33
34 kotlin {
35 val androidTargets = {
36 listOf(
37 androidNativeArm32(),
38 androidNativeArm64(),
39 androidNativeX86(),
40 androidNativeX64(),
41 )
42 }
43 val appleTargets = {
44 listOf(
45 iosX64(),
46 iosArm64(),
47 iosSimulatorArm64(),
48 macosX64(),
49 macosArm64(),
50 watchosX64(),
51 watchosArm32(),
52 watchosArm64(),
53 watchosSimulatorArm64(),
54 tvosX64(),
55 tvosArm64(),
56 tvosSimulatorArm64(),
57 )
58 }
59 val linuxTargets = {
60 listOf(
61 linuxX64(),
62 linuxArm64(),
63 )
64 }
65 // TODO: Linking failed, keep up with https://youtrack.jetbrains.com/issue/KT-65671
66 // val windowsTargets = {
67 // listOf(
68 // mingwX64(),
69 // )
70 // }
71 val enabledTargetList = mutableListOf<KotlinNativeTarget>()
72 enabledTargetList.addAll(androidTargets())
73 enabledTargetList.addAll(linuxTargets())
74 // TODO: Linking failed, keep up with https://youtrack.jetbrains.com/issue/KT-65671
75 // enabledTargetList.addAll(windowsTargets())
76
77 if (hostOs == "Mac OS X") enabledTargetList.addAll(appleTargets())
78 }
79
80 krossCompile {
81 libraries {
82 val cmakeDir = project.layout.buildDirectory.dir("cmake").get().asFile.absolutePath
83 val zxingCpp by creating {
84 sourceDir = file("../../core").absolutePath
85 outputPath = ""
86 libraryArtifactNames = listOf("libZXing.a")
87
88 cinterop {
89 val buildDir = "$cmakeDir/{libraryName}/{targetName}"
90 packageName = "zxingcpp.cinterop"
91 includeDirs.from(buildDir)
92 headers = listOf("$sourceDir/src/ZXingC.h")
93 compilerOpts += "-DZXING_EXPERIMENTAL_API=ON"
94 }
95 cmake.apply {
96 val buildDir = "$cmakeDir/{projectName}/{targetName}"
97 configParams {
98 this.buildDir = buildDir
99 }
100 configParams += (ModifiablePlatformEntriesImpl().apply {
101 buildType = "Release"
102 buildSharedLibs = false
103 } + CustomCMakeCacheEntries(
104 mapOf(
105 "ZXING_READERS" to "ON",
106 "ZXING_WRITERS" to "NEW",
107 "ZXING_EXPERIMENTAL_API" to "ON",
108 "ZXING_USE_BUNDLED_ZINT" to "ON",
109 "ZXING_C_API" to "ON",
110 )
111 )).asCMakeParams
112 buildParams {
113 this.buildDir = buildDir
114 config = "Release"
115 }
116 buildParams += CustomCMakeParams(listOf("-j16"))
117 }
118
119 androidNativeX64.ndk()
120 androidNativeX86.ndk()
121 androidNativeArm32.ndk()
122 androidNativeArm64.ndk()
123
124 // TODO: Find a way to build linux targets with cxx20. Detail: https://github.com/zxing-cpp/zxing-cpp/pull/719#discussion_r1485701269
125 linuxX64.konan {
126 cmake {
127 configParams += CustomCMakeCacheEntries(
128 mapOf(
129 "CMAKE_CXX_STANDARD" to "17",
130 )
131 ).asCMakeParams
132 }
133 }
134 linuxArm64.konan {
135 cmake {
136 configParams += CustomCMakeCacheEntries(
137 mapOf(
138 "CMAKE_CXX_STANDARD" to "17",
139 )
140 ).asCMakeParams
141 }
142 }
143 // TODO: Linking failed, keep up with https://youtrack.jetbrains.com/issue/KT-65671
144 // mingwX64.konan()
145
146 if (hostOs == "Mac OS X") {
147 iosX64.xcode()
148 iosArm64.xcode()
149 iosSimulatorArm64.xcode()
150 macosX64.xcode()
151 macosArm64.xcode()
152 watchosX64.xcode()
153 watchosArm32.xcode()
154 watchosArm64.xcode()
155 watchosSimulatorArm64.xcode()
156 tvosX64.xcode()
157 tvosArm64.xcode()
158 tvosSimulatorArm64.xcode()
159 }
160 }
161 }
162 }
163
164 publishing {
165 publications.withType<MavenPublication>().all {
166 artifactId = artifactId.replace(project.name, "kotlin-native")
167 groupId = project.group.toString()
168 version = project.version.toString()
169
170 pom {
171 name = "zxing-cpp"
172 description = "Wrapper for zxing-cpp barcode image processing library"
173 url = "https://github.com/zxing-cpp/zxing-cpp"
174 licenses {
175 license {
176 name = "The Apache License, Version 2.0"
177 url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
178 }
179 }
180 developers {
181 developer {
182 id = "zxing-cpp"
183 name = "zxing-cpp community"
184 email = "zxingcpp@gmail.com"
185 }
186 }
187 scm {
188 connection = "scm:git:git://github.com/zxing-cpp/zxing-cpp.git"
189 developerConnection = "scm:git:git://github.com/zxing-cpp/zxing-cpp.git"
190 url = "https://github.com/zxing-cpp/zxing-cpp"
191 }
192 }
193 }
194 repositories {
195 maven {
196 name = "sonatype"
197
198 val releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
199 val snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
200 setUrl(if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl)
201
202 credentials {
203 val ossrhUsername: String? by project
204 val ossrhPassword: String? by project
205 username = ossrhUsername
206 password = ossrhPassword
207 }
208 }
209 }
210 }
211
212 signing {
213 val signingKey: String? by project
214 val signingPassword: String? by project
215 if (signingKey != null && signingPassword != null) {
216 useInMemoryPgpKeys(signingKey, signingPassword)
217 sign(publishing.publications)
218 }
219 }