diff options
| author | Robert Günzler <r@gnzler.io> | 2020-04-24 12:43:14 +0200 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2020-04-24 12:43:14 +0200 |
| commit | 4e2d42677a8a15b3c6d058227aeb8b86861bb3dc (patch) | |
| tree | 3930ea9a6bf87ad0d6c0de4801eb4fafedd8e5e7 /.config/yamlfs/meson.yml | |
| parent | f9fc57288444b270269ce1d73679a810b65ecc94 (diff) | |
yamlfs: add more templates
Diffstat (limited to '.config/yamlfs/meson.yml')
| -rw-r--r-- | .config/yamlfs/meson.yml | 159 |
1 files changed, 159 insertions, 0 deletions
diff --git a/.config/yamlfs/meson.yml b/.config/yamlfs/meson.yml new file mode 100644 index 0000000..378afb1 --- /dev/null +++ b/.config/yamlfs/meson.yml @@ -0,0 +1,159 @@ +meson.build: |- + project( + '{% .name %}', + 'c', + version: '0.0.0+unknown', + license: 'MIT', + default_options: [ + 'c_std=c99' \ + 'warning_level=2' \ + 'werror=true' \ + ], + ) + + cc = meson.get_compiler('c') + add_project_arguments(cc.get_supported_arguments([ + '-D_POSIX_C_SOURCE=200809L', + + '-Wundef', + '-Wlogical-op', + '-Wmissing-include-dirs', + '-Wold-style-definition', + '-Wpointer-arith', + '-Winit-self', + '-Wfloat-equal', + '-Wstrict-prototypes', + '-Wredundant-decls', + '-Wimplicit-fallthrough=2', + '-Wendif-labels', + '-Wstrict-aliasing=2', + '-Woverflow', + '-Wformat=2', + + '-Wno-missing-braces', + '-Wno-missing-field-initializers', + '-Wno-unused-parameter', + ]), language: 'c') + + executable( + meson.project_name(), + files( + 'src/main.c', + ), + include_directories: include_directories('include'), + dependencies: [], + install: true, + ) + + {%- if .doc %} + scdoc = dependency( + 'scdoc', + version: '>=1.9.2', + native: true, + required: get_option('man-pages'), + ) + if scdoc.found() + scdoc_prog = find_program(scdoc.get_pkgconfig_variable('scdoc'), native: true) + sh = find_program('sh', native: true) + mandir = get_option('mandir') + man_files = [ + '{% .name %}.1.scd', + ] + foreach fn : man_files + topic = fn.split('.')[-3].split('/')[-1] + section = fn.split('.')[-2] + output = '@0@.@1@'.format(topic, section) + + custom_target( + output, + input: fn, + output: output, + command: [ + sh, '-c', '@0@ < @INPUT@ > @1@'.format(scdoc_prog.path(), output) + ], + install: true, + install_dir: '@0@/man@1@'.format(mandir, section), + ) + endforeach + endif + {%- end %} + + version = '"@0@ (" __DATE__ ")"'.format(meson.project_version()) + # embed version sourced from git ref + git = find_program('git', native: true, required: false) + if git.found() + git_commit_hash = run_command([ + git, 'describe', '--always', '--tags' + ]) + git_branch = run_command([ + git, 'rev-parse', '--abbrev-ref', 'HEAD' + ]) + if git_commit_hash.returncode() == 0 and git_branch.returncode() == 0 + version = '"@0@ (" __DATE__ ", branch \'@1@\')"'.format( + git_commit_hash.stdout().strip(), + git_branch.stdout().strip(), + ) + endif + endif + add_project_arguments('-DVERSION=@0@'.format(version), language: 'c') + +src: + main.c: |- + #define _POSIX_C_SOURCE 200809L + #include <stdlib.h> + #include <stdio.h> + + #include "{% .name %}.h" + + int main(int argc, char **argv) { + printf("%s version %s\n\n", *argv, VERSION); + + printf("args (len: %d)", argc-1); + for (int i=1; i < argc; ++i) { + printf(" '%s'", argv[i]); + } + printf("\n"); + + return 0; + } + +include: + {% .name | lower %}: |- + #ifndef {% .name | upper %}_H + #define {% .name | upper %}_H + + #ifndef VERSION + #define VERSION "0.0.0+unknown" + #endif + + /* TODO */ + + #endif + +.editorconfig: |- + ; http://editorconfig.org/ + + root = true + + [*] + charset = utf-8 + end_of_line = lf + indent_style = space + + [*.{c,h,cmake,txt}] + indent_style = tab + indent_size = 4 + + [*.md] + trim_trailing_whitespace = false + + [meson.build] + indent_size = 2 + + [Dockerfile] + indent_size = 4 + +README.md: |- + # {% .name %} + + TODO |