-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPackage.swift
81 lines (66 loc) · 2.75 KB
/
Package.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// swift-tools-version: 5.6
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
var libraryType: Product.Library.LibraryType? = nil
#if os(Windows)
libraryType = .dynamic
#endif
var cSettings: [CSetting] {
return [
.define("LUA_USE_APICHECK", .when(configuration: .debug)),
// Flags
//.unsafeFlags(["-Wall", "-fno-stack-protector", "-fno-common"]),
//.unsafeFlags(["-O2"], .when(configuration: .release)),
// Windows
.define("LUA_BUILD_AS_DLL", .when(platforms: [.windows])),
.define("_CRT_SECURE_NO_WARNINGS", .when(platforms: [.windows])), // Silence warnings
.define("_CINDEX_LIB_", .when(platforms: [.windows])),
// .unsafeFlags(["-Od"], .when(platforms: [.windows])),
// Linux
.define("LUA_USE_LINUX", .when(platforms: [.linux])),
.define("LUA_USE_READLINE", .when(platforms: [.linux])),
// macOS
.define("LUA_USE_MACOSX", .when(platforms: [.macOS])),
.define("LUA_USE_READLINE", .when(platforms: [.macOS])),
// iOS
.define("LUA_USE_POSIX", .when(platforms: [.iOS, .tvOS, .macCatalyst])),
.define("LUA_USE_DLOPEN", .when(platforms: [.iOS, .tvOS, .macCatalyst])),
.define("LUA_USE_READLINE", .when(platforms: [.iOS, .tvOS, .macCatalyst])),
]
}
var sources: [String] {
var array: [String] = []
let core = ["lapi.c", "lcode.c", "lctype.c", "ldebug.c", "ldo.c", "ldump.c", "lfunc.c", "lgc.c", "llex.c", "lmem.c", "lobject.c", "lopcodes.c", "lparser.c", "lstate.c", "lstring.c", "ltable.c", "ltm.c", "lundump.c", "lvm.c", "lzio.c"]
array.append(contentsOf: core.map({"src/" + $0}))
let lib = ["lauxlib.c", "lbaselib.c", "lcorolib.c", "ldblib.c", "liolib.c", "lmathlib.c", "loadlib.c", "loslib.c", "lstrlib.c", "ltablib.c", "lutf8lib.c", "linit.c"]
array.append(contentsOf: lib.map({"src/" + $0}))
return array
}
var exclude: [String] {
let files = ["Makefile", "lua.c", "luac.c"]
return files.map({"src/" + $0})
}
var cLanguageStandard: CLanguageStandard {
#if os(Windows)
return .c89
#else
return .c99
#endif
}
let package = Package(
name: "Lua",
products: [
.library(name: "Lua", type: libraryType, targets: ["Lua"]),
.library(name: "LuaC", type: libraryType, targets: ["LuaC"]),
],
targets: [
.target(name: "_LuaC",
exclude: exclude,
sources: sources,
publicHeadersPath: "Include",
cSettings: cSettings),
.target(name: "LuaC", dependencies: ["_LuaC"]),
.target(name: "Lua", dependencies: ["LuaC"]),
],
cLanguageStandard: cLanguageStandard
)