diff --git a/docs/markdown/Dependencies.md b/docs/markdown/Dependencies.md index 88e6575a7825..d91582523d44 100644 --- a/docs/markdown/Dependencies.md +++ b/docs/markdown/Dependencies.md @@ -266,11 +266,12 @@ DC="dmd" meson setup builddir ## Config tool -[CUPS](#cups), [LLVM](#llvm), [pcap](#pcap), [WxWidgets](#wxwidgets), -[libwmf](#libwmf), [GCrypt](#libgcrypt), [GPGME](#gpgme), and GnuStep either do not provide pkg-config -modules or additionally can be detected via a config tool -(cups-config, llvm-config, libgcrypt-config, etc). Meson has native support for these -tools, and they can be found like other dependencies: +[CUPS](#cups), [LLVM](#llvm), [ObjFW](#objfw), [pcap](#pcap), +[WxWidgets](#wxwidgets), [libwmf](#libwmf), [GCrypt](#libgcrypt), +[GPGME](#gpgme), and GnuStep either do not provide pkg-config modules or +additionally can be detected via a config tool (cups-config, llvm-config, +libgcrypt-config, etc). Meson has native support for these tools, and they can +be found like other dependencies: ```meson pcap_dep = dependency('pcap', version : '>=1.0') @@ -278,6 +279,7 @@ cups_dep = dependency('cups', version : '>=1.4') llvm_dep = dependency('llvm', version : '>=4.0') libgcrypt_dep = dependency('libgcrypt', version: '>= 1.8') gpgme_dep = dependency('gpgme', version: '>= 1.0') +objfw_dep = dependency('objfw', version: '>= 1.0') ``` *Since 0.55.0* Meson won't search $PATH any more for a config tool @@ -637,6 +639,36 @@ language-specific, you must specify the requested language using the Meson uses pkg-config to find NetCDF. +## ObjFW + +*(added 1.5.0)* + +Meson has native support for ObjFW, including support for ObjFW packages. + +In order to use ObjFW, simply create the dependency: + +```meson +objfw_dep = dependency('objfw') +``` + +In order to also use ObjFW packages, simply specify them as modules: + +```meson +objfw_dep = dependency('objfw', modules: ['SomePackage']) +``` + +If you need a dependency with and without packages, e.g. because your tests +want to use ObjFWTest, but you don't want to link your application against the +tests, simply get two dependencies and use them as appropriate: + +```meson +objfw_dep = dependency('objfw', modules: ['SomePackage']) +objfwtest_dep = dependency('objfw', modules: ['ObjFWTest']) +``` + +Then use `objfw_dep` for your library and only `objfwtest_dep` (not both) for +your tests. + ## OpenMP *(added 0.46.0)* diff --git a/docs/markdown/snippets/objfw_dep.md b/docs/markdown/snippets/objfw_dep.md new file mode 100644 index 000000000000..e65da2885b4a --- /dev/null +++ b/docs/markdown/snippets/objfw_dep.md @@ -0,0 +1,24 @@ +## A new dependency for ObjFW is now supported + +For example, you can create a simple application written using ObjFW like this: + +```meson +project('SimpleApp', 'objc') + +objfw_dep = dependency('objfw', version: '>= 1.0') + +executable('SimpleApp', 'SimpleApp.m', + dependencies: [objfw_dep]) +``` + +Modules are also supported. A test case using ObjFWTest can be created like +this: + +```meson +project('Tests', 'objc') + +objfwtest_dep = dependency('objfw', version: '>= 1.1', modules: ['ObjFWTest']) + +executable('Tests', ['FooTest.m', 'BarTest.m'], + dependencies: [objfwtest_dep]) +``` diff --git a/mesonbuild/dependencies/__init__.py b/mesonbuild/dependencies/__init__.py index abc2e22b2d86..89d2285ba3a6 100644 --- a/mesonbuild/dependencies/__init__.py +++ b/mesonbuild/dependencies/__init__.py @@ -223,6 +223,7 @@ def __init__(self, name: str, environment: 'Environment', kwargs: T.Dict[str, T. 'openssl': 'misc', 'libcrypto': 'misc', 'libssl': 'misc', + 'objfw': 'misc', # From platform: 'appleframeworks': 'platform', diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py index b255813b60b9..fd5965233dc6 100644 --- a/mesonbuild/dependencies/misc.py +++ b/mesonbuild/dependencies/misc.py @@ -474,6 +474,30 @@ def __init__(self, name: str, env: 'Environment', kwargs: T.Dict[str, T.Any]): self.link_args.extend(sublib) +class ObjFWDependency(ConfigToolDependency): + + tools = ['objfw-config'] + tool_name = 'objfw-config' + + def __init__(self, environment: 'Environment', kwargs: T.Dict[str, T.Any]): + super().__init__('objfw', environment, kwargs) + self.feature_since = ('1.5.0', '') + if not self.is_found: + return + + # TODO: Expose --reexport + # TODO: Expose --framework-libs + extra_flags = [] + + for module in mesonlib.stringlistify(mesonlib.extract_as_list(kwargs, 'modules')): + extra_flags.append('--package') + extra_flags.append(module) + + # TODO: Once Meson supports adding flags per language, only add --objcflags to ObjC + self.compile_args = self.get_config_value(['--cppflags', '--cflags', '--objcflags'] + extra_flags, 'compile_args') + self.link_args = self.get_config_value(['--ldflags', '--libs'] + extra_flags, 'link_args') + + @factory_methods({DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL, DependencyMethods.SYSTEM}) def curses_factory(env: 'Environment', for_machine: 'mesonlib.MachineChoice', @@ -616,3 +640,5 @@ def shaderc_factory(env: 'Environment', system_class=OpensslSystemDependency, cmake_class=CMakeDependencyFactory('OpenSSL', modules=['OpenSSL::SSL']), ) + +packages['objfw'] = ObjFWDependency diff --git a/test cases/objc/5 objfw/SimpleTest.m b/test cases/objc/5 objfw/SimpleTest.m new file mode 100644 index 000000000000..a1604d3bcc44 --- /dev/null +++ b/test cases/objc/5 objfw/SimpleTest.m @@ -0,0 +1,10 @@ +#import +#import + +@interface SimpleTest: OTTestCase +@end + +@implementation SimpleTest +- (void)testMeson { +} +@end diff --git a/test cases/objc/5 objfw/TestApplication.m b/test cases/objc/5 objfw/TestApplication.m new file mode 100644 index 000000000000..ed6fac1e9265 --- /dev/null +++ b/test cases/objc/5 objfw/TestApplication.m @@ -0,0 +1,12 @@ +#import + +@interface TestApplication: OFObject +@end + +OF_APPLICATION_DELEGATE(TestApplication) + +@implementation TestApplication +- (void)applicationDidFinishLaunching: (OFNotification *)notification { + [OFApplication terminate]; +} +@end diff --git a/test cases/objc/5 objfw/meson.build b/test cases/objc/5 objfw/meson.build new file mode 100644 index 000000000000..40ddb7968db4 --- /dev/null +++ b/test cases/objc/5 objfw/meson.build @@ -0,0 +1,14 @@ +project('objfw build tests', 'objc') + +objfw_dep = dependency('objfw', required: false) +objfwtest_dep = dependency('objfw', modules: ['ObjFWTest'], required: false) + +if not objfw_dep.found() or not objfwtest_dep.found() + error('MESON_SKIP_TEST: Need objfw dependency') +endif + +executable('TestApplication', 'TestApplication.m', + dependencies: [objfw_dep]) + +executable('SimpleTest', 'SimpleTest.m', + dependencies: [objfwtest_dep]) diff --git a/test cases/objcpp/3 objfw/SimpleTest.mm b/test cases/objcpp/3 objfw/SimpleTest.mm new file mode 100644 index 000000000000..a1604d3bcc44 --- /dev/null +++ b/test cases/objcpp/3 objfw/SimpleTest.mm @@ -0,0 +1,10 @@ +#import +#import + +@interface SimpleTest: OTTestCase +@end + +@implementation SimpleTest +- (void)testMeson { +} +@end diff --git a/test cases/objcpp/3 objfw/TestApplication.mm b/test cases/objcpp/3 objfw/TestApplication.mm new file mode 100644 index 000000000000..ed6fac1e9265 --- /dev/null +++ b/test cases/objcpp/3 objfw/TestApplication.mm @@ -0,0 +1,12 @@ +#import + +@interface TestApplication: OFObject +@end + +OF_APPLICATION_DELEGATE(TestApplication) + +@implementation TestApplication +- (void)applicationDidFinishLaunching: (OFNotification *)notification { + [OFApplication terminate]; +} +@end diff --git a/test cases/objcpp/3 objfw/meson.build b/test cases/objcpp/3 objfw/meson.build new file mode 100644 index 000000000000..da14681ebf1a --- /dev/null +++ b/test cases/objcpp/3 objfw/meson.build @@ -0,0 +1,14 @@ +project('objfw build tests', 'objcpp') + +objfw_dep = dependency('objfw', required: false) +objfwtest_dep = dependency('objfw', modules: ['ObjFWTest'], required: false) + +if not objfw_dep.found() or not objfwtest_dep.found() + error('MESON_SKIP_TEST: Need objfw dependency') +endif + +executable('TestApplication', 'TestApplication.mm', + dependencies: [objfw_dep]) + +executable('SimpleTest', 'SimpleTest.mm', + dependencies: [objfwtest_dep])