Skip to content

Commit d08c4a5

Browse files
authored
Improvements to README and tests (#1748)
* test: Prevent AST parser tests from waiting for the timeout on failure Previously, if these tests were to fail, they'd never call `done()` and so Jasmine would wait for the full timeout period before declaring the tests failed. (This would happen if you didn't have the NPM dependencies installed.) * fix: Import toplevel Gradle properties in SBG tests The build file for SBG tests uses some properties, such as ns_default_asm_version, that are defined in the toplevel build file. This build file needs to import those properties. * docs: Add README steps One step for installing the jsparser tests dependencies. This also updates the lockfile if you do it with a recent version of NPM; speculatively including that in this commit in case it doesn't break anything else. Another step for setting the appropriate environment variables. They're already mentioned in the Android Studio instructions above, but you'll need to set them separately in your shell if building from the command line. * test: Don't try to load lib/rt.jar in SBG tests This JAR file, which contains the Java runtime classes, doesn't exist as a separate file ever since Java 9.x. Therefore this test can't work as it previously did. This removes the setup code that tries to read rt.jar, which always fails. It adds assertions for the results of generateBinding(), since in the current state of the test, without access to rt.jar, the generation fails and generateBinding() returns null. * test: Add a small helper to SBG for introspecting system classes Since we can no longer load lib/rt.jar, and system classes no longer exist in an actual JAR file, this introduces a small helper function to get a BCEL JavaClass for a system class, using ClassPath.SYSTEM_CLASS_PATH. (I'm not sure why this only came up in tests and not in runtime execution of the static binding generator, though.) * test: Remove references to Pack200 from SBG test data The Pack200 interface was removed in Java 11, so these interfaces no longer exist in modern Java. I believe they were only used as sample interfaces in the tests anyway, so just remove them from the test data. * docs: Fix "runtests" command "gradlew runtest" doesn't work because Gradle complains the name of the target is ambiguous. * docs: Update inspector documentation Some of the paths need to be updated. The JSON file is now generated, not checked in to V8. So in order to edit the protocol we need to modify the PDL file, which is the source of the JSON file. * chore: Add fake project files for easier inspector debugging These files make it possible to run the test-app in Android Studio, then connect it to the devtools inspector with `ns debug android --start`. (The package.json lists a dependency, but there's no need to run `npm install` if you have the NativeScript CLI already installed globally.)
1 parent 5e767b9 commit d08c4a5

File tree

14 files changed

+1568
-205
lines changed

14 files changed

+1568
-205
lines changed

README.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,18 @@ Note: You might need to run the Android Studio from the command line in order to
6060

6161
## How to Build
6262

63+
* Install dependencies from NPM:
64+
65+
```Shell
66+
cd test-app/build-tools/jsparser
67+
npm install
68+
```
69+
70+
* Set environment variables:
71+
- `JAVA_HOME` such that `$JAVA_HOME/bin/java` points to your Java executable
72+
- `ANDROID_HOME` pointing to where you have installed the Android SDK
73+
- `ANDROID_NDK_HOME` pointing to the version of the Android NDK needed for this version of NativeScript
74+
6375
* Run command
6476

6577
Windows:
@@ -87,8 +99,27 @@ Note: You might need to run the Android Studio from the command line in order to
8799
``Note: Keep in mind the device or emulator needs to have an sdcard mounted.``
88100
* Run command
89101
```Shell
90-
gradlew runtest
102+
gradlew runtests
91103
```
104+
105+
## How to Connect the Inspector
106+
107+
* Install dependencies: run command
108+
```Shell
109+
cd test-app
110+
npm install
111+
```
112+
* Run the test app in Android Studio, or manually in the emulator.
113+
* Run command
114+
```Shell
115+
npx ns debug android --start
116+
```
117+
(If you instead have the `nativescript` NPM module installed globally,
118+
you can omit the `npm install` and the `npx` prefix.)
119+
* This will print out a URL, such as
120+
`devtools://devtools/bundled/inspector.html?ws=localhost:40000`.
121+
Open this URL in Chrome or Chromium.
122+
92123
## Contribute
93124
We love PRs! Check out the [contributing guidelines](CONTRIBUTING.md). If you want to contribute, but you are not sure where to start - look for [issues labeled `help wanted`](https://github.com/NativeScript/android-runtime/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22).
94125

docs/extending-inspector.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This step involves fetching and building the V8 projectory, explanation for whic
1212

1313
> Note: When passing arguments to gn to have a project generate, make sure to include the inspector sources. For an overview of all available gn arguments run `gn args project-dir --list`
1414
15-
1. Modify `v8/src/inspector/js_protocol.json` to only contain the domains that will be used in the runtime project. The right way to go about this is to copy-paste the `js_protocol` from the runtime project, and add on top of it. For a complete list of all protocol domains supported by the Chrome browser refer to [browser_protocol.json](https://chromium.googlesource.com/chromium/src/+log/master/third_party/WebKit/Source/core/inspector/browser_protocol.json) in the Chromium project. Example browser_protocol.json file can be found [here](https://chromedevtools.github.io/devtools-protocol/tot/).
15+
1. Modify `v8/include/js_protocol.pdl` to only contain the domains that will be used in the runtime project. The right way to go about this is to copy-paste the `js_protocol` from the runtime project, and add on top of it. For a complete list of all protocol domains supported by the Chrome browser refer to [browser_protocol.json](https://chromium.googlesource.com/chromium/src/+log/master/third_party/WebKit/Source/core/inspector/browser_protocol.json) in the Chromium project. Example browser_protocol.json file can be found [here](https://chromedevtools.github.io/devtools-protocol/tot/).
1616
2. Modify `v8/src/inspector/inspector_protocol_config.json` and include the names for the additional protocol domain definitions that would need to be generated.
1717
```json
1818
{
@@ -47,9 +47,9 @@ This step involves fetching and building the V8 projectory, explanation for whic
4747
```
4848
3. Figure out which parts of the big `js_inspector.json` protocol you will want to keep for the inspector implementation. It is likely that a lot of it will be browser-specific, so you don't need to spend extra time doing stub implementations for methods and events the application will not be making notifications for.
4949

50-
4. Run the ninja build. Upon completion, the inspector protocol files would be at `project-dir/arch.release/gen/src/inspector/protocol`.
50+
4. Run the ninja build. Upon completion, the inspector protocol files would be at `outgn/$ARCH-release/gen/src/inspector/protocol`.
5151

52-
5. Copy-Paste all `.cpp` and `.h` files in the runtime project at `runtime/src/main/cpp/v8_inspector/src/inspector/protocol`
52+
5. Copy-Paste all `.cpp` and `.h` files in the runtime project at `test-app/runtime/src/main/cpp/v8_inspector/src/inspector/protocol`
5353

5454
6. Create a new C++ class extending the desired Domain (e.g. DOM). Name it according to the convention already established by the V8 team - `v8-<domain>-agent-impl.h/cpp` - See [v8-dom-agent-impl.h](https://github.com/NativeScript/android-runtime/blob/5a04e09439e2bc6a201577895b9ac6538441e758/test-app/runtime/src/main/cpp/v8_inspector/src/inspector/v8-dom-agent-impl.h#L18). Implement the Backend::<Domain>'s methods in the `.cpp` file.
5555

0 commit comments

Comments
 (0)