meson: Pull in syn from crates.io

We don't have real crates.io support yet so this uses a hack where it
pulls wraps from my personal github.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
This commit is contained in:
Faith Ekstrand
2023-01-30 20:53:18 -06:00
committed by Marge Bot
parent 384f4448e1
commit 5a80c2e89a
9 changed files with 181 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
project(
'proc-macro2',
'rust',
version : '1.0.56',
license :'MIT OR Apache-2.0',
)
rc = meson.get_compiler('rust')
if rc.version().version_compare('< 1.31')
error('Minimum rustc supported version is 1.31')
endif
rust_args = [
'--cfg', 'feature="proc-macro"',
'--cfg', 'feature="default"',
'--cfg', 'use_proc_macro',
'--cfg', 'wrap_proc_macro',
]
if rc.version().version_compare('< 1.32')
rust_args += ['--cfg', 'no_libprocmacro_unwind_safe']
endif
if rc.version().version_compare('< 1.39')
rust_args += ['--cfg', 'no_bind_by_move_pattern_guard']
endif
if rc.version().version_compare('< 1.44')
rust_args += ['--cfg', 'no_lexerror_display']
endif
if rc.version().version_compare('< 1.45')
rust_args += ['--cfg', 'no_hygiene']
endif
if rc.version().version_compare('< 1.47')
rust_args += ['--cfg', 'no_ident_new_raw']
endif
if rc.version().version_compare('< 1.54')
rust_args += ['--cfg', 'no_literal_from_str']
endif
if rc.version().version_compare('< 1.55')
rust_args += ['--cfg', 'no_group_open_close']
endif
if rc.version().version_compare('< 1.57')
rust_args += ['--cfg', 'no_is_available']
endif
u_ind = subproject('unicode-ident').get_variable('lib')
lib = static_library(
'proc_macro2',
'src/lib.rs',
rust_args : rust_args,
override_options : ['rust_std=2018', 'build.rust_std=2018'],
link_with : u_ind,
rust_abi : 'rust',
native : true,
)

View File

@@ -0,0 +1,32 @@
project(
'quote',
'rust',
version : '1.0.25',
license :'MIT OR Apache-2.0',
)
rc = meson.get_compiler('rust')
if rc.version().version_compare('< 1.31')
error('Minimum rustc supported version is 1.31')
endif
rust_args = ['--cfg', 'feature="default"', '--cfg', 'feature="proc-macro"']
if rc.version().version_compare('< 1.53')
rust_args += ['--cfg', 'needs_invalid_span_workaround']
endif
pm2 = subproject('proc-macro2').get_variable('lib')
# XXX: workround for meson bug: https://github.com/mesonbuild/meson/issues/11306
rust_args += ['-L', 'dependency=subprojects/unicode-ident']
lib = static_library(
'quote',
'src/lib.rs',
rust_args : rust_args,
override_options : ['rust_std=2018', 'build.rust_std=2018'],
link_with : pm2,
rust_abi : 'rust',
native : true,
)

View File

@@ -0,0 +1,50 @@
project(
'syn',
'rust',
version : '2.0.15',
license :'MIT OR Apache-2.0',
)
rc = meson.get_compiler('rust')
rust_args = [
'--cfg', 'feature="default"',
'--cfg', 'feature="derive"',
'--cfg', 'feature="parsing"',
'--cfg', 'feature="printing"',
'--cfg', 'feature="clone-impls"',
'--cfg', 'feature="proc-macro"',
'--cfg', 'feature="quote"',
]
if rc.version().version_compare('< 1.36')
rust_args += ['--cfg', 'syn_omit_await_from_token_macro']
endif
if rc.version().version_compare('< 1.39')
rust_args += ['--cfg', 'syn_no_const_vec_new']
endif
if rc.version().version_compare('< 1.40')
rust_args += ['--cfg', 'syn_no_non_exhaustive']
endif
if rc.version().version_compare('< 1.56')
rust_args += ['--cfg', 'syn_no_negative_literal_parse']
endif
u_ind = subproject('unicode-ident').get_variable('lib')
quote = subproject('quote').get_variable('lib')
pm2 = subproject('proc-macro2').get_variable('lib')
lib = static_library(
'syn',
'src/lib.rs',
rust_args : rust_args,
override_options : ['rust_std=2021', 'build.rust_std=2021'],
link_with : [u_ind, quote, pm2],
rust_abi : 'rust',
native : true,
)
dep_syn = declare_dependency(
link_with : [lib, u_ind, quote, pm2],
)

View File

@@ -0,0 +1,14 @@
project(
'unicode-ident',
'rust',
version : '1.0.6',
license : '(MIT or Apache-2.0) AND Unicode-DFS-2016)',
)
lib = static_library(
'unicode_ident',
'src/lib.rs',
override_options : ['rust_std=2018', 'build.rust_std=2018'],
rust_abi : 'rust',
native : true,
)