libdragon 12.0.4 → 12.2.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 +44 -20
- package/modules/actions/start.js +1 -0
- package/modules/parameters.js +26 -2
- package/modules/project-info.js +2 -0
- package/package.json +18 -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,13 +60,16 @@ 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
|
|
|
64
70
|
### via NPM
|
|
65
71
|
|
|
66
|
-
Install [node.js](https://nodejs.org/en/download/) (`>=
|
|
72
|
+
Install [node.js](https://nodejs.org/en/download/) (`>= 24`) and install `libdragon` as a global NPM package;
|
|
67
73
|
|
|
68
74
|
```bash
|
|
69
75
|
npm install -g libdragon
|
|
@@ -163,7 +169,10 @@ 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
|
|
|
166
|
-
|
|
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
|
+
|
|
175
|
+
After cloning this repository on a system with node.js (`>= 24`) & docker (`>= 27.2.0`), in this repository's root do;
|
|
167
176
|
|
|
168
177
|
```bash
|
|
169
178
|
npm install
|
|
@@ -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,49 @@ 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.
|
|
274
|
-
|
|
275
|
-
To create your own dev container backed project, you can use the contents of the `.devcontainer` folder as reference. You don't need to include nodejs or the cli and you can just run `build.sh` as `postCreateCommand`. See the `devcontainer.json` for more details. As long as your container have the `DOCKER_CONTAINER` environment variable, the tool can work inside a container.
|
|
278
|
+
### Devcontainer support
|
|
276
279
|
|
|
277
|
-
|
|
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
|
+
> [!NOTE]
|
|
297
|
+
> When working in this devcontainer on a Linux host, you can build and install the latest executable in `${HOME}/.local/bin` by running `npm run install-host` (in the container) to test it on your host.
|
|
298
|
+
|
|
299
|
+
#### `libdragon` configuration
|
|
300
|
+
|
|
301
|
+
This is an example devcontainer setup for using the libdragon toolchain to build n64 ROMs. To start building with libdragon:
|
|
302
|
+
|
|
303
|
+
- Clone this repository with `--recurse-submodules` or run `git submodule update --init` in the devcontainer.
|
|
304
|
+
- Run `cd libdragon && ./build.sh && cd ..` to build and install the library.
|
|
305
|
+
- Run `make bench` to build the [test bench](#local-test-bench). You'll see the rom in `src` folder.
|
|
306
|
+
|
|
307
|
+
If you setup a similar devcontainer for your project, you can immediately start building n64 ROMs using libdragon.
|
|
308
|
+
|
|
309
|
+
#### Future direction
|
|
310
|
+
|
|
311
|
+
- 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.
|
|
312
|
+
- In the devcontainer, uploading via USB is not yet implemented.
|
|
313
|
+
- Error matching is not yet tested.
|
|
314
|
+
- Ideally the necessary extensions should be automatically installed. This is not configured yet.
|
|
315
|
+
|
|
292
316
|
## As an NPM dependency
|
|
293
317
|
|
|
294
318
|
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
|
@@ -39,6 +39,7 @@ const initContainer = async (libdragonInfo) => {
|
|
|
39
39
|
',target=' +
|
|
40
40
|
CONTAINER_TARGET_PATH, // Mount files
|
|
41
41
|
'-w=' + CONTAINER_TARGET_PATH, // Set working directory
|
|
42
|
+
"--add-host=host.docker.internal:host-gateway",
|
|
42
43
|
libdragonInfo.imageName,
|
|
43
44
|
'tail',
|
|
44
45
|
'-f',
|
package/modules/parameters.js
CHANGED
|
@@ -20,6 +20,7 @@ const { globals } = require('./globals');
|
|
|
20
20
|
* VENDOR_STRAT?: VendorStrategy;
|
|
21
21
|
* FILE?: string;
|
|
22
22
|
* BRANCH?: string;
|
|
23
|
+
* CWD?: string;
|
|
23
24
|
* }} CommandlineOptions
|
|
24
25
|
*/
|
|
25
26
|
|
|
@@ -33,6 +34,9 @@ const parseParameters = async (argv) => {
|
|
|
33
34
|
CURRENT_ACTION: undefined,
|
|
34
35
|
};
|
|
35
36
|
|
|
37
|
+
/** @type string[] */
|
|
38
|
+
let potentialExtraFlags = [];
|
|
39
|
+
|
|
36
40
|
for (let i = 2; i < argv.length; i++) {
|
|
37
41
|
const val = argv[i];
|
|
38
42
|
|
|
@@ -90,9 +94,15 @@ const parseParameters = async (argv) => {
|
|
|
90
94
|
continue;
|
|
91
95
|
}
|
|
92
96
|
|
|
97
|
+
if (['-C'].includes(val)) {
|
|
98
|
+
options.CWD = argv[++i];
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Collect unknown flags
|
|
93
103
|
if (val.indexOf('-') == 0) {
|
|
94
|
-
|
|
95
|
-
|
|
104
|
+
potentialExtraFlags.push(val);
|
|
105
|
+
continue;
|
|
96
106
|
}
|
|
97
107
|
|
|
98
108
|
if (options.CURRENT_ACTION) {
|
|
@@ -126,6 +136,20 @@ const parseParameters = async (argv) => {
|
|
|
126
136
|
process.exit(STATUS_BAD_PARAM);
|
|
127
137
|
}
|
|
128
138
|
|
|
139
|
+
// Because of https://github.com/microsoft/vscode-cpptools/issues/14169
|
|
140
|
+
// move any unkown flags before the action to the end of the container command
|
|
141
|
+
if (
|
|
142
|
+
options.CURRENT_ACTION !== actions.exec &&
|
|
143
|
+
potentialExtraFlags.length > 0
|
|
144
|
+
) {
|
|
145
|
+
log(chalk.red(`Invalid flag \`${potentialExtraFlags[0]}\``));
|
|
146
|
+
process.exit(STATUS_BAD_PARAM);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (options.CURRENT_ACTION === actions.exec) {
|
|
150
|
+
options.EXTRA_PARAMS = [...options.EXTRA_PARAMS, ...potentialExtraFlags];
|
|
151
|
+
}
|
|
152
|
+
|
|
129
153
|
if (
|
|
130
154
|
!(
|
|
131
155
|
/** @type {typeof actions[keyof actions][]} */ ([
|
package/modules/project-info.js
CHANGED
|
@@ -165,6 +165,8 @@ const readProjectInfo = async function (optionInfo) {
|
|
|
165
165
|
return /** @type {NoProjectInfo} */ (optionInfo);
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
+
optionInfo.options.CWD && process.chdir(optionInfo.options.CWD);
|
|
169
|
+
|
|
168
170
|
const projectRoot = await findLibdragonRoot();
|
|
169
171
|
|
|
170
172
|
if (
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "libdragon",
|
|
3
|
-
"version": "12.0
|
|
3
|
+
"version": "12.2.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": {
|
|
@@ -17,12 +17,14 @@
|
|
|
17
17
|
"start": "node index.js start",
|
|
18
18
|
"stop": "node index.js stop",
|
|
19
19
|
"pack": "node pack.mjs",
|
|
20
|
+
"install-host": "node pack.mjs --install",
|
|
20
21
|
"bundle": "node bundle.mjs",
|
|
21
22
|
"format": "prettier **/*.js **/*.mjs **/*.cjs --write",
|
|
22
23
|
"format-check": "prettier **/*.js **/*.mjs **/*.cjs --check",
|
|
23
24
|
"lint": "eslint --fix modules/**/*.js *.js *.mjs *.cjs",
|
|
24
25
|
"lint-check": "eslint modules/**/*.js *.js *.mjs *.cjs",
|
|
25
|
-
"tsc": "tsc"
|
|
26
|
+
"tsc": "tsc",
|
|
27
|
+
"cz": "cz"
|
|
26
28
|
},
|
|
27
29
|
"repository": {
|
|
28
30
|
"type": "git",
|
|
@@ -39,29 +41,24 @@
|
|
|
39
41
|
},
|
|
40
42
|
"homepage": "https://github.com/anacierdem/libdragon-docker#readme",
|
|
41
43
|
"dependencies": {
|
|
42
|
-
"chalk": "^4.1.
|
|
43
|
-
"command-line-usage": "^6.1.
|
|
44
|
-
"zx": "^8.
|
|
44
|
+
"chalk": "^4.1.2",
|
|
45
|
+
"command-line-usage": "^6.1.3",
|
|
46
|
+
"zx": "^8.8.5"
|
|
45
47
|
},
|
|
46
48
|
"devDependencies": {
|
|
47
|
-
"@semantic-release/changelog": "^6.0.
|
|
48
|
-
"@semantic-release/exec": "^
|
|
49
|
+
"@semantic-release/changelog": "^6.0.3",
|
|
50
|
+
"@semantic-release/exec": "^7.1.0",
|
|
49
51
|
"@semantic-release/git": "^10.0.1",
|
|
50
|
-
"@types/command-line-usage": "^5.0.
|
|
51
|
-
"commitizen": "^4.2.4",
|
|
52
|
+
"@types/command-line-usage": "^5.0.4",
|
|
52
53
|
"cz-conventional-changelog": "^3.3.0",
|
|
53
|
-
"esbuild": "^0.
|
|
54
|
-
"eslint": "^9.
|
|
55
|
-
"jest": "^29.
|
|
54
|
+
"esbuild": "^0.25.12",
|
|
55
|
+
"eslint": "^9.39.2",
|
|
56
|
+
"jest": "^29.7.0",
|
|
56
57
|
"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"
|
|
58
|
+
"prettier": "^2.8.8",
|
|
59
|
+
"semantic-release": "^25.0.3",
|
|
60
|
+
"typescript": "^4.9.5",
|
|
61
|
+
"zx": "^8.8.5"
|
|
65
62
|
},
|
|
66
63
|
"release": {
|
|
67
64
|
"plugins": [
|