@@ -8,6 +8,10 @@ val os: OperatingSystem = OperatingSystem.current()
88val libsDir = layout.buildDirectory.get().dir(" tmp" ).dir(" libs" )
99val libtommathDir = projectDir.resolve(" src/nativeInterop/libtommath" )
1010
11+ interface InjectedExecOps {
12+ @get:Inject val execOps: ExecOperations
13+ }
14+
1115fun KotlinNativeTarget.libtommath () {
1216 compilations.configureEach {
1317 cinterops.create(" tommath" ) {
@@ -128,8 +132,10 @@ android {
128132
129133if (os.isLinux) {
130134 tasks.getByName<CInteropProcess >(" cinteropTommathLinuxX64" ) {
135+ val execOps = project.objects.newInstance<InjectedExecOps >().execOps
136+
131137 doFirst {
132- exec {
138+ execOps. exec {
133139 executable = " make"
134140 workingDir = libtommathDir
135141 args(" clean" , " libtommath.a" )
@@ -146,10 +152,12 @@ if (os.isLinux) {
146152 }
147153
148154 tasks.getByName<CInteropProcess >(" cinteropTommathLinuxArm64" ) {
155+ val execOps = project.objects.newInstance<InjectedExecOps >().execOps
156+
149157 outputs.file(libsDir.dir(konanTarget.name).file(" libtommath.a" ))
150158
151159 doFirst {
152- exec {
160+ execOps. exec {
153161 executable = " make"
154162 workingDir = libtommathDir
155163 args(" clean" , " libtommath.a" )
@@ -167,10 +175,12 @@ if (os.isLinux) {
167175 }
168176
169177 tasks.getByName<CInteropProcess >(" cinteropTommathMingwX64" ) {
178+ val execOps = project.objects.newInstance<InjectedExecOps >().execOps
179+
170180 outputs.file(libsDir.dir(konanTarget.name).file(" libtommath.a" ))
171181
172182 doFirst {
173- exec {
183+ execOps. exec {
174184 executable = " make"
175185 workingDir = libtommathDir
176186 args(" clean" , " libtommath.a" )
@@ -189,10 +199,12 @@ if (os.isLinux) {
189199 }
190200} else if (os.isWindows) {
191201 tasks.getByName<CInteropProcess >(" cinteropTommathMingwX64" ) {
202+ val execOps = project.objects.newInstance<InjectedExecOps >().execOps
203+
192204 outputs.file(libsDir.dir(konanTarget.name).file(" libtommath.a" ))
193205
194206 doFirst {
195- exec {
207+ execOps. exec {
196208 executable = " make"
197209 workingDir = libtommathDir
198210 args(" clean" , " libtommath.a" )
@@ -211,17 +223,19 @@ if (os.isLinux) {
211223 }
212224} else if (os.isMacOsX) {
213225 tasks.getByName<CInteropProcess >(" cinteropTommathMacosX64" ) {
226+ val execOps = project.objects.newInstance<InjectedExecOps >().execOps
227+
214228 outputs.file(libsDir.dir(konanTarget.name).file(" libtommath.a" ))
215229
216230 doFirst {
217231 val output = ByteArrayOutputStream ()
218- exec {
232+ execOps. exec {
219233 standardOutput = output
220234 commandLine(" xcrun" , " --sdk" , " macosx" , " --show-sdk-path" )
221235 }
222236 val sysroot = output.use { it.toString().trimEnd() }
223237
224- exec {
238+ execOps. exec {
225239 executable = " make"
226240 workingDir = libtommathDir
227241 args(" clean" , " libtommath.a" )
@@ -240,17 +254,19 @@ if (os.isLinux) {
240254 }
241255
242256 tasks.getByName<CInteropProcess >(" cinteropTommathMacosArm64" ) {
257+ val execOps = project.objects.newInstance<InjectedExecOps >().execOps
258+
243259 outputs.file(libsDir.dir(konanTarget.name).file(" libtommath.a" ))
244260
245261 doFirst {
246262 val output = ByteArrayOutputStream ()
247- exec {
263+ execOps. exec {
248264 standardOutput = output
249265 commandLine(" xcrun" , " --sdk" , " macosx" , " --show-sdk-path" )
250266 }
251267 val sysroot = output.use { it.toString().trimEnd() }
252268
253- exec {
269+ execOps. exec {
254270 executable = " make"
255271 workingDir = libtommathDir
256272 args(" clean" , " libtommath.a" )
@@ -269,17 +285,19 @@ if (os.isLinux) {
269285 }
270286
271287 tasks.getByName<CInteropProcess >(" cinteropTommathIosArm64" ) {
288+ val execOps = project.objects.newInstance<InjectedExecOps >().execOps
289+
272290 outputs.file(libsDir.dir(konanTarget.name).file(" libtommath.a" ))
273291
274292 doFirst {
275293 val output = ByteArrayOutputStream ()
276- exec {
294+ execOps. exec {
277295 standardOutput = output
278296 commandLine(" xcrun" , " --sdk" , " iphoneos" , " --show-sdk-path" )
279297 }
280298 val sysroot = output.use { it.toString().trimEnd() }
281299
282- exec {
300+ execOps. exec {
283301 executable = " make"
284302 workingDir = libtommathDir
285303 args(" clean" , " libtommath.a" )
@@ -298,17 +316,19 @@ if (os.isLinux) {
298316 }
299317
300318 tasks.getByName<CInteropProcess >(" cinteropTommathIosX64" ) {
319+ val execOps = project.objects.newInstance<InjectedExecOps >().execOps
320+
301321 outputs.file(libsDir.dir(konanTarget.name).file(" libtommath.a" ))
302322
303323 doFirst {
304324 val output = ByteArrayOutputStream ()
305- exec {
325+ execOps. exec {
306326 standardOutput = output
307327 commandLine(" xcrun" , " --sdk" , " iphonesimulator" , " --show-sdk-path" )
308328 }
309329 val sysroot = output.use { it.toString().trimEnd() }
310330
311- exec {
331+ execOps. exec {
312332 executable = " make"
313333 workingDir = libtommathDir
314334 args(" clean" , " libtommath.a" )
@@ -327,17 +347,19 @@ if (os.isLinux) {
327347 }
328348
329349 tasks.getByName<CInteropProcess >(" cinteropTommathIosSimulatorArm64" ) {
350+ val execOps = project.objects.newInstance<InjectedExecOps >().execOps
351+
330352 outputs.file(libsDir.dir(konanTarget.name).file(" libtommath.a" ))
331353
332354 doFirst {
333355 val output = ByteArrayOutputStream ()
334- exec {
356+ execOps. exec {
335357 standardOutput = output
336358 commandLine(" xcrun" , " --sdk" , " iphonesimulator" , " --show-sdk-path" )
337359 }
338360 val sysroot = output.use { it.toString().trimEnd() }
339361
340- exec {
362+ execOps. exec {
341363 executable = " make"
342364 workingDir = libtommathDir
343365 args(" clean" , " libtommath.a" )
0 commit comments