You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by rg...@apache.org on 2021/08/18 19:40:53 UTC

[pulsar-client-node] branch gaoran/fix-windows-build-doc created (now 65c5573)

This is an automated email from the ASF dual-hosted git repository.

rgao pushed a change to branch gaoran/fix-windows-build-doc
in repository https://gitbox.apache.org/repos/asf/pulsar-client-node.git.


      at 65c5573  add windows building configuration in `binding.gyp`

This branch includes the following new commits:

     new 65c5573  add windows building configuration in `binding.gyp`

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[pulsar-client-node] 01/01: add windows building configuration in `binding.gyp`

Posted by rg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rgao pushed a commit to branch gaoran/fix-windows-build-doc
in repository https://gitbox.apache.org/repos/asf/pulsar-client-node.git

commit 65c557369b6a1fd06e86629379f90a7e93e7af16
Author: gaoran10 <ga...@126.com>
AuthorDate: Thu Aug 19 03:39:05 2021 +0800

    add windows building configuration in `binding.gyp`
---
 .gitignore  |  1 +
 README.md   |  5 +++++
 binding.gyp | 44 ++++++++++++++++++++++++++++++++++++++++----
 3 files changed, 46 insertions(+), 4 deletions(-)

diff --git a/.gitignore b/.gitignore
index 7a744e8..d89b6b7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -20,3 +20,4 @@
 build/
 node_modules/
 report/
+.idea
diff --git a/README.md b/README.md
index adeae3d..c890765 100644
--- a/README.md
+++ b/README.md
@@ -52,6 +52,11 @@ If an incompatible version of the C++ client is installed, you may fail to build
 
 ## How to install
 
+### Install in windows
+
+You need to clone the Pulsar repo in root path of `C:`(the Pulsar repo path will be `C:\pulsar`),
+then build the Pulsar c++ client in windows, refer to https://pulsar.apache.org/docs/en/next/client-libraries-cpp/.
+
 ### Please install pulsar-client in your project:
 
 ```shell
diff --git a/binding.gyp b/binding.gyp
index 4b7b2f4..668dd87 100644
--- a/binding.gyp
+++ b/binding.gyp
@@ -18,14 +18,24 @@
 #
 
 {
+  'conditions': [
+    ['OS=="win"', {
+      'variables': {
+        'PULSAR_CPP_PATH%': 'C:\pulsar\pulsar-client-cpp',
+      }
+    }]
+  ],
   "targets": [
     {
       "target_name": "Pulsar",
       "cflags!": ["-fno-exceptions"],
       "cflags_cc!": ["-fno-exceptions"],
-      "include_dirs": ["<!@(node -p \"require('node-addon-api').include\")"],
-      "dependencies": ["<!@(node -p \"require('node-addon-api').gyp\")"],
-      "defines": ["NAPI_DISABLE_CPP_EXCEPTIONS"],
+      "include_dirs": [
+        "<!@(node -p \"require('node-addon-api').include\")",
+        "<(PULSAR_CPP_PATH)\include",
+      ],
+      "dependencies": ["<!(node -p \"require('node-addon-api').gyp\")"],
+      "defines": ["NAPI_CPP_EXCEPTIONS"],
       "sources": [
         "src/addon.cc",
         "src/Message.cc",
@@ -39,7 +49,33 @@
         "src/Reader.cc",
         "src/ReaderConfig.cc",
       ],
-      "libraries": ["-lpulsar"],
+      'conditions': [
+        ['OS=="win"', {
+          "libraries": [
+            "-l<(PULSAR_CPP_PATH)\\build\lib\Release\pulsar.lib"
+          ],
+          "copies": [
+            {
+              "destination": "<(PRODUCT_DIR)",
+              "files": [
+                "<(PULSAR_CPP_PATH)\\build\lib\Release\pulsar.dll",
+                "<(PULSAR_CPP_PATH)\\vcpkg_installed\\x64-windows\\bin\libcurl.dll",
+                "<(PULSAR_CPP_PATH)\\vcpkg_installed\\x64-windows\\bin\libprotobuf.dll",
+                "<(PULSAR_CPP_PATH)\\vcpkg_installed\\x64-windows\\bin\libssl-1_1-x64.dll",
+                "<(PULSAR_CPP_PATH)\\vcpkg_installed\\x64-windows\\bin\libcrypto-1_1-x64.dll",
+                "<(PULSAR_CPP_PATH)\\vcpkg_installed\\x64-windows\\bin\dl.dll",
+                "<(PULSAR_CPP_PATH)\\vcpkg_installed\\x64-windows\\bin\snappy.dll",
+                "<(PULSAR_CPP_PATH)\\vcpkg_installed\\x64-windows\\bin\zlib1.dll",
+                "<(PULSAR_CPP_PATH)\\vcpkg_installed\\x64-windows\\bin\zstd.dll",
+              ]
+            }
+          ]
+        }, {  # 'OS!="win"'
+          "libraries": [
+            "-lpulsar"
+          ]
+        }]
+      ]
     }
   ]
 }