libdragon 12.1.0 → 12.2.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.
package/README.md CHANGED
@@ -5,7 +5,7 @@
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
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.
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 giving devcontainers a try instead. It is doing a very similar thing. See the [template](https://github.com/anacierdem/libdragon-template) to get up and running.
9
9
 
10
10
  ## Prerequisites
11
11
 
@@ -69,7 +69,7 @@ Download the [pre-built executable](https://github.com/anacierdem/libdragon-dock
69
69
 
70
70
  ### via NPM
71
71
 
72
- Install [node.js](https://nodejs.org/en/download/) (`>= 22`) and install `libdragon` as a global NPM package;
72
+ Install [node.js](https://nodejs.org/en/download/) (`>= 24`) and install `libdragon` as a global NPM package;
73
73
 
74
74
  ```bash
75
75
  npm install -g libdragon
@@ -114,10 +114,10 @@ Run `libdragon help [action]` for more details on individual actions.
114
114
  Use the `--branch` flag to set up a custom libdragon branch when initializing your project:
115
115
 
116
116
  ```bash
117
- libdragon init --branch unstable
117
+ libdragon init --branch preview
118
118
  ```
119
119
 
120
- This will use the `unstable` toolchain and code.
120
+ This will use the `preview` toolchain and code.
121
121
 
122
122
  ### Switching to a different branch of libdragon
123
123
 
@@ -146,17 +146,6 @@ libdragon install
146
146
 
147
147
  This will update all the artifacts in your container and your new code will start linking against the new version when you re-build it via `libdragon make`. The build system should pick up the change in the library and re-compile the dependent files.
148
148
 
149
- Instead of depending on the above command, you can automatically re-build the library by making it a make dependency in your project:
150
-
151
- ```makefile
152
- libdragon-install:
153
- $(MAKE) -C ./libdragon install
154
- ```
155
-
156
- If your build now depends on `libdragon-install`, it will force an install (which should be pretty quick if you don't have changes) and force the build system to rebuild your project when necessary.
157
-
158
- If you clone this repository, this setup is pretty much ready for you. Make sure you have a working libdragon setup and you get the submodules (e.g `git submodule update --init`). Then you can run `libdragon make bench` to execute the code in `./src` with your library changes. Also see [test bench](#local-test-bench).
159
-
160
149
  When managing your changes to the library, you have a few options:
161
150
 
162
151
  #### **Using `submodule` vendor strategy.**
@@ -170,9 +159,9 @@ To be able to share your project with the library change, you just commit your c
170
159
  ## Working on this repository
171
160
 
172
161
  > [!TIP]
173
- > You can simply use [`development` devcontainer](#development-configuration) support to get up an running quickly if your development environment supports it.
162
+ > You can simply use [devcontainer](#development-configuration) support to get up an running quickly if your development environment supports it.
174
163
 
175
- After cloning this repository on a system with node.js (`>= 18`) & docker (`>= 27.2.0`), in this repository's root do;
164
+ After cloning this repository on a system with node.js (or devcontainer) & docker, in this repository's root do;
176
165
 
177
166
  ```bash
178
167
  npm install
@@ -190,35 +179,13 @@ Then run;
190
179
  npm run libdragon -- init
191
180
  ```
192
181
 
193
- to download the pre-built toolchain image, start and initialize it. This will also install [test bench](#local-test-bench) dependencies into the container if any.
182
+ to download the pre-built toolchain image, start and initialize it.
194
183
 
195
184
  Now you will be able to work on the files simultaneously with the docker container and any built binaries will be available in your workspace as it is mounted on the container.
196
185
 
197
- There is a root `Makefile` making deeper makefiles easier with these recipes;
198
-
199
- bench: build the test bench (see below)
200
- examples: build libdragon examples
201
- tests: build the test ROM
202
- libdragon-install: build and install libdragon
203
- clean-bench: clean the test bench (see below)
204
- clean: clean everything and start from scratch
205
-
206
- For example, to re-build the original libdragon examples do;
207
-
208
- ```bash
209
- npm run libdragon -- make examples
210
- ```
211
-
212
- Similarly to run the `clean` recipe, run;
213
-
214
- ```bash
215
- npm run libdragon -- make clean
216
- ```
217
-
218
186
  > [!IMPORTANT]
219
187
  > Keep in mind that `--` is necessary for actual arguments when using npm scripts.
220
188
 
221
-
222
189
  To update the submodule and re-build everything;
223
190
 
224
191
  ```bash
@@ -227,20 +194,16 @@ npm run libdragon -- update
227
194
 
228
195
  ### Local test bench
229
196
 
230
- The root `bench` recipe is for building the code in root `src` folder. This is a quick way of testing your libdragon changes or a sample code built around libdragon, and is called the test bench. This recipe together with `examples` and `tests` recipes will build and install libdragon automatically as necessary. Thus, they will always produce a rom image using the libdragon code in the repository via their make dependencies, which is ideal for experimenting with libdragon itself.
197
+ There is a very barebones libdragon example in root `src` folder, called the test bench. You can build and clean it respectively with:
231
198
 
232
- There are also vscode launch configurations to quickly build and run the examples, tests and the bench. If you have [ares](https://ares-emu.net/) on your `PATH`, the launch configurations ending in `(emu)` will start it automatically. For the examples configuration, you can navigate to the relevant `.c` file and `Run selected example` will start it most of the time. In some cases, the output ROM name may not match the `.c` file and in those cases, you can select the ROM file instead and it should work.
233
-
234
- > [!NOTE]
235
- > This repository also uses [UNFLoader](https://github.com/buu342/N64-UNFLoader), so you can use the launch configurations without `(emu)` to run the code if you have a supported flashcart plugged in and have `UNFLoader` executable on your `PATH`.
236
- >
237
- > The special `Debug Test Bench (emu)` configuration will start ares with remote debugging for the test bench if you have `gdb-multiarch` executable on your `PATH`. It should automatically break in your `main` function.
238
-
239
- You can clean everything with the `clean` recipe/task (open the command palette and choose `Run Task -> clean`).
199
+ ```bash
200
+ npm run libdragon make -C ./src
201
+ npm run libdragon make -C ./src clean
202
+ ```
240
203
 
241
204
  ### Developing the tool itself
242
205
 
243
- For a quick development loop it really helps linking the code in this repository as the global libdragon installation. To do this run;
206
+ For a quick development loop it really helps linking the code in this repository as the global libdragon installation. To do this, run;
244
207
 
245
208
  ```bash
246
209
  npm link
@@ -277,38 +240,19 @@ It will create a `semantic-release` compatible commit from your current staged c
277
240
 
278
241
  ### Devcontainer support
279
242
 
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.
243
+ The repository provides a devcontainer configuration for supported IDEs. If you have docker and a compatible IDE, you can quickly start working on this project.
244
+ This has everything required to develop the tool itself. Just follow "Working on this repository" section inside the devcontainer.
282
245
 
283
246
  <details>
284
247
  <summary>vscode instructions</summary>
285
248
 
286
249
  - 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
250
  - Open command palette and run `Dev Containers: Reopen in container`.
288
- - Pick `development` or `libdragon` configuration.
289
251
  - It will prepare the container and open it in the editor.
290
252
  </details>
291
253
 
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.
254
+ > [!NOTE]
255
+ > 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.
312
256
 
313
257
  ## As an NPM dependency
314
258
 
@@ -16,6 +16,12 @@ const printUsage = async (info) => {
16
16
  alias: 'v',
17
17
  typeLabel: ' ',
18
18
  },
19
+ {
20
+ description:
21
+ 'Execute the tool as if it is running in provided path on the host. Equivalent to `chdir`ing into that path.',
22
+ alias: 'C',
23
+ typeLabel: '<path>',
24
+ },
19
25
  ];
20
26
 
21
27
  const optionDefinitions = [
@@ -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
- log(chalk.red(`Invalid flag \`${val}\``));
95
- process.exit(STATUS_BAD_PARAM);
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][]} */ ([
@@ -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,6 +1,6 @@
1
1
  {
2
2
  "name": "libdragon",
3
- "version": "12.1.0",
3
+ "version": "12.2.1",
4
4
  "description": "This is a docker wrapper for libdragon",
5
5
  "main": "index.js",
6
6
  "engines": {
@@ -17,6 +17,7 @@
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",