Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 19a36b4

Browse files
committed
Build with the unbundled libsass
Use environment variables to control how libsass is linked: LIBSASS_EXT variable empty or unset Build a bundled libsass source (from src/libsass). This is the default. LIBSASS_EXT=auto libsass is located using pkg-config and linked dynamically LIBSASS_EXT=yes LIBSASS_CFLAGS= LIBSASS_LDFLAGS= Link libsass manually, by adding compiler flags and linker flags in LIBSASS_CFLAGS and LIBSASS_LDFLAGS, respectively. For example this way libsass can be linked in statically (on Unix): LIBSASS_EXT=yes LIBSASS_CFLAGS=-I/usr/local/include LIBSASS_LDFLAGS=/usr/local/lib/libsass.a When using LIBSASS_EXT there is no need to checkout the libsass source into src/libsass submodule and the library from the package management system can be used. PR: #139 PR: #389 PR: #744
1 parent c97411e commit 19a36b4

File tree

4 files changed

+132
-49
lines changed

4 files changed

+132
-49
lines changed

binding.gyp

+28-47
Original file line numberDiff line numberDiff line change
@@ -4,56 +4,37 @@
44
'target_name': 'binding',
55
'sources': [
66
'src/binding.cpp',
7-
'src/sass_context_wrapper.cpp',
8-
'src/libsass/ast.cpp',
9-
'src/libsass/base64vlq.cpp',
10-
'src/libsass/bind.cpp',
11-
'src/libsass/cencode.c',
12-
'src/libsass/constants.cpp',
13-
'src/libsass/context.cpp',
14-
'src/libsass/contextualize.cpp',
15-
'src/libsass/copy_c_str.cpp',
16-
'src/libsass/error_handling.cpp',
17-
'src/libsass/eval.cpp',
18-
'src/libsass/expand.cpp',
19-
'src/libsass/extend.cpp',
20-
'src/libsass/file.cpp',
21-
'src/libsass/functions.cpp',
22-
'src/libsass/inspect.cpp',
23-
'src/libsass/json.cpp',
24-
'src/libsass/node.cpp',
25-
'src/libsass/output_compressed.cpp',
26-
'src/libsass/output_nested.cpp',
27-
'src/libsass/parser.cpp',
28-
'src/libsass/prelexer.cpp',
29-
'src/libsass/remove_placeholders.cpp',
30-
'src/libsass/sass.cpp',
31-
'src/libsass/sass2scss.cpp',
32-
'src/libsass/sass_context.cpp',
33-
'src/libsass/sass_functions.cpp',
34-
'src/libsass/sass_util.cpp',
35-
'src/libsass/sass_values.cpp',
36-
'src/libsass/source_map.cpp',
37-
'src/libsass/to_c.cpp',
38-
'src/libsass/to_string.cpp',
39-
'src/libsass/units.cpp',
40-
'src/libsass/utf8_string.cpp',
41-
'src/libsass/util.cpp'
7+
'src/sass_context_wrapper.cpp'
428
],
439
'include_dirs': [
44-
'<!(node -e "require(\'nan\')")'
45-
],
46-
'cflags!': [
47-
'-fno-exceptions'
48-
],
49-
'cflags_cc!': [
50-
'-fno-exceptions'
51-
],
52-
'cflags_cc': [
53-
'-fexceptions',
54-
'-frtti'
10+
'<!(node -e "require(\'nan\')")',
5511
],
5612
'conditions': [
13+
['libsass_ext == ""', {
14+
'dependencies': [
15+
'libsass.gyp:libsass',
16+
]
17+
}],
18+
['libsass_ext == "auto"', {
19+
'cflags_cc': [
20+
'<!(pkg-config --cflags libsass)',
21+
],
22+
'link_settings': {
23+
'ldflags': [
24+
'<!(pkg-config --libs libsass)',
25+
],
26+
}
27+
}],
28+
['libsass_ext == "yes"', {
29+
'cflags_cc': [
30+
'<(libsass_cflags)',
31+
],
32+
'link_settings': {
33+
'ldflags': [
34+
'<(libsass_ldflags)',
35+
],
36+
}
37+
}],
5738
['OS=="mac"', {
5839
'xcode_settings': {
5940
'OTHER_CPLUSPLUSFLAGS': [
@@ -67,7 +48,7 @@
6748
'GCC_ENABLE_CPP_RTTI': 'YES',
6849
'MACOSX_DEPLOYMENT_TARGET': '10.7'
6950
}
70-
}],
51+
}],
7152
['OS=="win"', {
7253
'msvs_settings': {
7354
'VCCLCompilerTool': {

libsass.gyp

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
{
2+
'targets': [
3+
{
4+
'target_name': 'libsass',
5+
'type': 'static_library',
6+
'sources': [
7+
'src/libsass/ast.cpp',
8+
'src/libsass/base64vlq.cpp',
9+
'src/libsass/bind.cpp',
10+
'src/libsass/cencode.c',
11+
'src/libsass/constants.cpp',
12+
'src/libsass/context.cpp',
13+
'src/libsass/contextualize.cpp',
14+
'src/libsass/copy_c_str.cpp',
15+
'src/libsass/error_handling.cpp',
16+
'src/libsass/eval.cpp',
17+
'src/libsass/expand.cpp',
18+
'src/libsass/extend.cpp',
19+
'src/libsass/file.cpp',
20+
'src/libsass/functions.cpp',
21+
'src/libsass/inspect.cpp',
22+
'src/libsass/json.cpp',
23+
'src/libsass/node.cpp',
24+
'src/libsass/output_compressed.cpp',
25+
'src/libsass/output_nested.cpp',
26+
'src/libsass/parser.cpp',
27+
'src/libsass/prelexer.cpp',
28+
'src/libsass/remove_placeholders.cpp',
29+
'src/libsass/sass.cpp',
30+
'src/libsass/sass2scss.cpp',
31+
'src/libsass/sass_context.cpp',
32+
'src/libsass/sass_functions.cpp',
33+
'src/libsass/sass_util.cpp',
34+
'src/libsass/sass_values.cpp',
35+
'src/libsass/source_map.cpp',
36+
'src/libsass/to_c.cpp',
37+
'src/libsass/to_string.cpp',
38+
'src/libsass/units.cpp',
39+
'src/libsass/utf8_string.cpp',
40+
'src/libsass/util.cpp'
41+
],
42+
'cflags!': [
43+
'-fno-exceptions'
44+
],
45+
'cflags_cc!': [
46+
'-fno-exceptions'
47+
],
48+
'cflags_cc': [
49+
'-fexceptions',
50+
'-frtti'
51+
],
52+
'direct_dependent_settings': {
53+
'include_dirs': [ 'src/libsass' ],
54+
},
55+
'conditions': [
56+
['OS=="mac"', {
57+
'xcode_settings': {
58+
'OTHER_CPLUSPLUSFLAGS': [
59+
'-std=c++11',
60+
'-stdlib=libc++'
61+
],
62+
'OTHER_LDFLAGS': [
63+
'-stdlib=libc++'
64+
],
65+
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
66+
'GCC_ENABLE_CPP_RTTI': 'YES',
67+
'MACOSX_DEPLOYMENT_TARGET': '10.7'
68+
}
69+
}],
70+
['OS=="win"', {
71+
'msvs_settings': {
72+
'VCCLCompilerTool': {
73+
'AdditionalOptions': [
74+
'/GR',
75+
'/EHsc'
76+
]
77+
}
78+
},
79+
'msvs_disabled_warnings': [
80+
# conversion from `double` to `size_t`, possible loss of data
81+
4244,
82+
# decorated name length exceeded
83+
4503
84+
]
85+
}],
86+
['OS!="win"', {
87+
'cflags_cc+': [
88+
'-std=c++0x'
89+
]
90+
}]
91+
]
92+
}
93+
]
94+
}

scripts/build.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,15 @@ function afterBuild(options) {
5353
*/
5454

5555
function build(options) {
56-
var arguments = [path.join('node_modules', 'pangyp', 'bin', 'node-gyp'), 'rebuild'].concat(options.args);
56+
var arguments = [
57+
path.join('node_modules', 'pangyp', 'bin', 'node-gyp'),
58+
'rebuild',
59+
].concat(
60+
[ 'libsass_ext', 'libsass_cflags',
61+
'libsass_ldflags' ].map(function(optvar) {
62+
return ["--", optvar, "=", process.env[optvar.toUpperCase() || '']].join('');
63+
})
64+
).concat(options.args);
5765

5866
console.log(['Building:', process.sass.runtime.execPath].concat(arguments).join(' '));
5967

src/sass_context_wrapper.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include <stdlib.h>
22
#include <nan.h>
33
#include <condition_variable>
4-
#include "libsass/sass_context.h"
4+
#include <sass_context.h>
55

66
#ifdef __cplusplus
77
extern "C" {

0 commit comments

Comments
 (0)