-
-
Notifications
You must be signed in to change notification settings - Fork 665
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[neko] Add support for loading arm ndlls (#10996)
* [neko] Add support for loading arm ndlls * [tests] Add test for correct ndll path
- Loading branch information
Showing
8 changed files
with
97 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import sys.io.Process; | ||
|
||
using StringTools; | ||
|
||
enum abstract Arch(String) { | ||
final Arm64; | ||
final Arm; | ||
final X86; | ||
final X86_64; | ||
|
||
public function getNdllSuffix():String { | ||
return switch abstract { | ||
case Arm64: "Arm64"; | ||
case Arm: "Arm"; | ||
case X86_64: "64"; | ||
case X86: ""; | ||
}; | ||
} | ||
} | ||
|
||
function getArchWindows() { | ||
return switch Sys.getEnv("PROCESSOR_ARCHITECTURE") { | ||
case "x86": X86; | ||
case "AMD64": X86_64; | ||
case "ARM64": Arm64; | ||
case other: throw 'Unknown CPU architecture: $other'; | ||
}; | ||
} | ||
|
||
function getArchUnix() { | ||
final uname = new Process("uname", ["-m"]); | ||
|
||
final arch = try { | ||
uname.stdout.readLine(); | ||
} catch (e:haxe.io.Eof) { | ||
""; | ||
}; | ||
|
||
uname.kill(); | ||
uname.close(); | ||
|
||
return switch arch { | ||
case "x86_64" | "amd64": X86_64; | ||
case "i386" | "x86": X86; | ||
case "arm64" | "aarch64": Arm64; | ||
case "arm": Arm; | ||
case other: throw 'Unknown CPU architecture: "$other"'; | ||
}; | ||
} | ||
|
||
function getArch() { | ||
return switch Sys.systemName() { | ||
case "Windows": getArchWindows(); | ||
default: getArchUnix(); | ||
}; | ||
} | ||
|
||
function main() { | ||
final arch = getArch(); | ||
|
||
final expectedNdllSubDir = Sys.systemName() + arch.getNdllSuffix() + "/"; | ||
|
||
final ndllPath = neko.vm.Loader.local().getPath()[0]; | ||
|
||
if (ndllPath.endsWith(expectedNdllSubDir)) { | ||
Sys.println("Success"); | ||
} else { | ||
Sys.println('Failure: Expected $ndllPath to end with $expectedNdllSubDir'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--cmd haxelib dev dummy_ndll dummy_ndll |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--main Main | ||
--neko bin/main.n | ||
-lib dummy_ndll | ||
--cmd neko bin/main.n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Success |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-cp ../src | ||
--run Main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters