Created
December 22, 2010 18:27
-
-
Save mhevery/751883 to your computer and use it in GitHub Desktop.
pHash for Node
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <v8.h> | |
#include <pHash.h> | |
using namespace v8; | |
extern "C" void | |
init (Handle<Object> target) | |
{ | |
HandleScope scope; | |
target->Set(String::New("hello"), String::New("world")); | |
ulong64 hash; | |
char* filename = "/Users/misko/Pictures/Me.jpg"; | |
ph_dct_imagehash(filename, hash); | |
target->Set(String::New("hash"), String::New("123")); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ node-waf -vvv configure build | |
Checking for program g++ or c++ : /usr/bin/g++ | |
19:26:16 ccroot dest platform: darwin ? x86_64 | |
Checking for program cpp : /usr/bin/cpp | |
Checking for program ar : /usr/bin/ar | |
Checking for program ranlib : /usr/bin/ranlib | |
19:26:16 action | |
def f(task): | |
env = task.env | |
wd = getattr(task, 'cwd', None) | |
def to_list(xx): | |
if isinstance(xx, str): return [xx] | |
return xx | |
lst = [] | |
lst.extend(to_list(env['CXX'])) | |
lst.extend(to_list(env['CXXFLAGS'])) | |
lst.extend(to_list(env['CPPFLAGS'])) | |
lst.extend(to_list(env['_CXXINCFLAGS'])) | |
lst.extend(to_list(env['_CXXDEFFLAGS'])) | |
lst.extend(to_list(env['CXX_SRC_F'])) | |
lst.extend([a.srcpath(env) for a in task.inputs]) | |
lst.extend(to_list(env['CXX_TGT_F'])) | |
lst.extend([a.bldpath(env) for a in task.outputs]) | |
lst = [x for x in lst if x] | |
return task.exec_command(lst, cwd=wd) | |
19:26:16 action | |
def f(task): | |
env = task.env | |
wd = getattr(task, 'cwd', None) | |
def to_list(xx): | |
if isinstance(xx, str): return [xx] | |
return xx | |
lst = [] | |
lst.extend(to_list(env['LINK_CXX'])) | |
lst.extend(to_list(env['CXXLNK_SRC_F'])) | |
lst.extend([a.srcpath(env) for a in task.inputs]) | |
lst.extend(to_list(env['CXXLNK_TGT_F'])) | |
lst.append(task.outputs[0].abspath(env)) | |
lst.extend(to_list(env['LINKFLAGS'])) | |
lst = [x for x in lst if x] | |
return task.exec_command(lst, cwd=wd) | |
Checking for g++ : ok | |
Checking for node path : ok /Users/misko/.node_libraries | |
Checking for node prefix : ok /usr/local/Cellar/node3/0.3.1 | |
Checking for library pHash : 19:26:16 build Build cache loading failed | |
19:26:16 build srcnode is .conf_check_0 and srcdir /Users/misko/work/node-phash/build/.conf_check_0 | |
19:26:16 build init variants | |
19:26:16 build list of variants is ['default'] | |
19:26:16 build compile called | |
19:26:16 build delayed operation TaskGen.flush() called | |
19:26:16 task_gen posting objects (normal) | |
19:26:16 group group None | |
19:26:16 group <task_gen 'testprog' of type task_gen defined in dir:///Users/misko/work/node-phash/build/.conf_check_0> | |
19:26:16 task_gen posting <task_gen 'testprog' of type task_gen defined in dir:///Users/misko/work/node-phash/build/.conf_check_0> 7615312 | |
19:26:16 task_gen -> exec_rule (7615312) | |
19:26:16 task_gen -> default_cc (7615312) | |
19:26:16 task_gen -> vars_target_cprogram (7615312) | |
19:26:16 task_gen -> apply_core (7615312) | |
19:26:16 task_gen -> apply_bundle (7615312) | |
19:26:16 task_gen -> apply_link (7615312) | |
19:26:16 task_gen -> create_task_macapp (7615312) | |
19:26:16 task_gen -> add_extra_flags (7615312) | |
19:26:16 task_gen -> init_cxx (7615312) | |
19:26:16 task_gen -> apply_type_vars (7615312) | |
19:26:16 task_gen -> set_macosx_deployment_target (7615312) | |
19:26:16 task_gen -> apply_lib_vars (7615312) | |
19:26:16 task_gen -> apply_framework (7615312) | |
19:26:16 task_gen -> apply_objdeps (7615312) | |
19:26:16 task_gen -> apply_incpaths (7615312) | |
19:26:16 task_gen -> apply_obj_vars_cxx (7615312) | |
19:26:16 task_gen -> default_link_install (7615312) | |
19:26:16 task_gen -> create_task_macplist (7615312) | |
19:26:16 task_gen -> apply_obj_vars (7615312) | |
19:26:16 task_gen -> apply_defines_cxx (7615312) | |
19:26:16 task_gen -> apply_verif (7615312) | |
19:26:16 task_gen posted testprog | |
19:26:16 build executor starting | |
19:26:16 envhash '\x00\x85\xf8\x02\xb2Z4\x9d\x8e\x977\xb4.\xc2<\xcd' ["['/usr/bin/g++']", "['-g']", '[]', '[]', '[]', '', "['-c', '-o', '']", '[]'] | |
19:26:16 ccroot _scan_preprocessor(self, node, env, path_lst) | |
19:26:16 preproc scanning test.cpp (in .conf_check_0) | |
19:26:16 preproc reading file '/Users/misko/work/node-phash/build/.conf_check_0/test.cpp' | |
19:26:16 deps deps for src:///Users/misko/work/node-phash/build/.conf_check_0/test.cpp: []; unresolved [] | |
19:26:16 deps scanner for cxx: build/.conf_check_0/test.cpp -> build/.conf_check_0/testbuild/default/test_1.o | |
returned [] [] | |
19:26:16 task task | |
{task: cxx test.cpp -> test_1.o} must run as it was never run before or the task code changed | |
19:26:16 runner system command -> ['/usr/bin/g++', '-g', '../test.cpp', '-c', '-o', 'default/test_1.o'] | |
19:26:17 envhash '\xd2\xf8\x04W+2\xbas\xc8\tc\xb2X9\x814' ["['/usr/bin/g++']", '', "['-o', '']", "['', '-lpHash']"] | |
19:26:17 task task | |
{task: cxx_link test_1.o -> testprog} must run as it was never run before or the task code changed | |
19:26:17 runner system command -> ['/usr/bin/g++', 'default/test_1.o', '-o', '/Users/misko/work/node-phash/build/.conf_check_0/testbuild/default/testprog', '-lpHash'] | |
not found | |
'configure' finished successfully (2.253s) | |
19:26:17 env {'files': [], 'commands': {'dist': 0, 'configure': True, 'distcheck': 0, 'install': 0, 'build': True, 'clean': 0, 'distclean': 0, 'check': 0, 'uninstall': 0}, 'hash': 0, 'argv': ['/usr/local/Cellar/node3/0.3.1/bin/node-waf', '-vvv', 'configure', 'build'], 'options': {'compile_targets': None, 'force': False, 'verbose': 3, 'nocache': False, 'progress_bar': 0, 'destdir': '', 'keep': False, 'zones': '', 'blddir': '', 'prefix': '/usr/local/', 'srcdir': '', 'jobs': 2, 'check_cxx_compiler': 'g++'}, 'blddir': '/Users/misko/work/node-phash/build', 'environ': {'LANG': 'en_US.UTF-8', 'TERM': 'xterm-color', 'SHELL': '/bin/bash', 'SHLVL': '1', 'PYTHONPATH': '/Library/GoogleCorpSupport/Python/2.5', 'OLDPWD': '/Users/misko/work', 'SSH_AUTH_SOCK': '/tmp/launch-MQO5Jg/Listeners', 'TERM_PROGRAM_VERSION': '273', '__CF_USER_TEXT_ENCODING': '0x37C9:0:0', 'PWD': '/Users/misko/work/node-phash', 'Apple_PubSub_Socket_Render': '/tmp/launch-uqBuxJ/Render', 'LOGNAME': 'misko', 'USER': 'misko', 'MANPATH': '/opt/local/share/man:', 'PATH': '/opt/local/bin:/opt/local/sbin:/usr/local/Cellar/node3/0.3.1/bin:.:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/bin/g4bin:/usr/local/git/bin:/usr/local/sbin:/usr/X11/bin', 'HOME': '/Users/misko', 'COMMAND_MODE': 'unix2003', '_': '/usr/local/Cellar/node3/0.3.1/bin/node-waf', 'DISPLAY': '/tmp/launch-hNXuat/org.macosforge.xquartz:0', 'TMPDIR': '/var/folders/++/+++rmE++6+0++4RjPqRgNE++BwY/-Tmp-/', 'TERM_PROGRAM': 'Apple_Terminal'}, 'srcdir': '/Users/misko/work/node-phash', 'cwd': '/Users/misko/work/node-phash'} | |
19:26:17 env {'version': 1069078, 'tools': [{'tool': 'ar', 'tooldir': None, 'funs': None}, {'tool': 'cxx', 'tooldir': None, 'funs': None}, {'tool': 'gxx', 'tooldir': None, 'funs': None}, {'tool': 'compiler_cxx', 'tooldir': None, 'funs': None}, {'tool': 'osx', 'tooldir': None, 'funs': None}, {'tool': 'node_addon', 'tooldir': None, 'funs': None}]} | |
19:26:17 build srcnode is node-phash and srcdir /Users/misko/work/node-phash | |
19:26:17 build init variants | |
19:26:17 build list of variants is [] | |
19:26:17 env {'CCFLAGS_MACBUNDLE': ['-fPIC'], 'program_PATTERN': '%s', 'CPPPATH_NODE': '/usr/local/Cellar/node3/0.3.1/include/node', 'CXX_SRC_F': '', 'LIBPATH_ST': '-L%s', 'DEST_CPU': 'x86_64', 'CXXFLAGS': ['-g'], 'CPPFLAGS_NODE': ['-D_GNU_SOURCE', '-DEV_MULTIPLICITY=0'], 'LIBPATH_NODE': '/usr/local/Cellar/node3/0.3.1/lib', 'CPP': '/usr/bin/cpp', 'ARFLAGS': 'rcs', 'SHLIB_MARKER': '', 'CXXFLAGS_DEBUG': ['-g'], 'CPPPATH_ST': '-I%s', 'LIBDIR': '/Users/misko/.node_libraries', 'SONAME_ST': '', 'STATICLIB_ST': '-l%s', 'PREFIX_NODE': '/usr/local/Cellar/node3/0.3.1', 'RPATH_ST': '-Wl,-rpath,%s', 'CC_VERSION': ('4', '2', '1'), 'LIB_ST': '-l%s', 'CXX_TGT_F': ['-c', '-o', ''], 'CXXLNK_SRC_F': '', 'FULLSTATIC_MARKER': '-static', 'LINK_CXX': ['/usr/bin/g++'], 'CXXLNK_TGT_F': ['-o', ''], 'CXXFLAGS_RELEASE': ['-O2'], 'STATICLIB_MARKER': '', 'RANLIB': '/usr/bin/ranlib', 'AR': '/usr/bin/ar', 'staticlib_PATTERN': 'lib%s.a', 'staticlib_LINKFLAGS': [], 'CXXDEFINES_ST': '-D%s', 'shlib_LINKFLAGS': ['-dynamiclib'], 'CXXFLAGS_NODE': ['-D_LARGEFILE_SOURCE', '-D_FILE_OFFSET_BITS=64'], 'CXX_NAME': 'gcc', 'LINKFLAGS_MACBUNDLE': ['-bundle', '-undefined', 'dynamic_lookup'], 'CXX': ['/usr/bin/g++'], 'COMPILER_CXX': 'g++', 'STATICLIBPATH_ST': '-L%s', 'PREFIX': '/usr/local', 'DEST_OS': 'darwin', 'NODE_PATH': '/Users/misko/.node_libraries', 'shlib_CXXFLAGS': ['-fPIC', '-compatibility_version', '1', '-current_version', '1'], 'shlib_PATTERN': 'lib%s.dylib', 'macbundle_PATTERN': '%s.bundle', 'CCFLAGS': ['-g'], 'CCFLAGS_NODE': ['-D_LARGEFILE_SOURCE', '-D_FILE_OFFSET_BITS=64']} | |
19:26:17 build init variants | |
19:26:17 build list of variants is ['default'] | |
Waf: Entering directory `/Users/misko/work/node-phash/build' | |
19:26:17 build compile called | |
19:26:17 build delayed operation TaskGen.flush() called | |
19:26:17 task_gen posting objects (normal) | |
19:26:17 group group None | |
19:26:17 group <task_gen 'hello' of type cxx_taskgen defined in dir:///Users/misko/work/node-phash> | |
19:26:17 task_gen posting <task_gen 'hello' of type cxx_taskgen defined in dir:///Users/misko/work/node-phash> 21547728 | |
19:26:17 task_gen -> add_extra_flags (21547728) | |
19:26:17 task_gen -> default_cc (21547728) | |
19:26:17 task_gen -> init_cxx (21547728) | |
19:26:17 task_gen -> init_node_addon (21547728) | |
19:26:17 task_gen -> apply_bundle (21547728) | |
19:26:17 task_gen -> node_addon_shlib_ext (21547728) | |
19:26:17 task_gen -> apply_type_vars (21547728) | |
19:26:17 task_gen -> exec_rule (21547728) | |
19:26:17 task_gen -> vars_target_cshlib (21547728) | |
19:26:17 task_gen -> apply_core (21547728) | |
19:26:17 task_gen -> apply_link (21547728) | |
19:26:17 task_gen -> apply_implib (21547728) | |
19:26:17 task_gen -> apply_vnum (21547728) | |
19:26:17 task_gen -> set_macosx_deployment_target (21547728) | |
19:26:17 task_gen -> apply_lib_vars (21547728) | |
19:26:17 task_gen -> apply_framework (21547728) | |
19:26:17 task_gen -> apply_objdeps (21547728) | |
19:26:17 task_gen -> apply_bundle_remove_dynamiclib (21547728) | |
19:26:17 task_gen -> apply_defines_cxx (21547728) | |
19:26:17 task_gen -> default_link_install (21547728) | |
19:26:17 task_gen -> apply_incpaths (21547728) | |
19:26:17 task_gen -> apply_obj_vars_cxx (21547728) | |
19:26:17 task_gen -> apply_verif (21547728) | |
19:26:17 task_gen -> apply_link_osx (21547728) | |
19:26:17 task_gen -> apply_obj_vars (21547728) | |
19:26:17 task_gen posted hello | |
19:26:17 build executor starting | |
19:26:17 envhash '\x90\xadS\xf5C\xe9\xae\xdfC_+\xd9\tu\xe8\xb3' ["['/usr/bin/g++']", "['-g', '-fPIC', '-compatibility_version', '1', '-current_version', '1', '-D_LARGEFILE_SOURCE', '-D_FILE_OFFSET_BITS=64']", "['-D_GNU_SOURCE', '-DEV_MULTIPLICITY=0']", "['-Idefault', '-I..', '-I/opt/local/include/', '-I/usr/local/Cellar/node3/0.3.1/include/node']", '[]', '', "['-c', '-o', '']", '[]'] | |
19:26:17 __init__ Task | |
{task: cxx hello.cc -> hello_1.o} | |
19:26:17 envhash '\x8fa\xbb\xba\xd6\x19\xe3\xbd-S\x0c\xb2\x9c\xd0\xbf\xcc' ["['/usr/bin/g++']", '', "['-o', '']", "['-bundle', '-undefined', 'dynamic_lookup', '-L/usr/local/Cellar/node3/0.3.1/lib']"] | |
19:26:17 __init__ Task | |
{task: cxx_link hello_1.o -> hello.node} | |
Waf: Leaving directory `/Users/misko/work/node-phash/build' | |
19:26:17 build install called | |
19:26:17 build delayed operation TaskGen.flush() called | |
19:26:17 task_gen posting objects (normal) | |
19:26:17 group group None | |
19:26:17 group <task_gen 'hello' of type cxx_taskgen defined in dir:///Users/misko/work/node-phash> | |
'build' finished successfully (0.111s) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var hello = require('./build/default/hello'); | |
console.log(hello); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
srcdir = '.' | |
blddir = 'build' | |
VERSION = '0.0.1' | |
def set_options(opt): | |
opt.tool_options('compiler_cxx') | |
def configure(conf): | |
conf.check_tool('compiler_cxx') | |
conf.check_tool('node_addon') | |
conf.check(lib='pHash', uselib_store='pHash') | |
def build(bld): | |
obj = bld.new_task_gen('cxx', 'shlib', 'node_addon') | |
obj.target = 'hello' | |
obj.source = 'hello.cc' | |
obj.includes = ['/opt/local/include/'] | |
obj.uselib = 'pHash' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment