Closed idranme closed 2 years ago
It would be better to generate unified glue code after building libraries for multiple platforms.
You can cross-compile to other platforms, deno_bindgen
invokes cargo build
internally - arguments after --
are passed to Cargo. It's a common practice to use Github CI to compile and distribute via Github releases. https://github.com/denoland/deno_bindgen#cli
This is similar to using similar workflows for publishing NAPI modules with napi-rs
For example, see https://github.com/littledivy/deno_audio/blob/main/.github/workflows/release.yml
If you don't want to use the CI, consider using cross or similar tools to achieve Rust cross-compilation.
It would be better to generate unified glue code after building libraries for multiple platforms.
I'm not sure what you mean by "unified glue code". It is already unified / same for all platforms.
You can cross-compile to other platforms,
deno_bindgen
invokescargo build
internally - arguments after--
are passed to Cargo. It's a common practice to use Github CI to compile and distribute via Github releases. https://github.com/denoland/deno_bindgen#cliThis is similar to using similar workflows for publishing NAPI modules with
napi-rs
For example, see https://github.com/littledivy/deno_audio/blob/main/.github/workflows/release.ymlIf you don't want to use the CI, consider using cross or similar tools to achieve Rust cross-compilation.
It would be better to generate unified glue code after building libraries for multiple platforms.
I'm not sure what you mean by "unified glue code". It is already unified / same for all platforms.
thanks, I have a problem
let libSuffix = "";
switch (Deno.build.os) {
case "windows":
libSuffix = "dll";
break;
case "darwin":
libSuffix = "dylib";
break;
case "linux":
libSuffix = "so";
break;
}
const libName = `./libadd.${libSuffix}`;
// Open library and define exported symbols
const dylib = Deno.dlopen(libName, {
"add": { parameters: ["isize", "isize"], result: "isize" },
});
"bindings.ts" may be able to judge that the platform loads the corresponding library like the above code
It does that already using x/plug
: https://deno.land/x/plug@0.5.1/plug.ts#L35
It does that already using
x/plug
: https://deno.land/x/plug@0.5.1/plug.ts#L35
well, thanks
At present, the compiled library can only be used for a single platform. If you want to support cross platform, you need to build multiple sets of code. This adds a lot of tedious work.