mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2025-05-10 09:43:51 +00:00
meson: fix regression that broke extracting version (#1253)
* meson: fix regression that broke extracting version In commit 33f67386fec8040a36a26b2038b39dd8dcf2814d the code that heuristically parsed the version broke due to the version being moved around into a more easily accessible define. While we are at it, pass the exact path of httplib.h to un-break usage as a meson subproject. This was broken in commit 8ecdb1197967dea050fd38a8e9b5020e02320b31 which checked the return code of trying to get the version; it was always broken, but formerly failed in silence and resulted in no version number. * meson: use the compiler builtins to extract the version from the header As a convenient string define, it is now possible to ask the preprocessor what the version of cpp-httplib is. This can be used from meson too, in order to avoid encoding C++ file structure into python regexes.
This commit is contained in:
parent
d87abeecf0
commit
abf3a67dd0
11
meson.build
11
meson.build
@ -21,12 +21,11 @@ project(
|
|||||||
version = meson.project_version()
|
version = meson.project_version()
|
||||||
python3 = find_program('python3')
|
python3 = find_program('python3')
|
||||||
if version == 'undefined'
|
if version == 'undefined'
|
||||||
# Meson doesn't have regular expressions, but since it is implemented
|
cxx = meson.get_compiler('cpp')
|
||||||
# in python we can be sure we can use it to parse the file manually
|
version = cxx.get_define('CPPHTTPLIB_VERSION',
|
||||||
version = run_command(
|
prefix: '#include <httplib.h>',
|
||||||
python3, '-c', 'import re; raw_version = re.search("User\-Agent.*cpp\-httplib/([0-9]+\.?)+", open("httplib.h").read()).group(0); print(re.search("([0-9]+\\.?)+", raw_version).group(0))',
|
include_directories: include_directories('.')).strip('"')
|
||||||
check: true
|
assert(version != '', 'failed to get version from httplib.h')
|
||||||
).stdout().strip()
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
message('cpp-httplib version ' + version)
|
message('cpp-httplib version ' + version)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user