Skip to content
This repository was archived by the owner on Aug 9, 2021. It is now read-only.

Commit 81c141e

Browse files
authored
Qode v2.0 - Remove Qt dependency from Qode (#15)
* upgrade qode node to v13.x * no qt * update node git * Removes all qt references and lib dependencies from qode * upgrade node to v12.16 * update readme and node submodule head * update readme * change node to v12.11.0 * Update readme and remove default custom runloop * Adds a way for nodegui_core to call uvLooper * upgrade node to v12.11.0 * Bump node to v13.8.0 with small icu * Adds current executable path detection * fix linux * Adds basic startFile reading * startFile reading enabled * Updates readme * Fix windows qode build with qode config * fix linux build * bump node to v13.9.0 * Adds new qode downloader * adds a basic release builder (need to check if this works) * fix version string * Adds additional check before extracting or downloading qode * fix tag * fix * add branch * Update prebuild.yml * Update prebuild.yml * Update prebuild.yml * Update prebuild.yml * Update prebuild.yml * Update prebuild.yml * Update prebuild.yml * Update prebuild.yml * Update prebuild.yml * Update prebuild.yml * update build yamls * update to tar-action * remove consolidation * fix cwd * update tar action
1 parent cc8a49b commit 81c141e

40 files changed

Lines changed: 23474 additions & 1041 deletions

.github/workflows/linux.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
on:
2+
release:
3+
types: [created]
4+
jobs:
5+
build:
6+
runs-on: ubuntu-18.04
7+
steps:
8+
- uses: actions/setup-node@master
9+
with:
10+
node-version: "13.x"
11+
- name: Ubuntu dependencies
12+
run: sudo apt-get install libgtk-3-dev
13+
14+
- uses: actions/checkout@v2
15+
with:
16+
ref: ${{ github.ref }}
17+
18+
- name: Build Qode binary
19+
run: node build.js
20+
env:
21+
SYNC_GIT_SUBMODULE: 1
22+
23+
- name: Compress files
24+
uses: master-atul/tar-action@v1.0.2
25+
with:
26+
command: c
27+
cwd: ./node/out/Release
28+
files: |
29+
./qode
30+
outPath: qode-linux-x64-${{github.event.release.tag_name}}.tar.gz
31+
32+
- name: Release
33+
uses: softprops/action-gh-release@master
34+
with:
35+
files: qode-*.tar.gz
36+
tag_name: ${{ github.event.release.tag_name }}
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/mac.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
on:
2+
release:
3+
types: [created]
4+
jobs:
5+
build:
6+
runs-on: macos-latest
7+
steps:
8+
- uses: actions/setup-node@master
9+
with:
10+
node-version: "13.x"
11+
- uses: actions/checkout@v2
12+
with:
13+
ref: ${{ github.ref }}
14+
15+
- name: Build Qode binary
16+
run: node build.js
17+
env:
18+
SYNC_GIT_SUBMODULE: 1
19+
20+
- name: Compress files
21+
uses: master-atul/tar-action@v0.0.1
22+
with:
23+
command: c
24+
cwd: ./node/out/Release
25+
files: |
26+
./qode
27+
outPath: qode-darwin-x64-${{github.event.release.tag_name}}.tar.gz
28+
29+
- name: Release
30+
uses: softprops/action-gh-release@master
31+
with:
32+
files: qode-*.tar.gz
33+
tag_name: ${{ github.event.release.tag_name }}
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/windows.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
on:
2+
release:
3+
types: [created]
4+
jobs:
5+
build:
6+
runs-on: windows-2016
7+
steps:
8+
- uses: actions/setup-node@master
9+
with:
10+
node-version: "13.x"
11+
- name: "Setup NASM for windows"
12+
uses: ilammy/setup-nasm@v1
13+
- name: Install Python2 for windows
14+
uses: actions/setup-python@v1
15+
with:
16+
python-version: '2.x'
17+
18+
- uses: actions/checkout@v2
19+
with:
20+
ref: ${{ github.ref }}
21+
22+
- name: Build Qode binary
23+
run: node build.js
24+
env:
25+
SYNC_GIT_SUBMODULE: 1
26+
27+
- name: Compress files
28+
uses: master-atul/tar-action@v0.0.1
29+
id: compress
30+
with:
31+
command: c
32+
cwd: ./node/out/Release
33+
files: |
34+
./qode.exe
35+
./qode.lib
36+
./qode.exp
37+
outPath: qode-win32-x64-${{github.event.release.tag_name}}.tar.gz
38+
39+
- name: Release
40+
uses: softprops/action-gh-release@master
41+
with:
42+
files: qode-*.tar.gz
43+
tag_name: ${{ github.event.release.tag_name }}
44+
env:
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 47 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
11
# Qode
22

3-
Qode is a lightly modified fork of Node.js that merges Node's event loop with Qt's event loop.
4-
It is designed to be used together with `@nodegui/nodegui`.
3+
Qode is a lightly modified fork of Node.js that allows Node's event loop to be merged with Qt's or any other Gui event loop.
4+
It is designed to be used together with `@nodegui/nodegui`. Qode achieves this by allowing message loop injection via a NodeJS addon.
55

66
<img alt="logo" src="https://github.com/nodegui/nodegui/raw/master/extras/logo/nodegui.png" height="200" />
77

8+
9+
## Changes in v2.0
10+
11+
> In version 2.0, Qode no longer depends on Qt as a dependency.
12+
>
13+
> This makes it easier to upgrade Qt and also allows devs to use their own version of Qt. Technically this means its possible to integrate with another Gui system (not Qt) aswell.
14+
>
15+
> Another benefit is that it helps in avoiding issues with 3rd party plugin development because of qt version mismatch.
16+
>
17+
> Now, Qode essentially becomes nodejs + `<some code changes to allow message loop injection via an addon>`
18+
19+
820
### Note:
921

1022
Qode is published as a NPM module as `@nodegui/qode`.
1123
For more details on the npm module visit: `npm/README.md`
24+
The changes to node are visible in the `qode-v12.x` branches in `https://github.com/nodegui/node`
1225

1326
## Changes to Node.js
1427

15-
- The event loop is replaced with QT's GUI message loop.
16-
- The process will quit when **BOTH** the QT message loop and Node.js event
17-
loop have quit. So if there are still Node.js requests pending, the process
18-
will wait until all of them have finished.
19-
- There are new `process.versions.qode` property added - This mentions the qode version.
20-
- There are new `process.versions.qt(runtime)` property added - This mentions the version of qt shared library you are using on runtime.
21-
- There are new `process.versions.qt(compiled)` property added - This mentions the version of qt used while compiling qode. Ideally both runtime and compile time versions should be same but binary compatible versions could work too.
22-
- Make sure to use a binary compatible version of nodejs when using alongside qode. For example is qode has node version of 12.x then use Node version 12.x when developing apps with qode.
28+
- The event loop remains the same as that of NodeJs until a new Gui message loop is injected via the qode api. See below for details on the api.
29+
- When a Gui message loop is injected, qode will use it as the primary event loop and will process NodeJs requests on the main thread as an when it arrives by listening to the libuv's events.
30+
- Note: Make sure to use a binary compatible version of nodejs when using alongside qode. For example is qode has node version of 12.x then use Node version 12.x when developing apps with qode.
2331

2432
Currently only 64bit OS's are supported.
2533

@@ -31,11 +39,9 @@ Use Powershell in windows (possibly with git bash or similar installed)
3139

3240
1. Do a git clone for this repo
3341

34-
2. Install Visual Studio Community 2017. Download the Visual studio Installer and install Visual Studio Community 2017. Make sure to choose "Desktop development with C++ " workload and install it. PS: Visual Studio 2019 will not work since NodeJS build toolchain doesnt support it aswell.
35-
36-
3. Installing QT. Download qt from: https://www.qt.io (5.x version)
42+
2. Install Visual Studio Community 2017. Download the Visual studio Installer and install Visual Studio Community 2017/2019. Make sure to choose "Desktop development with C++ " workload and install it.
3743

38-
4. Building Qode. Run `cmd /C "set QT_INSTALL_DIR=C:\path\to\qt\5.13.0\msvc2017_64&& node build.js"`
44+
3. Building Qode. Run `node build.js`
3945

4046
## Steps for Linux
4147

@@ -49,73 +55,35 @@ Use Powershell in windows (possibly with git bash or similar installed)
4955
sudo apt install libgtk-3-dev patchelf
5056
```
5157

52-
3. Installing QT.
53-
54-
- Download qt from: https://www.qt.io/offline-installers (Preferably 5.x version)
55-
- chmod a+x qt-opensource-linux-x64-5.12.4.run
56-
- ./qt-opensource-linux-x64-5.12.4.run
57-
- Click Next -> I accept checkbox and then Skip.
58-
- Make sure you note down the install path. Also make sure there are no spaces in the path.
59-
- From the list to choose components: - Check Desktop gcc 64bit and Qt Creator (Optional)
60-
- Choose LGPL license and install.
61-
62-
**or**
63-
64-
- You can even build from source. Just download qt-everywhere source code of the version of the QT you want to build and do a standard make build.
65-
66-
4. Building Qode. Run `QT_INSTALL_DIR=<path_to_qt_install_dir>/5.12.4/gcc_64 node build.js`
58+
3. Building Qode. Run `node build.js`
6759

6860
## Steps for MacOS
6961

7062
==================
7163

7264
1. Do a git clone for this repo
7365

74-
2. Installing QT.
75-
76-
- Download qt from: https://www.qt.io/offline-installers (Preferably 5.x version)
77-
- Install from the downloaded dmg.
78-
- Click Next -> I accept checkbox and then Skip.
79-
- Make sure you note down the install path. Also make sure there are no spaces in the path.
80-
- From the list to choose components: - Check Desktop gcc 64bit and Qt Creator (Optional)
81-
- Choose LGPL license and install.
82-
83-
**or**
84-
85-
- You can even build from source. Just download qt-everywhere source code of the version of the QT you want to build and do a standard make build.
86-
87-
3. Building Qode. Run `QT_INSTALL_DIR=/path/to/qt/5.13.0 node build.js`
66+
2. Building Qode. Run `node build.js`
8867

8968
### Common build errors:
9069

9170
1. if you get an error similar to:
9271

93-
```
94-
../../src/qode.h:5:10: fatal error: QApplication: No such file or directory
95-
#include <QApplication>
96-
^~~~~~~~~~~~~~
97-
```
98-
99-
Make sure you have installed QT5 and have specified the correct path in QT_INSTALL_DIR as mentioned above
100-
101-
2. if you get an error similar to:
102-
10372
```
10473
fatal error: gtk/gtk.h: No such file or directory
10574
#include <gtk/gtk.h>
10675
```
10776

10877
Make sure you have installed gtk headers as mentioned above.
10978

110-
3. If you get an error similar to:
111-
./qode: error while loading shared libraries: libQt5Core.so.5: cannot open shared object file: No such file or directory.
79+
2. If you get an error similar to:
80+
./qode: error while loading shared libraries: cannot open shared object file: No such file or directory.
11281

11382
Check the shared libraries used by qode by running `ldd ./qode`. Then you can provide the path where qode could find the libraries like this:
11483

115-
`LD_LIBRARY_PATH=<path_to_qt5_installation>/5.12.4/gcc_64/lib/:$LD_LIBRARY_PATH ./qode`
84+
`LD_LIBRARY_PATH=<path_to_lib>:$LD_LIBRARY_PATH ./qode`
11685

11786
And make sure you have installed gtk3 headers also for time being.
118-
Make sure you add LD_LIBRARY_PATH to the path to qt and then run the built executable
11987

12088
4. Yoga crashes when using with Qode. Make sure that node version you are using to compile nodegui is binary compatible with node version of Qode. or make sure you compile addons with Qode instead of Node.
12189

@@ -131,18 +99,18 @@ correctly in qode.
13199
## Build
132100

133101
```bash
134-
QT_INSTALL_DIR=<path_to_qt_install_directory> TARGET_ARCH=[x64|ia32] HOST_ARCH=[x64|ia32] node ./build.js
102+
TARGET_ARCH=[x64|ia32] HOST_ARCH=[x64|ia32] node ./build.js
135103
```
136104

137105
or
138106

139107
```
140-
`cmd /C "set QT_INSTALL_DIR=<path_to_qt_install_directory> && set TARGET_ARCH=[x64|ia32] && set HOST_ARCH=[x64|ia32] && node build.js"`
108+
`cmd /C "set TARGET_ARCH=[x64|ia32] && set HOST_ARCH=[x64|ia32] && node build.js"`
141109
```
142110

143111
_PS: I havent tested ia32 builds_
144112

145-
The output of the build will be present at qode/node/out/Release/<platform> (platform is darwin, win32 or linux)
113+
The output of the build will be present at node/out/Release/qode
146114

147115
## Configurations (Available from qode v1.0.3)
148116

@@ -152,16 +120,32 @@ Additional configurations can be done via a qode.json file in the same directory
152120

153121
```javascript
154122
{
155-
libraryPaths: [], //Specify extra library paths to load dlls from
156-
hideConsole: false, //If true it will hide the console window as soon as application is launched.
157-
distPath: "./dist/index.js" // This will try to load the index.js inside dist folder when qode.exe is run. Internally it just adds NODE_OPTIONS="--require ./dist/index.js"
123+
distPath: "./dist/index.js" // This will try to load the index.js inside dist folder when qode.exe is run.
158124
}
159125
```
160126

161127
## Troubleshooting
162128

163129
- If you face `python cant open file 'configure'` - This means the git submodules have not been synced. So either manually sync your git submodules or set the environment variable SYNC_GIT_SUBMODULE=true before running build. See https://github.com/nodegui/qode/issues/7
164130

131+
## Message Loop injection api
132+
133+
The NodeGui core addon uses the following api exposed by qode binary to inject Qt's event loop into nodejs
134+
135+
https://github.com/nodegui/node/blob/43e31129fc27f738b171dca3d744a0e4245dcc6d/src/qode_shared.h#L12
136+
137+
```c++
138+
namespace qode {
139+
extern int qode_argc;
140+
extern char **qode_argv;
141+
typedef bool (*QodeInjectedRunLoopFunc)();
142+
extern QodeInjectedRunLoopFunc qode_run_uv_loop_once;
143+
extern QodeInjectedRunLoopFunc qode_run_gui_loop;
144+
extern void InjectQodeRunLoop(QodeInjectedRunLoopFunc runLoop);
145+
extern void InjectQodeRunUvLoopOnce(QodeInjectedRunLoopFunc runUvLoopOnce);
146+
} // namespace qode
147+
```
148+
165149
## License
166150
167151
The MIT license.

build.js

Lines changed: 4 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -26,68 +26,25 @@ const checkEnvExists = (envVarName, defaultValue) => {
2626
return value;
2727
};
2828

29-
const runPreBuild = qtPath => {
30-
let command = "";
31-
switch (process.platform) {
32-
case "win32":
33-
command = `"${__dirname}\\deploy\\win32\\prebuild.bat"`;
34-
break;
35-
case "linux":
36-
command = `${__dirname}/deploy/linux/prebuild.sh`;
37-
break;
38-
case "darwin":
39-
command = `${__dirname}/deploy/darwin/prebuild.sh`;
40-
break;
41-
}
42-
const env = Object.assign({}, process.env, { QT_INSTALL_DIR: qtPath });
43-
execSync(command, { env });
44-
};
45-
46-
const runPostBuild = qtPath => {
47-
let command = "";
48-
switch (process.platform) {
49-
case "win32":
50-
command = `${__dirname}\\deploy\\win32\\postbuild.bat`;
51-
break;
52-
case "linux":
53-
command = `${__dirname}/deploy/linux/postbuild.sh`;
54-
break;
55-
case "darwin":
56-
command = `${__dirname}/deploy/darwin/postbuild.sh`;
57-
break;
58-
}
59-
const env = Object.assign({}, process.env, { QT_INSTALL_DIR: qtPath });
60-
execSync(command, { env });
61-
};
62-
6329
//==================================
6430
// BUILD PROCESS
6531
//==================================
6632
// Specify target_arch.
6733
const target_arch = checkEnvExists("TARGET_ARCH", "x64");
6834
const host_arch = checkEnvExists("HOST_ARCH", "x64");
69-
const qt_install_dir = checkEnvExists(
70-
"QT_INSTALL_DIR",
71-
"/usr/local/Cellar/qt/5.12.3"
72-
);
73-
74-
runPreBuild(qt_install_dir);
7535

7636
if (process.env.SYNC_GIT_SUBMODULE) {
7737
// Sync submodule.
7838
execSync("git submodule sync --recursive", { stdio: null });
7939
execSync("git submodule update --init --recursive", { stdio: null });
8040
}
8141
// Generate some dynamic gyp files.
82-
execSync(
83-
`python configure --dest-cpu=${target_arch}`,
84-
{
85-
cwd: "node"
86-
}
87-
);
42+
execSync(`python configure --dest-cpu=${target_arch} --with-intl=small-icu`, {
43+
cwd: "node"
44+
});
8845
// Update the build configuration.
8946
execSync(
90-
`python tools/gyp/gyp_main.py ../qode.gyp -f ninja -Dhost_arch=${host_arch} -Dtarget_arch=${target_arch} -Dqt_home_dir=${qt_install_dir} -I../config/node_overrides.gypi --depth .`,
47+
`python tools/gyp/gyp_main.py ../qode.gyp -f ninja -Dhost_arch=${host_arch} -Dtarget_arch=${target_arch} -I../config/node_overrides.gypi --depth .`,
9148
{
9249
cwd: "node"
9350
}
@@ -102,5 +59,3 @@ execSync(`ninja -j8 -C out/Release qode`, {
10259
cwd: "node",
10360
env: { PATH: epath }
10461
});
105-
106-
runPostBuild(qt_install_dir);

0 commit comments

Comments
 (0)