Skip to content

Commit 9b4781b

Browse files
committed
Statically link libortools.a into binding binary
1 parent d65050d commit 9b4781b

3 files changed

Lines changed: 15 additions & 11 deletions

File tree

binding.gyp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@
2727
'product_dir': '<(module_path)',
2828
'dependencies': [ 'action_before_build' ],
2929
'link_settings': {
30-
'libraries': ['-lortools'],
31-
'library_dirs': [
32-
'<(module_root_dir)/mason_packages/.link/lib'
33-
]
30+
'libraries': [
31+
'<(module_root_dir)/mason_packages/.link/lib/libortools.a',
32+
'<(module_root_dir)/mason_packages/.link/lib/libprotobuf.a',
33+
'<(module_root_dir)/mason_packages/.link/lib/libgflags.a',
34+
'-lz',
35+
],
3436
},
3537
'sources': [
3638
'src/main.cc',
@@ -42,7 +44,6 @@
4244
],
4345
'conditions': [
4446
['OS == "linux"', {
45-
'ldflags': ['-Wl,-z,origin -Wl,-rpath=\$$ORIGIN'],
4647
'cflags': [
4748
'<@(system_includes)'
4849
]

common.gypi

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
'-std=c++14',
66
'-Wall',
77
'-Wextra',
8-
'-D_GLIBCXX_USE_CXX11_ABI=0'
8+
'-ffunction-sections -fdata-sections',
9+
'-D_GLIBCXX_USE_CXX11_ABI=0',
10+
],
11+
'ldflags': [
12+
'-Wl,--gc-sections'
913
],
1014
'cflags_cc!': ['-std=gnu++0x','-fno-rtti', '-fno-exceptions'],
1115
'configurations': {

scripts/install-deps.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -o pipefail
55

66
# Point to or-tools upstream mason package commit until we have a
77
# new mason release. See https://github.com/mapbox/mason/pull/426
8-
MASON_RELEASE="0465138"
8+
MASON_RELEASE="ca9b4cb"
99
SPARSEHASH_RELEASE="2.0.2"
1010
ORTOOLS_RELEASE="6.0"
1111
PROTOBUF_RELEASE="3.0.0"
@@ -28,8 +28,7 @@ fi
2828
./third_party/mason/mason install or-tools ${ORTOOLS_RELEASE}
2929
./third_party/mason/mason link or-tools ${ORTOOLS_RELEASE}
3030

31-
mkdir -p ./build/Release/
32-
cp ./mason_packages/.link/lib/libortools.* ./build/Release/
3331

34-
mkdir -p ./lib/binding/
35-
cp ./mason_packages/.link/lib/libortools.* ./lib/binding/
32+
# We ship debug binaries with mason but for production builds we just strip debug symbols out.
33+
# In case you need debug symbols just comment out the following line and `npm --build-from-source`.
34+
find mason_packages/ -type f -name 'libortools.*' -exec strip --strip-unneeded {} \;

0 commit comments

Comments
 (0)