-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path_Root.jsmk
206 lines (192 loc) · 6.1 KB
/
_Root.jsmk
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
/**
* Our clap plugin is a single dso/dll that has dependencies on one or more
* other dsos. Our plugin package combines these all into a platform-specifi
* subdirectory structure.
*
* Windows, Linux:
* fluidsynth.clap/ <-- a directory
* fluidsynth.clap <--- the real clap plugin
* libfluidsynth-3.dll <-- the real fluidsynth
* libglib-2.0-0.dll <-- example of libfluidsynth-3 dependency
* ....
* README.md, LICENSE, etc
* MacOS:
* fluidsynth.clap/ <-- a directory/bundle
* Contents/
* MacOS/
* fluidsynth <-- the real clap plugin (shouldn't include .clap)
* PkgInfo
* Resources/
* clap.icns
* _CodeSignature/
* CodeResources (xml/plist)
*/
let pkgj = jsmk.file.read(jsmk.path.join(Project.ProjectDir, "package.json"));
let pkg = JSON.parse(pkgj);
let appName = pkg.label;
let appVers = pkg.version;
Project.EstablishDomain(appName, /(vs|gcc|clang)/,
{
AppName: appName,
Package: appName, // version-less (version installed inside)
Version: appVers,
Track: "beta",
TimestampFile: "BUILD.json",
CppStd: "c++17", // clap prefers modern c++
});
Project.Define({
win32: {
WIN32: null,
__PLATFORM_WIN32__: null,
_CONSOLE: null,
_CRT_SECURE_NO_WARNINGS: null,
},
linux: {
__PLATFORM_LINUX__: null,
LINUX: null
},
darwin: {
__PLATFORM_MACOS__: null,
__MACOSX_CORE__: null,
}
}[process.platform]);
let platform = process.platform;
let installRoot = Project.EvaluateBuildVar("InstallDir");
let fpkg = {
win32: "_prebuilt/fluidsynth-2.3.3-win10-x64",
linux: "_prebuilt/fluidsynth-2.3.3-linux-x64",
darwin: "/opt/homebrew",
// win32: "_prebuilt/fluidsynth-dev-win10-x64"
}[platform];
let fluidSearchpaths = [`${fpkg}/include`];
let fluidLibs =
{
win32: [`${fpkg}/lib/libfluidsynth.dll.a`],
linux: [`${fpkg}/lib/libfluidsynth.so.3`],
darwin: [],
}[platform];
let fluidModules =
{
darwin: ["libfluidsynth"]
}[platform];
if(platform == "darwin") // see build/*/notes.md
{
Project.NewProject("libfluidsynthProj", {
ProjectDir: "fluidsynth/src",
ProjectFilePath: "_LibFluidSynth.jsmk",
}).EstablishBarrier("after");
}
let m = Project.NewModule(appName);
let defs = {
CLAP_PLUGINS_HEADLERS: null,
CLAP_NO_YAS: null
};
let t1 = m.NewTask("compile", "cpp->o",
{
inputs: Project.Glob("src/*.cpp"),
defs,
searchpaths: [
"src",
`clap/include`,
`clap-helpers/include`,
...fluidSearchpaths,
],
});
// jsmk.WARNING(`fluidModules: ${fluidModules} ${platform}`);
// NB: name of task is depended upon during install+renaming.
// NB2: the name of the install dir is governed by package.json (see top)
let linkflags = {
darwin: [],
win32: [],
linux: ["-Wl,-rpath=$ORIGIN"]
}[platform];
let t2 = m.NewTask("FluidSynth", "cpp.o->so", {
inputs: t1.GetOutputs(),
deps: fluidLibs,
modules: fluidModules,
flags: linkflags,
});
switch(platform)
{
case "linux":
case "win32":
{
let ts = jsmk.GetActiveToolset().GetHandle();
let dsoGlob = (platform == "linux") ? "lib/*so*" : "bin/*.dll";
m.NewTask("installPlug", "install", {
inputs: t2.GetOutputs(),
installext: ".clap", // <--------- need separate rule for other files
installdir: "/"
});
/* windows dlls can be downloaded from fluidsynth github */
m.NewTask("installDLLs", "install", {
inputs: Project.Glob(`${fpkg}/${dsoGlob}`),
installdir: "/"
});
/* install the _built to _install, copying on the way --- */
m.NewTask("installLegal", "install", {
inputs: ["README.md", "LICENSE", "BUILD.json", "licenses"],
installdir: "etc",
});
/* finally, we zip ------------------------------- */
let zipfile = `${appName}.${ts}.zip`;
m.NewTask("fluidsynthPackage", "packagescript", {
ARGUMENTS: ["build/zipdir.js", installRoot,
jsmk.path.join(installRoot, "..", zipfile)]
});
}
break;
case "darwin":
// We only perform copy/fixup of dlls during the packaging phase.
// This is because the stripping overlaps with the required signing.
{
let binDir = "Contents/MacOS";
let resourcesDir = "Contents/Resources";
let tcpy = m.NewTask("installPlug", "install", {
inputs: t2.GetOutputs(),
installext: "", // <--------- need separate rule for other files
installdir: binDir,
});
/* no frameworks atm, statically linked
m.NewTask("packageDLLs", "installscript", {
ARGUMENTS: ["build/fixupDLLs.js",
jsmk.path.join(installRoot, frameworksDir),
...tcpy.GetOutputs()
]
})
*/
m.NewTask("installPkg", "install", {
inputs: ["build/darwin/Info.plist", "build/darwin/PkgInfo"],
installdir: "Contents"
});
m.NewTask("installLegal", "install", {
inputs: ["README.md", "LICENSE", "BUILD.json", "licenses", "build/darwin/clap.icns"],
installdir: resourcesDir,
});
// https://developer.apple.com/forums/thread/130855
// -- only sign binaries
// -- only apply entitlements to apps
m.NewTask("osxsign", "packagescript",
{
ARGUMENTS: [
"build/darwin/osxsign.js", installRoot,
]
});
let ts = jsmk.GetActiveToolset().GetHandle();
let dmgExt = `.${ts}.dmg`;
m.NewTask("osxdmg", "packagescript",
{
ARGUMENTS: [
"build/darwin/osxpackage.js", "FluidSynth.clap", installRoot, "build/darwin/Help.rtf",
installRoot+dmgExt
]
});
m.NewTask("osxnotarize", "repositscript",
{
ARGUMENTS: [
"build/darwin/osxnotarize.js", installRoot+dmgExt
]
});
}
break;
}