3

我正在将一个过时的 npm 包从 WAF 迁移到 GYP,但是在让一切正常工作时遇到了一些问题。它运行一个 WSCRIPT,它似乎包含一个 3rd 方库:

import Options
from os import unlink, symlink, popen, sys
from os.path import exists 

srcdir = '.'
blddir = 'build'
VERSION = '0.0.2'

def set_options(opt):
  opt.tool_options('compiler_cxx')

def configure(conf):
  conf.check_tool('compiler_cxx')
  conf.check_tool('node_addon')

  print(sys.platform)  
  if sys.platform == 'darwin':
      conf.check_tool('osx')
      tc_framework = 'TelldusCore'
      conf.env.append_value("FRAMEWORK_TC", tc_framework)
      tc_frameworkpath = '/Library/Frameworks/TelldusCore.framework/'
      conf.env.append_value("FRAMEWORKPATH_TC", tc_frameworkpath)
      tc_lib = tc_frameworkpath + 'Headers/'
      conf.env.append_value("CPPPATH_TC", tc_lib)
  elif sys.platform == 'linux2':
      conf.env.LIB_TC = 'telldus-core'
      #conf.env.LIBPATH_TC = ['/usr/lib']
      #conf.env.CCFLAGS_TC = ['-O0']
      conf.env.CCDEFINES_TC = ['TC']
      #conf.env.LINKFLAGS_TC = ['-g']
  else:
      raise ValueError("Dose not support: %r" % sys.platform)

def build(bld):
  obj = bld.new_task_gen('cxx', 'shlib', 'node_addon')
  obj.target = 'telldus'
  obj.source = 'telldus.cc'
  obj.uselib = "TC"

现在我尝试将其转换为 binding.gyp 脚本,但不确定如何包含该库:

{
  "targets": [
    {
    "target_name": "tellduscorejs2",
    "sources": [ "tellduscorejs2.cpp" ],
    "conditions": [
        ['OS=="mac"', {
            'defines': [
                'FRAMEWORK_TC=TelldusCore',
                'FRAMEWORKPATH_TC="/Library/Frameworks/TelldusCore.framework/"',
                'CPPPATH_TC="/Library/Frameworks/TelldusCore.framework/Headers/"'
            ]
        }],
        ['OS=="linux"', {
            'defines': [
                'LIB_TC=telldus-core',
                'CCDEFINES_TC=TC'
            ]
        }]
    ],
    'link_settings': {
        'libraries': [
            ???
        ],
    },
   }
  ]
}

如果有人能指出我是否在正确的路线上,或者我需要更改哪些内容以包含该库,将不胜感激!

4

1 回答 1

0

实际上,我已经为telldus-core 项目做到了这一点。见https://github.com/marchaos/telldus-core-js/

我还为设备和传感器添加了事件。

于 2012-12-14T12:17:47.360 回答