Add support for depending on ObjFW

This uses objfw-config to get to the flags, however, there's still
several todos that can only be addressed once dependencies can have
per-language flags.
pull/13157/head
Jonathan Schleifer 8 months ago committed by Eli Schwartz
parent 205f09e1b0
commit 6c6529337e
  1. 42
      docs/markdown/Dependencies.md
  2. 24
      docs/markdown/snippets/objfw_dep.md
  3. 1
      mesonbuild/dependencies/__init__.py
  4. 26
      mesonbuild/dependencies/misc.py
  5. 10
      test cases/objc/5 objfw/SimpleTest.m
  6. 12
      test cases/objc/5 objfw/TestApplication.m
  7. 14
      test cases/objc/5 objfw/meson.build
  8. 10
      test cases/objcpp/3 objfw/SimpleTest.mm
  9. 12
      test cases/objcpp/3 objfw/TestApplication.mm
  10. 14
      test cases/objcpp/3 objfw/meson.build

@ -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)*

@ -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])
```

@ -223,6 +223,7 @@ packages.defaults.update({
'openssl': 'misc',
'libcrypto': 'misc',
'libssl': 'misc',
'objfw': 'misc',
# From platform:
'appleframeworks': 'platform',

@ -474,6 +474,30 @@ class OpensslSystemDependency(SystemDependency):
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 @@ packages['libssl'] = libssl_factory = DependencyFactory(
system_class=OpensslSystemDependency,
cmake_class=CMakeDependencyFactory('OpenSSL', modules=['OpenSSL::SSL']),
)
packages['objfw'] = ObjFWDependency

@ -0,0 +1,10 @@
#import <ObjFW/ObjFW.h>
#import <ObjFWTest/ObjFWTest.h>
@interface SimpleTest: OTTestCase
@end
@implementation SimpleTest
- (void)testMeson {
}
@end

@ -0,0 +1,12 @@
#import <ObjFW/ObjFW.h>
@interface TestApplication: OFObject <OFApplicationDelegate>
@end
OF_APPLICATION_DELEGATE(TestApplication)
@implementation TestApplication
- (void)applicationDidFinishLaunching: (OFNotification *)notification {
[OFApplication terminate];
}
@end

@ -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])

@ -0,0 +1,10 @@
#import <ObjFW/ObjFW.h>
#import <ObjFWTest/ObjFWTest.h>
@interface SimpleTest: OTTestCase
@end
@implementation SimpleTest
- (void)testMeson {
}
@end

@ -0,0 +1,12 @@
#import <ObjFW/ObjFW.h>
@interface TestApplication: OFObject <OFApplicationDelegate>
@end
OF_APPLICATION_DELEGATE(TestApplication)
@implementation TestApplication
- (void)applicationDidFinishLaunching: (OFNotification *)notification {
[OFApplication terminate];
}
@end

@ -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])
Loading…
Cancel
Save