Skip to content

Commit

Permalink
Updates (pushing to new branch for testing)
Browse files Browse the repository at this point in the history
  • Loading branch information
amcn committed Jun 18, 2024
1 parent cc3af21 commit 82a70b6
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 38 deletions.
33 changes: 13 additions & 20 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ project('flatcc',
'c', 'cpp',
version : '0.6.1',
license : 'Apache-2.0',
default_options : ['c_std=c11', 'cpp_std=c++11', 'default_library=static'],
meson_version : '>=0.56.0'
default_options : [
'c_std=c11',
'cpp_std=c++11',
'werror=true',
'warning_level=3'
],
meson_version : '>=0.56.0',
)

buildtype = get_option('buildtype')
ignore_const_cond = get_option('ignore_const_cond')
allow_werror = get_option('allow_werror')
gnu_posix_memalign = get_option('gnu_posix_memalign')
has_c99_var_decl = get_option('c_std') != 'c89'

Expand All @@ -21,15 +25,15 @@ cxx = meson.get_compiler('cpp')

c_args = []

if get_option('flatcc_portable') or cc_id == 'msvc'
if get_option('portable') or cc_id == 'msvc'
c_args += '-DFLATCC_PORTABLE'
endif

if get_option('flatcc_debug_verify')
if get_option('debug_verify')
c_args += '-DFLATCC_DEBUG_VERIFY=1'
endif

if get_option('flatcc_fast_double')
if get_option('fast_double')
c_args += '-DGRISU3_PARSE_ALLOW_ERROR'
c_args += '-DFLATCC_USE_GRISU3=1'
endif
Expand All @@ -41,7 +45,6 @@ endif
if cc_id == 'mvsc'

has_c99_var_decl = cc_version.version_compare('>=18')
c_args += '-W3'

elif cc_id == 'clang'

Expand All @@ -50,7 +53,6 @@ elif cc_id == 'clang'
'-Wsign-conversion',
'-Wconversion',
'-pedantic',
'-Wextra'
]

if ignore_const_cond
Expand All @@ -63,11 +65,6 @@ elif cc_id == 'clang'

elif cc_id == 'gcc'

c_args += [
'-Wall',
'-Wextra',
]

if ignore_const_cond
c_args += '-Wno-type-limits'
endif
Expand All @@ -94,12 +91,8 @@ if build_machine.system() == 'windows'
c_args += '-D_CRT_SECURE_NO_WARNINGS'
endif

if allow_werror
c_args += '-Werror'
endif

# Reflection must be disabled temporarily when making breaking changes.
if get_option('flatcc_reflection')
if get_option('reflection')
c_args += '-DFLATCC_REFLECTION=1'
else
c_args += '-DFLATCC_REFLECTION=0'
Expand Down Expand Up @@ -152,7 +145,7 @@ flatcc_src = [
flatccrt_name = 'flatccrt'
flatcc_name = 'flatcc'

if buildtype == 'debug' and build_machine.system() != 'windows'
if buildtype == 'debug' and cc_id != 'msvc'
flatccrt_name = 'flatccrt_d'
flatcc_name = 'flatcc_d'
endif
Expand Down Expand Up @@ -203,7 +196,7 @@ meson.override_find_program('flatcc', flatcc)

subdir('rules')

if not get_option('flatcc_disable_tests') and not meson.is_subproject()
if not get_option('disable_tests') and not meson.is_subproject()
# For end user programs, samples, and test.
subdir('samples')
subdir('test')
Expand Down
19 changes: 9 additions & 10 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
# It is not needed for some non-compliant compilers such as
# recent gcc and clang.

option('flatcc_portable', type : 'boolean', value : false)
option('portable', type : 'boolean', value : false)

# Use this option to trigger assertions on flatcc errors. Useful to
# learn more about why api is used incorrectly or where a binary
# flatbuffer fails a verify test.

option('flatcc_debug_verify', type : 'boolean', value : false)
option('debug_verify', type : 'boolean', value : false)

# Controls the flatcc compilers ability to handle binary schema (bfbs).
# Can be used to trim down flatcc and libflatcc size, but is primarily
# for internal development because flatcc won't otherwise compile while
# there are breaking changes in generated code.

option('flatcc_reflection', type : 'boolean', value : true)
option('reflection', type : 'boolean', value : true)

# This option controls a special case in grisu3 but does not enable or
# disable grisu3 floating point parsing, which is enabled without
Expand All @@ -29,16 +29,15 @@ option('flatcc_reflection', type : 'boolean', value : true)
# buffers, and catastrophic on buffers that are not zero-terminated -
# regardless of size. Most platforms have a decent strtod these days.

option('flatcc_fast_double', type : 'boolean', value : false)
option('fast_double', type : 'boolean', value : false)

# Only build libraries, not samples, tests, or benchmarks.
# This option is implied true when building as a subproject
# regardless of this setting.

option('flatcc_disable_tests', type : 'boolean', value : false)
option('disable_tests', type : 'boolean', value : false)

option('ignore_const_cond', type: 'boolean', value: false)
option('allow_werror', type: 'boolean', value: true)
option('gnu_posix_memalign', type: 'boolean', value: true)

# --
Expand All @@ -59,20 +58,20 @@ option('gnu_posix_memalign', type: 'boolean', value: true)
# both ninja build and in flatcc. For now the myschema_reader.h is used
# to drive the depencies.

option('xflatcc_multi_dep_targets', type : 'boolean', value : false)
option('multi_dep_targets', type : 'boolean', value : false)

# Removes all tests, except the important `monster_test`.
# Useful for smaller test suite on new build targets
# and for testing dependency rules without noise.

option('xflatcc_monster_test_only', type : 'boolean', value : false)
option('monster_test_only', type : 'boolean', value : false)

# Currently (meson 0.34) it is not possible to generate .bfbs. files
# because there must be a registered compiler that handles .bfbs
# extension, but it is possible to use a custom target that does.

option('xflatcc_reflection_test_custom', type : 'boolean', value : true)
option('reflection_test_custom', type : 'boolean', value : true)

# Experimental support for automatically generating latest tag
# and revision from source control.
option('xflatcc_gen_version', type : 'boolean', value : false)
option('gen_version', type : 'boolean', value : false)
2 changes: 1 addition & 1 deletion rules/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ flatcc_common = custom_target('flatbuffer_common',
# option, but they are shared across schema and it is messy to
# update same file repeatedly).

if get_option('xflatcc_multi_dep_targets')
if get_option('multi_dep_targets')
flatcc_gen_output = [
'@BASENAME@_reader.h',
'@BASENAME@_builder.h',
Expand Down
3 changes: 1 addition & 2 deletions samples/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

monster_dir = join_paths(meson.current_source_dir(), 'monster')
monster_fbs = join_paths(monster_dir, 'monster.fbs')
monster_src = join_paths(monster_dir, 'monster.c')

subdir('monster')

if get_option('flatcc_reflection')
if get_option('reflection')
subdir('reflection')
endif
2 changes: 1 addition & 1 deletion scripts/build.cfg.meson
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FLATCC_BUILD_CONFIG=meson
FLATCC_BUILD_GEN=

FLATCC_BUILD_SYSTEM=meson
FLATCC_BUILD_SYSTEM="meson setup"
FLATCC_BUILD_CMD=ninja
FLATCC_TEST_CMD="meson test"

Expand Down
6 changes: 3 additions & 3 deletions test/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ flatbench_fbs = join_paths(bench_dir, 'schema/flatbench.fbs')
subdir('monster_test')

# Simply testing for debugging build rules and for smoke testing new platforms.
if get_option('xflatcc_monster_test_only')
if get_option('monster_test_only')
subdir_done()
endif

Expand All @@ -37,7 +37,7 @@ testdirs = [
'flatc_compat'
]

if get_option('flatcc_reflection')
if get_option('reflection')
testdirs += 'reflection_test'
else
warning('reflection disabled')
Expand All @@ -58,7 +58,7 @@ endforeach
# and dumps output in a condensed json file - so we add a run_target to
# drive the test instead.
if meson.backend() == 'ninja'
message('Note: run benchmark with `ninja flatbench`, not `ninja benchmark`')
message('run benchmark with `ninja flatbench`, not `ninja benchmark`')
endif

run_target('flatbench',
Expand Down
2 changes: 1 addition & 1 deletion test/reflection_test/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name = 'reflection_test'

out_dir = meson.current_build_dir()

if get_option('xflatcc_reflection_test_custom')
if get_option('reflection_test_custom')

bfbs_monster_test = custom_target('monster_test.bfbs',
output : 'monster_test.bfbs',
Expand Down

0 comments on commit 82a70b6

Please sign in to comment.