You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When writing an extension depending on external libraries, like libvosk.so, Perry compiler needs to know where to find them. To do this, you need to config the compiler behavior.
The user is asking if we can get the library search paths and link libraries from the build.rs script instead of configuring them in package.json. Let's check what information we can get from Cargo and the build output.
Yes, but it would be more complex
When Cargo builds a native library, the build.rs outputs:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
When writing an extension depending on external libraries, like
libvosk.so, Perry compiler needs to know where to find them. To do this, you need to config the compiler behavior.The user is asking if we can get the library search paths and link libraries from the build.rs script instead of configuring them in package.json. Let's check what information we can get from Cargo and the build output.
Yes, but it would be more complex
When Cargo builds a native library, the
build.rsoutputs:cargo:rustc-link-search=native=/path/to/lib(library search paths)cargo:rustc-link-lib=name(libraries to link)However, Cargo doesn't store these outputs in an easily parsable file after building. They're just printed to stdout.
Option 1: Parse Cargo build output (not recommended)
We could run Cargo, capture the output, and parse the
cargo:directives. But this is:Option 2: Keep both libDirs/libs in package.json (current approach)
This is explicit, predictable, and works consistently.
Option 3: Extract and run the logic from build.rs
We could re-implement the same library discovery logic in Perry, but that duplicates effort.
My recommendation: Keep the current approach with
libDirsandlibsin package.json. It's:If you want to avoid duplication, you could:
build.rslogic (but that would be more complex)What do you think?
Beta Was this translation helpful? Give feedback.
All reactions