forked from aguacongas/chatle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_goals.shade
478 lines (406 loc) · 15.2 KB
/
_goals.shade
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
use assembly="System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
use namespace="System"
use namespace="System.Globalization"
use namespace="System.IO"
use namespace="System.Linq"
use namespace="System.Threading.Tasks"
use import="BuildEnv"
use import="Environment"
use import="Files"
use import="Json"
use-ci-loggers
default BASE_DIR='${Directory.GetCurrentDirectory()}'
default TARGET_DIR='${Path.Combine(BASE_DIR, "artifacts")}'
default BUILD_DIR='${Path.Combine(TARGET_DIR, "build")}'
default TEST_DIR='${Path.Combine(TARGET_DIR, "test")}'
default Configuration='${E("Configuration")}'
default PACKAGELIST_JSON_FILENAME = 'NuGetPackageVerifier.json'
default SRC_PROJECT_GLOB = "src/*/project.json"
default TEST_PROJECT_GLOB = "test/*/project.json"
default SAMPLES_PROJECT_GLOB = "samples/*/project.json"
@{
if (!IsTravisCi)
{
if (IsTeamCity || !string.IsNullOrEmpty(E("APPVEYOR")))
{
GitVersion("true");
}
else
{
GitVersion("false");
}
}
if (string.IsNullOrEmpty(E("DOTNET_BUILD_VERSION")))
{
E("DOTNET_BUILD_VERSION", BuildNumber);
}
if (string.IsNullOrEmpty(E("NUGET_AUTHOR")))
{
E("NUGET_AUTHOR", 'Olivier Lefebvre');
}
if (string.IsNullOrEmpty(E("DOTNET_ASSEMBLY_FILE_VERSION")))
{
E("DOTNET_ASSEMBLY_FILE_VERSION", CreateDayBasedVersionNumber());
}
if (string.IsNullOrEmpty(Configuration))
{
Configuration = "Debug";
E("Configuration", Configuration);
}
if (string.IsNullOrEmpty(E("KOREBUILD_DOTNET_RESTORE_OPTIONS")))
{
E("KOREBUILD_DOTNET_RESTORE_OPTIONS", "--infer-runtimes");
}
}
#--for-ci
@{
Configuration = "Release";
E("Configuration", Configuration);
E("KOREBUILD_ADD_ASSEMBLY_INFO", "1");
E("KOREBUILD_DOTNET_PACK_OPTIONS", E("KOREBUILD_DOTNET_PACK_OPTIONS") + " --serviceable");
E("KOREBUILD_VERIFY_NUPKGS", "1");
}
#restore-npm-modules
@{
// Find all dirs that contain a package.json file
var npmDirs = GetDirectoriesContaining(Directory.GetCurrentDirectory(), "package.json").ToArray();
var npmOptions = E("KOREBUILD_NPM_INSTALL_OPTIONS") ?? "--quiet --depth 0";
Parallel.ForEach(npmDirs, npmDir => Npm("install " + npmOptions, npmDir));
}
#restore-bower-components
-// Find all dirs that contain a bower.json file
var bowerDirs = '${GetDirectoriesContaining(Directory.GetCurrentDirectory(), "bower.json")}'
bower each='var bowerDir in bowerDirs' bowerCommand='install ${E("KOREBUILD_BOWER_INSTALL_OPTIONS")}'
#run-gulp .repo-initialize .restore-npm-modules .restore-bower-components target='initialize'
-// Find all dirs that contain a gulpfile.js file
var gulpDirs = '${GetDirectoriesContaining(Directory.GetCurrentDirectory(), "gulpfile.js")}'
gulp each='var gulpDir in gulpDirs'
#clean-bin-folder
rimraf rimrafDir='bin' if='Directory.Exists("bin")'
#clean-npm-modules
-// Find all dirs that contain a package.json file
var npmDirs = '${
GetDirectoriesContaining(Directory.GetCurrentDirectory(), "package.json")
.Select(directory => Path.Combine(directory, "node_modules"))
.Where(directory => Directory.Exists(directory))
}'
rimraf each='var rimrafDir in npmDirs'
-// Target order is important because clean-npm-modules may (re)create bin folder.
#deep-clean .clean-npm-modules .clean-bin-folder description='Clean folders that may cause problems for `git clean`.'
#repo-initialize target='initialize'
use-volatile-feed
dotnet-restore if='!NoRestore'
#target-dir-clean .clean-bin-folder target='clean'
@{
if (Directory.Exists(TARGET_DIR))
{
var directory = new DirectoryInfo(TARGET_DIR);
directory.Attributes &= ~FileAttributes.ReadOnly;
foreach (var info in directory.GetFileSystemInfos("*", SearchOption.AllDirectories))
{
info.Attributes &= ~FileAttributes.ReadOnly;
}
directory.Delete(true);
}
}
#build-clean if='Directory.Exists("src")'
k-clean each='var projectFile in Files.Include("src/*/project.json")'
#ci-deep-clean .deep-clean target='clean' if='IsTeamCity'
#build-compile target='compile'
@{
var projectGlobs = new List<string>();
List<string> srcProjects = null;
if (Directory.Exists("src"))
{
Directory.CreateDirectory(TARGET_DIR);
string commitHash = null;
if (AddAssemblyInfo)
{
var commitHashFile = Path.Combine(TARGET_DIR, "commit");
GitCommand("rev-parse HEAD >> " + commitHashFile);
commitHash = File.ReadAllLines(commitHashFile)[0];
}
srcProjects = Files.Include(SRC_PROJECT_GLOB).ToList();
srcProjects.ForEach(projectFile =>
{
if (AddAssemblyInfo)
{
var projectText = File.ReadAllText(projectFile);
var project = (JsonObject)Json.Deserialize(projectText);
var isSharedProject = project.Keys.Contains("shared");
// We don't want to embed the commit hash in it because
// the consumers would get that file
if (!isSharedProject)
{
Console.WriteLine("Embedding commit hash in assembly");
var projectFolder = Path.GetDirectoryName(projectFile);
var commitHashAttribute = String.Format("[assembly: System.Reflection.AssemblyMetadata(\"CommitHash\", \"{0}\")]", commitHash);
var buildInfoFile = Path.Combine(projectFolder, "BuildInfo.generated.cs");
File.WriteAllText(buildInfoFile, commitHashAttribute);
}
}
});
projectGlobs.Add(SRC_PROJECT_GLOB);
}
if (!BuildSrcOnly && Directory.Exists("test"))
{
projectGlobs.Add(TEST_PROJECT_GLOB);
}
if (!BuildSrcOnly && Directory.Exists("samples"))
{
projectGlobs.Add(SAMPLES_PROJECT_GLOB);
}
if (projectGlobs.Any())
{
DotnetBuild(string.Join(" ", projectGlobs.ToArray()), Configuration, BuildFramework);
}
if (srcProjects != null)
{
srcProjects.ForEach(projectFile =>
{
DotnetPack(projectFile, BUILD_DIR, Configuration, E("KOREBUILD_DOTNET_PACK_OPTIONS") + " --no-build");
});
foreach (var nupkg in Files.Include(Path.Combine(BUILD_DIR, "*/" + Configuration + "/*.nupkg")))
{
File.Copy(nupkg, Path.Combine(BUILD_DIR, Path.GetFileName(nupkg)), true);
}
}
}
#native-compile target='compile' if='!IsLinux && Directory.Exists(Path.Combine(BASE_DIR, "src"))'
var programFilesX86 = '${Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86)}'
var nativeProjects ='${Files.Include(Path.Combine(BASE_DIR, "src", "**", "*.vcxproj"))}'
@{
if (nativeProjects.Any())
{
var msbuildVersions = new[] { "14.0", "12.0"};
for (var i = 0; i < msbuildVersions.Length; i++)
{
var msbuildPath = Path.Combine(programFilesX86, "MSBuild", msbuildVersions[i], "Bin", "MSBuild.exe");
if (File.Exists(msbuildPath))
{
var commonParameters =
" /p:Configuration=" + Configuration +
" /p:ProductVersion=1.0.0" +
" /p:FileRevision=" + E("DNX_ASSEMBLY_FILE_VERSION") +
" /p:BuildVersion=" + E("DNX_BUILD_VERSION");
foreach (var project in nativeProjects)
{
Exec(msbuildPath, project + " /p:Platform=Win32" + commonParameters);
Exec(msbuildPath, project + " /p:Platform=x64" + commonParameters);
}
break;
}
if (i == msbuildVersions.Length - 1)
{
Log.Warn("msbuild version 14 or 12 not found. Please ensure you have the VS 2015 or VS 2013 C++ SDK installed.");
Environment.Exit(1);
}
}
}
}
copy sourceDir='${Path.GetDirectoryName(project)}' include='bin/**/' outputDir='${Path.Combine(BUILD_DIR, Path.GetFileNameWithoutExtension(project))}' overwrite='${true}' each='var project in nativeProjects'
#nuget-verify target='package' description='Verify if all the packages are generated properly'
@{
if (ShouldVerifyNupkgs && File.Exists(PACKAGELIST_JSON_FILENAME))
{
var verifierDirectory = Directory.EnumerateDirectories(Path.Combine(KoreBuildFolderPath, "NuGetPackageVerifier")).First();
Exec(
Path.Combine(verifierDirectory, "NuGetPackageVerifier.exe"),
string.Format("\"{0} \" \"{1} \"", BUILD_DIR, Path.Combine(BASE_DIR, PACKAGELIST_JSON_FILENAME)));
}
}
#nuget-install target='install' description='Install NuGet packages to local repo'
-if (Directory.Exists("src")) {
nuget-packages-add sourcePackagesDir='${BUILD_DIR}' targetPackagesDir='${E("PACKAGES_PUBLISH_DIR")}'
nuget-resilient-publish sourcePackagesDir='${BUILD_DIR}' nugetFeed='${E("NUGET_PUBLISH_FEED")}' if='!string.IsNullOrEmpty(E("NUGET_PUBLISH_FEED"))'
-}
#xunit-test target='test' if='Directory.Exists("test")' description='run tests dotnet test'
@{
var projectFiles = Files.Include("test/**/project.json").Exclude("**/bin/*/app/project.json").ToList();
if (!IsLinux)
{
Log.Info("run opencover");
var coverageFile = Path.Combine(TARGET_DIR, "coverage.xml");
foreach (var projectFile in projectFiles)
{
OpenCoverTest(projectFile, coverageFile, Configuration);
}
}
else
{
Log.Info("run DotnetTest");
foreach (var projectFile in projectFiles)
{
DotnetTest(projectFile, Configuration, E("KOREBUILD_DOTNET_TEST_OPTIONS") + " --no-build");
}
}
}
#chutzpah-test target='test' if='Directory.Exists("test") && !IsLinux' description='run jasmine tests'
@{
var projectFiles = Files.Include("test/**/chutzpah.json").Exclude("**/bin/*/app/chutzpah.json").ToList();
Parallel.ForEach(projectFiles, projectFile => ChutzpahTest(projectFile));
}
#make-roslyn-fast
ngen-roslyn
#resx
@{
var cultures = CultureInfo.GetCultures(CultureTypes.NeutralCultures | CultureTypes.InstalledWin32Cultures | CultureTypes.SpecificCultures);
foreach (var file in Directory.EnumerateFiles(BASE_DIR, "*.resx", SearchOption.AllDirectories))
{
var splitFileName = Path.GetFileNameWithoutExtension(file).Split(new string[] { "." }, StringSplitOptions.None);
if (splitFileName.Length > 1)
{
var localeString = splitFileName.Last();
if (!cultures.Any(c => localeString.Equals(c.Name)))
{
UpdateResx(file);
}
}
else
{
UpdateResx(file);
}
}
}
#--no-restore
@{ NoRestore = true; }
#--quiet
@{
AddToE("KOREBUILD_DOTNET_RESTORE_OPTIONS", "--verbosity minimal");
AddToE("KOREBUILD_BOWER_INSTALL_OPTIONS", "--quiet");
AddToE("KOREBUILD_NPM_INSTALL_OPTIONS", "--quiet --depth 0 --progress false");
Quiet = true;
}
#--parallel
@{ ExecuteParallel = true; }
#--test-dnxcore
@{
Log.Warn("The --test-dnxcore flag is no longer supported. It will be ignored.");
}
functions @{
private static bool Quiet { get; set; }
private static bool NoRestore { get; set; }
private static bool ExecuteParallel { get; set; }
string E(string key) { return Environment.GetEnvironmentVariable(key); }
void E(string key, string value) { Environment.SetEnvironmentVariable(key, value); }
void AddToE(string key, string append)
{
var original = E(key);
if (string.IsNullOrEmpty(original))
{
E(key, append);
}
else
{
E(key, original + " " + append);
}
}
IEnumerable<string> GetDirectoriesContaining(string path, string searchPattern)
{
var sep = Path.DirectorySeparatorChar;
// Don't include directories that are children of a node_modules or bower_components directory
return Directory.GetFiles(path, searchPattern, SearchOption.AllDirectories)
.Where(p => p.IndexOf(sep + "node_modules" + sep) < 0 &&
p.IndexOf(sep + "bower_components" + sep) < 0 &&
p.IndexOf(sep + "wwwroot" + sep + "lib" + sep) < 0)
.Select(p => Path.GetDirectoryName(p))
.Distinct();
}
bool TestCommand(string program, string commandline)
{
// Tests whether a given command succeeds at the command line.
// Useful for testing whether a given command is installed and on the path, e.g. node
ProcessStartInfo processStartInfo;
if(!IsLinux)
{
processStartInfo = new ProcessStartInfo {
UseShellExecute = false,
FileName = "cmd",
Arguments = "/C " + program + " " + commandline,
};
} else
{
processStartInfo = new ProcessStartInfo {
UseShellExecute = false,
FileName = program,
Arguments = commandline,
};
}
try
{
Log.Info(string.Format("Testing for command: {0} {1}", program, commandline));
var process = Process.Start(processStartInfo);
process.WaitForExit();
if (process.ExitCode == 0)
{
Log.Info(" command found (0 exit code)");
return true;
}
else
{
Log.Warn(" command not found (non-0 exit code)");
return false;
}
}
catch (Exception ex)
{
Log.Warn(" command exception: " + ex.ToString());
Log.Warn(" command not found");
return false;
}
}
bool ShouldVerifyNupkgs
{
get { return E("KOREBUILD_VERIFY_NUPKGS") == "1"; }
}
bool BuildSrcOnly
{
get { return E("KOREBUILD_BUILD_SRC_ONLY") == "1"; }
}
bool AddAssemblyInfo
{
get { return E("KOREBUILD_ADD_ASSEMBLY_INFO") == "1"; }
}
string BuildFramework
{
get { return E("KOREBUILD_BUILD_FRAMEWORK"); }
}
}
macro name='Exec' program='string' commandline='string'
exec
macro name='Exec' program='string' commandline='string' workingdir='string'
exec
macro name='ExecClr' program='string' commandline='string'
exec-clr
macro name='ExecClr' program='string' commandline='string' workingdir='string'
exec-clr
macro name="DeleteFolder" delete='string'
directory
macro name="Copy" sourceDir='string' outputDir='string' include='string' overwrite='bool'
copy
macro name="CopyFolder" sourceDir='string' outputDir='string' overwrite='bool'
copy
macro name='Dotnet' command='string'
dotnet
macro name='Dotnet' command='string' dotnetDir='string'
dotnet
macro name="DotnetBuild" projectFile='string' configuration='string' framework='string'
dotnet-build
macro name="DotnetPack" projectFile='string' dotnetPackOutputDir='string' configuration='string' pack_options='string'
dotnet-pack
macro name="DotnetPublish" projectFile='string' outputFolder='string' framework='string' configuration='string'
dotnet-publish
macro name="DotnetTest" projectFile='string' configuration='string' test_options='string'
dotnet-test
macro name='Npm' npmCommand='string' npmDir='string'
npm
macro name="UpdateResx" resxFile='string'
k-generate-resx
macro name='GitCommand' gitCommand='string'
git
macro name="ChutzpahTest" projectFile='string'
chutzpah
macro name="OpenCoverTest" projectFile='string' coverageFile='string' configuration='string'
opencover
macro name="GitVersion" updateAssemblyInfo='string'
gitversion