Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Build with Meson #3073

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 52 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,27 @@ language: cpp
sudo: required

# don't create redundant code coverage reports
# - AUTOTOOLS=yes COVERAGE=yes BUILD=static
# - AUTOTOOLS=no COVERAGE=yes BUILD=shared
# - AUTOTOOLS=no COVERAGE=no BUILD=static
# - TOOLING=autotools COVERAGE=yes BUILD=static
# - TOOLING=make COVERAGE=yes BUILD=shared
# - TOOLING=make COVERAGE=no BUILD=static

# further speed up day by day travis-ci builds
# re-enable this if you change the makefiles
# this will still catch all coding errors!
# - AUTOTOOLS=yes COVERAGE=no BUILD=static
# - TOOLING=autotools COVERAGE=no BUILD=static

# currently there are various issues when
# built with coverage, clang and autotools
# - AUTOTOOLS=yes COVERAGE=yes BUILD=shared
# - TOOLING=autotools COVERAGE=yes BUILD=shared

matrix:
include :
include:
- os: linux
compiler: gcc
env: AUTOTOOLS=no COVERAGE=yes BUILD=static
env: TOOLING=make COVERAGE=yes BUILD=static
- os: linux
compiler: g++-5
env: AUTOTOOLS=yes COVERAGE=no BUILD=shared
env: TOOLING=autotools COVERAGE=no BUILD=shared
addons:
apt:
sources:
Expand All @@ -34,7 +34,7 @@ matrix:
- g++-5
- os: linux
compiler: g++-8
env: AUTOTOOLS=yes COVERAGE=no BUILD=shared
env: TOOLING=autotools COVERAGE=no BUILD=shared
addons:
apt:
sources:
Expand All @@ -45,19 +45,57 @@ matrix:
compiler: clang
# This build runs with ASan and we set `detect_odr_violation=0`
# to work around https://bugs.llvm.org/show_bug.cgi?id=37545.
env: AUTOTOOLS=no COVERAGE=no BUILD=static ASAN_OPTIONS=detect_odr_violation=0
env: TOOLING=make COVERAGE=no BUILD=static ASAN_OPTIONS=detect_odr_violation=0
- os: linux
compiler: clang
env: AUTOTOOLS=yes COVERAGE=no BUILD=shared
env: TOOLING=autotools COVERAGE=no BUILD=shared
- os: linux
compiler: gcc
env: TOOLING=meson COVERAGE=no BUILD=shared
addons:
apt:
packages:
- python3-pip
- python3-setuptools
- os: linux
compiler: clang
env: TOOLING=meson COVERAGE=yes BUILD=shared
addons:
apt:
packages:
- python3-pip
- python3-setuptools
- os: linux
compiler: gcc
env: TOOLING=meson COVERAGE=no BUILD=static
addons:
apt:
packages:
- python3-pip
- python3-setuptools
- os: linux
compiler: clang
env: TOOLING=meson COVERAGE=yes BUILD=static
addons:
apt:
packages:
- python3-pip
- python3-setuptools
- os: osx
compiler: clang
env: TOOLING=make COVERAGE=no BUILD=shared
- os: osx
compiler: clang
env: TOOLING=make COVERAGE=no BUILD=static
- os: osx
compiler: clang
env: AUTOTOOLS=no COVERAGE=no BUILD=shared
env: TOOLING=autotools COVERAGE=no BUILD=shared
- os: osx
compiler: clang
env: AUTOTOOLS=no COVERAGE=no BUILD=static
env: TOOLING=meson COVERAGE=no BUILD=shared
- os: osx
compiler: clang
env: AUTOTOOLS=yes COVERAGE=no BUILD=shared
env: TOOLING=meson COVERAGE=no BUILD=static

script:
- ./script/ci-build-libsass
Expand Down
1 change: 1 addition & 0 deletions contrib/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
plugin = shared_library('plugin', 'plugin.cpp', dependencies: [sass_dep])
7 changes: 7 additions & 0 deletions include/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
sass_inc = include_directories('.')
version_h = configure_file(input: 'sass/version.h.in', output: 'version.h',
configuration: {'PACKAGE_VERSION': meson.version()}
)

install_subdir('sass', install_dir: get_option('includedir'), exclude_files: ['version.h', 'version.h.in'])
install_headers('sass.h', 'sass2scss.h', version_h, subdir: 'sass')
14 changes: 14 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
project('libsass', 'c', 'cpp', version: '3.6.4', meson_version: '>=0.49', default_options: ['c_std=c11','cpp_std=c++11'])
cpp = meson.get_compiler('cpp')
if target_machine.system() == 'windows'
add_project_arguments('-D_WIN32', cpp.get_supported_arguments('-Wno-non-virtual-dtor'), language: 'cpp')
endif

deps = [
meson.get_compiler('cpp').find_library('dl', required: false)
]

subdir('res') # Must be before src as src_res is declared here and used there
subdir('include')
subdir('src')
subdir('contrib')
1 change: 1 addition & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
option('SASS_CUSTOM_ALLOCATOR', type: 'boolean', value: false, description: 'Activate a custom allocator for performance improvements')
6 changes: 6 additions & 0 deletions res/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
winres_path = files('resource.rc')
src_res = []

if host_machine.system() == 'windows'
src_res += [import('windows').compile_resources(winres_path)]
endif
81 changes: 55 additions & 26 deletions script/ci-build-libsass
Original file line number Diff line number Diff line change
Expand Up @@ -71,32 +71,61 @@ echo SASS_SASSC_PATH: $SASS_SASSC_PATH
echo SASS_SPEC_PATH: $SASS_SPEC_PATH
echo INSTALL_LOCATION: $PREFIX

if [ "x$AUTOTOOLS" == "xyes" ]; then

echo -en 'travis_fold:start:configure\r'
autoreconf --force --install
./configure --enable-tests $COVERAGE_OPT \
--disable-silent-rules \
--with-sassc-dir=$SASS_SASSC_PATH \
--with-sass-spec-dir=$SASS_SPEC_PATH \
--prefix=$PREFIX \
${SHARED_OPT}
echo -en 'travis_fold:end:configure\r'

make $MAKE_OPTS clean

else

make $MAKE_OPTS clean

# Run C++ unit tests
make -C test clean
make -C test test

fi

# install to prefix directory
PREFIX="$PREFIX" make $MAKE_OPTS install
# if [ "x$AUTOTOOLS" == "xyes" ]; then

# echo -en 'travis_fold:start:configure\r'
# autoreconf --force --install
# ./configure --enable-tests $COVERAGE_OPT \
# --disable-silent-rules \
# --with-sassc-dir=$SASS_SASSC_PATH \
# --with-sass-spec-dir=$SASS_SPEC_PATH \
# --prefix=$PREFIX \
# ${SHARED_OPT}
# echo -en 'travis_fold:end:configure\r'

# make $MAKE_OPTS clean

# else

# make $MAKE_OPTS clean

# # Run C++ unit tests
# make -C test clean
# make -C test test

# fi

case $TOOLING in
autotools)
echo -en 'travis_fold:start:configure\r'
autoreconf --force --install
./configure --enable-tests $COVERAGE_OPT \
--disable-silent-rules \
--with-sassc-dir=$SASS_SASSC_PATH \
--with-sass-spec-dir=$SASS_SPEC_PATH \
--prefix=$PREFIX \
${SHARED_OPT}
echo -en 'travis_fold:end:configure\r'

make $MAKE_OPTS clean

# install to prefix directory
PREFIX="$PREFIX" make $MAKE_OPTS install
;;
meson)
meson $MESON_OPTS --prefix=$PREFIX --default-library=$BUILD _build
ninja -C _build test
ninja -C _build install
;;
*)
make $MAKE_OPTS clean
make -C test clean
make -C test test

# install to prefix directory
PREFIX="$PREFIX" make $MAKE_OPTS install
;;
esac

ls -la $PREFIX/*

Expand Down
25 changes: 15 additions & 10 deletions script/ci-install-deps
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,20 @@ else
echo "no dependencies to install"
fi

if [ "x$AUTOTOOLS" == "xyes" ]; then
AUTOTOOLS=yes

if [ "$TRAVIS_OS_NAME" == "linux" ]; then
sudo add-apt-repository -y ppa:rbose-debianizer/automake &> /dev/null
sudo apt-get -qq update
sudo apt-get -qq install automake
fi

fi
case $TOOLING in
autotools)
if [ "$TRAVIS_OS_NAME" == "linux" ]; then
sudo add-apt-repository -y ppa:rbose-debianizer/automake &> /dev/null
sudo apt-get -qq update
sudo apt-get -qq install automake
fi
;;
meson)
if [ "$TRAVIS_OS_NAME" == "linux" ]; then
pip3 install meson ninja
else
pip install meson ninja
fi
esac

exit 0
9 changes: 9 additions & 0 deletions src/memory/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
src_memory = files(
'allocator.cpp',
'shared_ptr.cpp'
)
memory_lib_args = []
if get_option('SASS_CUSTOM_ALLOCATOR')
memory_lib_args += ['-DSASS_CUSTOM_ALLOCATOR']
endif
memory_lib = static_library('memory', src_memory, include_directories: sass_inc, cpp_args: memory_lib_args)
85 changes: 85 additions & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
src_cpp = files(
'ast.cpp',
'ast2c.cpp',
'ast_fwd_decl.cpp',
'ast_sel_cmp.cpp',
'ast_sel_super.cpp',
'ast_sel_unify.cpp',
'ast_sel_weave.cpp',
'ast_selectors.cpp',
'ast_supports.cpp',
'ast_values.cpp',
'backtrace.cpp',
'base64vlq.cpp',
'bind.cpp',
'c2ast.cpp',
'check_nesting.cpp',
'color_maps.cpp',
'constants.cpp',
'context.cpp',
'cssize.cpp',
'emitter.cpp',
'environment.cpp',
'error_handling.cpp',
'eval.cpp',
'eval_selectors.cpp',
'expand.cpp',
'extender.cpp',
'extension.cpp',
'file.cpp',
'fn_colors.cpp',
'fn_lists.cpp',
'fn_maps.cpp',
'fn_miscs.cpp',
'fn_numbers.cpp',
'fn_selectors.cpp',
'fn_strings.cpp',
'fn_utils.cpp',
'inspect.cpp',
'json.cpp',
'lexer.cpp',
'listize.cpp',
'operators.cpp',
'output.cpp',
'parser.cpp',
'parser_selectors.cpp',
'plugins.cpp',
'position.cpp',
'prelexer.cpp',
'remove_placeholders.cpp',
'sass.cpp',
'sass2scss.cpp',
'sass_context.cpp',
'sass_functions.cpp',
'sass_values.cpp',
'source.cpp',
'source_map.cpp',
'stylesheet.cpp',
'to_value.cpp',
'units.cpp',
'utf8_string.cpp',
'util.cpp',
'util_string.cpp',
'values.cpp'
)
src_c = files(
'c99func.c',
'cencode.c'
)
mgreter marked this conversation as resolved.
Show resolved Hide resolved

subdir('memory')

sass_lib = library('sass', src_cpp, src_c, src_res,
include_directories: sass_inc,
dependencies: deps,
c_args: ['-DADD_EXPORTS'],
cpp_args: ['-DADD_EXPORTS'],
install: true
)

sass_dep = declare_dependency(link_with: sass_lib, include_directories: sass_inc)

import('pkgconfig').generate(
sass_lib,
description: 'A C implementation of a Sass compiler'
)
Empty file added src/support/meson.build
Empty file.