@@ -329,31 +329,88 @@ task windowsPatches(type:Exec) {
329
329
commandLine ' cmd' , ' /c' , " Powershell -File $rootDir \\ scripts\\ windowsScript.ps1"
330
330
}
331
331
332
- task cmakeJniLib (type :Exec ) {
333
- workingDir ' jni'
334
- def args = []
335
- args. add(" cmake" )
336
- args. add(" -B build" )
337
- args. add(" -DKNN_PLUGIN_VERSION=${ opensearch_version} " )
338
- args. add(" -DAVX2_ENABLED=${ avx2_enabled} " )
339
- args. add(" -DAVX512_ENABLED=${ avx512_enabled} " )
340
- args. add(" -DAVX512_SPR_ENABLED=${ avx512_spr_enabled} " )
341
- args. add(" -DCOMMIT_LIB_PATCHES=${ commit_lib_patches} " )
342
- args. add(" -DAPPLY_LIB_PATCHES=${ apply_lib_patches} " )
343
- def javaHome = Jvm . current(). getJavaHome()
344
- logger. lifecycle(" Java home directory used by gradle: $javaHome " )
345
- if (Os . isFamily(Os . FAMILY_MAC )) {
346
- environment(' JAVA_HOME' ,javaHome)
347
- }
348
- if (Os . isFamily(Os . FAMILY_WINDOWS )) {
349
- dependsOn windowsPatches
350
- args. add(" -G" )
351
- args. add(" Unix Makefiles" )
352
- args. add(" -DBLAS_LIBRARIES=$rootDir \\ src\\ main\\ resources\\ windowsDependencies\\ libopenblas.dll" )
353
- args. add(" -DLAPACK_LIBRARIES=$rootDir \\ src\\ main\\ resources\\ windowsDependencies\\ libopenblas.dll" )
332
+ tasks. register(' checkCmakePath' , Exec ) {
333
+ def outputStream = new ByteArrayOutputStream ()
334
+ def findCmakePathArgs = []
335
+ findCmakePathArgs. add(" which" )
336
+ findCmakePathArgs. add(" cmake" )
337
+ commandLine findCmakePathArgs
338
+ standardOutput = outputStream
339
+ doLast {
340
+ def cmakePath = outputStream. toString(). trim()
341
+ println " CMake path: ${ cmakePath} "
342
+ // Ensure cmakePath is treated as a String. If parsing to an int is required,
343
+ // handle it explicitly, though a path typically should not be parsed as an int.
344
+ if (cmakePath. isEmpty()) {
345
+ throw new GradleException (" CMake not found in PATH. Please install CMake." )
346
+ }
347
+ workingDir ' jni'
348
+ def args = []
349
+ args. add(" cmake" )
350
+ args. add(" -B build" )
351
+ args. add(" -DKNN_PLUGIN_VERSION=${ opensearch_version} " )
352
+ args. add(" -DAVX2_ENABLED=${ avx2_enabled} " )
353
+ args. add(" -DAVX512_ENABLED=${ avx512_enabled} " )
354
+ args. add(" -DAVX512_SPR_ENABLED=${ avx512_spr_enabled} " )
355
+ args. add(" -DCOMMIT_LIB_PATCHES=${ commit_lib_patches} " )
356
+ args. add(" -DAPPLY_LIB_PATCHES=${ apply_lib_patches} " )
357
+ def javaHome = Jvm . current(). getJavaHome()
358
+ logger. lifecycle(" Java home directory used by gradle: $javaHome " )
359
+ if (Os . isFamily(Os . FAMILY_MAC )) {
360
+ environment(' JAVA_HOME' , javaHome)
361
+ }
362
+ if (Os . isFamily(Os . FAMILY_WINDOWS )) {
363
+ dependsOn windowsPatches
364
+ args. add(" -G" )
365
+ args. add(" Unix Makefiles" )
366
+ args. add(" -DBLAS_LIBRARIES=$rootDir \\ src\\ main\\ resources\\ windowsDependencies\\ libopenblas.dll" )
367
+ args. add(" -DLAPACK_LIBRARIES=$rootDir \\ src\\ main\\ resources\\ windowsDependencies\\ libopenblas.dll" )
368
+ }
369
+
370
+ commandLine args
354
371
}
372
+ }
355
373
356
- commandLine args
374
+ tasks. register(' cmakeJniLib' , Exec ) {
375
+ def outputStream = new ByteArrayOutputStream ()
376
+ def findCmakePathArgs = []
377
+ findCmakePathArgs. add(" which" )
378
+ findCmakePathArgs. add(" cmake" )
379
+ commandLine findCmakePathArgs
380
+ standardOutput = outputStream
381
+ doLast {
382
+ def cmakePath = outputStream. toString(). trim()
383
+ println " CMake path: ${ cmakePath} "
384
+ // Ensure cmakePath is treated as a String. If parsing to an int is required,
385
+ // handle it explicitly, though a path typically should not be parsed as an int.
386
+ if (cmakePath. isEmpty()) {
387
+ throw new GradleException (" CMake not found in PATH. Please install CMake." )
388
+ }
389
+ workingDir ' jni'
390
+ def args = []
391
+ args. add(" cmake" )
392
+ args. add(" -B build" )
393
+ args. add(" -DKNN_PLUGIN_VERSION=${ opensearch_version} " )
394
+ args. add(" -DAVX2_ENABLED=${ avx2_enabled} " )
395
+ args. add(" -DAVX512_ENABLED=${ avx512_enabled} " )
396
+ args. add(" -DAVX512_SPR_ENABLED=${ avx512_spr_enabled} " )
397
+ args. add(" -DCOMMIT_LIB_PATCHES=${ commit_lib_patches} " )
398
+ args. add(" -DAPPLY_LIB_PATCHES=${ apply_lib_patches} " )
399
+ def javaHome = Jvm . current(). getJavaHome()
400
+ logger. lifecycle(" Java home directory used by gradle: $javaHome " )
401
+ if (Os . isFamily(Os . FAMILY_MAC )) {
402
+ environment(' JAVA_HOME' , javaHome)
403
+ }
404
+ if (Os . isFamily(Os . FAMILY_WINDOWS )) {
405
+ dependsOn windowsPatches
406
+ args. add(" -G" )
407
+ args. add(" Unix Makefiles" )
408
+ args. add(" -DBLAS_LIBRARIES=$rootDir \\ src\\ main\\ resources\\ windowsDependencies\\ libopenblas.dll" )
409
+ args. add(" -DLAPACK_LIBRARIES=$rootDir \\ src\\ main\\ resources\\ windowsDependencies\\ libopenblas.dll" )
410
+ }
411
+
412
+ commandLine args
413
+ }
357
414
}
358
415
359
416
task buildJniLib (type :Exec ) {
0 commit comments