Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
A
ademco_hb
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
ademco_hb
Commits
2aa66343
Commit
2aa66343
authored
Jun 05, 2023
by
captainwong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ubuntu 20.04 rum node-demo ok
parent
375d86bf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
0 deletions
+43
-0
README.md
swig/README.md
+40
-0
nodejs-demo.js
swig/nodejs-demo.js
+3
-0
No files found.
swig/README.md
View file @
2aa66343
...
...
@@ -61,3 +61,43 @@ brew install swig
4. 运行示例
`node nodejs-demo.js`
### Ubuntu20.04
#### 1. 更新 `swig`
`apt` 安装的 `swig` 版本是 `4.0.1`不匹配,需要卸载后编译安装.
```
bash
apt update -y
# 卸载旧版 swig
apt purge swig -y
# 安装依赖库
apt install libpcre2-dev libbison-dev -y
# 下载解压 swig 4.1.1
wget https://sourceforge.net/projects/swig/files/swig/swig-4.1.1/swig-4.1.1.tar.gz/download -Oswig-4.1.1.tar.gz
tar -xzf swig-4.1.1.tar.gz
# 编译
cd swig-4.1.1
mkdir build && cd build
cmake ..
make && make install
```
#### 2. 安装 `node`
```
bash
curl -sL https://deb.nodesource.com/setup_18.x -o /tmp/nodesource_setup.sh
bash /tmp/nodesource_setup.sh
sudo apt-get install -y nodejs
npm install -g node-gyp
```
#### 3. 生成 `libademco_js.node` 动态库
```
bash
# cd /path/to/ademco_hb/swig
node-gyp configure build
# node nodejs-demo.js
```
\ No newline at end of file
swig/nodejs-demo.js
View file @
2aa66343
const
assert
=
require
(
'assert'
);
// windows:
const
libademco
=
require
(
'./build/Release/libademco_js'
);
// linux:
// const libademco = require('./build/Release/ademco_js');
libademco
.
ademcoPrint
(
"hello nodejs"
,
"hello nodejs"
.
length
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment