aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Schleifer <js@nil.im>2024-04-11 01:46:27 +0200
committerEli Schwartz <eschwartz93@gmail.com>2024-04-28 03:14:29 -0400
commit6c6529337e72812a64ff4a193d1888cc7822de58 (patch)
tree7672560e73f02b46d45b1d6569cf7bca3e33505e
parent205f09e1b022a71a64eb48e22bb52f76e0da21ef (diff)
downloadmeson-6c6529337e72812a64ff4a193d1888cc7822de58.zip
meson-6c6529337e72812a64ff4a193d1888cc7822de58.tar.gz
meson-6c6529337e72812a64ff4a193d1888cc7822de58.tar.bz2
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.
-rw-r--r--docs/markdown/Dependencies.md42
-rw-r--r--docs/markdown/snippets/objfw_dep.md24
-rw-r--r--mesonbuild/dependencies/__init__.py1
-rw-r--r--mesonbuild/dependencies/misc.py26
-rw-r--r--test cases/objc/5 objfw/SimpleTest.m10
-rw-r--r--test cases/objc/5 objfw/TestApplication.m12
-rw-r--r--test cases/objc/5 objfw/meson.build14
-rw-r--r--test cases/objcpp/3 objfw/SimpleTest.mm10
-rw-r--r--test cases/objcpp/3 objfw/TestApplication.mm12
-rw-r--r--test cases/objcpp/3 objfw/meson.build14
10 files changed, 160 insertions, 5 deletions
diff --git a/docs/markdown/Dependencies.md b/docs/markdown/Dependencies.md
index 88e6575..d915825 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 0000000..e65da28
--- /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 abc2e22..89d2285 100644
--- a/mesonbuild/dependencies/__init__.py
+++ b/mesonbuild/dependencies/__init__.py
@@ -223,6 +223,7 @@ packages.defaults.update({
'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 b255813..fd59652 100644
--- a/mesonbuild/dependencies/misc.py
+++ b/mesonbuild/dependencies/misc.py
@@ -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
diff --git a/test cases/objc/5 objfw/SimpleTest.m b/test cases/objc/5 objfw/SimpleTest.m
new file mode 100644
index 0000000..a1604d3
--- /dev/null
+++ b/test cases/objc/5 objfw/SimpleTest.m
@@ -0,0 +1,10 @@
+#import <ObjFW/ObjFW.h>
+#import <ObjFWTest/ObjFWTest.h>
+
+@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 0000000..ed6fac1
--- /dev/null
+++ b/test cases/objc/5 objfw/TestApplication.m
@@ -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
diff --git a/test cases/objc/5 objfw/meson.build b/test cases/objc/5 objfw/meson.build
new file mode 100644
index 0000000..40ddb79
--- /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 0000000..a1604d3
--- /dev/null
+++ b/test cases/objcpp/3 objfw/SimpleTest.mm
@@ -0,0 +1,10 @@
+#import <ObjFW/ObjFW.h>
+#import <ObjFWTest/ObjFWTest.h>
+
+@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 0000000..ed6fac1
--- /dev/null
+++ b/test cases/objcpp/3 objfw/TestApplication.mm
@@ -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
diff --git a/test cases/objcpp/3 objfw/meson.build b/test cases/objcpp/3 objfw/meson.build
new file mode 100644
index 0000000..da14681
--- /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])