8f2e8b57e52d — Danielle Hutzley 3 years ago
Move config.h and work on making it subproject-ready
5 files changed, 52 insertions(+), 22 deletions(-)

M .ccls
A => config.h.in
M include/meson.build
M meson.build
M meson_options.txt
M .ccls +2 -2
@@ 1,7 1,7 @@ 
 clang
 %c -std=c99
-%c --include=include/config.h.in
-%h --include=include/config.h.in
+%c --include=config.h.in
+%h --include=config.h.in
 -Iinclude
 -I../include
 -I.

          
A => config.h.in +29 -0
@@ 0,0 1,29 @@ 
+#ifndef __LAAL_CONFIG_H
+#define __LAAL_CONFIG_H
+/* This Source Code Form is subject to the terms of the Mozilla Public
+** License, v. 2.0. If a copy of the MPL was not distributed with this
+** file, You can obtain one at http://mozilla.org/MPL/2.0/.
+*/
+// LAAL private configuration
+
+// LAAL compiler types
+/// Use GCC/Clang syntax like __attribute__ for hints
+#mesondefine LAAL_COMPILER_GCC
+/// Use MSVC syntax like __declspec for hints
+#mesondefine LAAL_COMPILER_MSVC
+
+// The buffer size for file I/O
+#mesondefine LAAL_IO_BUFFER_SIZE
+
+#if defined(LAAL_COMPILER_MSVC)
+#define __LAAL_PURE __attribute__ ((pure))
+#define __LAAL_MUST_USE __attribute__ ((warn_unused_result))
+#elif defined(LAAL_COMPILER_MSVC)
+#define __LAAL_PURE __declspec(noalias)
+#define __LAAL_MUST_USE
+#else
+#define __LAAL_PURE
+#define __LAAL_MUST_USE
+#endif
+
+#endif // __LAAL_CONFIG_H

          
M include/meson.build +0 -19
@@ 15,24 15,5 @@ headers = files([
   'laal_writer.h'
 ])
 
-# configuration header
-config = configuration_data({
-  'LAAL_COMPILER_GCC' : false,
-  'LAAL_COMPILER_MSVC' : false,
-  'LAAL_IO_BUFFER_SIZE' : 255,
-})
-
-if get_option('target_compiler') == 'GCC/Clang'
-  config.set('LAAL_COMPILER_GCC', true)
-elif get_option('target_compiler') == 'MSVC'
-  config.set('LAAL_COMPILER_MSVC', true)
-endif
-config.set('LAAL_IO_BUFFER_SIZE', get_option('io_buffer_size'))
-
-configure_file(input : 'config.h.in',
-               output : 'config.h',
-               configuration : config)
-add_project_arguments('--include=include/config.h', language : 'c')
-
 include = include_directories('.')
 install_headers(headers, subdir : 'laal')

          
M meson.build +14 -0
@@ 14,6 14,20 @@ project(
     'default_library=shared'
   ])
 
+# Configuration data
+config = configuration_data({
+  'LAAL_COMPILER_GCC' : get_option('target_compiler') == 'GCC/Clang',
+  'LAAL_COMPILER_MSVC' : get_option('target_compiler') == 'MSVC',
+  'LAAL_IO_BUFFER_SIZE' : get_option('io_buffer_size'),
+})
+
+# Configuration header
+configure_file(input : 'config.h.in',
+               output : 'config.h',
+               configuration : config)
+add_project_arguments('--include=@0@/config.h'.format(meson.project_build_root()),
+                      language : 'c')
+
 # Subdirs
 # subdir('po')      # TODO: localisation
 # subdir('doc')     # TODO: documentation

          
M meson_options.txt +7 -1
@@ 1,4 1,10 @@ 
-option('target_compiler', type : 'combo', choices : ['GCC/Clang', 'MSVC', 'Other'],
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved.  This file is offered as-is,
+# without any warranty.
+#
+# Build configuration
+option('target_compiler', type : 'combo', choices : ['GCC/Clang', 'MSVC', 'Other'], yield : true,
       description : 'The compiler to include optimization hints for',
       value : 'Other')