Skip to content

Commit

Permalink
Merge pull request #76 from heri16/node
Browse files Browse the repository at this point in the history
Add Node JS example
  • Loading branch information
joseph-henry authored Sep 12, 2020
2 parents 96d25e4 + 57f7799 commit d43b92f
Show file tree
Hide file tree
Showing 14 changed files with 2,686 additions and 5 deletions.
11 changes: 6 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -426,13 +426,14 @@ set_target_properties (ztcore PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${INTERMEDIATE_LIBRARY_OUTPUT_PATH})

# libzt.a
add_library (${STATIC_LIB_NAME} STATIC $<TARGET_OBJECTS:libzt_obj>
$<TARGET_OBJECTS:zto_obj>
$<TARGET_OBJECTS:libnatpmp_obj>
$<TARGET_OBJECTS:miniupnpc_obj>
$<TARGET_OBJECTS:lwip_obj> ${libztSrcGlob})
add_library (${STATIC_LIB_NAME} STATIC $<TARGET_OBJECTS:zt_pic>
$<TARGET_OBJECTS:zto_pic>
$<TARGET_OBJECTS:natpmp_pic>
$<TARGET_OBJECTS:miniupnpc_pic>
$<TARGET_OBJECTS:lwip_pic> ${libztSrcGlob})
set_target_properties (${STATIC_LIB_NAME} PROPERTIES
OUTPUT_NAME zt
POSITION_INDEPENDENT_CODE ON
LIBRARY_OUTPUT_DIRECTORY ${INTERMEDIATE_LIBRARY_OUTPUT_PATH})
set_target_properties (${STATIC_LIB_NAME} PROPERTIES COMPILE_FLAGS "${ZT_FLAGS}")
if (BUILDING_WIN)
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ To build both `release` and `debug` libraries for only your host's architecture

```
make update; make patch; make host
# OR
brew install cmake
make clean; make update && make patch && make host_release CC=clang CXX=clang++
```

Typical build output:
Expand Down
2 changes: 2 additions & 0 deletions examples/node/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/.zerotier
/libzt
35 changes: 35 additions & 0 deletions examples/node/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
## Building from source

The npm install script will attempt to statically link to `libzt.a`.

You first need `Cmake` to build the fPIC-version of the `libzt.a` library.

To build both `release` and `debug` libraries for only your host's architecture use `make host`. Or optionally `make host_release` for release only. To build everything including things like iOS frameworks, Android packages, etc, use `make all`. Possible build targets can be seen by using `make list`. Resultant libraries will be placed in `/lib`:

```
brew install cmake
(cd ../.. ; make clean; make update && make patch && make host_release CC=clang CXX=clang++)
npm install
npm start
```

Typical build output:

```
lib
├── release
| └── linux-x86_64
| ├── libzt.a
| └── libzt.so
| └── macos-x86_64
| ├── libzt.a
└── debug
└── ...
```

## Licensing

ZeroTier is licensed under the BSL version 1.1. See [LICENSE.txt](./LICENSE.txt) and the ZeroTier pricing page for details. ZeroTier is free to use internally in businesses and academic institutions and for non-commercial purposes. Certain types of commercial use such as building closed-source apps and devices based on ZeroTier or offering ZeroTier network controllers and network management as a SaaS service require a commercial license.

A small amount of third party code is also included in ZeroTier and is not subject to our BSL license. See [AUTHORS.md](ext/ZeroTierOne/AUTHORS.md) for a list of third party code, where it is included, and the licenses that apply to it. All of the third party code in ZeroTier is liberally licensed (MIT, BSD, Apache, public domain, etc.). If you want a commercial license to use the ZeroTier SDK in your product contact us directly via [contact@zerotier.com](mailto:contact@zerotier.com)

8 changes: 8 additions & 0 deletions examples/node/auto-top.gypi
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Automatically generated file. Edits will be lost.
# Based on: autogypi.json

{
"includes": [
"node_modules/nbind/src/nbind-common.gypi"
]
}
11 changes: 11 additions & 0 deletions examples/node/auto.gypi
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Automatically generated file. Edits will be lost.
# Based on: autogypi.json

{
"include_dirs": [
"node_modules/nan"
],
"includes": [
"node_modules/nbind/src/nbind.gypi"
]
}
6 changes: 6 additions & 0 deletions examples/node/autogypi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"dependencies": [
"nbind"
],
"includes": []
}
Loading

0 comments on commit d43b92f

Please sign in to comment.