Skip to content

Commit

Permalink
Add support for depending on objfw
Browse files Browse the repository at this point in the history
This uses objfw-config to get to the flags, however, there's still
several to dos that can only be addressed once dependencies can have
per-language flags.
  • Loading branch information
Midar committed Apr 11, 2024
1 parent ac6be94 commit 7727311
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 0 deletions.
1 change: 1 addition & 0 deletions mesonbuild/dependencies/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
24 changes: 24 additions & 0 deletions mesonbuild/dependencies/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,24 @@ def __init__(self, name: str, env: 'Environment', kwargs: T.Dict[str, T.Any]):
self.link_args.extend(sublib)


class ObjFWDependencyConfigTool(ConfigToolDependency):

tools = ['objfw-config']
tool_name = 'objfw-config'

def __init__(self, name: str, environment: 'Environment', kwargs: T.Dict[str, T.Any]):
super().__init__(name, environment, kwargs)
if not self.is_found:
return
# TODO: Once Meson supports adding flags per language, only add --objcflags to ObjC
# TODO: Once Meson supports adding flags per language, add --cflags and --cxxflags
# TODO: Add support for --package, exposed as modules.
# TODO: Expose --reexport
# TODO: Expose --framework-libs
self.compile_args = self.get_config_value(['--cppflags', '--objcflags'], 'compile_args')
self.link_args = self.get_config_value(['--ldflags', '--libs'], 'link_args')


@factory_methods({DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL, DependencyMethods.SYSTEM})
def curses_factory(env: 'Environment',
for_machine: 'mesonlib.MachineChoice',
Expand Down Expand Up @@ -616,3 +634,9 @@ def shaderc_factory(env: 'Environment',
system_class=OpensslSystemDependency,
cmake_class=CMakeDependencyFactory('OpenSSL', modules=['OpenSSL::SSL']),
)

packages['objfw'] = objfw_factory = DependencyFactory(
'objfw',
[DependencyMethods.CONFIG_TOOL],
configtool_class=ObjFWDependencyConfigTool,
)
12 changes: 12 additions & 0 deletions test cases/objc/5 objfw/TestApplication.m
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions test cases/objc/5 objfw/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
project('TestApplication', 'objc',
version: '0.1',
default_options: ['warning_level=3'])

objfw_dep = dependency('objfw', required: false)
if not objfw_dep.found()
error('MESON_SKIP_TEST: Need objfw dependency')
endif

exe = executable('TestApplication', 'TestApplication.m',
dependencies: [objfw_dep])

test('basic', exe)
12 changes: 12 additions & 0 deletions test cases/objcpp/3 objfw/TestApplication.mm
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions test cases/objcpp/3 objfw/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
project('TestApplication', 'objcpp',
version: '0.1',
default_options: ['warning_level=3'])

objfw_dep = dependency('objfw', required: false)
if not objfw_dep.found()
error('MESON_SKIP_TEST: Need objfw dependency')
endif

exe = executable('TestApplication', 'TestApplication.mm',
dependencies: [objfw_dep])

test('basic', exe)

0 comments on commit 7727311

Please sign in to comment.