-
-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE REQUEST] Support for Apple Silicon (M1) #9
Comments
Running // Auto-generated with deno_bindgen
import { CachePolicy, prepare } from "https://deno.land/x/[email protected]/plug.ts"
function encode(v: string | Uint8Array): Uint8Array {
if (typeof v !== "string") return v
return new TextEncoder().encode(v)
}
function decode(v: Uint8Array): string {
return new TextDecoder().decode(v)
}
function readPointer(v: any): Uint8Array {
const ptr = new Deno.UnsafePointerView(v as bigint)
const lengthBe = new Uint8Array(4)
const view = new DataView(lengthBe.buffer)
ptr.copyInto(lengthBe, 0)
const buf = new Uint8Array(view.getUint32(0))
ptr.copyInto(buf, 4)
return buf
}
const url = new URL("../target/release", import.meta.url)
let uri = url.toString()
if (!uri.endsWith("/")) uri += "/"
let darwin: string | { aarch64: string; x86_64: string } = uri
+ "libdeno_audio.dylib"
if (url.protocol !== "file:") {
// Assume that remote assets follow naming scheme
// for each macOS artifact.
darwin = {
aarch64: uri + "libdeno_audio_arm64.dylib",
x86_64: uri + "libdeno_audio.dylib",
}
}
const opts = {
name: "deno_audio",
urls: {
darwin,
windows: uri + "deno_audio.dll",
linux: uri + "libdeno_audio.so",
},
policy: undefined,
}
const _lib = await prepare(opts, {
play: { parameters: ["pointer", "usize"], result: "void", nonblocking: true },
})
export function play(a0: string) {
const a0_buf = encode(a0)
const a0_ptr = Deno.UnsafePointer.of(a0_buf)
let rawResult = _lib.symbols.play(a0_ptr, a0_buf.byteLength)
const result = rawResult
return result
} ...and this library below: ...that worked like a charm. Anyway, it would be nice to provide arm64 binary at littledivy/deno_audio/releases too. |
Good news from GitHub blog: GitHub Actions: Self-hosted runners now support Apple M1 hardware |
How would I use your .dylib to use the play function in my code? |
When we try to run the module in a macOS running in arm64 architecture:
Notice the error part:
mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e))
The text was updated successfully, but these errors were encountered: