efl/src/lib/eldbus/meson.build

129 lines
3.7 KiB
Meson
Raw Normal View History

eldbus_deps = [ecore]
eldbus_pub_deps = [eina, eo, efl]
eldbus_ext_deps = []
pub_eo_files = [
'eldbus_model_connection.eo',
'eldbus_model_object.eo',
'eldbus_model_proxy.eo',
'eldbus_model_method.eo',
'eldbus_model_arguments.eo',
'eldbus_model_signal.eo',
'eldbus_model.eo'
]
foreach eo_file : pub_eo_files
pub_eo_file_target += custom_target('eolian_gen_' + eo_file,
input : eo_file,
output : [eo_file + '.h'],
depfile : eo_file + '.d',
install : true,
install_dir : dir_package_include,
command : eolian_gen + [ '-I', meson.current_source_dir(), eolian_include_directories,
'-o', 'h:' + join_paths(meson.current_build_dir(), eo_file + '.h'),
'-o', 'c:' + join_paths(meson.current_build_dir(), eo_file + '.c'),
'-o', 'd:' + join_paths(meson.current_build_dir(), eo_file + '.d'),
eldbus: Rename EAPI macro to ELDBUS_API in Eldbus library Summary: = The Rationale = EAPI was designed to be able to pass `__attribute__ ((visibility ("default")))` for symbols with GCC, which would mean that even if -fvisibility=hidden was used when compiling the library, the needed symbols would get exported. MSVC __almost__ works like GCC (or mingw) in which you can declare everything as export and it will just work (slower, but it will work). But there's a caveat: global variables will not work the same way for MSVC, but works for mingw and GCC. For global variables (as opposed to functions), MSVC requires correct DSO visibility for MSVC: instead of declaring a symbol as export for everything, you need to declare it as import when importing from another DSO and export when defining it locally. With current EAPI definitions, we get the following example working in mingw and MSVC (observe it doesn't define any global variables as exported symbols). Example 1: dll1: ``` EAPI void foo(void); EAPI void bar() { foo(); } ``` dll2: ``` EAPI void foo() { printf ("foo\n"); } ``` This works fine with API defined as __declspec(dllexport) in both cases and for gcc defining as `__atttribute__((visibility("default")))`. However, the following: Example 2: dll1: ``` EAPI extern int foo; EAPI void foobar(void); EAPI void bar() { foo = 5; foobar(); } ``` dll2: ``` EAPI int foo = 0; EAPI void foobar() { printf ("foo %d\n", foo); } ``` This will work on mingw but will not work for MSVC. And that's why EAPI is the only solution that worked for MSVC. Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com> Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev> Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com> Reviewers: vtorri, raster Subscribers: raster, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D12270
2021-05-23 12:07:51 -07:00
'-e', 'ELDBUS_API',
'-gchd', '@INPUT@'])
endforeach
pub_eo_types_files = [
'eldbus_types.eot'
]
foreach eo_file : pub_eo_types_files
pub_eo_file_target += custom_target('eolian_gen_' + eo_file,
input : eo_file,
output : [eo_file + '.h'],
depfile : eo_file + '.d',
install : true,
install_dir : dir_package_include,
command : eolian_gen + [ '-I', meson.current_source_dir(), eolian_include_directories,
'-o', 'h:' + join_paths(meson.current_build_dir(), eo_file + '.h'),
'-o', 'd:' + join_paths(meson.current_build_dir(), eo_file + '.d'),
eldbus: Rename EAPI macro to ELDBUS_API in Eldbus library Summary: = The Rationale = EAPI was designed to be able to pass `__attribute__ ((visibility ("default")))` for symbols with GCC, which would mean that even if -fvisibility=hidden was used when compiling the library, the needed symbols would get exported. MSVC __almost__ works like GCC (or mingw) in which you can declare everything as export and it will just work (slower, but it will work). But there's a caveat: global variables will not work the same way for MSVC, but works for mingw and GCC. For global variables (as opposed to functions), MSVC requires correct DSO visibility for MSVC: instead of declaring a symbol as export for everything, you need to declare it as import when importing from another DSO and export when defining it locally. With current EAPI definitions, we get the following example working in mingw and MSVC (observe it doesn't define any global variables as exported symbols). Example 1: dll1: ``` EAPI void foo(void); EAPI void bar() { foo(); } ``` dll2: ``` EAPI void foo() { printf ("foo\n"); } ``` This works fine with API defined as __declspec(dllexport) in both cases and for gcc defining as `__atttribute__((visibility("default")))`. However, the following: Example 2: dll1: ``` EAPI extern int foo; EAPI void foobar(void); EAPI void bar() { foo = 5; foobar(); } ``` dll2: ``` EAPI int foo = 0; EAPI void foobar() { printf ("foo %d\n", foo); } ``` This will work on mingw but will not work for MSVC. And that's why EAPI is the only solution that worked for MSVC. Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com> Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev> Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com> Reviewers: vtorri, raster Subscribers: raster, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D12270
2021-05-23 12:07:51 -07:00
'-e', 'ELDBUS_API',
'-ghd', '@INPUT@'])
endforeach
eolian_include_directories += ['-I', meson.current_source_dir()]
eldbus_header_src = [
'Eldbus.h',
eldbus: Rename EAPI macro to ELDBUS_API in Eldbus library Summary: = The Rationale = EAPI was designed to be able to pass `__attribute__ ((visibility ("default")))` for symbols with GCC, which would mean that even if -fvisibility=hidden was used when compiling the library, the needed symbols would get exported. MSVC __almost__ works like GCC (or mingw) in which you can declare everything as export and it will just work (slower, but it will work). But there's a caveat: global variables will not work the same way for MSVC, but works for mingw and GCC. For global variables (as opposed to functions), MSVC requires correct DSO visibility for MSVC: instead of declaring a symbol as export for everything, you need to declare it as import when importing from another DSO and export when defining it locally. With current EAPI definitions, we get the following example working in mingw and MSVC (observe it doesn't define any global variables as exported symbols). Example 1: dll1: ``` EAPI void foo(void); EAPI void bar() { foo(); } ``` dll2: ``` EAPI void foo() { printf ("foo\n"); } ``` This works fine with API defined as __declspec(dllexport) in both cases and for gcc defining as `__atttribute__((visibility("default")))`. However, the following: Example 2: dll1: ``` EAPI extern int foo; EAPI void foobar(void); EAPI void bar() { foo = 5; foobar(); } ``` dll2: ``` EAPI int foo = 0; EAPI void foobar() { printf ("foo %d\n", foo); } ``` This will work on mingw but will not work for MSVC. And that's why EAPI is the only solution that worked for MSVC. Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com> Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev> Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com> Reviewers: vtorri, raster Subscribers: raster, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D12270
2021-05-23 12:07:51 -07:00
'eldbus_api.h',
'eldbus_connection.h',
'eldbus_freedesktop.h',
'eldbus_message.h',
'eldbus_object.h',
'eldbus_pending.h',
'eldbus_proxy.h',
'eldbus_service.h',
'eldbus_signal_handler.h',
'eldbus_message_helper.h',
'eldbus_introspection.h',
'Eldbus_Model.h',
'eldbus_message_eina_value.h'
]
eldbus_src = files([
'eldbus_private.h',
'eldbus_private_types.h',
'eldbus_model_private.h',
'eldbus_model_proxy_private.h',
'eldbus_model_object_private.h',
'eldbus_model_arguments_private.h',
'eldbus_model_connection_private.h',
'eldbus_model_signal_private.h',
'eldbus_model_method_private.h',
'eldbus_proxy.c',
'eldbus_core.c',
'eldbus_message.c',
'eldbus_object.c',
'eldbus_pending.c',
'eldbus_freedesktop.c',
'eldbus_service.c',
'eldbus_signal_handler.c',
'eldbus_message_helper.c',
'eldbus_message_to_eina_value.c',
'eldbus_message_from_eina_value.c',
'eldbus_model.c',
'eldbus_model_connection.c',
'eldbus_model_object.c',
'eldbus_model_proxy.c',
'eldbus_model_method.c',
'eldbus_model_arguments.c',
'eldbus_model_signal.c',
'eldbus_introspection.c'
])
eldbus_ext_deps += dependency('dbus-1')
eldbus_lib = library('eldbus',
eldbus_src, pub_eo_file_target,
eldbus: Rename EAPI macro to ELDBUS_API in Eldbus library Summary: = The Rationale = EAPI was designed to be able to pass `__attribute__ ((visibility ("default")))` for symbols with GCC, which would mean that even if -fvisibility=hidden was used when compiling the library, the needed symbols would get exported. MSVC __almost__ works like GCC (or mingw) in which you can declare everything as export and it will just work (slower, but it will work). But there's a caveat: global variables will not work the same way for MSVC, but works for mingw and GCC. For global variables (as opposed to functions), MSVC requires correct DSO visibility for MSVC: instead of declaring a symbol as export for everything, you need to declare it as import when importing from another DSO and export when defining it locally. With current EAPI definitions, we get the following example working in mingw and MSVC (observe it doesn't define any global variables as exported symbols). Example 1: dll1: ``` EAPI void foo(void); EAPI void bar() { foo(); } ``` dll2: ``` EAPI void foo() { printf ("foo\n"); } ``` This works fine with API defined as __declspec(dllexport) in both cases and for gcc defining as `__atttribute__((visibility("default")))`. However, the following: Example 2: dll1: ``` EAPI extern int foo; EAPI void foobar(void); EAPI void bar() { foo = 5; foobar(); } ``` dll2: ``` EAPI int foo = 0; EAPI void foobar() { printf ("foo %d\n", foo); } ``` This will work on mingw but will not work for MSVC. And that's why EAPI is the only solution that worked for MSVC. Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com> Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev> Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com> Reviewers: vtorri, raster Subscribers: raster, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D12270
2021-05-23 12:07:51 -07:00
c_args : [package_c_args, '-DELDBUS_BUILD'],
dependencies: eldbus_pub_deps + eldbus_deps + eldbus_ext_deps,
include_directories : config_dir,
install: true,
version : meson.project_version()
)
eldbus = declare_dependency(
include_directories: [include_directories('.')],
link_with: eldbus_lib,
sources : pub_eo_file_target + priv_eo_file_target,
dependencies: eldbus_pub_deps,
)
#
# Only enable that again when the namespace problems are fixed. ref T8648
#
#if get_option('install-eo-files')
# install_data(pub_eo_files + pub_eo_types_files,
# install_dir: join_paths(eolian_include_dir, package_version_name)
# )
#endif
install_headers(eldbus_header_src,
install_dir : dir_package_include,
)