Project

Profile

Help

Download (33 KB) Statistics
| Branch: | Revision:

he / build-n.gradle @ d1236b02

1 72bf04c6 Norman Walsh
// Find C# compiler: the first path that exists in this list
2
// will be used as the C# compiler.
3
//
4
def csharpCompiler = null
5
["C:/Windows/Microsoft.net/Framework/${dotNetFrameworkVersion}/csc.exe",
6
 "z:/some/other/compiler/path"].each { csc ->
7
  // This only makes sense on Windows, so always using file:/// is ok
8
  if (csharpCompiler == null && pathExists(csc)) {
9
    csharpCompiler = csc
10
  }
11
}
12
13 9b52d94c Norman Walsh
def additionalIkvmOptions = []
14
if (hasProperty("ikvmDebug")) {
15
  additionalIkvmOptions += ["-debug"]
16
}
17
18 72bf04c6 Norman Walsh
task hen_setupPreprocess(
19
  type: Copy,
20 4ae20fb4 Norman Walsh
  dependsOn: ["hej_featureKeys"],
21 72bf04c6 Norman Walsh
  description: "Copy HE sources for preprocessing HE"
22
) {
23
  from "${projectDir}/src/main/java"
24
  into "${buildDir}/filtered/hen"
25
  include "net/sf/saxon/**/*.java"
26
  include "net/sf/saxon/data/**"
27
  exclude "net/sf/saxon/option/cpp/**"
28
  exclude "net/sf/saxon/jetonnet/**"
29
  exclude "net/sf/saxon/Gizmo.java"
30
  exclude "**/TransformerFactoryImpl.java"
31
  exclude "net/sf/saxon/BasicTransformerFactory.java"
32
  exclude "**/ant/**"
33
  exclude "**/dom/**"
34
  exclude "**/dom4j/**"
35
  exclude "**/java/**"
36
  exclude "**/testdriver/**"
37
  exclude "net/sf/saxon/testdriver/**/*.java"
38
  exclude "**/jaxp/**"
39
  exclude "**/jdom/**"
40
  exclude "**/jdom2/**"
41
  exclude "**/axiom/**"
42
  exclude "**/s9api/DOMDestination.java"
43
  exclude "**/sql/**"
44
  exclude "**/xom/**"
45
  exclude "**/xpath/**"
46
  exclude "**/xqj/**"
47
  exclude "**/stax/**"
48
}
49
50
task pen_setupPreprocess(
51
  type: Copy,
52 4ae20fb4 Norman Walsh
  dependsOn: ["hec_featureKeys"],
53 72bf04c6 Norman Walsh
  description: "Copy PE sources for preprocessing PE"
54
) {
55
  from "${projectDir}/src/main/java"
56
  into "${buildDir}/filtered/pen"
57
  include "net/sf/saxon/**/*.java"
58
  include "net/sf/saxon/data/**"
59
  exclude "net/sf/saxon/option/cpp/**"
60
  exclude "net/sf/saxon/jetonnet/**"
61
  exclude "net/sf/saxon/Gizmo.java"
62
  exclude "**/TransformerFactoryImpl.java"
63
  exclude "net/sf/saxon/BasicTransformerFactory.java"
64
  exclude "**/testdriver/**"
65
  exclude "**/ant/**"
66
  exclude "**/dom/**"
67
  exclude "**/dom4j/**"
68
  exclude "**/java/**"
69
  exclude "**/jaxp/**"
70
  exclude "**/jdom/**"
71
  exclude "**/jdom2/**"
72
  exclude "**/axiom/**"
73
  exclude "**/s9api/DOMDestination.java"
74
  exclude "**/sql/**"
75
  exclude "**/xom/**"
76
  exclude "**/xpath/**"
77
  exclude "**/xqj/**"
78
  exclude "**/stax/**"
79
  include "com/saxonica/**/*.java"
80
  exclude "com/saxonica/ee/**/*.java"
81
  exclude "com/saxonica/functions/extfn/cpp/*.java"
82
  exclude "com/saxonica/testdriver/**/*.java"
83
  exclude "net/sf/saxon/testdriver/**/*.java"
84
  exclude "com/saxonica/jaxp/*.java"
85
  exclude "com/saxonica/js/**"
86
  exclude "com/saxonica/config/ProfessionalXPathFactory.java" 
87
  exclude "com/saxonica/config/EnterpriseConfiguration.java" 
88
  exclude "com/saxonica/config/JavaPlatformPE.java" 
89
  exclude "com/saxonica/config/JavaPlatformEE.java" 
90
  exclude "com/saxonica/config/JavaPlatformC.java"
91
  exclude "com/saxonica/config/ee/**" 
92
  exclude "com/saxonica/stream/**" 
93
  exclude "com/saxonica/schema/**" 
94
  exclude "com/saxonica/bytecode/**" 
95
  exclude "com/saxonica/expr/ee/**" 
96
  exclude "com/saxonica/update/**/*.java"
97
  exclude "com/saxonica/validate/**/*.java"
98
  exclude "com/saxonica/expr/CastToUnion.java"
99
  exclude "com/saxonica/expr/CastableToUnion.java"
100
  exclude "com/saxonica/expr/CastableToUnion.java"
101
  exclude "com/saxonica/Validate.java"
102
  exclude "com/saxonica/config/ProfessionalTransformerFactory.java"
103
  exclude "com/saxonica/config/ProfessionalXPathFactory.java"
104
  exclude "com/saxonica/config/EnterpriseTransformerFactory.java"
105
  exclude "com/saxonica/config/StreamingTransformerFactory.java"
106
  exclude "com/saxonica/config/EnterpriseXPathFactory.java"
107
  exclude "com/saxonica/config/DynamicLoaderEE.java"
108
  exclude "com/saxonica/config/StandardSchemaResolver.java"
109
  exclude "com/saxonica/functions/extfn/NativeCall.java"
110
  exclude "**/xqj/**"
111
}
112
113
task een_setupPreprocess(
114
  type: Copy,
115 4ae20fb4 Norman Walsh
  dependsOn: ["hec_featureKeys"],
116 72bf04c6 Norman Walsh
  description: "Copy EE sources for preprocessing EE"
117
) {
118
  from "${projectDir}/src/main/java"
119
  into "${buildDir}/filtered/een"
120
  include "net/sf/saxon/**/*.java"
121
  include "net/sf/saxon/data/**"
122
  exclude "net/sf/saxon/TransformerFactoryImpl.java"
123
  exclude "net/sf/saxon/BasicTransformerFactory.java"
124
  exclude "net/sf/saxon/option/cpp/**"
125
  exclude "net/sf/saxon/jetonnet/**"
126 8e6cebbc Norman Walsh
  exclude "net/sf/saxon/Gizmo.java"
127 72bf04c6 Norman Walsh
  exclude "**/ant/**"
128
  exclude "**/dom/**"
129
  exclude "**/dom4j/**"
130
  exclude "**/java/**"
131
  exclude "**/jaxp/**"
132
  exclude "**/jdom/**"
133
  exclude "**/jdom2/**"
134
  exclude "**/axiom/**"
135
  exclude "**/s9api/DOMDestination.java"
136
  exclude "**/sql/**"
137
  exclude "**/xom/**"
138
  exclude "**/xpath/**"
139
  exclude "**/xqj/**"
140
  exclude "**/stax/**"
141
  include "com/saxonica/**/*.java"
142
  exclude "com/saxonica/functions/extfn/cpp/*.java"
143
  exclude "com/saxonica/testdriver/**/*.java"
144
  exclude "net/sf/saxon/testdriver/**/*.java"
145
  exclude "com/saxonica/ee/jaxp/*.java"
146
  exclude "com/saxonica/js/**"
147
  exclude "com/saxonica/ee/domino/**/*.java"
148
  exclude "com/saxonica/config/JavaPlatformPE.java"
149
  exclude "com/saxonica/config/JavaPlatformEE.java"
150
  exclude "com/saxonica/config/JavaPlatformC.java"
151
  exclude "com/saxonica/config/ProfessionalXPathFactory.java"
152
  exclude "com/saxonica/config/EnterpriseXPathFactory.java"
153
  exclude "com/saxonica/config/ProfessionalTransformerFactory.java"
154
  exclude "com/saxonica/config/EnterpriseTransformerFactory.java"
155
  exclude "com/saxonica/config/StreamingTransformerFactory.java"
156
  exclude "com/saxonica/config/NativePlatformPE.java"
157
  exclude "**/xqj/**"
158
}
159
160
task hen_preprocess(
161
  type: JavaExec,
162
  dependsOn: ["hen_setupPreprocess"],
163
  description: "Preprocess HE sources"
164
) {
165
  inputs.files fileTree(dir: "${buildDir}/filtered/hen")
166
  outputs.files fileTree(dir: "${buildDir}/preprocess/hen")
167
  classpath = configurations.preprocessor
168
  main = "com.igormaznitsa.jcp.JcpPreprocessor"
169
  args "/c",
170
    "/i:${buildDir}/filtered/hen", "/o:${buildDir}/preprocess/hen",
171
    "/p:EE=false", "/p:PE=false", "/p:DOTNET=true",
172
    "/p:SAXONC=false", "/p:BYTECODE=false"
173
  doFirst {
174
    mkdir "${buildDir}/preprocess/hen"
175
  }
176
}
177
178
task pen_preprocess(
179
  type: JavaExec,
180
  dependsOn: ["pen_setupPreprocess"],
181
  description: "Preprocess PE sources"
182
) {
183
  inputs.files fileTree(dir: "${buildDir}/filtered/pen")
184
  outputs.files fileTree(dir: "${buildDir}/preprocess/pen")
185
  classpath = configurations.preprocessor
186
  main = "com.igormaznitsa.jcp.JcpPreprocessor"
187
  args "/c",
188
    "/i:${buildDir}/filtered/pen", "/o:${buildDir}/preprocess/pen",
189
    "/p:EE=false", "/p:PE=true", "/p:DOTNET=true",
190
    "/p:SAXONC=false", "/p:BYTECODE=false", "/p:HOF=true"
191
  doFirst {
192
    mkdir "${buildDir}/preprocess/pen"
193
  }
194
}
195
196
task een_preprocess(
197
  type: JavaExec,
198
  dependsOn: ["een_setupPreprocess"],
199
  description: "Preprocess EE sources"
200
) {
201
  inputs.files fileTree(dir: "${buildDir}/filtered/een")
202
  outputs.files fileTree(dir: "${buildDir}/preprocess/een")
203
  classpath = configurations.preprocessor
204
  main = "com.igormaznitsa.jcp.JcpPreprocessor"
205
  args "/c",
206
    "/i:${buildDir}/filtered/een", "/o:${buildDir}/preprocess/een",
207
    "/p:EE=true", "/p:PE=false", "/p:DOTNET=true",
208
    "/p:SAXONC=false", "/p:BYTECODE=true", "/p:HOF=true",
209
    "/p:STREAM=true", "/p:SCHEMA=true"
210
  doFirst {
211
    mkdir "${buildDir}/preprocess/een"
212
  }
213
}
214
215
task hen_sources(
216
  type: Copy,
217
  dependsOn: ["hen_preprocess"],
218
  description: "Collect the preprocessed HE sources for compilation"
219
) {
220
  from "${buildDir}/preprocess/hen"
221
  into "${buildDir}/src/hen"
222
  filter { line ->
223
    if (line.contains("import com.saxonica")
224
        || line.contains("import net.sf.saxon.stax")
225
        || line.contains("import net.sf.saxon.jaxp")
226
        || line.contains("net.sf.saxon.xpath.JAXPXPathStaticContext")) {
227
      null
228
    } else {
229
      line
230
    }
231
  }
232
}
233
234
task pen_sources(
235
  type: Copy,
236
  dependsOn: ["pen_preprocess"],
237
  description: "Collect the preprocessed PE sources for compilation"
238
) {
239
  from "${buildDir}/preprocess/pen"
240
  into "${buildDir}/src/pen"
241
  filter { line ->
242
    if (line.contains("import com.saxonica.ee")
243
        || line.contains("import com.saxonica.config.ee")
244
        || line.contains("net.sf.saxon.xpath.JAXPXPathStaticContext")
245
        || line.contains("import net.sf.saxon.stax")
246
        || line.contains("import net.sf.saxon.jaxp")) {
247
      null
248
    } else {
249
      line
250
    }
251
  }
252
}
253
254
task een_sources(
255
  type: Copy,
256
  dependsOn: ["een_preprocess"],
257
  description: "Collect the preprocessed EE sources for compilation"
258
) {
259
  from "${buildDir}/preprocess/een"
260
  into "${buildDir}/src/een"
261
  filter { line ->
262
    if (line.contains("net.sf.saxon.xpath.JAXPXPathStaticContext")
263
        || line.contains("import com.saxonica.ee.jaxp.SchemaFactoryImpl")
264
        || line.contains("import net.sf.saxon.stax")
265
        || line.contains("import net.sf.saxon.jaxp")) {
266
      null
267
    } else {
268
      line
269
    }
270
  }
271
}
272
273
// ============================================================
274
275
Task chsa = task hen_copySaxonApi(
276
  type: Copy,
277
  description: "Copy the Saxon.API C# files"
278
) {
279
  from "${projectDir}/src/main/csharp/api/Saxon.Api"
280
  into "${buildDir}/n/csharp/api/Saxon.Api"
281
  include "*.cs"
282
}
283
284
task hen_ApiAssemblyInfo(
285
  description: "Create the AssemblyInfo.cs file for the Saxon.Api"
286
) {
287
  outputs.file("${buildDir}/n/csharp/api/Saxon.Api/Properties/AssemblyInfo.cs")
288
  doLast {
289
    new File("${buildDir}/n/csharp/api/Saxon.Api/Properties/AssemblyInfo.cs")
290
      .withWriter("utf-8") { writer ->
291
        writer.writeLine("          using System.Reflection;")
292
        writer.writeLine("          using System.Runtime.CompilerServices;")
293
        writer.writeLine("          using System.Runtime.InteropServices;")
294
        writer.writeLine("          [assembly: AssemblyTitle(\"Saxon.Api\")]")
295
        writer.writeLine("          [assembly: AssemblyDescription(\"\")]")
296
        writer.writeLine("          [assembly: AssemblyConfiguration(\"\")]")
297
        writer.writeLine("          [assembly: AssemblyCompany(\"Saxonica\")]")
298
        writer.writeLine("          [assembly: AssemblyProduct(\"Saxon.Api\")]")
299
        writer.writeLine("          [assembly: AssemblyCopyright(\"Copyright © Saxonica 2019\")]")
300
        writer.writeLine("          [assembly: AssemblyTrademark(\"\")]")
301
        writer.writeLine("          [assembly: AssemblyCulture(\"\")]")
302
        writer.writeLine("          [assembly: ComVisible(false)]")
303
        writer.writeLine("          [assembly: Guid(\"8cf9aad8-da5f-47f0-9251-1fbcbdcfe477\")]")
304
        writer.writeLine("          [assembly: AssemblyVersion(\"${saxonVersion}\")]")
305
        writer.writeLine("          [assembly: AssemblyFileVersion(\"${saxonVersion}\")]")
306
      }
307
  }
308
  doFirst {
309
    mkdir "${buildDir}/n/csharp/api/Saxon.Api/Properties"
310
  }
311
}
312
313
task hen_copySaxonCmd(
314
  type: Copy,
315
  description: "Copy the cmd C# files"
316
) {
317
  from "${projectDir}/src/main/csharp/cmd"
318
  into "${buildDir}/n/csharp/cmd"
319
  include "**/Transform.cs"
320
  include "**/Query.cs"
321
  include "**/Validate.cs"
322
}
323
324
task hen_copySamples(
325
  type: Copy,
326
  description: "Copy the HE sample C# files"
327
) {
328
  from "${projectDir}/src/samples/cs"
329
  into "${buildDir}/n/csharp/samples"
330
  include "ExamplesEE.cs"
331
  include "ExamplesHE.cs"
332
  include "ExamplesPE.cs"
333
  include "SampleExtensions.cs"
334
  include "XPathExample.cs"
335
}
336
337
task hen_copyDevelopmentSources(
338
  dependsOn: ["hen_copySaxonApi", "hen_ApiAssemblyInfo",
339
              "hen_copySaxonCmd", "hen_copySamples"],
340
  description: "Setup the C# build environment"
341
) {
342
    // Just a task to hang dependencies on
343
}
344
345
task henCompile(
346
  type: JavaCompile,
347
  dependsOn: ["hen_sources", "hen_copyDevelopmentSources"],
348
  description: "Compile HE for .NET"
349
) {
350
  classpath = configurations.compileClasspath + configurations.compileDotNet
351
  source = "${buildDir}/src/hen"
352
  destinationDirectory = new File("${buildDir}/classes/hen")
353
}
354
355
task penCompile(
356
  type: JavaCompile,
357
  dependsOn: ["pen_sources", "hen_copyDevelopmentSources"],
358
  description: "Compile PE for .NET"
359
) {
360
  classpath = configurations.compileClasspath + configurations.compileDotNet
361
  source = "${buildDir}/src/pen"
362
  destinationDirectory = new File("${buildDir}/classes/pen")
363
}
364
365
task eenCompile(
366
  type: JavaCompile,
367
  dependsOn: ["een_sources", "hen_copyDevelopmentSources"],
368
  description: "Compile EE for .NET"
369
) {
370
  classpath = configurations.compileClasspath + configurations.asmDotNet
371
  source = "${buildDir}/src/een"
372
  destinationDirectory = new File("${buildDir}/classes/een")
373
}
374
375
task hen_jar(
376
  type: Jar,
377
  dependsOn: ["henCompile"],
378
  description: "Build the HE jar file for Saxon .NET"
379
) {
380 76f5c46e Norman Walsh
  archiveBaseName = "saxon10he"
381 72bf04c6 Norman Walsh
  destinationDirectory = file("${buildDir}/n/jar")
382
  from ("build/classes/hen") {
383
    include "net/**/*.class"
384
    exclude "net/sf/saxon/option/**/*.class"
385
  }
386
  from ("build/src/hen") {
387
    include "**"
388
  }
389
  doFirst {
390
    mkdir "build/n/jar"
391
  }
392
}
393
394
task pen_jar(
395
  type: Jar,
396
  dependsOn: ["penCompile"],
397
  description: "Build the PE jar file for Saxon .NET"
398
) {
399 76f5c46e Norman Walsh
  archiveBaseName = "saxon10pe"
400 72bf04c6 Norman Walsh
  destinationDirectory = file("${buildDir}/n/jar")
401
  from ("build/classes/pen") {
402
    include "net/**/*.class"
403
    exclude "net/sf/saxon/ant/*.class"
404
    exclude "**/sql/**/*.class"
405
    include "com/saxonica/**/*.class"
406
    exclude "com/saxonica/bytecode/**/*.class"
407
    exclude "com/saxonica/jaxp/**/**/*.class"
408
    exclude "com/saxonica/schema/**/*.class"
409
    exclude "com/saxonica/stream/**/*.class"
410
    exclude "com/saxonica/testdriver/**/*.class"
411
    exclude "net/sf/saxon/testdriver/**/*.class"
412
    exclude "com/saxonica/update/**/*.class"
413
    exclude "com/saxonica/validate/**/*.class"
414
    exclude "com/saxonica/expr/CastToUnion.class"
415
    exclude "com/saxonica/expr/CastableToUnion.class"
416
    exclude "com/saxonica/expr/CastableToList.class"
417
    exclude "com/saxonica/Validate.class"
418
    exclude "com/saxonica/config/EnterpriseConfiguration.class"
419
    exclude "com/saxonica/config/EnterpriseConfiguration\$SurrogateSchema.class"
420
    exclude "com/saxonica/config/EnterpriseConfiguration\$1.class"
421
    exclude "com/saxonica/config/ProfessionalTransformerFactory.class"
422
    exclude "com/saxonica/config/ProfessionalXPathFactory.class"
423
    exclude "com/saxonica/config/EnterpriseTransformerFactory.class"
424
    exclude "com/saxonica/config/StreamingTransformerFactory.class"
425
    exclude "com/saxonica/config/EnterpriseXPathFactory.class"
426
    exclude "com/saxonica/config/DynamicLoaderEE.class"
427
    exclude "com/saxonica/config/StandardSchemaResolver.class"
428
    exclude "com/saxonica/expr/ee/*.class"
429
  }
430
  from ("src/main/java") {
431
    include "net/sf/saxon/data/**"
432
  }
433
  doFirst {
434
    mkdir "build/n/jar"
435
  }
436
}
437
438
task een_jar(
439
  type: Jar,
440
  dependsOn: ["eenCompile"],
441
  description: "Build the EE jar file for Saxon .NET"
442
) {
443 76f5c46e Norman Walsh
  archiveBaseName = "saxon10ee"
444 72bf04c6 Norman Walsh
  destinationDirectory = file("${buildDir}/n/jar")
445
  from ("build/classes/een") {
446
    include "net/**/*.class"
447
    include "com/saxonica/**/*.class"
448
    include "org/objectweb/**/*.class"
449
    exclude "com/saxonica/config/EnterpriseTransformerFactory.class"
450
    exclude "com/saxonica/config/EnterpriseXPathFactory.class"
451
  }
452
  from ("src/main/java") {
453
    include "net/sf/saxon/data/**"
454
  }
455
  doFirst {
456
    mkdir "build/n/jar"
457
  }
458
}
459
460
task ikvm_prepareJarAsm(
461
  type: Copy,
462
  description: "Copy the ASM jars for IKVM"
463
) {
464
  from "lib/asm-${asmVersion}"
465
  into "${buildDir}/n/jar/asm-${asmVersion}"
466
  include "*.jar"
467
}
468
469
task ikvm_prepareJar(
470
  type: Copy,
471
  dependsOn: ["ikvm_prepareJarAsm", "rejar_Xerces"],
472
  description: "Copy the ICU4J, TagSoup, Mail, and Xerces jars for IKVM"
473
) {
474
  from "${icu4jJar}"
475
  into "${buildDir}/n/jar"
476
  from "${tagsoupJar}"
477
  into "${buildDir}/n/jar"
478
  from "${mailJar}"
479
  into "${buildDir}/n/jar"
480
  from "${buildDir}/xerces/xerces.jar"
481
  into "${buildDir}/n/jar"
482
}
483
484
task "n_notices"(
485
  type: Copy,
486
  description: "Copy the notices into the staging directory"
487
) {
488
  from "src/docs/notices"
489
  into "${buildDir}/n/notices"
490
}
491
492
["h", "p", "e"].each { initial ->
493
  def release = initial + "e"
494
  def RELEASE = release.toUpperCase()
495
  task "${release}n_setupDll"(
496
    type: Copy,
497
    dependsOn: ["${release}n_jar", "ikvm_prepareJar"],
498
    description: "Setup the IKVM environment for ${RELEASE}"
499
) {
500
    from "${ikvmDir}/ikvm-${ikvmVersion}/bin"
501
    into "${buildDir}/n/bin/${release}"
502
    include "IKVM.OpenJDK.Core.dll"
503
    include "IKVM.OpenJDK.Charsets.dll"
504
    include "IKVM.OpenJDK.Text.dll"
505
    include "IKVM.OpenJDK.Util.dll"
506
    include "IKVM.OpenJDK.XML.API.dll"
507
    include "IKVM.OpenJDK.Security.dll"
508
    //include "xercesImpl.dll"
509
    include "IKVM.Runtime.dll"
510
  }
511
512
  task "${release}n_iss"(
513
    type: Copy,
514
    description: "Create the ${release}.iss file for the .net installer"
515
  ) {
516
    inputs.file("${projectDir}/src/dotnet/${release}.iss")
517
    outputs.file("${buildDir}/n/${release}.iss")
518
519
    from "${projectDir}/src/dotnet/${release}.iss"
520
    into "${buildDir}/n"
521
    filter { line ->
522
      line \
523
        .replace("@@SOURCE_DIR@@", "bin\\${release}") \
524
        .replace("@@OUTPUT_DIR@@", "..\\..\\..\\distributions") \
525
        .replace("@@VERSION@@", saxonVersion) \
526
        .replace("@@VERSION_H@@", version_h) \
527
        .replace("@@IKVM_STRONGNAME@@", ikvmStrongname) \
528
        .replace("@@MAJOR_VERSION@@", saxonMajorVersion) \
529 d1236b02 Norman Walsh
        .replace("@@MINOR_VERSION@@", saxonMinorVersion) \
530 72bf04c6 Norman Walsh
        .replace("@@COPYRIGHT_YEAR@@", "2020")
531
    }
532
  }
533
534
  task "${release}nInstaller"(
535
    type: Exec,
536
    dependsOn: ["${release}nProduct", "${release}n_iss", "n_notices"],
537
    description: "Build the ${RELEASE} installer for .NET"
538
  ) {
539
    commandLine "${dotNetInstaller}",
540
      "/cc", "${buildDir}/n/${release}.iss"
541
  }
542
}
543
544
task henDll(
545
  type: Exec,
546
  dependsOn: ["hen_setupDll"],
547
  description: "Build HE .dll with IKVM"
548
) {
549
  inputs.files("${buildDir}/n/bin/he")
550
  inputs.file("${buildDir}/xerces/xerces.jar")
551
  inputs.file("${ikvmDir}/saxondotnet.snk")
552 76f5c46e Norman Walsh
  outputs.file("build/n/bin/he/saxon10he.dll")
553 9b52d94c Norman Walsh
554
  def ikvmCommand = [ "${ikvmDir}/ikvm-${ikvmVersion}/bin/ikvmc.exe" ] \
555
  + additionalIkvmOptions \
556 76f5c46e Norman Walsh
  + ["-out:${buildDir}/n/bin/he/saxon10he.dll",
557
     "-assembly:saxon10he",
558 9b52d94c Norman Walsh
     "-target:library",
559
     "-keyfile:${ikvmDir}/saxondotnet.snk",
560
     "-version:${saxonVersion}",
561
     "-srcpath:${buildDir}/preprocess/hen",
562
     "-reference:mscorlib.dll",
563
     "-reference:System.Xml.dll",
564
     "-reference:System.dll",
565
     "-reference:${buildDir}/n/bin/he/IKVM.OpenJDK.Core.dll",
566 76f5c46e Norman Walsh
     "${buildDir}/n/jar/saxon10he.jar",
567 9b52d94c Norman Walsh
     "${buildDir}/n/jar/xerces.jar"]
568
569
  commandLine ikvmCommand
570 72bf04c6 Norman Walsh
  doFirst {
571
    mkdir "${buildDir}/n/bin/he"
572
  }
573
}
574
575
task penDll(
576
  type: Exec,
577
  dependsOn: ["pen_setupDll"],
578
  description: "Build PE .dll with IKVM"
579
) {
580
  inputs.files("${buildDir}/n/bin/pe")
581
  inputs.file("${buildDir}/xerces/xerces.jar")
582
  inputs.file("${ikvmDir}/saxondotnet.snk")
583 76f5c46e Norman Walsh
  outputs.file("build/n/bin/pe/saxon10pe.dll")
584 9b52d94c Norman Walsh
585
  def ikvmCommand = [ "${ikvmDir}/ikvm-${ikvmVersion}/bin/ikvmc.exe" ] \
586
  + additionalIkvmOptions \
587 76f5c46e Norman Walsh
  + ["-out:${buildDir}/n/bin/pe/saxon10pe.dll",
588
     "-assembly:saxon10pe",
589 9b52d94c Norman Walsh
     "-target:library",
590
     "-keyfile:${ikvmDir}/saxondotnet.snk",
591
     "-version:${saxonVersion}",
592
     "-srcpath:${buildDir}/preprocess/pen",
593
     "-reference:mscorlib.dll",
594
     "-reference:System.Xml.dll",
595
     "-reference:System.dll",
596
     "-reference:${buildDir}/n/bin/pe/IKVM.OpenJDK.Core.dll",
597
     "-reference:System.Security.dll",
598 76f5c46e Norman Walsh
     "${buildDir}/n/jar/saxon10pe.jar",
599 9b52d94c Norman Walsh
     "${buildDir}/n/jar/xerces.jar",
600
     "${buildDir}/n/jar/tagsoup-${tagsoupVersion}.jar",
601
     "${buildDir}/n/jar/javax.mail-${mailVersion}.jar",
602
     "${buildDir}/n/jar/icu4j-${icu4jVersion}.jar"]
603
604
  commandLine ikvmCommand
605 72bf04c6 Norman Walsh
  doFirst {
606
    mkdir "${buildDir}/n/bin/pe"
607
  }
608
}
609
610
task eenDll(
611
  type: Exec,
612
  dependsOn: ["een_setupDll"],
613
  description: "Build EE .dll with IKVM"
614
) {
615
  inputs.files("${buildDir}/n/bin/ee")
616
  inputs.file("${buildDir}/xerces/xerces.jar")
617
  inputs.file("${ikvmDir}/saxondotnet.snk")
618 76f5c46e Norman Walsh
  outputs.file("build/n/bin/ee/saxon10ee.dll")
619 9b52d94c Norman Walsh
620
  def ikvmCommand = [ "${ikvmDir}/ikvm-${ikvmVersion}/bin/ikvmc.exe" ] \
621
  + additionalIkvmOptions \
622 76f5c46e Norman Walsh
  + ["-out:${buildDir}/n/bin/ee/saxon10ee.dll",
623
     "-assembly:saxon10ee",
624 9b52d94c Norman Walsh
     "-target:library",
625
     "-keyfile:${ikvmDir}/saxondotnet.snk",
626
     "-version:${saxonVersion}",
627
     "-srcpath:${buildDir}/preprocess/een",
628
     "-reference:mscorlib.dll",
629
     "-reference:System.Xml.dll",
630
     "-reference:System.dll",
631
     "-reference:${buildDir}/n/bin/ee/IKVM.OpenJDK.Core.dll",
632
     "-reference:System.Security.dll",
633 76f5c46e Norman Walsh
     "${buildDir}/n/jar/saxon10ee.jar",
634 9b52d94c Norman Walsh
     "${buildDir}/n/jar/xerces.jar",
635
     "${buildDir}/n/jar/asm-${asmVersion}/asm-${asmVersion}.jar",
636
     "${buildDir}/n/jar/asm-${asmVersion}/asm-analysis-${asmVersion}.jar",
637
     "${buildDir}/n/jar/asm-${asmVersion}/asm-commons-${asmVersion}.jar",
638
     "${buildDir}/n/jar/asm-${asmVersion}/asm-tree-${asmVersion}.jar",
639
     "${buildDir}/n/jar/asm-${asmVersion}/asm-util-${asmVersion}.jar",
640
     "${buildDir}/n/jar/tagsoup-${tagsoupVersion}.jar",
641
     "${buildDir}/n/jar/javax.mail-${mailVersion}.jar",
642
     "${buildDir}/n/jar/icu4j-${icu4jVersion}.jar"]
643
644
  commandLine ikvmCommand
645 72bf04c6 Norman Walsh
  doFirst {
646
    mkdir "${buildDir}/n/bin/ee"
647
  }
648
}
649
650
task productDlls(
651
  dependsOn: ["henDll", "penDll", "eenDll"],
652
  description: "Build all the product .dll files with IKVM"
653
) {
654
  doLast {
655
    println("Built DLLs")
656
  }
657
}
658
659
// ============================================================
660
// Tasks to rejar Xerces and Resolver for .NET
661
662
task unjar_XercesImpl(
663
  type: Copy,
664
  description: "Unjar XercesImple for .NET build"
665
) {
666
  inputs.file("lib/xercesImpl.jar")
667
  outputs.files(fileTree("${buildDir}/xerces/org/apache/xerces"))
668
  from zipTree(file("lib/xercesImpl.jar"))
669
  into "${buildDir}/xerces"
670
}
671
672
task unjar_Resolver(
673
  type: Copy,
674
  description: "Unjar Resolver for .NET build"
675
) {
676
  inputs.file("${resolverJar}")
677
  outputs.files(fileTree("${buildDir}/xerces/org/apache/xml/resolver"))
678
  from zipTree(file("${resolverJar}"))
679
  into "${buildDir}/xerces"
680
}
681
682
task rejar_Xerces(
683
  type: Jar,
684
  dependsOn: ["unjar_XercesImpl", "unjar_Resolver"],
685
  description: "Unjar Xerces and Resolver for .NET build"
686
) {
687
  archiveBaseName = "xerces"
688
  destinationDirectory = file("${buildDir}/xerces")
689
  from ("${buildDir}/xerces") {
690
    include "**/*.class"
691
    include "**/*.properties"
692
    exclude "org.w3c.dom.html.HTMLDOMImplementation.class"
693
    exclude "META-INF/MANIFEST.MF"
694
  }
695
}
696
697
task hen_cmdAssemblyInfo(
698
  description: "Create the AssemblyInfo.cs file for the Saxon commands"
699
) {
700
  outputs.file("${buildDir}/n/csharp/cmd/AssemblyInfo.cs")
701
  doLast {
702
    new File("${buildDir}/n/csharp/cmd/AssemblyInfo.cs")
703
      .withWriter("utf-8") { writer ->
704
        writer.writeLine("          using System.Reflection;")
705
        writer.writeLine("          using System.Runtime.CompilerServices;")
706
        writer.writeLine("          using System.Runtime.InteropServices;")
707
        writer.writeLine("          [assembly: AssemblyCompany(\"Saxonica\")]")
708
        writer.writeLine("          [assembly: AssemblyProduct(\"Saxon.HE\")]")
709
        writer.writeLine("          [assembly: AssemblyCopyright(\"Copyright © Saxonica 2019\")]")
710
        writer.writeLine("          [assembly: AssemblyVersion(\"${saxonVersion}\")]")
711
        writer.writeLine("          [assembly: AssemblyFileVersion(\"${saxonVersion}\")]")
712
      }
713
  }
714
  doFirst {
715
    mkdir "${buildDir}/n/csharp/cmd"
716
  }
717
}
718
719
// If we didn't find a C# compiler, abort all the C# compile steps
720
if (csharpCompiler == null) {
721
  ["h", "p", "e"].each { initial ->
722
    def release = initial + "e"
723
    def Release = initial.toUpperCase() + "e"
724
    def RELEASE = release.toUpperCase()
725
    def product = "${release}n"
726
    ["csharpApi", "csharpTransform", "csharpQuery"].each { step ->
727
      def desc = "Compile Saxon.Api for ${RELEASE}"
728
      if (step == "csharpTransform") {
729
        desc = "Compile Tranform.exe for ${RELEASE}"
730
      } else if (step == "csharpQuery") {
731
        desc = "Compile Query.exe for ${RELEASE}"
732
      }
733
      desc = desc + " (Fails on this platform)"
734
      task "${product}_${step}"(
735
        description: desc
736
      ) {
737
        doLast {
738
          throw new GradleException("Cannot build .NET; no C# compiler.")
739
        }
740
      }
741
    }
742
  }
743
  task een_csharpValidate(
744
    description: "Compile Validate.exe for EE (Fails on this platform)"
745
  ) {
746
    doLast {
747
      throw new GradleException("Cannot build .NET; no C# compiler.")
748
    }
749
  } 
750
} else {
751
  task hen_csharpApi(
752
    dependsOn: ["henDll"],
753
    description: "Compile Saxon.Api for HE"
754
  ) {
755
    inputs.files("${buildDir}/n/build/dll/he")
756
    inputs.files("${buildDir}/n/csharp/api")
757 76f5c46e Norman Walsh
    outputs.file("${buildDir}/n/bin/he/saxon10he-api.dll")
758 72bf04c6 Norman Walsh
759
    doLast {
760
      def args = [csharpCompiler,
761 76f5c46e Norman Walsh
                  "-out:${buildDir}/n/bin/he/saxon10he-api.dll",
762
                  "-target:library", "-doc:${buildDir}/n/saxon10he-api.xml",
763 72bf04c6 Norman Walsh
                  "-keyfile:${ikvmDir}/saxondotnet.snk"]
764
      fileTree(dir: "${buildDir}/n/bin/he",
765
               include: "*.dll").each { dll ->
766
        args += ["-reference:${dll}"]
767
      }
768
      fileTree(dir: "${buildDir}/n/csharp/api/Saxon.Api",
769
               include: "**/*.cs").each { cs ->
770
        args += [cs]
771
      }
772
773
      exec {
774
        commandLine args
775
      }
776
    }
777
  }
778
779
  task hen_csharpTransform(
780
    dependsOn: ["henDll", "hen_csharpApi", "hen_cmdAssemblyInfo"],
781
    description: "Compile Transform.exe for HE"
782
  ) {
783
    inputs.files("${buildDir}/n/build/dll/he")
784
    inputs.files("${buildDir}/n/csharp/cmd")
785
    outputs.file("${buildDir}/n/bin/he/Transform.exe")
786
787
    doLast {
788
      def args = [csharpCompiler,
789
                  "-out:${buildDir}/n/bin/he/Transform.exe",
790
                  "-target:exe",
791
                  "-keyfile:${ikvmDir}/saxondotnet.snk"]
792
      fileTree(dir: "${buildDir}/n/bin/he",
793
               include: "*.dll").each { dll ->
794
        args += ["-reference:${dll}"]
795
      }
796
      // This only runs on Windows, so make sure you use "\"
797
      args += ["${buildDir}\\n\\csharp\\cmd\\Transform.cs",
798
               "${buildDir}\\n\\csharp\\cmd\\AssemblyInfo.cs"]
799
800
      exec {
801
        commandLine args
802
      }
803
    }
804
  }
805
806
  task hen_csharpQuery(
807
    dependsOn: ["henDll", "hen_csharpApi", "hen_cmdAssemblyInfo"],
808
    description: "Compile Query.exe for HE"
809
  ) {
810
    inputs.files("${buildDir}/n/build/dll/he")
811
    inputs.files("${buildDir}/n/csharp/cmd")
812
    outputs.file("${buildDir}/n/bin/he/Query.exe")
813
814
    doLast {
815
      def args = [csharpCompiler,
816
                  "-out:${buildDir}/n/bin/he/Query.exe",
817
                  "-target:exe",
818
                  "-keyfile:${ikvmDir}/saxondotnet.snk"]
819
      fileTree(dir: "${buildDir}/n/bin/he",
820
               include: "*.dll").each { dll ->
821
        args += ["-reference:${dll}"]
822
      }
823
      // This only runs on Windows, so make sure you use "\"
824
      args += ["${buildDir}\\n\\csharp\\cmd\\Query.cs",
825
               "${buildDir}\\n\\csharp\\cmd\\AssemblyInfo.cs"]
826
827
      exec {
828
        commandLine args
829
      }
830
    }
831
  }
832
833
  task pen_csharpApi(
834
    dependsOn: ["penDll"],
835
    description: "Compile Saxon.Api for PE"
836
  ) {
837
    inputs.files("${buildDir}/n/build/dll/pe")
838
    inputs.files("${buildDir}/n/csharp/api")
839 76f5c46e Norman Walsh
    outputs.file("${buildDir}/n/bin/pe/saxon10pe-api.dll")
840 72bf04c6 Norman Walsh
841
    doLast {
842
      def args = [csharpCompiler,
843 76f5c46e Norman Walsh
                  "-out:${buildDir}/n/bin/pe/saxon10pe-api.dll",
844
                  "-target:library", "-doc:${buildDir}/n/saxon10pe-api.xml",
845 72bf04c6 Norman Walsh
                  "-keyfile:${ikvmDir}/saxondotnet.snk"]
846
      fileTree(dir: "${buildDir}/n/bin/pe",
847
               include: "*.dll").each { dll ->
848
        args += ["-reference:${dll}"]
849
      }
850
      fileTree(dir: "${buildDir}/n/csharp/api/Saxon.Api",
851
               include: "**/*.cs").each { cs ->
852
        args += [cs]
853
      }
854
855
      exec {
856
        commandLine args
857
      }
858
    }
859
  }
860
861
  task pen_csharpTransform(
862
    dependsOn: ["penDll", "pen_csharpApi", "hen_cmdAssemblyInfo"],
863
    description: "Compile Transform.exe for PE"
864
  ) {
865
    inputs.files("${buildDir}/n/build/dll/pe")
866
    inputs.files("${buildDir}/n/csharp/cmd")
867
    outputs.file("${buildDir}/n/bin/pe/Transform.exe")
868
869
    doLast {
870
      def args = [csharpCompiler,
871
                  "-out:${buildDir}/n/bin/pe/Transform.exe",
872
                  "-target:exe",
873
                  "-keyfile:${ikvmDir}/saxondotnet.snk"]
874
      fileTree(dir: "${buildDir}/n/bin/pe",
875
               include: "*.dll").each { dll ->
876
        args += ["-reference:${dll}"]
877
      }
878
      // This only runs on Windows, so make sure you use "\"
879
      args += ["${buildDir}\\n\\csharp\\cmd\\Transform.cs",
880
               "${buildDir}\\n\\csharp\\cmd\\AssemblyInfo.cs"]
881
882
      exec {
883
        commandLine args
884
      }
885
    }
886
  }
887
888
  task pen_csharpQuery(
889
    dependsOn: ["penDll", "pen_csharpApi", "hen_cmdAssemblyInfo"],
890
    description: "Compile Query.exe for PE"
891
  ) {
892
    inputs.files("${buildDir}/n/build/dll/pe")
893
    inputs.files("${buildDir}/n/csharp/cmd")
894
    outputs.file("${buildDir}/n/bin/pe/Query.exe")
895
896
    doLast {
897
      def args = [csharpCompiler,
898
                  "-out:${buildDir}/n/bin/pe/Query.exe",
899
                  "-target:exe",
900
                  "-keyfile:${ikvmDir}/saxondotnet.snk"]
901
      fileTree(dir: "${buildDir}/n/bin/pe",
902
               include: "*.dll").each { dll ->
903
        args += ["-reference:${dll}"]
904
      }
905
      // This only runs on Windows, so make sure you use "\"
906
      args += ["${buildDir}\\n\\csharp\\cmd\\Query.cs",
907
               "${buildDir}\\n\\csharp\\cmd\\AssemblyInfo.cs"]
908
909
      exec {
910
        commandLine args
911
      }
912
    }
913
  }
914
915
  task een_csharpApi(
916
    dependsOn: ["eenDll"],
917
    description: "Compile Saxon.Api for EE"
918
  ) {
919
    inputs.files("${buildDir}/n/build/dll/ee")
920
    inputs.files("${buildDir}/n/csharp/api")
921 76f5c46e Norman Walsh
    outputs.file("${buildDir}/n/bin/ee/saxon10ee-api.dll")
922 72bf04c6 Norman Walsh
923
    doLast {
924
      def args = [csharpCompiler,
925 76f5c46e Norman Walsh
                  "-out:${buildDir}/n/bin/ee/saxon10ee-api.dll",
926
                  "-target:library", "-doc:${buildDir}/n/saxon10ee-api.xml",
927 72bf04c6 Norman Walsh
                  "-keyfile:${ikvmDir}/saxondotnet.snk"]
928
      fileTree(dir: "${buildDir}/n/bin/ee",
929
               include: "*.dll").each { dll ->
930
        args += ["-reference:${dll}"]
931
      }
932
      fileTree(dir: "${buildDir}/n/csharp/api/Saxon.Api",
933
               include: "**/*.cs").each { cs ->
934
        args += [cs]
935
      }
936
937
      exec {
938
        commandLine args
939
      }
940
    }
941
  }
942
943
  task een_csharpTransform(
944
    dependsOn: ["eenDll", "een_csharpApi", "hen_cmdAssemblyInfo"],
945
    description: "Compile Transform.exe for EE"
946
  ) {
947
    inputs.files("${buildDir}/n/build/dll/ee")
948
    inputs.files("${buildDir}/n/csharp/cmd")
949
    outputs.file("${buildDir}/n/bin/ee/Transform.exe")
950
951
    doLast {
952
      def args = [csharpCompiler,
953
                  "-out:${buildDir}/n/bin/ee/Transform.exe",
954
                  "-target:exe",
955
                  "-keyfile:${ikvmDir}/saxondotnet.snk"]
956
      fileTree(dir: "${buildDir}/n/bin/ee",
957
               include: "*.dll").each { dll ->
958
        args += ["-reference:${dll}"]
959
      }
960
      // This only runs on Windows, so make sure you use "\"
961
      args += ["${buildDir}\\n\\csharp\\cmd\\Transform.cs",
962
               "${buildDir}\\n\\csharp\\cmd\\AssemblyInfo.cs"]
963
964
      exec {
965
        commandLine args
966
      }
967
    }
968
  }
969
970
  task een_csharpQuery(
971
    dependsOn: ["eenDll", "een_csharpApi", "hen_cmdAssemblyInfo"],
972
    description: "Compile Query.exe for EE"
973
  ) {
974
    inputs.files("${buildDir}/n/build/dll/ee")
975
    inputs.files("${buildDir}/n/csharp/cmd")
976
    outputs.file("${buildDir}/n/bin/ee/Query.exe")
977
978
    doLast {
979
      def args = [csharpCompiler,
980
                  "-out:${buildDir}/n/bin/ee/Query.exe",
981
                  "-target:exe",
982
                  "-keyfile:${ikvmDir}/saxondotnet.snk"]
983
      fileTree(dir: "${buildDir}/n/bin/ee",
984
               include: "*.dll").each { dll ->
985
        args += ["-reference:${dll}"]
986
      }
987
      // This only runs on Windows, so make sure you use "\"
988
      args += ["${buildDir}\\n\\csharp\\cmd\\Query.cs",
989
               "${buildDir}\\n\\csharp\\cmd\\AssemblyInfo.cs"]
990
991
      exec {
992
        commandLine args
993
      }
994
    }
995
  }
996
997
  task een_csharpValidate(
998
    dependsOn: ["eenDll", "een_csharpApi", "hen_cmdAssemblyInfo"],
999
    description: "Compile Validate.exe for EE"
1000
  ) {
1001
    inputs.files("${buildDir}/n/build/dll/ee")
1002
    inputs.files("${buildDir}/n/csharp/cmd")
1003
    outputs.file("${buildDir}/n/bin/ee/Validate.exe")
1004
1005
    doLast {
1006
      def args = [csharpCompiler,
1007
                  "-out:${buildDir}/n/bin/ee/Validate.exe",
1008
                  "-target:exe",
1009
                  "-keyfile:${ikvmDir}/saxondotnet.snk"]
1010
      fileTree(dir: "${buildDir}/n/bin/ee",
1011
               include: "*.dll").each { dll ->
1012
        args += ["-reference:${dll}"]
1013
      }
1014
      // This only runs on Windows, so make sure you use "\"
1015
      args += ["${buildDir}\\n\\csharp\\cmd\\Validate.cs",
1016
               "${buildDir}\\n\\csharp\\cmd\\AssemblyInfo.cs"]
1017
1018
      exec {
1019
        commandLine args
1020
      }
1021
    }
1022
  }
1023
}
1024
1025
task henProduct(
1026
  type: Copy,
1027
  dependsOn: ["hen_csharpApi", "hen_csharpTransform", "hen_csharpQuery"],
1028
  description: "Build Saxon HE for .NET"
1029
) {
1030 76f5c46e Norman Walsh
  from "${buildDir}/n/saxon10he-api.xml"
1031 72bf04c6 Norman Walsh
  into "${buildDir}/n/bin/he"
1032
}
1033
1034
task penProduct(
1035
  type: Copy,
1036
  dependsOn: ["pen_csharpApi", "pen_csharpTransform", "pen_csharpQuery"],
1037
  description: "Build Saxon PE for .NET"
1038
) {
1039 76f5c46e Norman Walsh
  from "${buildDir}/n/saxon10pe-api.xml"
1040 72bf04c6 Norman Walsh
  into "${buildDir}/n/bin/pe"
1041
}
1042
1043
task eenProduct(
1044
  type: Copy,
1045
  dependsOn: ["een_csharpApi", "een_csharpTransform", "een_csharpQuery", "een_csharpValidate"],
1046
  description: "Build Saxon EE for .NET"
1047
) {
1048 76f5c46e Norman Walsh
  from "${buildDir}/n/saxon10ee-api.xml"
1049 72bf04c6 Norman Walsh
  into "${buildDir}/n/bin/ee"
1050
}
1051
1052
task dotNetProducts(
1053
  dependsOn: ["henProduct", "penProduct", "eenProduct"],
1054
  description: "Builds all of the .NET products"
1055
) {
1056
  // nop
1057
}
1058
1059
task dotNetInstallers(
1060
  dependsOn: ["henInstaller", "penInstaller", "eenInstaller"],
1061
  description: "Builds all of the .NET installers"
1062
) {
1063
  // nop
1064
}