diff --git a/.travis.yml b/.travis.yml index d2a0ca0f45..257a40e8b3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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: @@ -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: @@ -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 diff --git a/contrib/meson.build b/contrib/meson.build new file mode 100644 index 0000000000..8d4ddcefed --- /dev/null +++ b/contrib/meson.build @@ -0,0 +1 @@ +plugin = shared_library('plugin', 'plugin.cpp', dependencies: [sass_dep]) diff --git a/include/meson.build b/include/meson.build new file mode 100644 index 0000000000..4c5c6baea6 --- /dev/null +++ b/include/meson.build @@ -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') diff --git a/meson.build b/meson.build new file mode 100644 index 0000000000..cf11613e5c --- /dev/null +++ b/meson.build @@ -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') diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000000..b072202c5e --- /dev/null +++ b/meson_options.txt @@ -0,0 +1 @@ +option('SASS_CUSTOM_ALLOCATOR', type: 'boolean', value: false, description: 'Activate a custom allocator for performance improvements') diff --git a/res/meson.build b/res/meson.build new file mode 100644 index 0000000000..deea00c941 --- /dev/null +++ b/res/meson.build @@ -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 diff --git a/script/ci-build-libsass b/script/ci-build-libsass index d4ade4eb73..487bea2816 100755 --- a/script/ci-build-libsass +++ b/script/ci-build-libsass @@ -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/* diff --git a/script/ci-install-deps b/script/ci-install-deps index 27b485aa75..6a36e4108e 100755 --- a/script/ci-install-deps +++ b/script/ci-install-deps @@ -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 diff --git a/src/memory/meson.build b/src/memory/meson.build new file mode 100644 index 0000000000..a84bdc31b6 --- /dev/null +++ b/src/memory/meson.build @@ -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) diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000000..77d574bbbb --- /dev/null +++ b/src/meson.build @@ -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' +) + +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' +) diff --git a/src/support/meson.build b/src/support/meson.build new file mode 100644 index 0000000000..e69de29bb2