|
3 | 3 | import ./private/platformInfo
|
4 | 4 | import ../pystring/strimpl
|
5 | 5 | export strimpl
|
6 |
| -import std/strutils |
7 | 6 |
|
8 | 7 | proc version*(): PyStr = str `platform.version`()
|
9 | 8 |
|
10 |
| -func python_implementation*(): PyStr = str "PyNim" |
11 |
| -func system*(): PyStr = str `platform.system` |
12 |
| -const machineS = str hostCPU.toUpperAscii() |
13 |
| -func machine*(): PyStr = machineS |
| 9 | +func python_implementation*(): PyStr{.inline.} = str "PyNim" |
| 10 | +func system*(): PyStr{.inline.} = str `platform.system` |
| 11 | + |
| 12 | +const machineS = hostCPU |
| 13 | +#[ doc says: |
| 14 | +
|
| 15 | +``` |
| 16 | +Possible values: |
| 17 | + "i386", "amd64", |
| 18 | + "powerpc", "powerpc64", "powerpc64el", |
| 19 | +
|
| 20 | + "alpha", "sparc", "loongarch64". |
| 21 | + "mips", "mipsel", "mips64", "mips64el", |
| 22 | + "arm", "arm64", "riscv32", "riscv64", |
| 23 | +``` |
| 24 | +]# |
| 25 | +# refer to compiler/platform.nim, |
| 26 | +# there're more |
| 27 | + |
| 28 | +# compiler/semfold.nim |
| 29 | +# proc getConstExpr(m: PSym, n: PNode; idgen: IdGenerator; g: ModuleGraph): PNode |
| 30 | +# of mHostCPU: result = newStrNodeT(platform.CPU[g.config.target.targetCPU].name.toLowerAscii, n, g) |
| 31 | + |
| 32 | +when defined(windows): |
| 33 | + import std/strutils |
| 34 | + template winNormMachine(machine): string = |
| 35 | + case machine |
| 36 | + of "i386": "x86" |
| 37 | + of "alpha": "Alpha" |
| 38 | + elif machine.startsWith"powerpc": "PowerPC" |
| 39 | + elif machine.startsWith"mips": "MIPS" |
| 40 | + #elif machine.startsWith"arm": machine.toUpperAscii |
| 41 | + else: # including ia64, arm[64], amd64 |
| 42 | + machine |
| 43 | + |
| 44 | +func machine*(): PyStr{.inline.} = |
| 45 | + when defined(windows): |
| 46 | + winNormMachine machineS |
| 47 | + else: |
| 48 | + case machineS |
| 49 | + of "amd64": "x86_64" |
| 50 | + of "arm64": "aarch64" |
| 51 | + else: machineS |
14 | 52 |
|
0 commit comments