From 27dcf32e461a7fba1a25ddb100dd930ceabb700b Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Mon, 11 Sep 2023 19:34:00 +0200 Subject: [PATCH 01/10] Add libsass 3.6.4 This is a direct copy of https://github.com/lazka/libsass/tree/meson which I've created for gtk back in the days. There is an open PR for adding meson support upstream in https://github.com/sass/libsass/pull/3073 but the project is considered deprecated and hasn't seen a commit in over a year, so there is not much hope for progress there. There is a newer 3.6.5 release out, but I wanted to copy things as is from my fork first and look at updating it later. --- releases.json | 8 ++ subprojects/libsass.wrap | 9 ++ .../packagefiles/libsass/include/meson.build | 14 +++ subprojects/packagefiles/libsass/meson.build | 25 ++++ .../packagefiles/libsass/src/meson.build | 107 ++++++++++++++++++ 5 files changed, 163 insertions(+) create mode 100644 subprojects/libsass.wrap create mode 100644 subprojects/packagefiles/libsass/include/meson.build create mode 100644 subprojects/packagefiles/libsass/meson.build create mode 100644 subprojects/packagefiles/libsass/src/meson.build diff --git a/releases.json b/releases.json index c329654fd..bc4733aa5 100644 --- a/releases.json +++ b/releases.json @@ -1437,6 +1437,14 @@ "1.6.17-2" ] }, + "libsass": { + "dependency_names": [ + "libsass" + ], + "versions": [ + "3.6.4-1" + ] + }, "libsndfile": { "dependency_names": [ "sndfile" diff --git a/subprojects/libsass.wrap b/subprojects/libsass.wrap new file mode 100644 index 000000000..2c060ec16 --- /dev/null +++ b/subprojects/libsass.wrap @@ -0,0 +1,9 @@ +[wrap-file] +directory = libsass-3.6.4 +source_url = https://github.com/sass/libsass/archive/refs/tags/3.6.4.tar.gz +source_filename = libsass-3.6.4.tar.gz +source_hash = f9484d9a6df60576e791566eab2f757a97fd414fce01dd41fc0a693ea5db2889 +patch_directory = libsass + +[provide] +libsass = libsass_dep diff --git a/subprojects/packagefiles/libsass/include/meson.build b/subprojects/packagefiles/libsass/include/meson.build new file mode 100644 index 000000000..98598c31c --- /dev/null +++ b/subprojects/packagefiles/libsass/include/meson.build @@ -0,0 +1,14 @@ +install_headers('sass.h', 'sass2scss.h') + +version_conf_data = configuration_data() +version_conf_data.set('PACKAGE_VERSION', meson.project_version()) + +version_h = configure_file( + input: 'sass/version.h.in', + output: 'version.h', + configuration: version_conf_data) + +install_headers( + 'sass/base.h', 'sass/context.h', 'sass/functions.h', 'sass/values.h', + version_h, + subdir: 'sass') diff --git a/subprojects/packagefiles/libsass/meson.build b/subprojects/packagefiles/libsass/meson.build new file mode 100644 index 000000000..72ec5c7e3 --- /dev/null +++ b/subprojects/packagefiles/libsass/meson.build @@ -0,0 +1,25 @@ +project('libsass', 'c', 'cpp', + version: '3.6.4', + meson_version : '>= 0.48.0', + default_options: [ + 'c_std=c99', + 'cpp_std=c++11', + 'buildtype=debugoptimized', + ]) + +add_project_arguments( + '-DLIBSASS_VERSION="@0@"'.format(meson.project_version()), + language: ['cpp']) + +cpp = meson.get_compiler('cpp') +if cpp.get_id() != 'msvc' + add_project_arguments( + cpp.get_supported_arguments(['-Wno-non-virtual-dtor']), + language: ['cpp']) +endif + +inc = include_directories('include') +winres_path = files(join_paths('res', 'resource.rc')) + +subdir('include') +subdir('src') diff --git a/subprojects/packagefiles/libsass/src/meson.build b/subprojects/packagefiles/libsass/src/meson.build new file mode 100644 index 000000000..0a4414038 --- /dev/null +++ b/subprojects/packagefiles/libsass/src/meson.build @@ -0,0 +1,107 @@ +cpp_sources = [ + 'ast.cpp', + 'ast_values.cpp', + 'ast_supports.cpp', + 'ast_sel_cmp.cpp', + 'ast_sel_unify.cpp', + 'ast_sel_super.cpp', + 'ast_sel_weave.cpp', + 'ast_selectors.cpp', + 'context.cpp', + 'constants.cpp', + 'fn_utils.cpp', + 'fn_miscs.cpp', + 'fn_maps.cpp', + 'fn_lists.cpp', + 'fn_colors.cpp', + 'fn_numbers.cpp', + 'fn_strings.cpp', + 'fn_selectors.cpp', + 'color_maps.cpp', + 'environment.cpp', + 'ast_fwd_decl.cpp', + 'bind.cpp', + 'file.cpp', + 'util.cpp', + 'util_string.cpp', + 'json.cpp', + 'units.cpp', + 'values.cpp', + 'plugins.cpp', + 'source.cpp', + 'position.cpp', + 'lexer.cpp', + 'parser.cpp', + 'parser_selectors.cpp', + 'prelexer.cpp', + 'eval.cpp', + 'eval_selectors.cpp', + 'expand.cpp', + 'listize.cpp', + 'cssize.cpp', + 'extender.cpp', + 'extension.cpp', + 'stylesheet.cpp', + 'output.cpp', + 'inspect.cpp', + 'emitter.cpp', + 'check_nesting.cpp', + 'remove_placeholders.cpp', + 'sass.cpp', + 'sass_values.cpp', + 'sass_context.cpp', + 'sass_functions.cpp', + 'sass2scss.cpp', + 'backtrace.cpp', + 'operators.cpp', + 'ast2c.cpp', + 'c2ast.cpp', + 'to_value.cpp', + 'source_map.cpp', + 'error_handling.cpp', + 'memory/allocator.cpp', + 'memory/shared_ptr.cpp', + 'utf8_string.cpp', + 'base64vlq.cpp', +] + +c_sources = [ + 'cencode.c', +] + +sass_sources = cpp_sources + c_sources + +if host_machine.system() == 'windows' + windows = import('windows') + sass_sources += [windows.compile_resources(winres_path)] +endif + +dl_dep = cpp.find_library('dl', required : false) + +libsass = shared_library( + 'sass', + sass_sources, + dependencies: [dl_dep], + c_args: ['-DADD_EXPORTS'], + cpp_args: ['-DADD_EXPORTS'], + include_directories: inc, + install: true) + +libsass_dep = declare_dependency( + link_with: libsass, + include_directories: [inc]) + +conf_data = configuration_data() +conf_data.set('prefix', get_option('prefix')) +conf_data.set('exec_prefix', '${prefix}') +conf_data.set('libdir', join_paths('${exec_prefix}', get_option('libdir'))) +conf_data.set('includedir', join_paths('${prefix}', get_option('includedir'))) +conf_data.set('VERSION', meson.project_version()) + +pkg_install_dir = join_paths(get_option('libdir'), 'pkgconfig') + +configure_file( + input: 'support/libsass.pc.in', + output: 'libsass.pc', + configuration: conf_data, + install_dir: pkg_install_dir) From d81f2978b7fc1f7d3733472afd55715f318d8f83 Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Mon, 11 Sep 2023 20:31:19 +0200 Subject: [PATCH 02/10] libsass: add_project_arguments: don't check the compiler and don't pass an array --- subprojects/packagefiles/libsass/meson.build | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/subprojects/packagefiles/libsass/meson.build b/subprojects/packagefiles/libsass/meson.build index 72ec5c7e3..bcae663b3 100644 --- a/subprojects/packagefiles/libsass/meson.build +++ b/subprojects/packagefiles/libsass/meson.build @@ -12,11 +12,9 @@ add_project_arguments( language: ['cpp']) cpp = meson.get_compiler('cpp') -if cpp.get_id() != 'msvc' - add_project_arguments( - cpp.get_supported_arguments(['-Wno-non-virtual-dtor']), - language: ['cpp']) -endif +add_project_arguments( + cpp.get_supported_arguments('-Wno-non-virtual-dtor'), + language: ['cpp']) inc = include_directories('include') winres_path = files(join_paths('res', 'resource.rc')) From 2eb81411f7a440e6cc0edc93ad016140be6c05b0 Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Mon, 11 Sep 2023 20:37:46 +0200 Subject: [PATCH 03/10] libsass: use dependency('dl') with newer meson gtk3, which depends on this still works with 0.60, so allow older meson here too --- subprojects/packagefiles/libsass/src/meson.build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/subprojects/packagefiles/libsass/src/meson.build b/subprojects/packagefiles/libsass/src/meson.build index 0a4414038..2b14d5858 100644 --- a/subprojects/packagefiles/libsass/src/meson.build +++ b/subprojects/packagefiles/libsass/src/meson.build @@ -76,7 +76,11 @@ if host_machine.system() == 'windows' sass_sources += [windows.compile_resources(winres_path)] endif -dl_dep = cpp.find_library('dl', required : false) +if meson.version().version_compare('>= 0.62') + dl_dep = dependency('dl', required : false) +else + dl_dep = cc.find_library('dl', required : false) +endif libsass = shared_library( 'sass', From 3f10502dd95c6e4986f224000e08d2863b3a9a73 Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Mon, 11 Sep 2023 20:44:16 +0200 Subject: [PATCH 04/10] libsass: allow static builds and don't define ADD_EXPORTS then --- subprojects/packagefiles/libsass/src/meson.build | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/subprojects/packagefiles/libsass/src/meson.build b/subprojects/packagefiles/libsass/src/meson.build index 2b14d5858..69c6de3e5 100644 --- a/subprojects/packagefiles/libsass/src/meson.build +++ b/subprojects/packagefiles/libsass/src/meson.build @@ -82,12 +82,17 @@ else dl_dep = cc.find_library('dl', required : false) endif -libsass = shared_library( +lib_args = [] +if get_option('default_library') != 'static' + lib_args += ['-DADD_EXPORTS'] +endif + +libsass = library( 'sass', sass_sources, dependencies: [dl_dep], - c_args: ['-DADD_EXPORTS'], - cpp_args: ['-DADD_EXPORTS'], + c_args: lib_args, + cpp_args: lib_args, include_directories: inc, install: true) From 43c7eb30df789ba98741d822e06a3efabff31673 Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Tue, 12 Sep 2023 13:02:25 +0200 Subject: [PATCH 05/10] libsass: remove -Wno-non-virtual-dtor, no longer needed With newer meson this is no longer needed: https://github.com/mesonbuild/meson/pull/10339 --- subprojects/packagefiles/libsass/meson.build | 5 ----- 1 file changed, 5 deletions(-) diff --git a/subprojects/packagefiles/libsass/meson.build b/subprojects/packagefiles/libsass/meson.build index bcae663b3..3448dc1ae 100644 --- a/subprojects/packagefiles/libsass/meson.build +++ b/subprojects/packagefiles/libsass/meson.build @@ -11,11 +11,6 @@ add_project_arguments( '-DLIBSASS_VERSION="@0@"'.format(meson.project_version()), language: ['cpp']) -cpp = meson.get_compiler('cpp') -add_project_arguments( - cpp.get_supported_arguments('-Wno-non-virtual-dtor'), - language: ['cpp']) - inc = include_directories('include') winres_path = files(join_paths('res', 'resource.rc')) From 6d6243fced2e63eabadcc571aa75e66d0fd329f6 Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Tue, 12 Sep 2023 14:15:19 +0200 Subject: [PATCH 06/10] libsass: libdl is required on non-windows It's always used on non-Windows, and not used on Windows, so make it required with the newer dependency() feature on non-Windows, and a no-op on Windows. --- subprojects/packagefiles/libsass/src/meson.build | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/subprojects/packagefiles/libsass/src/meson.build b/subprojects/packagefiles/libsass/src/meson.build index 69c6de3e5..9d8480067 100644 --- a/subprojects/packagefiles/libsass/src/meson.build +++ b/subprojects/packagefiles/libsass/src/meson.build @@ -76,10 +76,14 @@ if host_machine.system() == 'windows' sass_sources += [windows.compile_resources(winres_path)] endif -if meson.version().version_compare('>= 0.62') - dl_dep = dependency('dl', required : false) +if host_machine.system() != 'windows' + if meson.version().version_compare('>= 0.62') + dl_dep = dependency('dl') + else + dl_dep = cc.find_library('dl', required : false) + endif else - dl_dep = cc.find_library('dl', required : false) + dl_dep = declare_dependency() endif lib_args = [] From b565450a368ea480ecbe3235b3685fc50c8f1a1d Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Tue, 12 Sep 2023 14:17:32 +0200 Subject: [PATCH 07/10] libsass: only define ADD_EXPORTS on Windows it's only used there --- subprojects/packagefiles/libsass/src/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subprojects/packagefiles/libsass/src/meson.build b/subprojects/packagefiles/libsass/src/meson.build index 9d8480067..536203a1d 100644 --- a/subprojects/packagefiles/libsass/src/meson.build +++ b/subprojects/packagefiles/libsass/src/meson.build @@ -87,7 +87,7 @@ else endif lib_args = [] -if get_option('default_library') != 'static' +if host_machine.system() == 'windows' and get_option('default_library') != 'static' lib_args += ['-DADD_EXPORTS'] endif From 93987b85db3c8106d126178cb7828f7fc3b5431e Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Tue, 12 Sep 2023 14:23:08 +0200 Subject: [PATCH 08/10] libsass: use the pkgconfig module for creating the .pc file --- .../packagefiles/libsass/src/meson.build | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/subprojects/packagefiles/libsass/src/meson.build b/subprojects/packagefiles/libsass/src/meson.build index 536203a1d..dd3e5c26e 100644 --- a/subprojects/packagefiles/libsass/src/meson.build +++ b/subprojects/packagefiles/libsass/src/meson.build @@ -104,17 +104,10 @@ libsass_dep = declare_dependency( link_with: libsass, include_directories: [inc]) -conf_data = configuration_data() -conf_data.set('prefix', get_option('prefix')) -conf_data.set('exec_prefix', '${prefix}') -conf_data.set('libdir', join_paths('${exec_prefix}', get_option('libdir'))) -conf_data.set('includedir', join_paths('${prefix}', get_option('includedir'))) -conf_data.set('VERSION', meson.project_version()) - -pkg_install_dir = join_paths(get_option('libdir'), 'pkgconfig') - -configure_file( - input: 'support/libsass.pc.in', - output: 'libsass.pc', - configuration: conf_data, - install_dir: pkg_install_dir) +pkg = import('pkgconfig') +pkg.generate( + libsass, + name: 'libsass', + description: 'A C implementation of a Sass compiler', + url: 'https://github.com/sass/libsass', +) From 2f0542cee881a1c91b8b708b207a89a4f6e6a69d Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Tue, 12 Sep 2023 14:40:03 +0200 Subject: [PATCH 09/10] libsass: set soversion to 1 to match upstream --- subprojects/packagefiles/libsass/src/meson.build | 1 + 1 file changed, 1 insertion(+) diff --git a/subprojects/packagefiles/libsass/src/meson.build b/subprojects/packagefiles/libsass/src/meson.build index dd3e5c26e..85bcc0674 100644 --- a/subprojects/packagefiles/libsass/src/meson.build +++ b/subprojects/packagefiles/libsass/src/meson.build @@ -98,6 +98,7 @@ libsass = library( c_args: lib_args, cpp_args: lib_args, include_directories: inc, + soversion: '1', install: true) libsass_dep = declare_dependency( From c63ff45dfbb17705969b9a3fb1019c389dbaa43c Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Tue, 12 Sep 2023 19:21:56 +0200 Subject: [PATCH 10/10] libsass: use dependency() instead of declare_dependency() for the dummy dependency case --- subprojects/packagefiles/libsass/src/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subprojects/packagefiles/libsass/src/meson.build b/subprojects/packagefiles/libsass/src/meson.build index 85bcc0674..994b3fbcd 100644 --- a/subprojects/packagefiles/libsass/src/meson.build +++ b/subprojects/packagefiles/libsass/src/meson.build @@ -83,7 +83,7 @@ if host_machine.system() != 'windows' dl_dep = cc.find_library('dl', required : false) endif else - dl_dep = declare_dependency() + dl_dep = dependency('', required: false) endif lib_args = []