From 956dbb7230cee774200a51ccf2abf998ed686597 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Thu, 9 Dec 2021 03:31:50 +0100 Subject: [PATCH] Add cmark wrap --- .gitignore | 21 ++++-- meson.build | 2 +- subprojects/cmark.wrap | 9 +++ subprojects/packagefiles/cmark/meson.build | 87 ++++++++++++++++++++++ 4 files changed, 112 insertions(+), 7 deletions(-) create mode 100644 subprojects/cmark.wrap create mode 100644 subprojects/packagefiles/cmark/meson.build diff --git a/.gitignore b/.gitignore index a90f846f..086ff9b9 100644 --- a/.gitignore +++ b/.gitignore @@ -14,18 +14,19 @@ subprojects/Olm.wrap subprojects/Olm/ subprojects/coeurl.wrap subprojects/coeurl/ -subprojects/curl-7.77.0/ +subprojects/curl-*/ subprojects/curl.wrap -subprojects/libevent-2.1.12-stable/ +subprojects/libevent-*/ subprojects/libevent.wrap subprojects/lmdb++/ -subprojects/lmdb-LMDB_0.9.29/ -subprojects/nlohmann_json-3.9.1/ +subprojects/lmdb-LMDB_*/ +subprojects/nlohmann_json-*/ subprojects/nlohmann_json.wrap -subprojects/openssl-1.1.1l/ +subprojects/openssl-*/ subprojects/openssl.wrap subprojects/packagecache/ -subprojects/spdlog-1.9.2/ +subprojects/spdlog-*/ +subprojects/cmark-*/ # GTAGS GTAGS @@ -143,3 +144,11 @@ package.dir # Archives *.bz2 + +# analyzer stuff +heaptrack.* +massif.out.* +*.dump +.cache/ +.flatpak-builder/ +.hunter-emscripen/ diff --git a/meson.build b/meson.build index b15f3218..4e227523 100644 --- a/meson.build +++ b/meson.build @@ -19,7 +19,7 @@ deps = [ dependency('blurhash'), dependency('spdlog'), dependency('cmark'), - dependency('lmdb', fallback: ['lmdb', 'lmdb_dep']), + dependency('lmdb'), dependency('Qt5Keychain'), dependency('threads'), ] diff --git a/subprojects/cmark.wrap b/subprojects/cmark.wrap new file mode 100644 index 00000000..a81566b4 --- /dev/null +++ b/subprojects/cmark.wrap @@ -0,0 +1,9 @@ +[wrap-file] +directory = cmark-0.30.2 + +source_url = https://github.com/commonmark/cmark/archive/refs/tags/0.30.2.tar.gz +source_filename = cmark-0.30.2.tar.gz +source_hash = 6c7d2bcaea1433d977d8fed0b55b71c9d045a7cdf616e3cd2dce9007da753db3 + +patch_directory = cmark + diff --git a/subprojects/packagefiles/cmark/meson.build b/subprojects/packagefiles/cmark/meson.build new file mode 100644 index 00000000..dc6925d8 --- /dev/null +++ b/subprojects/packagefiles/cmark/meson.build @@ -0,0 +1,87 @@ +project( + 'cmark', 'c', + version: '0.30.2', + default_options: [ + 'warning_level=2' + ], + meson_version: '>= 0.54.0' +) + +sources = files( + 'src/cmark.c', + 'src/node.c', + 'src/iterator.c', + 'src/blocks.c', + 'src/inlines.c', + 'src/scanners.c', + #'src/scanners.re', + 'src/utf8.c', + 'src/buffer.c', + 'src/references.c', + 'src/render.c', + 'src/man.c', + 'src/xml.c', + 'src/html.c', + 'src/commonmark.c', + 'src/latex.c', + 'src/houdini_href_e.c', + 'src/houdini_html_e.c', + 'src/houdini_html_u.c', + 'src/cmark_ctype.c' +) + +compiler = meson.get_compiler('c') + +conf_data = configuration_data() +conf_data.set('HAVE_STDBOOL_H', compiler.has_header('stdbool.h')) +conf_data.set('HAVE___BUILTIN_EXPECT', compiler.compiles('int main() { __builtin_expect(0,0); return 0; }'), name: 'Has __builtin_expect') +conf_data.set('HAVE___ATTRIBUTE__', compiler.compiles(''' + int f(void) __attribute__ (()); + int main() { return 0; } +''', name: 'Has __attribute__')) + +config_file = configure_file(input: 'src/config.h.in', + output: 'config.h', + configuration: conf_data, + format: 'cmake', +) + +split_version = meson.project_version().split('.') +version_file = configure_file(input: 'src/cmark_version.h.in', + output: 'cmark_version.h', + configuration: { + 'PROJECT_VERSION_MAJOR': split_version[0].to_int(), + 'PROJECT_VERSION_MINOR': split_version[1].to_int(), + 'PROJECT_VERSION_PATCH': split_version[2].to_int(), + }, + format: 'cmake@', +) + +install_headers( + 'src/cmark.h', + config_file, + version_file, +) + +inc = include_directories('src') +cmark = library( + 'cmark', + sources, + config_file, + version_file, + include_directories: inc, +) + +cmark_dep = declare_dependency( + link_with: cmark, + include_directories: inc, +) +meson.override_dependency('cmark', cmark_dep) + +# Generate pc file +pkg = import('pkgconfig') + +pkg.generate(cmark, + name: 'cmark', + description: 'CommonMark parsing and rendering library and program in C') +