libdragon 12.0.3 → 12.1.0
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.
- package/README.md +39 -18
- package/modules/actions/start.js +6 -11
- package/modules/helpers.js +5 -12
- package/modules/npm-utils.js +10 -1
- package/modules/project-info.js +1 -1
- package/modules/utils.js +2 -7
- package/package.json +17 -21
package/README.md
CHANGED
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
This is a wrapper for a docker container to make managing the libdragon toolchain easier. It has the additional advantage that libdragon toolchain and library can be installed on a per-project basis instead of managing system-wide installations.
|
|
6
6
|
|
|
7
|
+
> [!NOTE]
|
|
8
|
+
> I've started this project a few years before [devcontainers](https://containers.dev/) were a thing. The cli still works and provides minor additional functionality, but if you already have a containerized environment, I suggest using a devcontainer instead. It is doing essentially the same thing. You can find more info in [`libdragon` devcontainer](#libdragon-configuration) section. I'll continue to improve that configuration to make it a compelling alternative.
|
|
9
|
+
|
|
7
10
|
## Prerequisites
|
|
8
11
|
|
|
9
12
|
You should have [docker](https://www.docker.com/products/docker-desktop) (`>= 27.2.0`) and [git](https://git-scm.com/downloads) installed on your system.
|
|
@@ -33,7 +36,7 @@ Download the [pre-built executable](https://github.com/anacierdem/libdragon-dock
|
|
|
33
36
|
<details>
|
|
34
37
|
<summary>Windows instructions</summary>
|
|
35
38
|
|
|
36
|
-
- Download
|
|
39
|
+
- Download Windows executable and copy it to `C:\bin`
|
|
37
40
|
- Press `Windows + R` key combination and then enter `rundll32 sysdm.cpl,EditEnvironmentVariables`
|
|
38
41
|
- In the `Environment Variables` window find the `Path` variable under `User variables for <your user name>`
|
|
39
42
|
- Double click it and add a new entry as `C:\bin`
|
|
@@ -46,7 +49,7 @@ Download the [pre-built executable](https://github.com/anacierdem/libdragon-dock
|
|
|
46
49
|
<details>
|
|
47
50
|
<summary>MacOS instructions</summary>
|
|
48
51
|
|
|
49
|
-
- Download
|
|
52
|
+
- Download MacOS executable and copy it to `/usr/local/bin`
|
|
50
53
|
- Right click it and choose `Open`.
|
|
51
54
|
- It will show a warning, approve it by clicking `Open` again. You can close the newly opened terminal window.
|
|
52
55
|
- You should now be able to use the `libdragon` command.
|
|
@@ -57,7 +60,10 @@ Download the [pre-built executable](https://github.com/anacierdem/libdragon-dock
|
|
|
57
60
|
<details>
|
|
58
61
|
<summary>Linux instructions</summary>
|
|
59
62
|
|
|
60
|
-
-
|
|
63
|
+
- Download Linux executable and copy it to `~/.local/bin`, or somewhere convenient on your `PATH`.
|
|
64
|
+
- Run `chmod u+x ~/.local/bin/libdragon`
|
|
65
|
+
- You should now be able to use the `libdragon` command on new shell sessions.
|
|
66
|
+
- To update it with a new version, replace the file and repeat the other steps.
|
|
61
67
|
|
|
62
68
|
</details>
|
|
63
69
|
|
|
@@ -163,6 +169,9 @@ To be able to share your project with the library change, you just commit your c
|
|
|
163
169
|
|
|
164
170
|
## Working on this repository
|
|
165
171
|
|
|
172
|
+
> [!TIP]
|
|
173
|
+
> You can simply use [`development` devcontainer](#development-configuration) support to get up an running quickly if your development environment supports it.
|
|
174
|
+
|
|
166
175
|
After cloning this repository on a system with node.js (`>= 18`) & docker (`>= 27.2.0`), in this repository's root do;
|
|
167
176
|
|
|
168
177
|
```bash
|
|
@@ -237,7 +246,7 @@ For a quick development loop it really helps linking the code in this repository
|
|
|
237
246
|
npm link
|
|
238
247
|
```
|
|
239
248
|
|
|
240
|
-
in the root of the repository. Once you do this, running `libdragon` will use the code here rather than the actual npm installation. Then you can test your changes in the libdragon project here or elsewhere on your computer.
|
|
249
|
+
in the root of the repository. Once you do this, running `libdragon` will use the code here rather than the actual npm installation. Then you can test your changes in the libdragon project here or elsewhere on your computer.
|
|
241
250
|
|
|
242
251
|
When you are happy with your changes, you can verify you conform to the coding standards via:
|
|
243
252
|
|
|
@@ -261,34 +270,46 @@ npm run test
|
|
|
261
270
|
This repository uses [`semantic-release`](https://github.com/semantic-release/semantic-release) and manages releases from specially formatted commit messages. To simplify creating them you can use:
|
|
262
271
|
|
|
263
272
|
```bash
|
|
264
|
-
|
|
273
|
+
npm run cz
|
|
265
274
|
```
|
|
266
275
|
|
|
267
276
|
It will create a `semantic-release` compatible commit from your current staged changes.
|
|
268
277
|
|
|
269
|
-
###
|
|
270
|
-
|
|
271
|
-
The repository provides a configuration (in `.devcontainer`) so that IDEs that support it can create and run the Docker container for you. Then, you can start working on it as if you are working on a machine with libdragon installed.
|
|
272
|
-
|
|
273
|
-
With the provided setup, you can continue using the cli in the container and it will work for non-container specific actions like `install`, `disasm` etc. You don't have to use the cli in the container, but you can. In general it will be easier and faster to just run `make` in the container but this setup is included to ease developing the cli as well.
|
|
278
|
+
### Devcontainer support
|
|
274
279
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
#### Caveats
|
|
278
|
-
|
|
279
|
-
- In the devcontainer, uploading via USB will not work.
|
|
280
|
-
- Error matching is not yet tested.
|
|
281
|
-
- Ideally the necessary extensions should be automatically installed. This is not configured yet.
|
|
280
|
+
The repository provides two devcontainer configurations (`development` and `libdragon`) for supported IDEs. If you have docker and a compatible IDE, you can quickly start working on this project.
|
|
281
|
+
To create your own dev container backed project, you can use the contents of the `.devcontainer` folder as reference.
|
|
282
282
|
|
|
283
283
|
<details>
|
|
284
284
|
<summary>vscode instructions</summary>
|
|
285
285
|
|
|
286
286
|
- Make sure you have the [Dev container extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) installed and you fulfill its [requirements](https://code.visualstudio.com/docs/devcontainers/containers).
|
|
287
|
-
- Clone this repository with `--recurse-submodules` or run `git submodule update --init`.
|
|
288
287
|
- Open command palette and run `Dev Containers: Reopen in container`.
|
|
288
|
+
- Pick `development` or `libdragon` configuration.
|
|
289
289
|
- It will prepare the container and open it in the editor.
|
|
290
290
|
</details>
|
|
291
291
|
|
|
292
|
+
#### `development` configuration
|
|
293
|
+
|
|
294
|
+
This has everything required to develop the tool itself. Just follow "Working on this repository" section inside the devcontainer.
|
|
295
|
+
|
|
296
|
+
#### `libdragon` configuration
|
|
297
|
+
|
|
298
|
+
This is an example devcontainer setup for using the libdragon toolchain to build n64 ROMs. To start building with libdragon:
|
|
299
|
+
|
|
300
|
+
- Clone this repository with `--recurse-submodules` or run `git submodule update --init` in the devcontainer.
|
|
301
|
+
- Run `cd libdragon && ./build.sh && cd ..` to build and install the library.
|
|
302
|
+
- Run `make bench` to build the [test bench](#local-test-bench). You'll see the rom in `src` folder.
|
|
303
|
+
|
|
304
|
+
If you setup a similar devcontainer for your project, you can immediately start building n64 ROMs using libdragon.
|
|
305
|
+
|
|
306
|
+
#### Future direction
|
|
307
|
+
|
|
308
|
+
- The cli is not enabled on `libdragon` devcontainer, so you cannot currently use actions like `install` or `disasm`. This is supported by the cli (via `DOCKER_CONTAINER`) but not yet enabled on the devcontainer.
|
|
309
|
+
- In the devcontainer, uploading via USB is not yet implemented.
|
|
310
|
+
- Error matching is not yet tested.
|
|
311
|
+
- Ideally the necessary extensions should be automatically installed. This is not configured yet.
|
|
312
|
+
|
|
292
313
|
## As an NPM dependency
|
|
293
314
|
|
|
294
315
|
You can install libdragon as an NPM dependency by `npm install libdragon --save` in order to use docker in your N64 projects. A `libdragon` command similar to global installation is provided that can be used in your NPM scripts as follows;
|
package/modules/actions/start.js
CHANGED
|
@@ -34,13 +34,13 @@ const initContainer = async (libdragonInfo) => {
|
|
|
34
34
|
'run',
|
|
35
35
|
'-d', // Detached
|
|
36
36
|
'--mount',
|
|
37
|
-
'
|
|
37
|
+
'type=bind,source=' +
|
|
38
38
|
libdragonInfo.root +
|
|
39
39
|
',target=' +
|
|
40
|
-
CONTAINER_TARGET_PATH
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
CONTAINER_TARGET_PATH, // Mount files
|
|
41
|
+
'-w=' + CONTAINER_TARGET_PATH, // Set working directory
|
|
42
|
+
"--add-host=host.docker.internal:host-gateway",
|
|
43
|
+
libdragonInfo.imageName,
|
|
44
44
|
'tail',
|
|
45
45
|
'-f',
|
|
46
46
|
'/dev/null',
|
|
@@ -59,12 +59,7 @@ const initContainer = async (libdragonInfo) => {
|
|
|
59
59
|
'-R',
|
|
60
60
|
`${uid >= 0 ? uid : ''}:${gid >= 0 ? gid : ''}`,
|
|
61
61
|
'/n64_toolchain',
|
|
62
|
-
]
|
|
63
|
-
{
|
|
64
|
-
spawnOptions: {
|
|
65
|
-
shell: true,
|
|
66
|
-
},
|
|
67
|
-
}
|
|
62
|
+
]
|
|
68
63
|
);
|
|
69
64
|
} catch (e) {
|
|
70
65
|
// Dispose the invalid container, clean and exit
|
package/modules/helpers.js
CHANGED
|
@@ -124,12 +124,11 @@ async function dirExists(path) {
|
|
|
124
124
|
* }} SpawnOptions
|
|
125
125
|
*/
|
|
126
126
|
|
|
127
|
+
// A simple Promise wrapper for child_process.spawn. Return the err/out streams
|
|
128
|
+
// from the process by default. Specify inheritStdout / inheritStderr to disable
|
|
129
|
+
// this and inherit the parent process's stream, passing through the TTY if any.
|
|
127
130
|
/**
|
|
128
|
-
*
|
|
129
|
-
* from the process by default. Specify inheritStdout / inheritStderr to disable
|
|
130
|
-
* this and inherit the parent process's stream, passing through the TTY if any.
|
|
131
|
-
* Runs everything in a shell, so be careful with user input. By default, we get
|
|
132
|
-
* the input from user but this is the whole idea of most of the logic here.
|
|
131
|
+
*
|
|
133
132
|
* @param {string} cmd
|
|
134
133
|
* @param {string[]} params
|
|
135
134
|
* @param {SpawnOptions} options
|
|
@@ -185,15 +184,10 @@ function spawnProcess(
|
|
|
185
184
|
enableErrorTTY ? 'inherit' : 'pipe',
|
|
186
185
|
],
|
|
187
186
|
env: {
|
|
187
|
+
...process.env,
|
|
188
188
|
// Prevent the annoying docker "What's next?" message. It messes up everything.
|
|
189
189
|
DOCKER_CLI_HINTS: 'false',
|
|
190
190
|
},
|
|
191
|
-
// On macos, we need to run the command in a shell for some docker commands
|
|
192
|
-
// to work properly. The ones with paths in them probably not working on
|
|
193
|
-
// macOS. No need to do this on Windows, as it'd now require additional
|
|
194
|
-
// escaping for the paths.
|
|
195
|
-
// shell: process.platform === 'darwin',
|
|
196
|
-
shell: true,
|
|
197
191
|
...spawnOptions,
|
|
198
192
|
});
|
|
199
193
|
|
|
@@ -320,7 +314,6 @@ const dockerExec = /** @type {DockerExec} */ (
|
|
|
320
314
|
...options,
|
|
321
315
|
spawnOptions: {
|
|
322
316
|
cwd: workDir,
|
|
323
|
-
shell: false,
|
|
324
317
|
...options?.spawnOptions,
|
|
325
318
|
},
|
|
326
319
|
});
|
package/modules/npm-utils.js
CHANGED
|
@@ -21,7 +21,16 @@ async function findNPMRoot() {
|
|
|
21
21
|
function runNPM(params) {
|
|
22
22
|
return spawnProcess(
|
|
23
23
|
/^win/.test(process.platform) ? 'npm.cmd' : 'npm',
|
|
24
|
-
params
|
|
24
|
+
params,
|
|
25
|
+
{
|
|
26
|
+
userCommand: false,
|
|
27
|
+
inheritStdin: true,
|
|
28
|
+
inheritStdout: false,
|
|
29
|
+
inheritStderr: false,
|
|
30
|
+
spawnOptions: {
|
|
31
|
+
shell: true,
|
|
32
|
+
},
|
|
33
|
+
}
|
|
25
34
|
);
|
|
26
35
|
}
|
|
27
36
|
module.exports = {
|
package/modules/project-info.js
CHANGED
package/modules/utils.js
CHANGED
|
@@ -40,12 +40,7 @@ const installDependencies = async (libdragonInfo) => {
|
|
|
40
40
|
CONTAINER_TARGET_PATH + '/' + libdragonInfo.vendorDirectory,
|
|
41
41
|
...dockerHostUserParams(libdragonInfo),
|
|
42
42
|
],
|
|
43
|
-
['/bin/bash', './build.sh']
|
|
44
|
-
{
|
|
45
|
-
spawnOptions: {
|
|
46
|
-
shell: true,
|
|
47
|
-
},
|
|
48
|
-
}
|
|
43
|
+
['/bin/bash', './build.sh']
|
|
49
44
|
);
|
|
50
45
|
};
|
|
51
46
|
|
|
@@ -138,7 +133,7 @@ async function runGit(libdragonInfo, params, options = {}) {
|
|
|
138
133
|
|
|
139
134
|
return await spawnProcess(
|
|
140
135
|
'git',
|
|
141
|
-
['-C',
|
|
136
|
+
['-C', libdragonInfo.root, ...params],
|
|
142
137
|
// Windows git is breaking the TTY somehow - disable TTY for now
|
|
143
138
|
// We are not able to display progress for the initial clone b/c of this
|
|
144
139
|
// Enable progress otherwise.
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "libdragon",
|
|
3
|
-
"version": "12.0
|
|
3
|
+
"version": "12.1.0",
|
|
4
4
|
"description": "This is a docker wrapper for libdragon",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"engines": {
|
|
7
|
-
"node": ">=
|
|
7
|
+
"node": ">=24",
|
|
8
8
|
"npm": ">=10"
|
|
9
9
|
},
|
|
10
10
|
"bin": {
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"format-check": "prettier **/*.js **/*.mjs **/*.cjs --check",
|
|
23
23
|
"lint": "eslint --fix modules/**/*.js *.js *.mjs *.cjs",
|
|
24
24
|
"lint-check": "eslint modules/**/*.js *.js *.mjs *.cjs",
|
|
25
|
-
"tsc": "tsc"
|
|
25
|
+
"tsc": "tsc",
|
|
26
|
+
"cz": "cz"
|
|
26
27
|
},
|
|
27
28
|
"repository": {
|
|
28
29
|
"type": "git",
|
|
@@ -39,29 +40,24 @@
|
|
|
39
40
|
},
|
|
40
41
|
"homepage": "https://github.com/anacierdem/libdragon-docker#readme",
|
|
41
42
|
"dependencies": {
|
|
42
|
-
"chalk": "^4.1.
|
|
43
|
-
"command-line-usage": "^6.1.
|
|
44
|
-
"zx": "^8.
|
|
43
|
+
"chalk": "^4.1.2",
|
|
44
|
+
"command-line-usage": "^6.1.3",
|
|
45
|
+
"zx": "^8.8.5"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
|
-
"@semantic-release/changelog": "^6.0.
|
|
48
|
-
"@semantic-release/exec": "^
|
|
48
|
+
"@semantic-release/changelog": "^6.0.3",
|
|
49
|
+
"@semantic-release/exec": "^7.1.0",
|
|
49
50
|
"@semantic-release/git": "^10.0.1",
|
|
50
|
-
"@types/command-line-usage": "^5.0.
|
|
51
|
-
"commitizen": "^4.2.4",
|
|
51
|
+
"@types/command-line-usage": "^5.0.4",
|
|
52
52
|
"cz-conventional-changelog": "^3.3.0",
|
|
53
|
-
"esbuild": "^0.
|
|
54
|
-
"eslint": "^9.
|
|
55
|
-
"jest": "^29.
|
|
53
|
+
"esbuild": "^0.25.12",
|
|
54
|
+
"eslint": "^9.39.2",
|
|
55
|
+
"jest": "^29.7.0",
|
|
56
56
|
"postject": "^1.0.0-alpha.6",
|
|
57
|
-
"prettier": "^2.
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"zx": "^8.1.8"
|
|
62
|
-
},
|
|
63
|
-
"overrides": {
|
|
64
|
-
"minimist": "1.2.6"
|
|
57
|
+
"prettier": "^2.8.8",
|
|
58
|
+
"semantic-release": "^25.0.3",
|
|
59
|
+
"typescript": "^4.9.5",
|
|
60
|
+
"zx": "^8.8.5"
|
|
65
61
|
},
|
|
66
62
|
"release": {
|
|
67
63
|
"plugins": [
|