nodejs 编译debug

下载源码

遇到问题

1.按照文章上来说,执行vsbuild.bat,set PYTHON=c:\python27\python.exe",但是没有任何反应,并且没有错误显示
注释掉 vsbuild.bat第一行
@echo off发现,错误是执行到run-python`,顺藤摸瓜脚本第550行,找到tools\msvs\find_python.cmd

  1. 直接运行find_python.cmd,发现什么反应都没有,同样注释掉第一行
    打印出"C:\Program Files\Python35\python.exe" -V 2>&1 | findstr /R "^Python.2.*" 1>NUL
    可以找错了
    所以直接改
FOR /F "delims=" %%a IN ('where python 2^> NUL') DO (  
  SET need_path=0
  SET p=%%~dpa
  IF NOT ERRORLEVEL 1 GOTO :validate
)

改为 
FOR /F "delims=" %%a IN ('where python 2^> NUL') DO (  
  SET need_path=0
  SET p="c:\Python27\"
  IF NOT ERRORLEVEL 1 GOTO :validate
)


运行成功

3.再次运行vsbuild.bat

creating config.gypi  
Traceback (most recent call last):  
  File "configure", line 1461, in <module>
    bin_override = get_bin_override()
  File "configure", line 1374, in get_bin_override
    os.symlink(sys.executable, python_link)
AttributeError: 'module' object has no attribute 'symlink'  
Failed to create vc project files.  

看到错猜是python os没有找到symlink方法

  1. 顺势找到该函数所在文件 configure
def get_bin_override():  
  # If the system python is not the python we are running (which should be
  # python 2), then create a directory with a symlink called `python` to our
  # sys.executable. This directory will be prefixed to the PATH, so that
  # other tools that shell out to `python` will use the appropriate python

  if os.path.realpath(which('python')) == os.path.realpath(sys.executable):
    return
  ...
  os.symlink(sys.executable, python_link)
  ...
  return bin_override


看注释和首行代码,Python路径应该都是一致的,怎么会问题?

//添加打印
print os.path.realpath(which('python'))  
print os.path.realpath(sys.executable)  

//最终显示  
C:\Python27\python.exe  
c:\Python27\python.exe  


所以把上面的find_python.cmd中的c盘改成大写就可以了