Skip to content

Search path for x64 aarch #30

Closed
Closed
@mohebifar

Description

I noticed that in our fork of ast-grep-angular, the prebuilds for x64 reside in a dir named X64 (capital X) instead of x64 (lower case x) .

https://www.npmjs.com/package/@codemod.com/ast-grep-lang-angular/v/0.0.2?activeTab=code

Should we update the post install script to search for multiple possible dirs instead of just looking at x64?

My solution for now has been to patch setup-lang:

@@ -67,14 +67,20 @@ const ARCH_MAP: Record<string, string> = {
  */
 function resolvePrebuild(dir: string) {
   const os = PLATFORM_MAP[process.platform]
-  const arch = ARCH_MAP[process.arch]
-  const prebuild = path.join(dir, 'prebuilds', `prebuild-${os}-${arch}`, 'parser.so')
-  if (!os || !arch || !fs.existsSync(prebuild)) {
-    log(`no prebuild for ${os} ${arch}`)
+  const archs = ARCH_MAP[process.arch]
+  if (!os || archs?.length === 0) {
+    log(`os or arch not found ${os} ${archs}`)
     return undefined
   }
-  log(`found prebuild for ${os} ${arch}`)
-  return prebuild
+
+  for (const arch of archs) {
+    const prebuild = path.join(dir, 'prebuilds', `prebuild-${os}-${arch}`, 'parser.so')
+    if (fs.existsSync(prebuild)) {
+      return prebuild
+    }
+  }
+  log(`no prebuild found for ${os} ${archs}`)
+  return undefined
 }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions