Skip to content

Commit 8c62627

Browse files
committed
Merge pull request #89 from asottile/libsass_3.3_betas
Libsass 3.3 betas
2 parents 764fc11 + 44c235d commit 8c62627

File tree

6 files changed

+46
-44
lines changed

6 files changed

+46
-44
lines changed

MANIFEST.in

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
include libsass/*.h
2-
include libsass/*.hpp
3-
include libsass/*.cpp
1+
recursive-include libsas *.c
2+
recursive-include libsas *.cpp
3+
recursive-include libsas *.h
4+
recursive-include libsas *.hpp
45
include libsass/Makefile
5-
include libsass/Makefile.am
6-
include libsass/b64/*.h
7-
include libsass/utf8/*.h
8-
include win32/*.h
96
include test/*.scss
107
include README.rst

Makefile

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,24 @@
99
# $ make -j 4 && python -m unittest sasstests
1010

1111
PY_HEADERS := -I/usr/include/python2.7
12-
C_SOURCES := $(wildcard libsass/*.c)
13-
C_OBJECTS = $(patsubst libsass/%.c,build2/libsass/c/%.o,$(C_SOURCES))
14-
CPP_SOURCES := $(wildcard libsass/*.cpp)
15-
CPP_OBJECTS = $(patsubst libsass/%.cpp,build2/libsass/cpp/%.o,$(CPP_SOURCES))
12+
C_SOURCES := $(wildcard libsass/src/*.c)
13+
C_OBJECTS = $(patsubst libsass/src/%.c,build2/libsass/c/%.o,$(C_SOURCES))
14+
CPP_SOURCES := $(wildcard libsass/src/*.cpp)
15+
CPP_OBJECTS = $(patsubst libsass/src/%.cpp,build2/libsass/cpp/%.o,$(CPP_SOURCES))
1616

1717
all: _sass.so
1818

19-
build2/libsass/c/%.o: libsass/%.c
19+
build2/libsass/c/%.o: libsass/src/%.c
2020
@mkdir -p build2/libsass/c/
21-
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I./libsass $(PY_HEADERS) -c $^ -o $@ -c -O2 -fPIC -std=c++0x -Wall -Wno-parentheses
21+
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I./libsass/include $(PY_HEADERS) -c $^ -o $@ -c -O2 -fPIC -std=c++0x -Wall -Wno-parentheses
2222

23-
build2/libsass/cpp/%.o: libsass/%.cpp
23+
build2/libsass/cpp/%.o: libsass/src/%.cpp
2424
@mkdir -p build2/libsass/cpp/
25-
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I./libsass $(PY_HEADERS) -c $^ -o $@ -c -O2 -fPIC -std=c++0x -Wall -Wno-parentheses
25+
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I./libsass/include $(PY_HEADERS) -c $^ -o $@ -c -O2 -fPIC -std=c++0x -Wall -Wno-parentheses
2626

2727
build2/pysass.o: pysass.cpp
2828
@mkdir -p build2
29-
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I./libsass $(PY_HEADERS) -c $^ -o $@ -c -O2 -fPIC -std=c++0x -Wall -Wno-parentheses
29+
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I./libsass/include $(PY_HEADERS) -c $^ -o $@ -c -O2 -fPIC -std=c++0x -Wall -Wno-parentheses
3030

3131
_sass.so: $(C_OBJECTS) $(CPP_OBJECTS) build2/pysass.o
3232
g++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro $^ -L./libsass -o $@ -fPIC -lstdc++

libsass

Submodule libsass updated 155 files

pysass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include <string.h>
22
#include <Python.h>
3-
#include "sass_context.h"
3+
#include <sass/context.h>
44

55
#if PY_MAJOR_VERSION >= 3
66
#define PySass_IF_PY3(three, two) (three)

sasstests.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,11 @@ def normalize_path(path):
5656
'version': 3,
5757
'file': 'test/a.css',
5858
'sources': ['test/a.scss'],
59-
'sourcesContent': [],
6059
'names': [],
61-
'mappings': ';AAKA,IAAI,CAAC;EAHH,gBAAgB,EAAE,KAAM,GAGpB;;'
62-
'EAEJ,IAAI,CAAC,CAAC,CAAJ;IACA,KAAK,EAAE,IAAK,GADX',
60+
'mappings': (
61+
';AAKA,IAAI,CAAC;EAHH,gBAAgB,EAAE,KAAM,GAQzB;;EALD,IAAI,CAEF,CAAC,'
62+
'CAAC;IACA,KAAK,EAAE,IAAK,GACb'
63+
),
6364
}
6465

6566
B_EXPECTED_CSS = '''\
@@ -457,10 +458,10 @@ def test_build_one(self):
457458
'version': 3,
458459
'file': '../test/b.css',
459460
'sources': ['../test/b.scss'],
460-
'sourcesContent': [],
461461
'names': [],
462-
'mappings': ';AACE,CAAC,CAAC,CAAC,CAAD;'
463-
'EACA,SAAS,EAAE,IAAK,GADf',
462+
'mappings': (
463+
';AAAA,CAAC,CACC,CAAC,CAAC;EACA,SAAS,EAAE,IAAK,GACjB'
464+
),
464465
},
465466
os.path.join(d, 'css', 'b.scss.css.map')
466467
)
@@ -476,11 +477,11 @@ def test_build_one(self):
476477
'version': 3,
477478
'file': '../test/d.css',
478479
'sources': ['../test/d.scss'],
479-
'sourcesContent': [],
480480
'names': [],
481-
'mappings': ';;AAKA,IAAI,CAAC;EAHH,gBAAgB,EAAE,KAAM,GAGpB;'
482-
';EAEJ,IAAI,CAAC,CAAC,CAAJ'
483-
';IACA,IAAI,EAAE,0BAA2B,GADhC',
481+
'mappings': (
482+
';;AAKA,IAAI,CAAC;EAHH,gBAAgB,EAAE,KAAM,GAQzB;;EALD,'
483+
'IAAI,CAEF,CAAC,CAAC;IACA,IAAI,EAAE,0BAA2B,GAClC'
484+
),
484485
},
485486
os.path.join(d, 'css', 'd.scss.css.map')
486487
)
@@ -757,7 +758,7 @@ def test_error(self):
757758
except sass.CompileError as e:
758759
msg, = e.args
759760
assert msg.decode('UTF-8').startswith(
760-
'Error: invalid property name'
761+
'Error: Invalid CSS after '
761762
), msg
762763
return
763764
except Exception as e:

setup.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,29 @@
2020
use_setuptools()
2121
from setuptools import Extension, setup
2222

23-
LIBSASS_DIR = 'libsass'
23+
LIBSASS_SOURCE_DIR = os.path.join('libsass', 'src')
2424

25-
26-
if not os.path.isfile(os.path.join(LIBSASS_DIR, 'Makefile')) and \
25+
if not os.path.isfile(os.path.join('libsass', 'Makefile')) and \
2726
os.path.isdir('.git'):
2827
print(file=sys.stderr)
2928
print('You seem to miss initializing submodules; '
3029
'try the following command', file=sys.stderr)
3130
print(' git submodule update --init', file=sys.stderr)
3231
print(file=sys.stderr)
3332

34-
libsass_files = os.listdir(LIBSASS_DIR)
35-
libsass_sources = [f for f in libsass_files if f.endswith(('.c', '.cpp'))]
36-
libsass_headers = [f for f in libsass_files if f.endswith(('.h', '.hpp'))]
37-
headers = [os.path.join(LIBSASS_DIR, f) for f in libsass_headers]
38-
sources = [os.path.join(LIBSASS_DIR, f) for f in libsass_sources]
39-
sources.append('pysass.cpp')
33+
sources = ['pysass.cpp']
34+
headers = []
35+
for directory in (
36+
os.path.join('libsass', 'src'),
37+
os.path.join('libsass', 'include')
38+
):
39+
for pth, _, filenames in os.walk(directory):
40+
for filename in filenames:
41+
filename = os.path.join(pth, filename)
42+
if filename.endswith(('.c', '.cpp')):
43+
sources.append(filename)
44+
elif filename.endswith('.h'):
45+
headers.append(filename)
4046

4147
if sys.platform == 'win32':
4248
from distutils.msvc9compiler import get_build_version
@@ -98,7 +104,7 @@ def customize_compiler(compiler):
98104
# Dirty workaround to avoid link error...
99105
# Python distutils doesn't provide any way to configure different
100106
# flags for each cc and c++.
101-
cencode_path = os.path.join(LIBSASS_DIR, 'cencode.c')
107+
cencode_path = os.path.join(LIBSASS_SOURCE_DIR, 'cencode.c')
102108
cencode_body = ''
103109
with open(cencode_path) as f:
104110
cencode_body = f.read()
@@ -131,9 +137,9 @@ def restore_cencode():
131137
sass_extension = Extension(
132138
'_sass',
133139
sources,
134-
library_dirs=[os.path.join('.', LIBSASS_DIR)],
135-
include_dirs=[os.path.join('.', LIBSASS_DIR)],
136-
depends=libsass_headers,
140+
library_dirs=[os.path.join('.', 'libsass', 'src')],
141+
include_dirs=[os.path.join('.', 'libsass', 'include')],
142+
depends=headers,
137143
extra_compile_args=flags,
138144
extra_link_args=link_flags,
139145
)
@@ -216,8 +222,6 @@ def run(self):
216222
package_data={
217223
'': [
218224
'README.rst',
219-
os.path.join(LIBSASS_DIR, 'Makefile'),
220-
os.path.join(LIBSASS_DIR, 'Makefile.am'),
221225
'test/*.sass'
222226
]
223227
},

0 commit comments

Comments
 (0)