@retrovm/nobj 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +21 -3
  2. package/nobj.ts +14 -5
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -104,13 +104,13 @@ By default both platform and architecture are inferred from the running process.
104
104
  ```ts
105
105
  encodeSymbols(symbols, 'arm64', 'linux') // Linux/arm64
106
106
  encodeSymbols(symbols, 'x64', 'win32') // Windows/x64
107
- encodeSymbols(symbols, 'arm64', 'darwin') // macOS/arm64
107
+ encodeSymbols(symbols, 'arm64', 'macos') // macOS/arm64
108
108
  ```
109
109
 
110
110
  | `TargetPlatform` | Format | Section |
111
111
  |------------------|--------|-----------|
112
112
  | `'win32'` | COFF | `.rdata` |
113
- | `'darwin'` | Mach-O | `__const` |
113
+ | `'macos'` | Mach-O | `__const` |
114
114
  | `'linux'` | ELF64 | `.rodata` |
115
115
 
116
116
  | `TargetArch` | COFF machine | Mach-O cputype |
@@ -132,4 +132,22 @@ The generated files are minimal but correct — accepted by `clang`, `lld` and `
132
132
 
133
133
  ## License
134
134
 
135
- 2026 - MIT © Juan Carlos González Amestoy
135
+ Copyright (c) 2026 Juan Carlos González Amestoy
136
+
137
+ Permission is hereby granted, free of charge, to any person obtaining a copy
138
+ of this software and associated documentation files (the "Software"), to deal
139
+ in the Software without restriction, including without limitation the rights
140
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
141
+ copies of the Software, and to permit persons to whom the Software is
142
+ furnished to do so, subject to the following conditions:
143
+
144
+ The above copyright notice and this permission notice shall be included in all
145
+ copies or substantial portions of the Software.
146
+
147
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
148
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
149
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
150
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
151
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
152
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
153
+ SOFTWARE.
package/nobj.ts CHANGED
@@ -25,7 +25,7 @@ export interface ObjSymbol {
25
25
  obj: SymbolValue;
26
26
  }
27
27
 
28
- export type TargetPlatform = 'win32' | 'darwin' | 'linux';
28
+ export type TargetPlatform = 'win32' | 'macos' | 'linux';
29
29
  export type TargetArch = 'x64' | 'arm64';
30
30
 
31
31
  // ─── Helpers ─────────────────────────────────────────────────────────────────
@@ -54,6 +54,15 @@ function hostArch(): TargetArch {
54
54
  throw new Error(`Unsupported host architecture: ${process.arch}`);
55
55
  }
56
56
 
57
+ export function hostPlatform(): TargetPlatform {
58
+ switch (process.platform) {
59
+ case 'win32': return 'win32';
60
+ case 'darwin': return 'macos';
61
+ case 'linux': return 'linux';
62
+ default: throw new Error(`Unsupported platform: ${process.platform}`);
63
+ }
64
+ }
65
+
57
66
  // ═══════════════════════════════════════════════════════════════════════════════
58
67
  // Windows — COFF
59
68
  // ═══════════════════════════════════════════════════════════════════════════════
@@ -493,12 +502,12 @@ function doObjectLinux(symbols: ObjSymbol[], arch: TargetArch): Buffer {
493
502
  function dispatch(
494
503
  symbols: ObjSymbol[],
495
504
  arch: TargetArch = hostArch(),
496
- platform: TargetPlatform = process.platform as TargetPlatform,
505
+ platform: TargetPlatform = hostPlatform(),
497
506
  ): Buffer {
498
507
  switch (platform) {
499
- case 'win32': return doObjectWindows(symbols, arch);
500
- case 'darwin': return doObjectMacOS(symbols, arch);
501
- case 'linux': return doObjectLinux(symbols, arch);
508
+ case 'win32': return doObjectWindows(symbols, arch);
509
+ case 'macos': return doObjectMacOS(symbols, arch);
510
+ case 'linux': return doObjectLinux(symbols, arch);
502
511
  default: throw new Error(`Unsupported platform: ${platform}`);
503
512
  }
504
513
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@retrovm/nobj",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Generate native linkable object files (COFF, Mach-O, ELF64) from TypeScript/Bun — zero native dependencies",
5
5
  "license": "MIT",
6
6
  "author": "Juan Carlos González Amestoy",