Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add objfw dependency #13067

Merged
merged 4 commits into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ jobs:
find /opt/homebrew/Cellar/python* -name EXTERNALLY-MANAGED -print0 | xargs -0 rm -vf
# use python3 from homebrew because it is a valid framework, unlike the actions one:
# https://github.com/actions/setup-python/issues/58
- run: brew install pkg-config ninja llvm qt@5 boost ldc hdf5 openmpi lapack scalapack sdl2 boost-python3 gtk-doc zstd ncurses
- run: brew install pkg-config ninja llvm qt@5 boost ldc hdf5 openmpi lapack scalapack sdl2 boost-python3 gtk-doc zstd ncurses objfw
- run: |
python3 -m pip install --upgrade setuptools
python3 -m pip install --upgrade pip
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/msys2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ jobs:
mingw-w64-${{ matrix.MSYS2_ARCH }}-python-setuptools
mingw-w64-${{ matrix.MSYS2_ARCH }}-python-pip
mingw-w64-${{ matrix.MSYS2_ARCH }}-python-fastjsonschema
mingw-w64-${{ matrix.MSYS2_ARCH }}-objfw
mingw-w64-${{ matrix.MSYS2_ARCH }}-${{ matrix.TOOLCHAIN }}

- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion ci/ciimage/fedora/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pkgs=(
boost-python3-devel
itstool gtk3-devel java-latest-openjdk-devel gtk-doc llvm-devel clang-devel SDL2-devel graphviz-devel zlib zlib-devel zlib-static
#hdf5-openmpi-devel hdf5-devel netcdf-openmpi-devel netcdf-devel netcdf-fortran-openmpi-devel netcdf-fortran-devel scalapack-openmpi-devel
doxygen vulkan-devel vulkan-validation-layers-devel openssh mercurial gtk-sharp2-devel libpcap-devel gpgme-devel
doxygen vulkan-devel vulkan-validation-layers-devel openssh objfw mercurial gtk-sharp2-devel libpcap-devel gpgme-devel
qt5-qtbase-devel qt5-qttools-devel qt5-linguist qt5-qtbase-private-devel
libwmf-devel valgrind cmake openmpi-devel nasm gnustep-base-devel gettext-devel ncurses-devel
libxml2-devel libxslt-devel libyaml-devel glib2-devel json-glib-devel libgcrypt-devel wayland-devel wayland-protocols-devel
Expand Down
42 changes: 37 additions & 5 deletions docs/markdown/Dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,18 +266,20 @@ 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')
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
Expand Down Expand Up @@ -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)*
Expand Down
24 changes: 24 additions & 0 deletions docs/markdown/snippets/objfw_dep.md
Original file line number Diff line number Diff line change
@@ -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])
```
9 changes: 4 additions & 5 deletions mesonbuild/compilers/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@
# There is currently no pgc++ for Windows, only for Mac and Linux.
defaults['cpp'] = ['icl', 'cl', 'c++', 'g++', 'clang++', 'clang-cl']
defaults['fortran'] = ['ifort', 'gfortran', 'flang', 'pgfortran', 'g95']
# Clang and clang++ are valid, but currently unsupported.
defaults['objc'] = ['cc', 'gcc']
defaults['objcpp'] = ['c++', 'g++']
defaults['objc'] = ['clang-cl', 'gcc']
defaults['objcpp'] = ['clang-cl', 'g++']
defaults['cs'] = ['csc', 'mcs']
else:
if platform.machine().lower() == 'e2k':
Expand All @@ -59,8 +58,8 @@
else:
defaults['c'] = ['cc', 'gcc', 'clang', 'nvc', 'pgcc', 'icc', 'icx']
defaults['cpp'] = ['c++', 'g++', 'clang++', 'nvc++', 'pgc++', 'icpc', 'icpx']
defaults['objc'] = ['cc', 'gcc', 'clang']
defaults['objcpp'] = ['c++', 'g++', 'clang++']
defaults['objc'] = ['clang', 'gcc']
defaults['objcpp'] = ['clang++', 'g++']
defaults['fortran'] = ['gfortran', 'flang', 'nvfortran', 'pgfortran', 'ifort', 'ifx', 'g95']
defaults['cs'] = ['mcs', 'csc']
defaults['d'] = ['ldc2', 'ldc', 'gdc', 'dmd']
Expand Down
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
26 changes: 26 additions & 0 deletions mesonbuild/dependencies/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -616,3 +640,5 @@ def shaderc_factory(env: 'Environment',
system_class=OpensslSystemDependency,
cmake_class=CMakeDependencyFactory('OpenSSL', modules=['OpenSSL::SSL']),
)

packages['objfw'] = ObjFWDependency
5 changes: 4 additions & 1 deletion test cases/cmake/24 mixing languages/meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
project('CMake mix', ['c', 'cpp'])
# Explicitly require PIE so that mixing compilers with different defaults for
# whether to use PIE works.
project('CMake mix', ['c', 'cpp'],
default_options: ['b_pie=true'])

if not add_languages('objc', required : false)
error('MESON_SKIP_TEST: No ObjC compiler')
Expand Down
10 changes: 10 additions & 0 deletions test cases/objc/5 objfw/SimpleTest.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#import <ObjFW/ObjFW.h>
#import <ObjFWTest/ObjFWTest.h>

@interface SimpleTest: OTTestCase
@end

@implementation SimpleTest
- (void)testMeson {
}
@end
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
14 changes: 14 additions & 0 deletions test cases/objc/5 objfw/meson.build
Original file line number Diff line number Diff line change
@@ -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])
10 changes: 10 additions & 0 deletions test cases/objcpp/3 objfw/SimpleTest.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#import <ObjFW/ObjFW.h>
#import <ObjFWTest/ObjFWTest.h>

@interface SimpleTest: OTTestCase
@end

@implementation SimpleTest
- (void)testMeson {
}
@end
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
14 changes: 14 additions & 0 deletions test cases/objcpp/3 objfw/meson.build
Original file line number Diff line number Diff line change
@@ -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])
6 changes: 6 additions & 0 deletions test cases/osx/7 bitcode/test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"env": {
"OBJC": "cc",
"OBJCXX": "c++"
}
}
Loading