Browse Source

[build] Add GENERATE_IMPLIB() macro

ISSUE:
commit_hash:06b43755e4e7b85ca605886d6aba3ccef96c4906
deshevoy 2 months ago
parent
commit
da67de0509
1 changed files with 18 additions and 0 deletions
  1. 18 0
      build/ymake.core.conf

+ 18 - 0
build/ymake.core.conf

@@ -5884,3 +5884,21 @@ macro WITHOUT_VERSION() {
 macro LINK_EXCLUDE_LIBRARIES(Libs...) {
     SET_APPEND(_LINK_EXCLUDE_LIBRARIES_GLOBAL $Libs)
 }
+
+### @usage: GENERATE_IMPLIB(Lib, Path, [SONAME Name])
+###
+### Generates a wrapper for external dynamic library using Implib.so and excludes the real library from linker command
+###
+### The wrapper loads the real library on the first call to any of its functions
+###
+### @example:
+###
+###     PEERDIR(build/platform/cuda)
+###
+###     GENERATE_IMPLIB(cuda $CUDA_TARGET_ROOT/lib64/stubs/libcuda.so SONAME libcuda.so.1)
+###
+macro GENERATE_IMPLIB(Lib, Path, SONAME="") {
+    .CMD=${tool:"contrib/tools/implib"} --target $HARDWARE_TYPE --outdir $BINDIR ${pre=--library-load-name :SONAME} $Path ${hide;output;nopath;suf=.init.c:Path} ${hide;output;nopath;suf=.tramp.S:Path}
+
+    LINK_EXCLUDE_LIBRARIES($Lib)
+}