@@ -21,7 +21,8 @@ enum class License(val id: String, val longName: String, val url: String) {
2121 " The Apache Software License, Version 2.0" ,
2222 " https://www.apache.org/licenses/LICENSE-2.0.txt" ,
2323 ),
24- MIT (" MIT" , " The MIT License" , " https://opensource.org/licenses/mit-license.php" ),
24+ BSD3 (" BSD-3-Clause" , " BSD 3-Clause" , " https://opensource.org/license/BSD-3-Clause" ),
25+ MIT (" MIT" , " The MIT License" , " https://opensource.org/license/mit" ),
2526 Curl (" curl" , " curl License" , " https://spdx.org/licenses/curl.html" ),
2627 ZLib (" Zlib" , " zlib License" , " https://www.zlib.net/zlib_license.html" ),
2728 ;
@@ -55,111 +56,117 @@ val venvBin = "$venvPath/" + if (OS.current == OS.Windows) "Scripts" else "bin"
5556cli(" $venvBin /pip" , " install" , " -U" , " conan" , inheritIO = true )
5657runCatching { cli(" $venvBin /conan" , " profile" , " detect" ) }
5758
58- val publicationGroup = listOf (" libcurl" , " libnghttp2" , " openssl" , " zlib" )
59- val pkg = publicationGroup.joinToString(" -" )
59+ val conanPath = layout.buildDirectory.dir(" conan" ).get().asFile
60+ val initBuildTask = tasks.register(" cleanConan" ) {
61+ doFirst {
62+ conanPath.deleteRecursively()
63+ }
64+ }
65+ val assembleTask = tasks.register(" assembleAll" )
66+
67+ val publicationGroups = listOf (
68+ listOf (" libcurl" , " libnghttp2" , " openssl" , " zlib" ),
69+ listOf (" zstd" ),
70+ )
71+ publicationGroups.forEach { publicationGroup ->
72+ val pkg = publicationGroup.joinToString(" -" )
6073
61- val versionsRaw = cli(" $venvBin /conan" , " search" , publicationGroup.first(), " -f" , " json" , " -v" , " quiet" )
62- val pkgVersion = Json .decodeFromString<JsonObject >(versionsRaw).jsonObject
63- .getValue(" conancenter" ).jsonObject
64- .keys.last()
65- .split(" /" ).last()
66- val graphRaw =
67- cli(" $venvBin /conan" , " graph" , " info" , " packages/$pkg " , " --version=$pkgVersion " , " -f" , " json" , " -v" , " quiet" )
68- val artifacts = Json .decodeFromString<JsonObject >(graphRaw)
69- .getValue(" graph" ).jsonObject
70- .getValue(" nodes" ).jsonObject
71- .values.mapNotNull { nodes ->
72- nodes.jsonObject.run {
73- getValue(" name" ).jsonPrimitive.contentOrNull?.takeIf { println (" $it : ${it in publicationGroup} " ); it in publicationGroup }?.let { name ->
74- val version = getValue(" version" ).jsonPrimitive.contentOrNull
75- version?.let {
76- Artifact (
77- pkg = pkg,
78- name = name,
79- version = version,
80- license = License .get(getValue(" license" ).jsonPrimitive.content),
81- )
74+ val versionsRaw = cli(" $venvBin /conan" , " search" , publicationGroup.first(), " -f" , " json" , " -v" , " quiet" )
75+ val pkgVersion = Json .decodeFromString<JsonObject >(versionsRaw).jsonObject
76+ .getValue(" conancenter" ).jsonObject
77+ .keys.last()
78+ .split(" /" ).last()
79+ val graphRaw =
80+ cli(" $venvBin /conan" , " graph" , " info" , " packages/$pkg " , " --version=$pkgVersion " , " -f" , " json" , " -v" , " quiet" )
81+ val artifacts = Json .decodeFromString<JsonObject >(graphRaw)
82+ .getValue(" graph" ).jsonObject
83+ .getValue(" nodes" ).jsonObject
84+ .values.mapNotNull { nodes ->
85+ nodes.jsonObject.run {
86+ getValue(" name" ).jsonPrimitive.contentOrNull?.takeIf { it in publicationGroup }?.let { name ->
87+ val version = getValue(" version" ).jsonPrimitive.contentOrNull
88+ version?.let {
89+ Artifact (
90+ pkg = pkg,
91+ name = name,
92+ version = version,
93+ license = License .get(getValue(" license" ).jsonPrimitive.content),
94+ )
95+ }
8296 }
8397 }
8498 }
85- }
8699
87- val targets = System .getenv(" BUILD_TARGETS" )?.takeIf { it.isNotBlank() }?.split(" ," ) ? : when (OS .current) {
88- OS .macOS -> listOf (
89- " ios-device-arm64" ,
90- " ios-simulator-arm64" ,
91- " ios-simulator-x64" ,
92- " tvos-device-arm64" ,
93- " tvos-simulator-arm64" ,
94- " tvos-simulator-x64" ,
95- " watchos-device-arm32" ,
96- " watchos-device-arm64" ,
97- " watchos-device-arm64_32" ,
98- " watchos-simulator-arm64" ,
99- " watchos-simulator-x64" ,
100- " macos-arm64" ,
101- " macos-x64" ,
100+ val targets = System .getenv(" BUILD_TARGETS" )?.takeIf { it.isNotBlank() }?.split(" ," ) ? : when (OS .current) {
101+ OS .macOS -> listOf (
102+ " ios-device-arm64" ,
103+ " ios-simulator-arm64" ,
104+ " ios-simulator-x64" ,
105+ " tvos-device-arm64" ,
106+ " tvos-simulator-arm64" ,
107+ " tvos-simulator-x64" ,
108+ " watchos-device-arm32" ,
109+ " watchos-device-arm64" ,
110+ " watchos-device-arm64_32" ,
111+ " watchos-simulator-arm64" ,
112+ " watchos-simulator-x64" ,
113+ " macos-arm64" ,
114+ " macos-x64" ,
102115
103- " android-arm64" ,
104- " android-arm32" ,
105- " android-x64" ,
106- " android-x86" ,
107- " wasm" ,
108- )
116+ " android-arm64" ,
117+ " android-arm32" ,
118+ " android-x64" ,
119+ " android-x86" ,
120+ " wasm" ,
121+ )
109122
110- OS .Linux -> listOf (
111- " linux-x64" ,
112- " linux-arm64" ,
113- )
123+ OS .Linux -> listOf (
124+ " linux-x64" ,
125+ " linux-arm64" ,
126+ )
114127
115- OS .Windows -> listOf (
116- " mingw-x64" ,
117- " windows-x64" ,
118- )
119- }
120- val conanPath = layout.buildDirectory.dir(" conan" ).get().asFile
121- val initBuildTask = tasks.register(" cleanConan" ) {
122- doFirst {
123- conanPath.deleteRecursively()
128+ OS .Windows -> listOf (
129+ " mingw-x64" ,
130+ " windows-x64" ,
131+ )
124132 }
125- }
126- for (artifact in artifacts) {
127- if ( artifact.isPublished) continue
128- tasks.register( " writeMetadata ${artifact.name} " ) {
129- dependsOn(initBuildTask)
130- doLast {
131- val root = artifact.outputDir.get().asFile
132- root.mkdirs( )
133- File (root, " version .txt" ).writeText(artifact.version )
134- File (root, " licenseId.txt " ).writeText(artifact.license.id)
133+ for (artifact in artifacts) {
134+ if (artifact.isPublished) continue
135+ tasks.register( " writeMetadata ${ artifact.name} " ) {
136+ dependsOn(initBuildTask)
137+ doLast {
138+ val root = artifact.outputDir.get().asFile
139+ root.mkdirs()
140+ File ( root, " version.txt " ).writeText(artifact.version )
141+ File (root, " licenseId .txt" ).writeText(artifact.license.id )
142+ }
135143 }
136144 }
137- }
138- val assembleTask = tasks.register(" assembleAll" )
139- for (profile in targets) {
140- if (artifacts.all { it.isPublished }) continue
145+ for (profile in targets) {
146+ if (artifacts.all { it.isPublished }) continue
141147
142- val pkgProfileName = listOf (pkg, profile).joinToString(" -" )
143- val taskName = " assemble$pkgProfileName "
144- val buildTask = tasks.register(taskName) {
145- dependsOn(initBuildTask)
146- doLast {
147- build(pkg, pkgVersion, profile)
148+ val pkgProfileName = listOf (pkg, profile).joinToString(" -" )
149+ val taskName = " assemble$pkgProfileName "
150+ val buildTask = tasks.register(taskName) {
151+ dependsOn(initBuildTask)
152+ doLast {
153+ build(pkg, pkgVersion, profile)
154+ }
148155 }
149- }
150- assembleTask.get().dependsOn(buildTask)
156+ assembleTask.get().dependsOn(buildTask)
151157
152- for (artifact in artifacts) {
153- if (artifact.isPublished) continue
154- val zipTask = tasks.register<Zip >(" zip${artifact.name} -$profile " ) {
155- dependsOn(buildTask)
156- dependsOn(" writeMetadata${artifact.name} " )
157- archiveFileName = " $profile .zip"
158- destinationDirectory = artifact.outputDir
159- archiveClassifier = profile
160- from(layout.buildDirectory.dir(" conan/build/$pkg /$profile /output/${artifact.name} " ))
158+ for (artifact in artifacts) {
159+ if (artifact.isPublished) continue
160+ val zipTask = tasks.register<Zip >(" zip${artifact.name} -$profile " ) {
161+ dependsOn(buildTask)
162+ dependsOn(" writeMetadata${artifact.name} " )
163+ archiveFileName = " $profile .zip"
164+ destinationDirectory = artifact.outputDir
165+ archiveClassifier = profile
166+ from(layout.buildDirectory.dir(" conan/build/$pkg /$profile /output/${artifact.name} " ))
167+ }
168+ assembleTask.get().dependsOn(zipTask)
161169 }
162- assembleTask.get().dependsOn(zipTask)
163170 }
164171}
165172
0 commit comments