diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-29 04:41:38 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-29 04:41:38 +0000 |
commit | 7b6e527f440cd7e6f8be2b07cee320ee6ca18786 (patch) | |
tree | 4a2738d69fa2814659fdadddf5826282e73d81f4 /test cases/swift | |
parent | Initial commit. (diff) | |
download | meson-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 '')
31 files changed, 139 insertions, 0 deletions
diff --git a/test cases/swift/1 exe/main.swift b/test cases/swift/1 exe/main.swift new file mode 100644 index 0000000..1b489de --- /dev/null +++ b/test cases/swift/1 exe/main.swift @@ -0,0 +1 @@ +print("Swift executable is working.") diff --git a/test cases/swift/1 exe/meson.build b/test cases/swift/1 exe/meson.build new file mode 100644 index 0000000..4436a8e --- /dev/null +++ b/test cases/swift/1 exe/meson.build @@ -0,0 +1,3 @@ +project('swift exe', 'swift') + +test('swifttest', executable('swifttest', 'main.swift')) diff --git a/test cases/swift/2 multifile/libfile.swift b/test cases/swift/2 multifile/libfile.swift new file mode 100644 index 0000000..45f941c --- /dev/null +++ b/test cases/swift/2 multifile/libfile.swift @@ -0,0 +1,3 @@ +func printSomething(text: String) { + print("Got this: \(text)") +} diff --git a/test cases/swift/2 multifile/main.swift b/test cases/swift/2 multifile/main.swift new file mode 100644 index 0000000..9867e85 --- /dev/null +++ b/test cases/swift/2 multifile/main.swift @@ -0,0 +1,5 @@ +#if swift(>=3.0) +printSomething(text:"String from main") +#else +printSomething("String from main") +#endif diff --git a/test cases/swift/2 multifile/meson.build b/test cases/swift/2 multifile/meson.build new file mode 100644 index 0000000..9012f3d --- /dev/null +++ b/test cases/swift/2 multifile/meson.build @@ -0,0 +1,3 @@ +project('2 files', 'swift') + +test('2files', executable('twofiles', 'main.swift', 'libfile.swift')) diff --git a/test cases/swift/3 library/exe/main.swift b/test cases/swift/3 library/exe/main.swift new file mode 100644 index 0000000..c5de373 --- /dev/null +++ b/test cases/swift/3 library/exe/main.swift @@ -0,0 +1,7 @@ +import DataSource + +let data = getData() +let data2 = getOther() + +print("String from module: \(data)") +print("Other string: \(data2)") diff --git a/test cases/swift/3 library/exe/meson.build b/test cases/swift/3 library/exe/meson.build new file mode 100644 index 0000000..6c13957 --- /dev/null +++ b/test cases/swift/3 library/exe/meson.build @@ -0,0 +1,2 @@ +exe = executable('dataprog', 'main.swift', link_with : datasource) +test('dataprog', exe) diff --git a/test cases/swift/3 library/lib/datasource.swift b/test cases/swift/3 library/lib/datasource.swift new file mode 100644 index 0000000..4ac7c2a --- /dev/null +++ b/test cases/swift/3 library/lib/datasource.swift @@ -0,0 +1,3 @@ +public func getData() -> String { + return "String from module." +} diff --git a/test cases/swift/3 library/lib/meson.build b/test cases/swift/3 library/lib/meson.build new file mode 100644 index 0000000..fc65556 --- /dev/null +++ b/test cases/swift/3 library/lib/meson.build @@ -0,0 +1 @@ +datasource = static_library('DataSource', 'datasource.swift', 'othersource.swift') diff --git a/test cases/swift/3 library/lib/othersource.swift b/test cases/swift/3 library/lib/othersource.swift new file mode 100644 index 0000000..fb668ba --- /dev/null +++ b/test cases/swift/3 library/lib/othersource.swift @@ -0,0 +1,3 @@ +public func getOther() -> String { + return "String from other source." +} diff --git a/test cases/swift/3 library/meson.build b/test cases/swift/3 library/meson.build new file mode 100644 index 0000000..d601721 --- /dev/null +++ b/test cases/swift/3 library/meson.build @@ -0,0 +1,4 @@ +project('linking', 'swift') + +subdir('lib') +subdir('exe') diff --git a/test cases/swift/4 generate/gen/main.swift b/test cases/swift/4 generate/gen/main.swift new file mode 100644 index 0000000..03acdbb --- /dev/null +++ b/test cases/swift/4 generate/gen/main.swift @@ -0,0 +1,18 @@ +#if os(OSX) + import Darwin +#else + import Glibc +#endif + +#if swift(>=3.0) +let fname = CommandLine.arguments[1] +#else +let fname = Process.arguments[1] +#endif +let code = "public func getGenerated() -> Int {\n return 42\n}\n" + +let f = fopen(fname, "w") + +fwrite(code, 1, Int(strlen(code)), f) +print("Name: \(fname)") +fclose(f) diff --git a/test cases/swift/4 generate/gen/meson.build b/test cases/swift/4 generate/gen/meson.build new file mode 100644 index 0000000..8cd7e04 --- /dev/null +++ b/test cases/swift/4 generate/gen/meson.build @@ -0,0 +1,6 @@ +gen = executable('gen', 'main.swift') + +srcs = custom_target('gensrc', + output : 'gen.swift', + command : [gen, '@OUTPUT@'] +) diff --git a/test cases/swift/4 generate/meson.build b/test cases/swift/4 generate/meson.build new file mode 100644 index 0000000..ccc7d5c --- /dev/null +++ b/test cases/swift/4 generate/meson.build @@ -0,0 +1,4 @@ +project('swift generator', 'swift') + +subdir('gen') +subdir('user') diff --git a/test cases/swift/4 generate/user/main.swift b/test cases/swift/4 generate/user/main.swift new file mode 100644 index 0000000..e6b46cd --- /dev/null +++ b/test cases/swift/4 generate/user/main.swift @@ -0,0 +1,3 @@ +let generated = getGenerated() + +print("Generated number is: \(generated).") diff --git a/test cases/swift/4 generate/user/meson.build b/test cases/swift/4 generate/user/meson.build new file mode 100644 index 0000000..fc4722d --- /dev/null +++ b/test cases/swift/4 generate/user/meson.build @@ -0,0 +1,2 @@ +user = executable('user', 'main.swift', srcs) +test('User test', user) diff --git a/test cases/swift/5 mixed/main.swift b/test cases/swift/5 mixed/main.swift new file mode 100644 index 0000000..5574126 --- /dev/null +++ b/test cases/swift/5 mixed/main.swift @@ -0,0 +1,3 @@ +let num = getNumber() + +print("The number returned from C code is: \(num).") diff --git a/test cases/swift/5 mixed/meson.build b/test cases/swift/5 mixed/meson.build new file mode 100644 index 0000000..71cb99d --- /dev/null +++ b/test cases/swift/5 mixed/meson.build @@ -0,0 +1,6 @@ +project('mixed', 'c', 'swift') + +lib = static_library('mylib', 'mylib.c') +exe = executable('prog', 'main.swift', 'mylib.h', + link_with : lib) +test('c interface', exe) diff --git a/test cases/swift/5 mixed/mylib.c b/test cases/swift/5 mixed/mylib.c new file mode 100644 index 0000000..e091836 --- /dev/null +++ b/test cases/swift/5 mixed/mylib.c @@ -0,0 +1,5 @@ +#include"mylib.h" + +int getNumber() { + return 42; +} diff --git a/test cases/swift/5 mixed/mylib.h b/test cases/swift/5 mixed/mylib.h new file mode 100644 index 0000000..21bd9eb --- /dev/null +++ b/test cases/swift/5 mixed/mylib.h @@ -0,0 +1,3 @@ +#pragma once + +int getNumber(); diff --git a/test cases/swift/6 modulemap/main.swift b/test cases/swift/6 modulemap/main.swift new file mode 100644 index 0000000..1a38c25 --- /dev/null +++ b/test cases/swift/6 modulemap/main.swift @@ -0,0 +1,5 @@ +import mylib + +let num = getNumber() + +print("The number returned from C code is: \(num).") diff --git a/test cases/swift/6 modulemap/meson.build b/test cases/swift/6 modulemap/meson.build new file mode 100644 index 0000000..f1c90db --- /dev/null +++ b/test cases/swift/6 modulemap/meson.build @@ -0,0 +1,8 @@ +project('mixed', 'c', 'swift') + +i = include_directories('.') +lib = static_library('mylib', 'mylib.c') +exe = executable('prog', 'main.swift', + include_directories : [i], + link_with : lib) +test('c module', exe) diff --git a/test cases/swift/6 modulemap/module.modulemap b/test cases/swift/6 modulemap/module.modulemap new file mode 100644 index 0000000..5aab62e --- /dev/null +++ b/test cases/swift/6 modulemap/module.modulemap @@ -0,0 +1,5 @@ +module mylib [extern_c] { + header "mylib.h" + link "mylib" + export * +} diff --git a/test cases/swift/6 modulemap/mylib.c b/test cases/swift/6 modulemap/mylib.c new file mode 100644 index 0000000..e091836 --- /dev/null +++ b/test cases/swift/6 modulemap/mylib.c @@ -0,0 +1,5 @@ +#include"mylib.h" + +int getNumber() { + return 42; +} diff --git a/test cases/swift/6 modulemap/mylib.h b/test cases/swift/6 modulemap/mylib.h new file mode 100644 index 0000000..21bd9eb --- /dev/null +++ b/test cases/swift/6 modulemap/mylib.h @@ -0,0 +1,3 @@ +#pragma once + +int getNumber(); diff --git a/test cases/swift/7 modulemap subdir/main.swift b/test cases/swift/7 modulemap subdir/main.swift new file mode 100644 index 0000000..1a38c25 --- /dev/null +++ b/test cases/swift/7 modulemap subdir/main.swift @@ -0,0 +1,5 @@ +import mylib + +let num = getNumber() + +print("The number returned from C code is: \(num).") diff --git a/test cases/swift/7 modulemap subdir/meson.build b/test cases/swift/7 modulemap subdir/meson.build new file mode 100644 index 0000000..cd769eb --- /dev/null +++ b/test cases/swift/7 modulemap subdir/meson.build @@ -0,0 +1,6 @@ +project('mixed', 'c', 'swift') +add_project_arguments('-embed-bitcode', language : 'swift') +subdir('mylib') +exe = executable('prog', 'main.swift', + dependencies : dep) +test('c module', exe) diff --git a/test cases/swift/7 modulemap subdir/mylib/meson.build b/test cases/swift/7 modulemap subdir/mylib/meson.build new file mode 100644 index 0000000..2549e2b --- /dev/null +++ b/test cases/swift/7 modulemap subdir/mylib/meson.build @@ -0,0 +1,4 @@ + +i = include_directories('.') +lib = static_library('mylib', 'mylib.c') +dep = declare_dependency(include_directories : i, link_with : lib) diff --git a/test cases/swift/7 modulemap subdir/mylib/module.modulemap b/test cases/swift/7 modulemap subdir/mylib/module.modulemap new file mode 100644 index 0000000..5aab62e --- /dev/null +++ b/test cases/swift/7 modulemap subdir/mylib/module.modulemap @@ -0,0 +1,5 @@ +module mylib [extern_c] { + header "mylib.h" + link "mylib" + export * +} diff --git a/test cases/swift/7 modulemap subdir/mylib/mylib.c b/test cases/swift/7 modulemap subdir/mylib/mylib.c new file mode 100644 index 0000000..e091836 --- /dev/null +++ b/test cases/swift/7 modulemap subdir/mylib/mylib.c @@ -0,0 +1,5 @@ +#include"mylib.h" + +int getNumber() { + return 42; +} diff --git a/test cases/swift/7 modulemap subdir/mylib/mylib.h b/test cases/swift/7 modulemap subdir/mylib/mylib.h new file mode 100644 index 0000000..21bd9eb --- /dev/null +++ b/test cases/swift/7 modulemap subdir/mylib/mylib.h @@ -0,0 +1,3 @@ +#pragma once + +int getNumber(); |