window 下生成NodeJs(v8.9.3) 的 VS2015 解決方案node.sln


 window 下生成NodeJs(v8.9.3) 的 VS2015 解決方案node.sln

使用步驟 也可以參照 github:

https://github.com/nodejs/node/blob/master/BUILDING.md#windows-1

1. 從 github 同步 

https://github.com/nodejs/node

2.安裝 python 2.7 或者 2.6

https://www.python.org/downloads/

當然, 如果有Python 環境, 就跳過好了

3. 修改 common.gypi

因為如果 不修改的話, 會報好多錯誤的....

E:\Projects\C++\node-git\trunk\tools>gyp_node.py  -Dtarget_arch=x64 -f msvs
gyp: name 'node_shared' is not defined while evaluating condition 'node_shared=="true"' in E:\Projects\C++\node-git\trunk\node.gyp

E:\Projects\C++\node-git\trunk\tools>gyp_node.py  -Dtarget_arch=x64 -f msvs
gyp: name 'node_shared' is not defined while evaluating condition 'node_shared=="true"' in E:\Projects\C++\node-git\trunk\node.gyp

E:\Projects\C++\node-git\trunk\tools>gyp_node.py  -Dtarget_arch=x64 -f msvs
gyp: name 'node_use_openssl' is not defined while evaluating condition 'OS=="win" and node_use_openssl=="true" and node_shared_openssl=="false"' in E:\Projects\C++\node-git\trunk\node.gyp

E:\Projects\C++\node-git\trunk\tools>gyp_node.py  -Dtarget_arch=x64 -f msvs
gyp: name 'node_shared_openssl' is not defined while evaluating condition 'OS=="win" and node_use_openssl=="true" and node_shared_openssl=="false"' in E:\Projects\C++\node-git\trunk\node.gyp

E:\Projects\C++\node-git\trunk\tools>gyp_node.py  -Dtarget_arch=x64 -f msvs
gyp: name 'openssl_fips' is not defined while evaluating condition 'openssl_fips != ""' in E:\Projects\C++\node-git\trunk\node.gyp

E:\Projects\C++\node-git\trunk\tools>gyp_node.py  -Dtarget_arch=x64 -f msvs
gyp: name 'v8_enable_inspector' is not defined while evaluating condition 'v8_enable_inspector==1' in E:\Projects\C++\node-git\trunk\node.gyp

E:\Projects\C++\node-git\trunk\tools>gyp_node.py  -Dtarget_arch=x64 -f msvs
gyp: name 'node_enable_d8' is not defined while evaluating condition 'node_enable_d8=="true"' in E:\Projects\C++\node-git\trunk\node.gyp

E:\Projects\C++\node-git\trunk\tools>gyp_node.py  -Dtarget_arch=x64 -f msvs
gyp: name 'node_release_urlbase' is not defined while evaluating condition 'node_release_urlbase!=""' in E:\Projects\C++\node-git\trunk\node.gyp

E:\Projects\C++\node-git\trunk\tools>gyp_node.py  -Dtarget_arch=x64 -f msvs
gyp: name 'debug_http2' is not defined while evaluating condition 'debug_http2==1' in E:\Projects\C++\node-git\trunk\node.gyp

E:\Projects\C++\node-git\trunk\tools>gyp_node.py  -Dtarget_arch=x64 -f msvs
gyp: name 'v8_enable_i18n_support' is not defined while evaluating condition 'v8_enable_i18n_support==1' in E:\Projects\C++\node-git\trunk\node.gyp

好多變量都沒有定義.....

下面是修改的部分(紅色粗體字,變量值是我自己的缺少設置,可以改), 文件在主目錄下

{
  'variables': {
    'asan%': 0,
    'werror': '',                     # Turn off -Werror in V8 build.
    'visibility%': 'hidden',          # V8's visibility setting
    'target_arch%': 'ia32',           # set v8's target architecture
    'host_arch%': 'ia32',             # set v8's host architecture
    'want_separate_host_toolset%': 0, # V8 should not build target and host
    'library%': 'static_library',     # allow override to 'shared_library' for DLL/.so builds
    'component%': 'static_library',   # NB. these names match with what V8 expects
    'msvs_multi_core_compile': '0',   # we do enable multicore compiles, but not using the V8 way
    'python%': 'python',

    'node_shared': 'false',
    'node_enable_d8': 'false',
    'v8_enable_inspector': 1,
    'v8_enable_i18n_support': 'true',
    'debug_http2': 1,
    'debug_nghttp2': 1,
    'node_use_openssl': 'false',
    'node_shared_openssl': 'true',
    'openssl_fips': '',
    'node_release_urlbase': '',
    
    'node_shared%': 'false',
    'force_dynamic_crt%': 0,
    'node_use_v8_platform%': 'true',
    'node_use_bundled_v8%': 'true',
    'node_module_version%': '',
.....

4.修改 deps\v8\src\v8.gyp

貌似調用 deps\v8\src\v8.gyp 的時候, 有個參數沒有傳進去,target_arch的值我用的 是 'x64':

E:\Projects\C++\node-git\trunk\tools>gyp_node.py  -Dtarget_arch=x64 -f msvs
gyp: name 'debug_nghttp2' is not defined while evaluating condition 'debug_nghttp2 == 1' in E:\Projects\C++\node-git\trunk\deps\nghttp2\nghttp2.gyp
gyp: Undefined variable target_arch in E:\Projects\C++\node-git\trunk\deps\v8\src\v8.gyp

所以,手動加了這個變量

{
  'variables': {
    'target_arch': 'x64',

    'v8_code': 1,
.....

5. 生成 解決方案 

一般來說,使用 gyp 生成 VS 的解決方案的, 都是 使用類似的 命令行: 

"gyp_XXXX.py  -Dtarget_arch=x64 -f msvs"    XXXX 就是工程/解決方案名,例如 V8的 就是 gyp_V8.gyp; Node的就是gyp_node.gyp
tools>gyp_node.py  -Dtarget_arch=x64 -f msvs

 

Over!

6.如果 用 vcbuild.bat 生成, 就不會有這些錯誤

以上是直接 運行 gyp_node.py  會產生 缺少 變量,  但是 如果 用 vcbuild.bat, 就不會.  >>git上有issue說明<< ^_^


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM