summaryrefslogtreecommitdiffstats
path: root/test cases/osx
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-29 04:41:38 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-29 04:41:38 +0000
commit7b6e527f440cd7e6f8be2b07cee320ee6ca18786 (patch)
tree4a2738d69fa2814659fdadddf5826282e73d81f4 /test cases/osx
parentInitial commit. (diff)
downloadmeson-7b6e527f440cd7e6f8be2b07cee320ee6ca18786.tar.xz
meson-7b6e527f440cd7e6f8be2b07cee320ee6ca18786.zip
Adding upstream version 1.0.1.upstream/1.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test cases/osx')
-rw-r--r--test cases/osx/1 basic/main.c5
-rw-r--r--test cases/osx/1 basic/meson.build3
-rw-r--r--test cases/osx/2 library versions/CMakeLists.txt29
-rw-r--r--test cases/osx/2 library versions/exe.orig.c7
-rw-r--r--test cases/osx/2 library versions/lib.c3
-rw-r--r--test cases/osx/2 library versions/meson.build81
-rw-r--r--test cases/osx/2 library versions/require_pkgconfig.py9
-rw-r--r--test cases/osx/2 library versions/test.json12
-rw-r--r--test cases/osx/3 has function xcode8/meson.build30
-rw-r--r--test cases/osx/4 framework/meson.build32
-rw-r--r--test cases/osx/4 framework/prog.c3
-rw-r--r--test cases/osx/4 framework/stat.c1
-rw-r--r--test cases/osx/4 framework/test.json6
-rw-r--r--test cases/osx/4 framework/xcode-frameworks.pngbin0 -> 421385 bytes
-rw-r--r--test cases/osx/5 extra frameworks/meson.build10
-rw-r--r--test cases/osx/5 extra frameworks/prog.c3
-rw-r--r--test cases/osx/5 extra frameworks/stat.c1
-rw-r--r--test cases/osx/5 extra frameworks/test.json6
-rw-r--r--test cases/osx/6 multiframework/main.m5
-rw-r--r--test cases/osx/6 multiframework/meson.build13
-rw-r--r--test cases/osx/7 bitcode/libbar.mm6
-rw-r--r--test cases/osx/7 bitcode/libfile.c5
-rw-r--r--test cases/osx/7 bitcode/libfoo.m6
-rw-r--r--test cases/osx/7 bitcode/meson.build11
-rw-r--r--test cases/osx/7 bitcode/vis.h6
-rw-r--r--test cases/osx/8 pie/main.c5
-rw-r--r--test cases/osx/8 pie/meson.build3
27 files changed, 301 insertions, 0 deletions
diff --git a/test cases/osx/1 basic/main.c b/test cases/osx/1 basic/main.c
new file mode 100644
index 0000000..0a07218
--- /dev/null
+++ b/test cases/osx/1 basic/main.c
@@ -0,0 +1,5 @@
+#include <CoreFoundation/CoreFoundation.h>
+
+int main(void) {
+ return 0;
+}
diff --git a/test cases/osx/1 basic/meson.build b/test cases/osx/1 basic/meson.build
new file mode 100644
index 0000000..e0412e1
--- /dev/null
+++ b/test cases/osx/1 basic/meson.build
@@ -0,0 +1,3 @@
+project('osx fundamentals', 'c')
+e = executable('prog', 'main.c')
+test('basic', e)
diff --git a/test cases/osx/2 library versions/CMakeLists.txt b/test cases/osx/2 library versions/CMakeLists.txt
new file mode 100644
index 0000000..2cd03b9
--- /dev/null
+++ b/test cases/osx/2 library versions/CMakeLists.txt
@@ -0,0 +1,29 @@
+cmake_minimum_required(VERSION 3.6.0)
+project(dylibversion C)
+
+# This file is here for debugging purposes to easily compare how
+# CMake does it.
+
+# libnoversion.dylib
+add_library(noversion SHARED lib.c)
+
+# libonlysoversion.dylib -> libonlysoversion.5.dylib
+# libonlyversion.1.4.5.dylib
+# -current_version 1.4.5
+
+add_library(onlyversion SHARED lib.c)
+set_target_properties(onlyversion PROPERTIES VERSION 1.4.5)
+
+# libonlysoversion.6.dylib
+# -compatibility_version 6.0.0
+
+add_library(onlysoversion SHARED lib.c)
+set_target_properties(onlysoversion PROPERTIES SOVERSION 6)
+
+# libsome.1.4.5.dylib
+# libsome.6.dylib -> libsome.1.4.5.dylib
+# libsome.dylib -> libsome.6.dylib
+# -current_version 1.4.5 -compatibility_version 5.0.0
+
+add_library(some SHARED lib.c)
+set_target_properties(some PROPERTIES VERSION 1.4.5 SOVERSION 6)
diff --git a/test cases/osx/2 library versions/exe.orig.c b/test cases/osx/2 library versions/exe.orig.c
new file mode 100644
index 0000000..ad38e6d
--- /dev/null
+++ b/test cases/osx/2 library versions/exe.orig.c
@@ -0,0 +1,7 @@
+int myFunc (void);
+
+int main (void) {
+ if (myFunc() == 55)
+ return 0;
+ return 1;
+}
diff --git a/test cases/osx/2 library versions/lib.c b/test cases/osx/2 library versions/lib.c
new file mode 100644
index 0000000..bd251d7
--- /dev/null
+++ b/test cases/osx/2 library versions/lib.c
@@ -0,0 +1,3 @@
+int myFunc(void) {
+ return 55;
+}
diff --git a/test cases/osx/2 library versions/meson.build b/test cases/osx/2 library versions/meson.build
new file mode 100644
index 0000000..5420133
--- /dev/null
+++ b/test cases/osx/2 library versions/meson.build
@@ -0,0 +1,81 @@
+project('library versions', 'c')
+
+if run_command(find_program('require_pkgconfig.py'), check: true).stdout().strip() == 'yes'
+ required = true
+else
+ required = false
+endif
+
+zlib_dep = dependency('zlib', required: required)
+if zlib_dep.found()
+ build_rpath = zlib_dep.type_name() == 'pkgconfig' ? zlib_dep.get_pkgconfig_variable('libdir') : 'lib'
+ some = shared_library('some', 'lib.c',
+ # duplicate the rpath again, in order
+ # to test Meson's RPATH deduplication
+ build_rpath : build_rpath,
+ dependencies : zlib_dep,
+ version : '1.2.3',
+ soversion : '7',
+ install : true)
+else
+ some = shared_library('some', 'lib.c',
+ version : '1.2.3',
+ soversion : '7',
+ install : true)
+endif
+
+noversion = shared_library('noversion', 'lib.c',
+ install : true)
+
+onlyversion = shared_library('onlyversion', 'lib.c',
+ version : '1.4.5',
+ install : true)
+
+onlysoversion = shared_library('onlysoversion', 'lib.c',
+ # Also test that int soversion is acceptable
+ soversion : 5,
+ install : true)
+
+shared_library('intver', 'lib.c',
+ darwin_versions : 2)
+
+shared_library('stringver', 'lib.c',
+ darwin_versions : '2.3')
+
+shared_library('stringlistver', 'lib.c',
+ darwin_versions : ['2.4'])
+
+shared_library('intstringver', 'lib.c',
+ darwin_versions : [1111, '2.5'])
+
+shared_library('stringlistvers', 'lib.c',
+ darwin_versions : ['2.6', '2.6.1'])
+
+# Hack to make the executables below depend on the shared libraries above
+# without actually adding them as `link_with` dependencies since we want to try
+# linking to them with -lfoo linker arguments.
+out = custom_target('library-dependency-hack',
+ input : 'exe.orig.c',
+ output : 'exe.c',
+ depends : [some, noversion, onlyversion, onlysoversion],
+ command : ['cp', '@INPUT@', '@OUTPUT@'])
+
+# Manually test if the linker can find the above libraries
+# i.e., whether they were generated with the right naming scheme
+test('manually linked 1', executable('manuallink1', out,
+ link_args : ['-L.', '-lsome'],
+ build_rpath : meson.current_build_dir()))
+
+test('manually linked 2', executable('manuallink2', out,
+ link_args : ['-L.', '-lnoversion'],
+ build_rpath : meson.current_build_dir()))
+
+test('manually linked 3', executable('manuallink3', out,
+ link_args : ['-L.', '-lonlyversion'],
+ build_rpath : meson.current_build_dir()))
+
+test('manually linked 4', executable('manuallink4', out,
+ link_args : ['-L.', '-lonlysoversion'],
+ build_rpath : meson.current_build_dir()))
+
+shared_module('module', 'lib.c', install : true)
diff --git a/test cases/osx/2 library versions/require_pkgconfig.py b/test cases/osx/2 library versions/require_pkgconfig.py
new file mode 100644
index 0000000..3d228aa
--- /dev/null
+++ b/test cases/osx/2 library versions/require_pkgconfig.py
@@ -0,0 +1,9 @@
+#!/usr/bin/env python3
+
+import os
+import shutil
+
+if 'CI' in os.environ or shutil.which('pkg-config'):
+ print('yes')
+else:
+ print('no')
diff --git a/test cases/osx/2 library versions/test.json b/test cases/osx/2 library versions/test.json
new file mode 100644
index 0000000..3234425
--- /dev/null
+++ b/test cases/osx/2 library versions/test.json
@@ -0,0 +1,12 @@
+{
+ "installed": [
+ {"type": "file", "file": "usr/lib/libsome.dylib"},
+ {"type": "file", "file": "usr/lib/libsome.7.dylib"},
+ {"type": "file", "file": "usr/lib/libnoversion.dylib"},
+ {"type": "file", "file": "usr/lib/libonlyversion.dylib"},
+ {"type": "file", "file": "usr/lib/libonlyversion.1.dylib"},
+ {"type": "file", "file": "usr/lib/libonlysoversion.dylib"},
+ {"type": "file", "file": "usr/lib/libonlysoversion.5.dylib"},
+ {"type": "file", "file": "usr/lib/libmodule.dylib"}
+ ]
+}
diff --git a/test cases/osx/3 has function xcode8/meson.build b/test cases/osx/3 has function xcode8/meson.build
new file mode 100644
index 0000000..edd3688
--- /dev/null
+++ b/test cases/osx/3 has function xcode8/meson.build
@@ -0,0 +1,30 @@
+project('has function xcode8', 'c')
+
+cc = meson.get_compiler('c')
+
+# XCode 8 location for the macOS 10.12 SDK
+sdk_args = ['-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk']
+args_10_11 = ['-mmacosx-version-min=10.11'] + sdk_args
+args_10_12 = ['-mmacosx-version-min=10.12'] + sdk_args
+
+# XCode 9 location for the macOS 10.13 SDK
+sdk_args = ['-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk']
+args_10_12 = ['-mmacosx-version-min=10.13'] + sdk_args
+
+# Test requires XCode 8 which has the MacOSX 10.12 SDK
+if cc.version().version_compare('>=8.0') and cc.version().version_compare('<8.1')
+ if cc.has_function('clock_gettime', args : args_10_11, prefix : '#include <time.h>')
+ error('Should not have found clock_gettime via <time.h> when targeting Mac OS X 10.11')
+ endif
+ if not cc.has_function('clock_gettime', args : args_10_12, prefix : '#include <time.h>')
+ error('Did NOT find clock_gettime via <time.h> when targeting Mac OS X 10.12')
+ endif
+ if not cc.has_function('clock_gettime', args : args_10_11)
+ error('Did NOT find clock_gettime w/o a prototype when targeting Mac OS X 10.11')
+ endif
+ if not cc.has_function('clock_gettime', args : args_10_12)
+ error('Did NOT find clock_gettime w/o a prototype when targeting Mac OS X 10.12')
+ endif
+else
+ error('MESON_SKIP_TEST Test needs XCode 8.')
+endif
diff --git a/test cases/osx/4 framework/meson.build b/test cases/osx/4 framework/meson.build
new file mode 100644
index 0000000..d1f7036
--- /dev/null
+++ b/test cases/osx/4 framework/meson.build
@@ -0,0 +1,32 @@
+# Primitive test for adding frameworks in XCode
+# When opening the xcodeproj, the Folder "Frameworks" should contain two frameworks (OpenGL.framework and Foundation.framework)
+# "Target Membership" of ...
+# - OpenGL.framework should be only to prog@exe
+# - Foundation.framework should be only to stat@sta
+# "Build Phase" / "Link Binary with Libraries" for the target
+# - "prog@exe" should be only "Foundation.framework"
+# - "stat@sta" should be only "OpenGL.framework"
+# see "xcode-frameworks.png" for an example
+
+project('xcode framework test', 'objc', default_options : ['libdir=libtest'])
+
+dep_main = dependency('appleframeworks', modules : ['Foundation'])
+
+if meson.is_cross_build()
+ # This is only available in iOS, not macOS. Just test finding it.
+ uikit_dep = dependency('appleframeworks', modules: 'UIKit')
+else
+ dep_libs = dependency('appleframeworks', modules : ['OpenGL'], required : false)
+ if not dep_libs.found()
+ error('OpenGL framework not found')
+ endif
+ assert(dep_libs.type_name() == 'appleframeworks', 'type_name is wrong')
+ # Only add the C compiler now, to ensure all lookups above were done with the ObjC one.
+ add_languages('c')
+ stlib = static_library('stat', 'stat.c', install : true, dependencies: dep_libs)
+ exe = executable('prog', 'prog.c', install : true, dependencies: dep_main)
+ uikit_dep = dependency('appleframeworks', modules: 'UIKit', required: false)
+ if uikit_dep.found()
+ error('UIKit found on macOS even though it should not be there.')
+ endif
+endif
diff --git a/test cases/osx/4 framework/prog.c b/test cases/osx/4 framework/prog.c
new file mode 100644
index 0000000..9b6bdc2
--- /dev/null
+++ b/test cases/osx/4 framework/prog.c
@@ -0,0 +1,3 @@
+int main(void) {
+ return 0;
+}
diff --git a/test cases/osx/4 framework/stat.c b/test cases/osx/4 framework/stat.c
new file mode 100644
index 0000000..4825cef
--- /dev/null
+++ b/test cases/osx/4 framework/stat.c
@@ -0,0 +1 @@
+int func(void) { return 933; }
diff --git a/test cases/osx/4 framework/test.json b/test cases/osx/4 framework/test.json
new file mode 100644
index 0000000..8def69a
--- /dev/null
+++ b/test cases/osx/4 framework/test.json
@@ -0,0 +1,6 @@
+{
+ "installed": [
+ {"type": "file", "file": "usr/bin/prog"},
+ {"type": "file", "file": "usr/lib/libstat.a"}
+ ]
+}
diff --git a/test cases/osx/4 framework/xcode-frameworks.png b/test cases/osx/4 framework/xcode-frameworks.png
new file mode 100644
index 0000000..673d05a
--- /dev/null
+++ b/test cases/osx/4 framework/xcode-frameworks.png
Binary files differ
diff --git a/test cases/osx/5 extra frameworks/meson.build b/test cases/osx/5 extra frameworks/meson.build
new file mode 100644
index 0000000..0bd2c17
--- /dev/null
+++ b/test cases/osx/5 extra frameworks/meson.build
@@ -0,0 +1,10 @@
+project('xcode extra framework test', 'c')
+
+dep_libs = dependency('OpenGL', method : 'extraframework')
+assert(dep_libs.type_name() == 'extraframeworks', 'type_name is ' + dep_libs.type_name())
+
+dep_main = dependency('Foundation')
+assert(dep_main.type_name() == 'extraframeworks', 'type_name is ' + dep_main.type_name())
+
+stlib = static_library('stat', 'stat.c', install : true, dependencies: dep_libs)
+exe = executable('prog', 'prog.c', install : true, dependencies: dep_main)
diff --git a/test cases/osx/5 extra frameworks/prog.c b/test cases/osx/5 extra frameworks/prog.c
new file mode 100644
index 0000000..9b6bdc2
--- /dev/null
+++ b/test cases/osx/5 extra frameworks/prog.c
@@ -0,0 +1,3 @@
+int main(void) {
+ return 0;
+}
diff --git a/test cases/osx/5 extra frameworks/stat.c b/test cases/osx/5 extra frameworks/stat.c
new file mode 100644
index 0000000..4825cef
--- /dev/null
+++ b/test cases/osx/5 extra frameworks/stat.c
@@ -0,0 +1 @@
+int func(void) { return 933; }
diff --git a/test cases/osx/5 extra frameworks/test.json b/test cases/osx/5 extra frameworks/test.json
new file mode 100644
index 0000000..8def69a
--- /dev/null
+++ b/test cases/osx/5 extra frameworks/test.json
@@ -0,0 +1,6 @@
+{
+ "installed": [
+ {"type": "file", "file": "usr/bin/prog"},
+ {"type": "file", "file": "usr/lib/libstat.a"}
+ ]
+}
diff --git a/test cases/osx/6 multiframework/main.m b/test cases/osx/6 multiframework/main.m
new file mode 100644
index 0000000..8a6799b
--- /dev/null
+++ b/test cases/osx/6 multiframework/main.m
@@ -0,0 +1,5 @@
+#import <Cocoa/Cocoa.h>
+
+int main(int argc, const char * argv[]) {
+ return NSApplicationMain(argc, argv);
+}
diff --git a/test cases/osx/6 multiframework/meson.build b/test cases/osx/6 multiframework/meson.build
new file mode 100644
index 0000000..2884624
--- /dev/null
+++ b/test cases/osx/6 multiframework/meson.build
@@ -0,0 +1,13 @@
+project('multiframework', 'objc')
+
+# In theory only 'AppKit' would be enough but there was a bug
+# that causes a build failure when defining two modules. The
+# arguments for the latter module overwrote the arguments for
+# the first one rather than adding to them.
+cocoa_dep = dependency('appleframeworks', modules : ['AppKit', 'foundation'])
+
+executable('deptester',
+ 'main.m',
+ objc_args : ['-fobjc-arc'],
+ dependencies : [cocoa_dep],
+)
diff --git a/test cases/osx/7 bitcode/libbar.mm b/test cases/osx/7 bitcode/libbar.mm
new file mode 100644
index 0000000..489b1d1
--- /dev/null
+++ b/test cases/osx/7 bitcode/libbar.mm
@@ -0,0 +1,6 @@
+#import <stdio.h>
+#import "vis.h"
+
+int EXPORT_PUBLIC libbar(void) {
+ return 0;
+}
diff --git a/test cases/osx/7 bitcode/libfile.c b/test cases/osx/7 bitcode/libfile.c
new file mode 100644
index 0000000..8edc66b
--- /dev/null
+++ b/test cases/osx/7 bitcode/libfile.c
@@ -0,0 +1,5 @@
+#include "vis.h"
+
+int EXPORT_PUBLIC libfunc(void) {
+ return 3;
+}
diff --git a/test cases/osx/7 bitcode/libfoo.m b/test cases/osx/7 bitcode/libfoo.m
new file mode 100644
index 0000000..c0f4985
--- /dev/null
+++ b/test cases/osx/7 bitcode/libfoo.m
@@ -0,0 +1,6 @@
+#import <stdio.h>
+#import "vis.h"
+
+int EXPORT_PUBLIC libfoo(void) {
+ return 0;
+}
diff --git a/test cases/osx/7 bitcode/meson.build b/test cases/osx/7 bitcode/meson.build
new file mode 100644
index 0000000..50ce3f2
--- /dev/null
+++ b/test cases/osx/7 bitcode/meson.build
@@ -0,0 +1,11 @@
+project('bitcode test', 'c', 'objc', 'objcpp',
+ default_options : ['b_bitcode=true'])
+
+both_libraries('alib', 'libfoo.m')
+shared_module('amodule', 'libfoo.m')
+
+both_libraries('blib', 'libbar.mm')
+shared_module('bmodule', 'libbar.mm')
+
+both_libraries('clib', 'libfile.c')
+shared_module('cmodule', 'libfile.c')
diff --git a/test cases/osx/7 bitcode/vis.h b/test cases/osx/7 bitcode/vis.h
new file mode 100644
index 0000000..fa252b4
--- /dev/null
+++ b/test cases/osx/7 bitcode/vis.h
@@ -0,0 +1,6 @@
+#if defined __GNUC__
+ #define EXPORT_PUBLIC __attribute__ ((visibility("default")))
+#else
+ #pragma message ("Compiler does not support symbol visibility.")
+ #define EXPORT_PUBLIC
+#endif
diff --git a/test cases/osx/8 pie/main.c b/test cases/osx/8 pie/main.c
new file mode 100644
index 0000000..0a07218
--- /dev/null
+++ b/test cases/osx/8 pie/main.c
@@ -0,0 +1,5 @@
+#include <CoreFoundation/CoreFoundation.h>
+
+int main(void) {
+ return 0;
+}
diff --git a/test cases/osx/8 pie/meson.build b/test cases/osx/8 pie/meson.build
new file mode 100644
index 0000000..e4d66ed
--- /dev/null
+++ b/test cases/osx/8 pie/meson.build
@@ -0,0 +1,3 @@
+project('osx pie', 'c')
+e = executable('prog', 'main.c', pie : true)
+test('pie', e)