UNPKG

3.42 kBPlain TextView Raw
1##
2# @license
3# Copyright 2018 Google Inc. All Rights Reserved.
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15# =============================================================================
16
17# Node.js TensorFlow Binding config:
18{
19 'variables' : {
20 'tensorflow_include_dir' : '<(module_root_dir)/deps/include',
21 'tensorflow_headers' : [
22 '<@(tensorflow_include_dir)/tensorflow/c/c_api.h',
23 '<@(tensorflow_include_dir)/tensorflow/c/eager/c_api.h',
24 ],
25 'tensorflow-library-action': 'move'
26 },
27 'targets' : [{
28 'target_name' : 'tfjs_binding',
29 'sources' : [
30 'binding/tfjs_backend.cc',
31 'binding/tfjs_binding.cc'
32 ],
33 'include_dirs' : [ '..', '<(tensorflow_include_dir)' ],
34 'conditions' : [
35 [
36 'OS=="linux"', {
37 'libraries' : [
38 '-Wl,-rpath,\$$ORIGIN/../../deps/lib',
39 '-ltensorflow',
40 '-ltensorflow_framework',
41 ],
42 'library_dirs' : ['<(module_root_dir)/deps/lib'],
43 }
44 ],
45 [
46 'OS=="mac"', {
47 'libraries' : [
48 '<(module_root_dir)/deps/lib/libtensorflow.dylib',
49 '<(module_root_dir)/deps/lib/libtensorflow_framework.dylib',
50 ],
51 'postbuilds': [
52 {
53 'postbuild_name': 'Adjust libtensorflow load path',
54 'action': [
55 'install_name_tool',
56 "-change",
57 "@rpath/libtensorflow.1.dylib",
58 "@loader_path/../../deps/lib/libtensorflow.dylib",
59 "<(PRODUCT_DIR)/tfjs_binding.node"
60 ]
61 },
62 {
63 'postbuild_name': 'Adjust libtensorflow_framework load path',
64 'action': [
65 'install_name_tool',
66 "-change",
67 "@rpath/libtensorflow_framework.1.dylib",
68 "@loader_path/../../deps/lib/libtensorflow_framework.dylib",
69 "<(PRODUCT_DIR)/tfjs_binding.node"
70 ]
71 }
72 ],
73 }
74 ],
75 [
76 'OS=="win"', {
77 'defines': ['COMPILER_MSVC'],
78 'libraries': ['tensorflow'],
79 'library_dirs' : ['<(module_root_dir)/deps/lib'],
80 'variables': {
81 'tensorflow-library-target': 'windows'
82 },
83 'msvs_disabled_warnings': [
84 # Warning C4190: 'TF_NewWhile' has C-linkage specified, but returns
85 # UDT 'TF_WhileParams' which is incompatible with C.
86 # (in include/tensorflow/c/c_api.h)
87 4190
88 ]
89 },
90 ]
91 ],
92 }
93 , {
94 "target_name": "action_after_build",
95 "type": "none",
96 "dependencies": [ "<(module_name)" ],
97 "copies": [
98 {
99 "files": [ "<(PRODUCT_DIR)/<(module_name).node" ],
100 "destination": "<(module_path)"
101 }
102 ]
103 }
104 ],
105 "defines": [
106 "NAPI_VERSION=<(napi_build_version)"
107 ]
108}