-
Notifications
You must be signed in to change notification settings - Fork 584
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit 'dec88548b45fcb2c0484ef5fc7b02aa8e3e13127' of github.com…
…:realm/realm-js into kneth/cmake-and-monorepo
- Loading branch information
Showing
60 changed files
with
1,263 additions
and
2,011 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
include("${CMAKE_CURRENT_LIST_DIR}/../vendor/realm-core/tools/cmake/ios.toolchain.cmake") | ||
|
||
set(CMAKE_SYSTEM_NAME iOS) | ||
set(CMAKE_C_VISIBILITY_PRESET hidden) | ||
set(CMAKE_CXX_VISIBILITY_PRESET hidden) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# VSCode Debugging | ||
|
||
## Setup | ||
|
||
First make sure your environment is setup by following the [building instructions](./building.md) | ||
|
||
Then you will need the following plugins for VSCode: | ||
* [C/C++ by Microsoft](https://github.com/Microsoft/vscode-cpptools) | ||
* [CodeLLDB](https://github.com/vadimcn/vscode-lldb) | ||
|
||
## Building | ||
|
||
In order to debug C++, you must first build the project in debug mode. This can be done with the command | ||
|
||
```bash | ||
$ npm run rebuild --debug | ||
``` | ||
|
||
After this is completed there should be a `debug` folder visible in your `compiled` directory. If not, perhaps delete the `compiled` directory and try again. | ||
|
||
## Debugging Realm Unit Tests through Example | ||
|
||
First lets take a look at `.vscode/launch.json`. This contains various ways to launch commands from vscode. For this example we will look at the command `LLDB Launch Unit Tests`. | ||
|
||
```json | ||
{ | ||
"type": "lldb", | ||
"request": "launch", | ||
"name": "LLDB Launch Unit Tests", | ||
"program": "node", | ||
"args": [ | ||
"--expose_gc", | ||
"${workspaceFolder}/tests/node_modules/jasmine/bin/jasmine.js", | ||
"spec/unit_tests.js", | ||
"--filter=." | ||
], | ||
"cwd": "${workspaceFolder}/tests" | ||
} | ||
``` | ||
|
||
A quick read through this code shows that the launch type is `lldb` provided by the CodeLLDB extension, and it is using the `node` command to invoke the `jasmine` test framework with our `spec/unit_tests.js`. The filter option is currently running all tests. To make things easier, let's modify that parameter to take a single test (`testListPush` from `tests/list-tests.js`). | ||
|
||
```json | ||
{ | ||
"type": "lldb", | ||
"request": "launch", | ||
"name": "LLDB Launch Unit Tests", | ||
"program": "node", | ||
"args": [ | ||
"--expose_gc", | ||
"${workspaceFolder}/tests/node_modules/jasmine/bin/jasmine.js", | ||
"spec/unit_tests.js", | ||
"--filter=testListPush" | ||
], | ||
"cwd": "${workspaceFolder}/tests" | ||
} | ||
``` | ||
|
||
As we are fairly certain this will perform a `push` command on a realm list, we can place a breakpoint in the push function in `src/js_list.hpp` by locating the push function and clicking next to the desired line number (see example below) | ||
|
||
 | ||
|
||
Now we can run the test and see what happens. Click on the debug tab in the left bar of vscode: | ||
|
||
 | ||
|
||
Select the `LLDB Launch Unit Tests` from the run tab: | ||
|
||
 | ||
|
||
Now press play and we should arrive at our new breakpoint. | ||
|
||
|
||
 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
The Realm JavaScript SDK has limited support for running behind an HTTP proxy: | ||
|
||
Current limitations: | ||
- This is currently only supported on Realm JS v10.3.0 or higher running on Node.js. | ||
- You must install the [`fetch-with-proxy`](https://www.npmjs.com/package/fetch-with-proxy) package manually. | ||
- You must set the `HTTPS_PROXY` environment variable, hence the proxy cannot be set at runtime or on a per-app basis. | ||
- HTTPS connections from the client to the proxy server, is not supported. I.e. the URL specified in the `HTTPS_PROXY` must start with `http://`. | ||
|
||
## Installing `fetch-with-proxy` | ||
|
||
In the time of writing this tutorial a manual step is required to switch out the node-fetch package used by the network transport layer. NPM CLI v6.9.0 or higher is required. | ||
|
||
After installing Realm JS, run the following command to install a different package into our Network Transport package: | ||
|
||
``` | ||
npm install node-fetch@npm:fetch-with-proxy --prefix node_modules/realm-network-transport | ||
``` | ||
|
||
## Setting `HTTPS_PROXY` and running a script | ||
|
||
Let's say you have a `index.js` script that you want to run, while routing all of Realm JS's requests through an HTTP proxy located at `http://127.0.0.1:3128`. | ||
|
||
On a Unix system you can simply prefix the assignment of an environment variable before the command, like this: | ||
|
||
``` | ||
HTTPS_PROXY=http://127.0.0.1:3128 node index.js | ||
``` | ||
|
||
On a Windows system you have to configure the variable through "Advanced system settings" > "Environment Variables" > "Edit System Variable". |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
{ | ||
"query-language": { | ||
"title": "Query language" | ||
} | ||
} | ||
{ | ||
"query-language": { | ||
"title": "Query language" | ||
}, | ||
"http-proxy": { | ||
"title": "Using Realm JS behind an HTTP Proxy" | ||
} | ||
} |
Oops, something went wrong.