Project

Profile

Help

How to connect?
Download (32.8 KB) Statistics
| Branch: | Revision:

he / build-n.gradle @ 9b52d94c

1
// 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
def additionalIkvmOptions = []
14
if (hasProperty("ikvmDebug")) {
15
  additionalIkvmOptions += ["-debug"]
16
}
17

    
18
task hen_setupPreprocess(
19
  type: Copy,
20
  description: "Copy HE sources for preprocessing HE"
21
) {
22
  from "${projectDir}/src/main/java"
23
  into "${buildDir}/filtered/hen"
24
  include "net/sf/saxon/**/*.java"
25
  include "net/sf/saxon/data/**"
26
  exclude "net/sf/saxon/option/cpp/**"
27
  exclude "net/sf/saxon/jetonnet/**"
28
  exclude "net/sf/saxon/Gizmo.java"
29
  exclude "**/TransformerFactoryImpl.java"
30
  exclude "net/sf/saxon/BasicTransformerFactory.java"
31
  exclude "**/ant/**"
32
  exclude "**/dom/**"
33
  exclude "**/dom4j/**"
34
  exclude "**/java/**"
35
  exclude "**/testdriver/**"
36
  exclude "net/sf/saxon/testdriver/**/*.java"
37
  exclude "**/jaxp/**"
38
  exclude "**/jdom/**"
39
  exclude "**/jdom2/**"
40
  exclude "**/axiom/**"
41
  exclude "**/s9api/DOMDestination.java"
42
  exclude "**/sql/**"
43
  exclude "**/xom/**"
44
  exclude "**/xpath/**"
45
  exclude "**/xqj/**"
46
  exclude "**/stax/**"
47
}
48

    
49
task pen_setupPreprocess(
50
  type: Copy,
51
  description: "Copy PE sources for preprocessing PE"
52
) {
53
  from "${projectDir}/src/main/java"
54
  into "${buildDir}/filtered/pen"
55
  include "net/sf/saxon/**/*.java"
56
  include "net/sf/saxon/data/**"
57
  exclude "net/sf/saxon/option/cpp/**"
58
  exclude "net/sf/saxon/jetonnet/**"
59
  exclude "net/sf/saxon/Gizmo.java"
60
  exclude "**/TransformerFactoryImpl.java"
61
  exclude "net/sf/saxon/BasicTransformerFactory.java"
62
  exclude "**/testdriver/**"
63
  exclude "**/ant/**"
64
  exclude "**/dom/**"
65
  exclude "**/dom4j/**"
66
  exclude "**/java/**"
67
  exclude "**/jaxp/**"
68
  exclude "**/jdom/**"
69
  exclude "**/jdom2/**"
70
  exclude "**/axiom/**"
71
  exclude "**/s9api/DOMDestination.java"
72
  exclude "**/sql/**"
73
  exclude "**/xom/**"
74
  exclude "**/xpath/**"
75
  exclude "**/xqj/**"
76
  exclude "**/stax/**"
77
  include "com/saxonica/**/*.java"
78
  exclude "com/saxonica/ee/**/*.java"
79
  exclude "com/saxonica/functions/extfn/cpp/*.java"
80
  exclude "com/saxonica/testdriver/**/*.java"
81
  exclude "net/sf/saxon/testdriver/**/*.java"
82
  exclude "com/saxonica/jaxp/*.java"
83
  exclude "com/saxonica/js/**"
84
  exclude "com/saxonica/config/ProfessionalXPathFactory.java" 
85
  exclude "com/saxonica/config/EnterpriseConfiguration.java" 
86
  exclude "com/saxonica/config/JavaPlatformPE.java" 
87
  exclude "com/saxonica/config/JavaPlatformEE.java" 
88
  exclude "com/saxonica/config/JavaPlatformC.java"
89
  exclude "com/saxonica/config/ee/**" 
90
  exclude "com/saxonica/stream/**" 
91
  exclude "com/saxonica/schema/**" 
92
  exclude "com/saxonica/bytecode/**" 
93
  exclude "com/saxonica/expr/ee/**" 
94
  exclude "com/saxonica/update/**/*.java"
95
  exclude "com/saxonica/validate/**/*.java"
96
  exclude "com/saxonica/expr/CastToUnion.java"
97
  exclude "com/saxonica/expr/CastableToUnion.java"
98
  exclude "com/saxonica/expr/CastableToUnion.java"
99
  exclude "com/saxonica/Validate.java"
100
  exclude "com/saxonica/config/ProfessionalTransformerFactory.java"
101
  exclude "com/saxonica/config/ProfessionalXPathFactory.java"
102
  exclude "com/saxonica/config/EnterpriseTransformerFactory.java"
103
  exclude "com/saxonica/config/StreamingTransformerFactory.java"
104
  exclude "com/saxonica/config/EnterpriseXPathFactory.java"
105
  exclude "com/saxonica/config/DynamicLoaderEE.java"
106
  exclude "com/saxonica/config/StandardSchemaResolver.java"
107
  exclude "com/saxonica/functions/extfn/NativeCall.java"
108
  exclude "**/xqj/**"
109
}
110

    
111
task een_setupPreprocess(
112
  type: Copy,
113
  description: "Copy EE sources for preprocessing EE"
114
) {
115
  from "${projectDir}/src/main/java"
116
  into "${buildDir}/filtered/een"
117
  include "net/sf/saxon/**/*.java"
118
  include "net/sf/saxon/data/**"
119
  exclude "net/sf/saxon/TransformerFactoryImpl.java"
120
  exclude "net/sf/saxon/BasicTransformerFactory.java"
121
  exclude "net/sf/saxon/option/cpp/**"
122
  exclude "net/sf/saxon/jetonnet/**"
123
  exclude "**/ant/**"
124
  exclude "**/dom/**"
125
  exclude "**/dom4j/**"
126
  exclude "**/java/**"
127
  exclude "**/jaxp/**"
128
  exclude "**/jdom/**"
129
  exclude "**/jdom2/**"
130
  exclude "**/axiom/**"
131
  exclude "**/s9api/DOMDestination.java"
132
  exclude "**/sql/**"
133
  exclude "**/xom/**"
134
  exclude "**/xpath/**"
135
  exclude "**/xqj/**"
136
  exclude "**/stax/**"
137
  include "com/saxonica/**/*.java"
138
  exclude "com/saxonica/functions/extfn/cpp/*.java"
139
  exclude "com/saxonica/testdriver/**/*.java"
140
  exclude "net/sf/saxon/testdriver/**/*.java"
141
  exclude "com/saxonica/ee/jaxp/*.java"
142
  exclude "com/saxonica/js/**"
143
  exclude "com/saxonica/ee/domino/**/*.java"
144
  exclude "com/saxonica/config/JavaPlatformPE.java"
145
  exclude "com/saxonica/config/JavaPlatformEE.java"
146
  exclude "com/saxonica/config/JavaPlatformC.java"
147
  exclude "com/saxonica/config/ProfessionalXPathFactory.java"
148
  exclude "com/saxonica/config/EnterpriseXPathFactory.java"
149
  exclude "com/saxonica/config/ProfessionalTransformerFactory.java"
150
  exclude "com/saxonica/config/EnterpriseTransformerFactory.java"
151
  exclude "com/saxonica/config/StreamingTransformerFactory.java"
152
  exclude "com/saxonica/config/NativePlatformPE.java"
153
  exclude "**/xqj/**"
154
}
155

    
156
task hen_preprocess(
157
  type: JavaExec,
158
  dependsOn: ["hen_setupPreprocess"],
159
  description: "Preprocess HE sources"
160
) {
161
  inputs.files fileTree(dir: "${buildDir}/filtered/hen")
162
  outputs.files fileTree(dir: "${buildDir}/preprocess/hen")
163
  classpath = configurations.preprocessor
164
  main = "com.igormaznitsa.jcp.JcpPreprocessor"
165
  args "/c",
166
    "/i:${buildDir}/filtered/hen", "/o:${buildDir}/preprocess/hen",
167
    "/p:EE=false", "/p:PE=false", "/p:DOTNET=true",
168
    "/p:SAXONC=false", "/p:BYTECODE=false"
169
  doFirst {
170
    mkdir "${buildDir}/preprocess/hen"
171
  }
172
}
173

    
174
task pen_preprocess(
175
  type: JavaExec,
176
  dependsOn: ["pen_setupPreprocess"],
177
  description: "Preprocess PE sources"
178
) {
179
  inputs.files fileTree(dir: "${buildDir}/filtered/pen")
180
  outputs.files fileTree(dir: "${buildDir}/preprocess/pen")
181
  classpath = configurations.preprocessor
182
  main = "com.igormaznitsa.jcp.JcpPreprocessor"
183
  args "/c",
184
    "/i:${buildDir}/filtered/pen", "/o:${buildDir}/preprocess/pen",
185
    "/p:EE=false", "/p:PE=true", "/p:DOTNET=true",
186
    "/p:SAXONC=false", "/p:BYTECODE=false", "/p:HOF=true"
187
  doFirst {
188
    mkdir "${buildDir}/preprocess/pen"
189
  }
190
}
191

    
192
task een_preprocess(
193
  type: JavaExec,
194
  dependsOn: ["een_setupPreprocess"],
195
  description: "Preprocess EE sources"
196
) {
197
  inputs.files fileTree(dir: "${buildDir}/filtered/een")
198
  outputs.files fileTree(dir: "${buildDir}/preprocess/een")
199
  classpath = configurations.preprocessor
200
  main = "com.igormaznitsa.jcp.JcpPreprocessor"
201
  args "/c",
202
    "/i:${buildDir}/filtered/een", "/o:${buildDir}/preprocess/een",
203
    "/p:EE=true", "/p:PE=false", "/p:DOTNET=true",
204
    "/p:SAXONC=false", "/p:BYTECODE=true", "/p:HOF=true",
205
    "/p:STREAM=true", "/p:SCHEMA=true"
206
  doFirst {
207
    mkdir "${buildDir}/preprocess/een"
208
  }
209
}
210

    
211
task hen_sources(
212
  type: Copy,
213
  dependsOn: ["hen_preprocess"],
214
  description: "Collect the preprocessed HE sources for compilation"
215
) {
216
  from "${buildDir}/preprocess/hen"
217
  into "${buildDir}/src/hen"
218
  filter { line ->
219
    if (line.contains("import com.saxonica")
220
        || line.contains("import net.sf.saxon.stax")
221
        || line.contains("import net.sf.saxon.jaxp")
222
        || line.contains("net.sf.saxon.xpath.JAXPXPathStaticContext")) {
223
      null
224
    } else {
225
      line
226
    }
227
  }
228
}
229

    
230
task pen_sources(
231
  type: Copy,
232
  dependsOn: ["pen_preprocess"],
233
  description: "Collect the preprocessed PE sources for compilation"
234
) {
235
  from "${buildDir}/preprocess/pen"
236
  into "${buildDir}/src/pen"
237
  filter { line ->
238
    if (line.contains("import com.saxonica.ee")
239
        || line.contains("import com.saxonica.config.ee")
240
        || line.contains("net.sf.saxon.xpath.JAXPXPathStaticContext")
241
        || line.contains("import net.sf.saxon.stax")
242
        || line.contains("import net.sf.saxon.jaxp")) {
243
      null
244
    } else {
245
      line
246
    }
247
  }
248
}
249

    
250
task een_sources(
251
  type: Copy,
252
  dependsOn: ["een_preprocess"],
253
  description: "Collect the preprocessed EE sources for compilation"
254
) {
255
  from "${buildDir}/preprocess/een"
256
  into "${buildDir}/src/een"
257
  filter { line ->
258
    if (line.contains("net.sf.saxon.xpath.JAXPXPathStaticContext")
259
        || line.contains("import com.saxonica.ee.jaxp.SchemaFactoryImpl")
260
        || line.contains("import net.sf.saxon.stax")
261
        || line.contains("import net.sf.saxon.jaxp")) {
262
      null
263
    } else {
264
      line
265
    }
266
  }
267
}
268

    
269
// ============================================================
270

    
271
Task chsa = task hen_copySaxonApi(
272
  type: Copy,
273
  description: "Copy the Saxon.API C# files"
274
) {
275
  from "${projectDir}/src/main/csharp/api/Saxon.Api"
276
  into "${buildDir}/n/csharp/api/Saxon.Api"
277
  include "*.cs"
278
}
279

    
280
task hen_ApiAssemblyInfo(
281
  description: "Create the AssemblyInfo.cs file for the Saxon.Api"
282
) {
283
  outputs.file("${buildDir}/n/csharp/api/Saxon.Api/Properties/AssemblyInfo.cs")
284
  doLast {
285
    new File("${buildDir}/n/csharp/api/Saxon.Api/Properties/AssemblyInfo.cs")
286
      .withWriter("utf-8") { writer ->
287
        writer.writeLine("          using System.Reflection;")
288
        writer.writeLine("          using System.Runtime.CompilerServices;")
289
        writer.writeLine("          using System.Runtime.InteropServices;")
290
        writer.writeLine("          [assembly: AssemblyTitle(\"Saxon.Api\")]")
291
        writer.writeLine("          [assembly: AssemblyDescription(\"\")]")
292
        writer.writeLine("          [assembly: AssemblyConfiguration(\"\")]")
293
        writer.writeLine("          [assembly: AssemblyCompany(\"Saxonica\")]")
294
        writer.writeLine("          [assembly: AssemblyProduct(\"Saxon.Api\")]")
295
        writer.writeLine("          [assembly: AssemblyCopyright(\"Copyright © Saxonica 2019\")]")
296
        writer.writeLine("          [assembly: AssemblyTrademark(\"\")]")
297
        writer.writeLine("          [assembly: AssemblyCulture(\"\")]")
298
        writer.writeLine("          [assembly: ComVisible(false)]")
299
        writer.writeLine("          [assembly: Guid(\"8cf9aad8-da5f-47f0-9251-1fbcbdcfe477\")]")
300
        writer.writeLine("          [assembly: AssemblyVersion(\"${saxonVersion}\")]")
301
        writer.writeLine("          [assembly: AssemblyFileVersion(\"${saxonVersion}\")]")
302
      }
303
  }
304
  doFirst {
305
    mkdir "${buildDir}/n/csharp/api/Saxon.Api/Properties"
306
  }
307
}
308

    
309
task hen_copySaxonCmd(
310
  type: Copy,
311
  description: "Copy the cmd C# files"
312
) {
313
  from "${projectDir}/src/main/csharp/cmd"
314
  into "${buildDir}/n/csharp/cmd"
315
  include "**/Transform.cs"
316
  include "**/Query.cs"
317
  include "**/Validate.cs"
318
}
319

    
320
task hen_copySamples(
321
  type: Copy,
322
  description: "Copy the HE sample C# files"
323
) {
324
  from "${projectDir}/src/samples/cs"
325
  into "${buildDir}/n/csharp/samples"
326
  include "ExamplesEE.cs"
327
  include "ExamplesHE.cs"
328
  include "ExamplesPE.cs"
329
  include "SampleExtensions.cs"
330
  include "XPathExample.cs"
331
}
332

    
333
task hen_copyDevelopmentSources(
334
  dependsOn: ["hen_copySaxonApi", "hen_ApiAssemblyInfo",
335
              "hen_copySaxonCmd", "hen_copySamples"],
336
  description: "Setup the C# build environment"
337
) {
338
    // Just a task to hang dependencies on
339
}
340

    
341
task henCompile(
342
  type: JavaCompile,
343
  dependsOn: ["hen_sources", "hen_copyDevelopmentSources"],
344
  description: "Compile HE for .NET"
345
) {
346
  classpath = configurations.compileClasspath + configurations.compileDotNet
347
  source = "${buildDir}/src/hen"
348
  destinationDirectory = new File("${buildDir}/classes/hen")
349
}
350

    
351
task penCompile(
352
  type: JavaCompile,
353
  dependsOn: ["pen_sources", "hen_copyDevelopmentSources"],
354
  description: "Compile PE for .NET"
355
) {
356
  classpath = configurations.compileClasspath + configurations.compileDotNet
357
  source = "${buildDir}/src/pen"
358
  destinationDirectory = new File("${buildDir}/classes/pen")
359
}
360

    
361
task eenCompile(
362
  type: JavaCompile,
363
  dependsOn: ["een_sources", "hen_copyDevelopmentSources"],
364
  description: "Compile EE for .NET"
365
) {
366
  classpath = configurations.compileClasspath + configurations.asmDotNet
367
  source = "${buildDir}/src/een"
368
  destinationDirectory = new File("${buildDir}/classes/een")
369
}
370

    
371
task hen_jar(
372
  type: Jar,
373
  dependsOn: ["henCompile"],
374
  description: "Build the HE jar file for Saxon .NET"
375
) {
376
  archiveBaseName = "saxon9he"
377
  destinationDirectory = file("${buildDir}/n/jar")
378
  from ("build/classes/hen") {
379
    include "net/**/*.class"
380
    exclude "net/sf/saxon/option/**/*.class"
381
  }
382
  from ("build/src/hen") {
383
    include "**"
384
  }
385
  doFirst {
386
    mkdir "build/n/jar"
387
  }
388
}
389

    
390
task pen_jar(
391
  type: Jar,
392
  dependsOn: ["penCompile"],
393
  description: "Build the PE jar file for Saxon .NET"
394
) {
395
  archiveBaseName = "saxon9pe"
396
  destinationDirectory = file("${buildDir}/n/jar")
397
  from ("build/classes/pen") {
398
    include "net/**/*.class"
399
    exclude "net/sf/saxon/ant/*.class"
400
    exclude "**/sql/**/*.class"
401
    include "com/saxonica/**/*.class"
402
    exclude "com/saxonica/bytecode/**/*.class"
403
    exclude "com/saxonica/jaxp/**/**/*.class"
404
    exclude "com/saxonica/schema/**/*.class"
405
    exclude "com/saxonica/stream/**/*.class"
406
    exclude "com/saxonica/testdriver/**/*.class"
407
    exclude "net/sf/saxon/testdriver/**/*.class"
408
    exclude "com/saxonica/update/**/*.class"
409
    exclude "com/saxonica/validate/**/*.class"
410
    exclude "com/saxonica/expr/CastToUnion.class"
411
    exclude "com/saxonica/expr/CastableToUnion.class"
412
    exclude "com/saxonica/expr/CastableToList.class"
413
    exclude "com/saxonica/Validate.class"
414
    exclude "com/saxonica/config/EnterpriseConfiguration.class"
415
    exclude "com/saxonica/config/EnterpriseConfiguration\$SurrogateSchema.class"
416
    exclude "com/saxonica/config/EnterpriseConfiguration\$1.class"
417
    exclude "com/saxonica/config/ProfessionalTransformerFactory.class"
418
    exclude "com/saxonica/config/ProfessionalXPathFactory.class"
419
    exclude "com/saxonica/config/EnterpriseTransformerFactory.class"
420
    exclude "com/saxonica/config/StreamingTransformerFactory.class"
421
    exclude "com/saxonica/config/EnterpriseXPathFactory.class"
422
    exclude "com/saxonica/config/DynamicLoaderEE.class"
423
    exclude "com/saxonica/config/StandardSchemaResolver.class"
424
    exclude "com/saxonica/expr/ee/*.class"
425
  }
426
  from ("src/main/java") {
427
    include "net/sf/saxon/data/**"
428
  }
429
  doFirst {
430
    mkdir "build/n/jar"
431
  }
432
}
433

    
434
task een_jar(
435
  type: Jar,
436
  dependsOn: ["eenCompile"],
437
  description: "Build the EE jar file for Saxon .NET"
438
) {
439
  archiveBaseName = "saxon9ee"
440
  destinationDirectory = file("${buildDir}/n/jar")
441
  from ("build/classes/een") {
442
    include "net/**/*.class"
443
    include "com/saxonica/**/*.class"
444
    include "org/objectweb/**/*.class"
445
    exclude "com/saxonica/config/EnterpriseTransformerFactory.class"
446
    exclude "com/saxonica/config/EnterpriseXPathFactory.class"
447
  }
448
  from ("src/main/java") {
449
    include "net/sf/saxon/data/**"
450
  }
451
  doFirst {
452
    mkdir "build/n/jar"
453
  }
454
}
455

    
456
task ikvm_prepareJarAsm(
457
  type: Copy,
458
  description: "Copy the ASM jars for IKVM"
459
) {
460
  from "lib/asm-${asmVersion}"
461
  into "${buildDir}/n/jar/asm-${asmVersion}"
462
  include "*.jar"
463
}
464

    
465
task ikvm_prepareJar(
466
  type: Copy,
467
  dependsOn: ["ikvm_prepareJarAsm", "rejar_Xerces"],
468
  description: "Copy the ICU4J, TagSoup, Mail, and Xerces jars for IKVM"
469
) {
470
  from "${icu4jJar}"
471
  into "${buildDir}/n/jar"
472
  from "${tagsoupJar}"
473
  into "${buildDir}/n/jar"
474
  from "${mailJar}"
475
  into "${buildDir}/n/jar"
476
  from "${buildDir}/xerces/xerces.jar"
477
  into "${buildDir}/n/jar"
478
}
479

    
480
task "n_notices"(
481
  type: Copy,
482
  description: "Copy the notices into the staging directory"
483
) {
484
  from "src/docs/notices"
485
  into "${buildDir}/n/notices"
486
}
487

    
488
["h", "p", "e"].each { initial ->
489
  def release = initial + "e"
490
  def RELEASE = release.toUpperCase()
491
  task "${release}n_setupDll"(
492
    type: Copy,
493
    dependsOn: ["${release}n_jar", "ikvm_prepareJar"],
494
    description: "Setup the IKVM environment for ${RELEASE}"
495
) {
496
    from "${ikvmDir}/ikvm-${ikvmVersion}/bin"
497
    into "${buildDir}/n/bin/${release}"
498
    include "IKVM.OpenJDK.Core.dll"
499
    include "IKVM.OpenJDK.Charsets.dll"
500
    include "IKVM.OpenJDK.Text.dll"
501
    include "IKVM.OpenJDK.Util.dll"
502
    include "IKVM.OpenJDK.XML.API.dll"
503
    include "IKVM.OpenJDK.Security.dll"
504
    //include "xercesImpl.dll"
505
    include "IKVM.Runtime.dll"
506
  }
507

    
508
  task "${release}n_iss"(
509
    type: Copy,
510
    description: "Create the ${release}.iss file for the .net installer"
511
  ) {
512
    inputs.file("${projectDir}/src/dotnet/${release}.iss")
513
    outputs.file("${buildDir}/n/${release}.iss")
514

    
515
    from "${projectDir}/src/dotnet/${release}.iss"
516
    into "${buildDir}/n"
517
    filter { line ->
518
      line \
519
        .replace("@@SOURCE_DIR@@", "bin\\${release}") \
520
        .replace("@@OUTPUT_DIR@@", "..\\..\\..\\distributions") \
521
        .replace("@@VERSION@@", saxonVersion) \
522
        .replace("@@VERSION_H@@", version_h) \
523
        .replace("@@IKVM_STRONGNAME@@", ikvmStrongname) \
524
        .replace("@@MAJOR_VERSION@@", saxonMajorVersion) \
525
        .replace("@@COPYRIGHT_YEAR@@", "2020")
526
    }
527
  }
528

    
529
  task "${release}nInstaller"(
530
    type: Exec,
531
    dependsOn: ["${release}nProduct", "${release}n_iss", "n_notices"],
532
    description: "Build the ${RELEASE} installer for .NET"
533
  ) {
534
    commandLine "${dotNetInstaller}",
535
      "/cc", "${buildDir}/n/${release}.iss"
536
  }
537
}
538

    
539
task henDll(
540
  type: Exec,
541
  dependsOn: ["hen_setupDll"],
542
  description: "Build HE .dll with IKVM"
543
) {
544
  inputs.files("${buildDir}/n/bin/he")
545
  inputs.file("${buildDir}/xerces/xerces.jar")
546
  inputs.file("${ikvmDir}/saxondotnet.snk")
547
  outputs.file("build/n/bin/he/saxon9he.dll")
548

    
549
  def ikvmCommand = [ "${ikvmDir}/ikvm-${ikvmVersion}/bin/ikvmc.exe" ] \
550
  + additionalIkvmOptions \
551
  + ["-out:${buildDir}/n/bin/he/saxon9he.dll",
552
     "-assembly:saxon9he",
553
     "-target:library",
554
     "-keyfile:${ikvmDir}/saxondotnet.snk",
555
     "-version:${saxonVersion}",
556
     "-srcpath:${buildDir}/preprocess/hen",
557
     "-reference:mscorlib.dll",
558
     "-reference:System.Xml.dll",
559
     "-reference:System.dll",
560
     "-reference:${buildDir}/n/bin/he/IKVM.OpenJDK.Core.dll",
561
     "${buildDir}/n/jar/saxon9he.jar",
562
     "${buildDir}/n/jar/xerces.jar"]
563

    
564
  commandLine ikvmCommand
565
  doFirst {
566
    mkdir "${buildDir}/n/bin/he"
567
  }
568
}
569

    
570
task penDll(
571
  type: Exec,
572
  dependsOn: ["pen_setupDll"],
573
  description: "Build PE .dll with IKVM"
574
) {
575
  inputs.files("${buildDir}/n/bin/pe")
576
  inputs.file("${buildDir}/xerces/xerces.jar")
577
  inputs.file("${ikvmDir}/saxondotnet.snk")
578
  outputs.file("build/n/bin/pe/saxon9pe.dll")
579

    
580
  def ikvmCommand = [ "${ikvmDir}/ikvm-${ikvmVersion}/bin/ikvmc.exe" ] \
581
  + additionalIkvmOptions \
582
  + ["-out:${buildDir}/n/bin/pe/saxon9pe.dll",
583
     "-assembly:saxon9pe",
584
     "-target:library",
585
     "-keyfile:${ikvmDir}/saxondotnet.snk",
586
     "-version:${saxonVersion}",
587
     "-srcpath:${buildDir}/preprocess/pen",
588
     "-reference:mscorlib.dll",
589
     "-reference:System.Xml.dll",
590
     "-reference:System.dll",
591
     "-reference:${buildDir}/n/bin/pe/IKVM.OpenJDK.Core.dll",
592
     "-reference:System.Security.dll",
593
     "${buildDir}/n/jar/saxon9pe.jar",
594
     "${buildDir}/n/jar/xerces.jar",
595
     "${buildDir}/n/jar/tagsoup-${tagsoupVersion}.jar",
596
     "${buildDir}/n/jar/javax.mail-${mailVersion}.jar",
597
     "${buildDir}/n/jar/icu4j-${icu4jVersion}.jar"]
598

    
599
  commandLine ikvmCommand
600
  doFirst {
601
    mkdir "${buildDir}/n/bin/pe"
602
  }
603
}
604

    
605
task eenDll(
606
  type: Exec,
607
  dependsOn: ["een_setupDll"],
608
  description: "Build EE .dll with IKVM"
609
) {
610
  inputs.files("${buildDir}/n/bin/ee")
611
  inputs.file("${buildDir}/xerces/xerces.jar")
612
  inputs.file("${ikvmDir}/saxondotnet.snk")
613
  outputs.file("build/n/bin/ee/saxon9ee.dll")
614

    
615
  def ikvmCommand = [ "${ikvmDir}/ikvm-${ikvmVersion}/bin/ikvmc.exe" ] \
616
  + additionalIkvmOptions \
617
  + ["-out:${buildDir}/n/bin/ee/saxon9ee.dll",
618
     "-assembly:saxon9ee",
619
     "-target:library",
620
     "-keyfile:${ikvmDir}/saxondotnet.snk",
621
     "-version:${saxonVersion}",
622
     "-srcpath:${buildDir}/preprocess/een",
623
     "-reference:mscorlib.dll",
624
     "-reference:System.Xml.dll",
625
     "-reference:System.dll",
626
     "-reference:${buildDir}/n/bin/ee/IKVM.OpenJDK.Core.dll",
627
     "-reference:System.Security.dll",
628
     "${buildDir}/n/jar/saxon9ee.jar",
629
     "${buildDir}/n/jar/xerces.jar",
630
     "${buildDir}/n/jar/asm-${asmVersion}/asm-${asmVersion}.jar",
631
     "${buildDir}/n/jar/asm-${asmVersion}/asm-analysis-${asmVersion}.jar",
632
     "${buildDir}/n/jar/asm-${asmVersion}/asm-commons-${asmVersion}.jar",
633
     "${buildDir}/n/jar/asm-${asmVersion}/asm-tree-${asmVersion}.jar",
634
     "${buildDir}/n/jar/asm-${asmVersion}/asm-util-${asmVersion}.jar",
635
     "${buildDir}/n/jar/tagsoup-${tagsoupVersion}.jar",
636
     "${buildDir}/n/jar/javax.mail-${mailVersion}.jar",
637
     "${buildDir}/n/jar/icu4j-${icu4jVersion}.jar"]
638

    
639
  commandLine ikvmCommand
640
  doFirst {
641
    mkdir "${buildDir}/n/bin/ee"
642
  }
643
}
644

    
645
task productDlls(
646
  dependsOn: ["henDll", "penDll", "eenDll"],
647
  description: "Build all the product .dll files with IKVM"
648
) {
649
  doLast {
650
    println("Built DLLs")
651
  }
652
}
653

    
654
// ============================================================
655
// Tasks to rejar Xerces and Resolver for .NET
656

    
657
task unjar_XercesImpl(
658
  type: Copy,
659
  description: "Unjar XercesImple for .NET build"
660
) {
661
  inputs.file("lib/xercesImpl.jar")
662
  outputs.files(fileTree("${buildDir}/xerces/org/apache/xerces"))
663
  from zipTree(file("lib/xercesImpl.jar"))
664
  into "${buildDir}/xerces"
665
}
666

    
667
task unjar_Resolver(
668
  type: Copy,
669
  description: "Unjar Resolver for .NET build"
670
) {
671
  inputs.file("${resolverJar}")
672
  outputs.files(fileTree("${buildDir}/xerces/org/apache/xml/resolver"))
673
  from zipTree(file("${resolverJar}"))
674
  into "${buildDir}/xerces"
675
}
676

    
677
task rejar_Xerces(
678
  type: Jar,
679
  dependsOn: ["unjar_XercesImpl", "unjar_Resolver"],
680
  description: "Unjar Xerces and Resolver for .NET build"
681
) {
682
  archiveBaseName = "xerces"
683
  destinationDirectory = file("${buildDir}/xerces")
684
  from ("${buildDir}/xerces") {
685
    include "**/*.class"
686
    include "**/*.properties"
687
    exclude "org.w3c.dom.html.HTMLDOMImplementation.class"
688
    exclude "META-INF/MANIFEST.MF"
689
  }
690
}
691

    
692
task hen_cmdAssemblyInfo(
693
  description: "Create the AssemblyInfo.cs file for the Saxon commands"
694
) {
695
  outputs.file("${buildDir}/n/csharp/cmd/AssemblyInfo.cs")
696
  doLast {
697
    new File("${buildDir}/n/csharp/cmd/AssemblyInfo.cs")
698
      .withWriter("utf-8") { writer ->
699
        writer.writeLine("          using System.Reflection;")
700
        writer.writeLine("          using System.Runtime.CompilerServices;")
701
        writer.writeLine("          using System.Runtime.InteropServices;")
702
        writer.writeLine("          [assembly: AssemblyCompany(\"Saxonica\")]")
703
        writer.writeLine("          [assembly: AssemblyProduct(\"Saxon.HE\")]")
704
        writer.writeLine("          [assembly: AssemblyCopyright(\"Copyright © Saxonica 2019\")]")
705
        writer.writeLine("          [assembly: AssemblyVersion(\"${saxonVersion}\")]")
706
        writer.writeLine("          [assembly: AssemblyFileVersion(\"${saxonVersion}\")]")
707
      }
708
  }
709
  doFirst {
710
    mkdir "${buildDir}/n/csharp/cmd"
711
  }
712
}
713

    
714
// If we didn't find a C# compiler, abort all the C# compile steps
715
if (csharpCompiler == null) {
716
  ["h", "p", "e"].each { initial ->
717
    def release = initial + "e"
718
    def Release = initial.toUpperCase() + "e"
719
    def RELEASE = release.toUpperCase()
720
    def product = "${release}n"
721
    ["csharpApi", "csharpTransform", "csharpQuery"].each { step ->
722
      def desc = "Compile Saxon.Api for ${RELEASE}"
723
      if (step == "csharpTransform") {
724
        desc = "Compile Tranform.exe for ${RELEASE}"
725
      } else if (step == "csharpQuery") {
726
        desc = "Compile Query.exe for ${RELEASE}"
727
      }
728
      desc = desc + " (Fails on this platform)"
729
      task "${product}_${step}"(
730
        description: desc
731
      ) {
732
        doLast {
733
          throw new GradleException("Cannot build .NET; no C# compiler.")
734
        }
735
      }
736
    }
737
  }
738
  task een_csharpValidate(
739
    description: "Compile Validate.exe for EE (Fails on this platform)"
740
  ) {
741
    doLast {
742
      throw new GradleException("Cannot build .NET; no C# compiler.")
743
    }
744
  } 
745
} else {
746
  task hen_csharpApi(
747
    dependsOn: ["henDll"],
748
    description: "Compile Saxon.Api for HE"
749
  ) {
750
    inputs.files("${buildDir}/n/build/dll/he")
751
    inputs.files("${buildDir}/n/csharp/api")
752
    outputs.file("${buildDir}/n/bin/he/saxon9he-api.dll")
753

    
754
    doLast {
755
      def args = [csharpCompiler,
756
                  "-out:${buildDir}/n/bin/he/saxon9he-api.dll",
757
                  "-target:library", "-doc:${buildDir}/n/saxon9he-api.xml",
758
                  "-keyfile:${ikvmDir}/saxondotnet.snk"]
759
      fileTree(dir: "${buildDir}/n/bin/he",
760
               include: "*.dll").each { dll ->
761
        args += ["-reference:${dll}"]
762
      }
763
      fileTree(dir: "${buildDir}/n/csharp/api/Saxon.Api",
764
               include: "**/*.cs").each { cs ->
765
        args += [cs]
766
      }
767

    
768
      exec {
769
        commandLine args
770
      }
771
    }
772
  }
773

    
774
  task hen_csharpTransform(
775
    dependsOn: ["henDll", "hen_csharpApi", "hen_cmdAssemblyInfo"],
776
    description: "Compile Transform.exe for HE"
777
  ) {
778
    inputs.files("${buildDir}/n/build/dll/he")
779
    inputs.files("${buildDir}/n/csharp/cmd")
780
    outputs.file("${buildDir}/n/bin/he/Transform.exe")
781

    
782
    doLast {
783
      def args = [csharpCompiler,
784
                  "-out:${buildDir}/n/bin/he/Transform.exe",
785
                  "-target:exe",
786
                  "-keyfile:${ikvmDir}/saxondotnet.snk"]
787
      fileTree(dir: "${buildDir}/n/bin/he",
788
               include: "*.dll").each { dll ->
789
        args += ["-reference:${dll}"]
790
      }
791
      // This only runs on Windows, so make sure you use "\"
792
      args += ["${buildDir}\\n\\csharp\\cmd\\Transform.cs",
793
               "${buildDir}\\n\\csharp\\cmd\\AssemblyInfo.cs"]
794

    
795
      exec {
796
        commandLine args
797
      }
798
    }
799
  }
800

    
801
  task hen_csharpQuery(
802
    dependsOn: ["henDll", "hen_csharpApi", "hen_cmdAssemblyInfo"],
803
    description: "Compile Query.exe for HE"
804
  ) {
805
    inputs.files("${buildDir}/n/build/dll/he")
806
    inputs.files("${buildDir}/n/csharp/cmd")
807
    outputs.file("${buildDir}/n/bin/he/Query.exe")
808

    
809
    doLast {
810
      def args = [csharpCompiler,
811
                  "-out:${buildDir}/n/bin/he/Query.exe",
812
                  "-target:exe",
813
                  "-keyfile:${ikvmDir}/saxondotnet.snk"]
814
      fileTree(dir: "${buildDir}/n/bin/he",
815
               include: "*.dll").each { dll ->
816
        args += ["-reference:${dll}"]
817
      }
818
      // This only runs on Windows, so make sure you use "\"
819
      args += ["${buildDir}\\n\\csharp\\cmd\\Query.cs",
820
               "${buildDir}\\n\\csharp\\cmd\\AssemblyInfo.cs"]
821

    
822
      exec {
823
        commandLine args
824
      }
825
    }
826
  }
827

    
828
  task pen_csharpApi(
829
    dependsOn: ["penDll"],
830
    description: "Compile Saxon.Api for PE"
831
  ) {
832
    inputs.files("${buildDir}/n/build/dll/pe")
833
    inputs.files("${buildDir}/n/csharp/api")
834
    outputs.file("${buildDir}/n/bin/pe/saxon9pe-api.dll")
835

    
836
    doLast {
837
      def args = [csharpCompiler,
838
                  "-out:${buildDir}/n/bin/pe/saxon9pe-api.dll",
839
                  "-target:library", "-doc:${buildDir}/n/saxon9pe-api.xml",
840
                  "-keyfile:${ikvmDir}/saxondotnet.snk"]
841
      fileTree(dir: "${buildDir}/n/bin/pe",
842
               include: "*.dll").each { dll ->
843
        args += ["-reference:${dll}"]
844
      }
845
      fileTree(dir: "${buildDir}/n/csharp/api/Saxon.Api",
846
               include: "**/*.cs").each { cs ->
847
        args += [cs]
848
      }
849

    
850
      exec {
851
        commandLine args
852
      }
853
    }
854
  }
855

    
856
  task pen_csharpTransform(
857
    dependsOn: ["penDll", "pen_csharpApi", "hen_cmdAssemblyInfo"],
858
    description: "Compile Transform.exe for PE"
859
  ) {
860
    inputs.files("${buildDir}/n/build/dll/pe")
861
    inputs.files("${buildDir}/n/csharp/cmd")
862
    outputs.file("${buildDir}/n/bin/pe/Transform.exe")
863

    
864
    doLast {
865
      def args = [csharpCompiler,
866
                  "-out:${buildDir}/n/bin/pe/Transform.exe",
867
                  "-target:exe",
868
                  "-keyfile:${ikvmDir}/saxondotnet.snk"]
869
      fileTree(dir: "${buildDir}/n/bin/pe",
870
               include: "*.dll").each { dll ->
871
        args += ["-reference:${dll}"]
872
      }
873
      // This only runs on Windows, so make sure you use "\"
874
      args += ["${buildDir}\\n\\csharp\\cmd\\Transform.cs",
875
               "${buildDir}\\n\\csharp\\cmd\\AssemblyInfo.cs"]
876

    
877
      exec {
878
        commandLine args
879
      }
880
    }
881
  }
882

    
883
  task pen_csharpQuery(
884
    dependsOn: ["penDll", "pen_csharpApi", "hen_cmdAssemblyInfo"],
885
    description: "Compile Query.exe for PE"
886
  ) {
887
    inputs.files("${buildDir}/n/build/dll/pe")
888
    inputs.files("${buildDir}/n/csharp/cmd")
889
    outputs.file("${buildDir}/n/bin/pe/Query.exe")
890

    
891
    doLast {
892
      def args = [csharpCompiler,
893
                  "-out:${buildDir}/n/bin/pe/Query.exe",
894
                  "-target:exe",
895
                  "-keyfile:${ikvmDir}/saxondotnet.snk"]
896
      fileTree(dir: "${buildDir}/n/bin/pe",
897
               include: "*.dll").each { dll ->
898
        args += ["-reference:${dll}"]
899
      }
900
      // This only runs on Windows, so make sure you use "\"
901
      args += ["${buildDir}\\n\\csharp\\cmd\\Query.cs",
902
               "${buildDir}\\n\\csharp\\cmd\\AssemblyInfo.cs"]
903

    
904
      exec {
905
        commandLine args
906
      }
907
    }
908
  }
909

    
910
  task een_csharpApi(
911
    dependsOn: ["eenDll"],
912
    description: "Compile Saxon.Api for EE"
913
  ) {
914
    inputs.files("${buildDir}/n/build/dll/ee")
915
    inputs.files("${buildDir}/n/csharp/api")
916
    outputs.file("${buildDir}/n/bin/ee/saxon9ee-api.dll")
917

    
918
    doLast {
919
      def args = [csharpCompiler,
920
                  "-out:${buildDir}/n/bin/ee/saxon9ee-api.dll",
921
                  "-target:library", "-doc:${buildDir}/n/saxon9ee-api.xml",
922
                  "-keyfile:${ikvmDir}/saxondotnet.snk"]
923
      fileTree(dir: "${buildDir}/n/bin/ee",
924
               include: "*.dll").each { dll ->
925
        args += ["-reference:${dll}"]
926
      }
927
      fileTree(dir: "${buildDir}/n/csharp/api/Saxon.Api",
928
               include: "**/*.cs").each { cs ->
929
        args += [cs]
930
      }
931

    
932
      exec {
933
        commandLine args
934
      }
935
    }
936
  }
937

    
938
  task een_csharpTransform(
939
    dependsOn: ["eenDll", "een_csharpApi", "hen_cmdAssemblyInfo"],
940
    description: "Compile Transform.exe for EE"
941
  ) {
942
    inputs.files("${buildDir}/n/build/dll/ee")
943
    inputs.files("${buildDir}/n/csharp/cmd")
944
    outputs.file("${buildDir}/n/bin/ee/Transform.exe")
945

    
946
    doLast {
947
      def args = [csharpCompiler,
948
                  "-out:${buildDir}/n/bin/ee/Transform.exe",
949
                  "-target:exe",
950
                  "-keyfile:${ikvmDir}/saxondotnet.snk"]
951
      fileTree(dir: "${buildDir}/n/bin/ee",
952
               include: "*.dll").each { dll ->
953
        args += ["-reference:${dll}"]
954
      }
955
      // This only runs on Windows, so make sure you use "\"
956
      args += ["${buildDir}\\n\\csharp\\cmd\\Transform.cs",
957
               "${buildDir}\\n\\csharp\\cmd\\AssemblyInfo.cs"]
958

    
959
      exec {
960
        commandLine args
961
      }
962
    }
963
  }
964

    
965
  task een_csharpQuery(
966
    dependsOn: ["eenDll", "een_csharpApi", "hen_cmdAssemblyInfo"],
967
    description: "Compile Query.exe for EE"
968
  ) {
969
    inputs.files("${buildDir}/n/build/dll/ee")
970
    inputs.files("${buildDir}/n/csharp/cmd")
971
    outputs.file("${buildDir}/n/bin/ee/Query.exe")
972

    
973
    doLast {
974
      def args = [csharpCompiler,
975
                  "-out:${buildDir}/n/bin/ee/Query.exe",
976
                  "-target:exe",
977
                  "-keyfile:${ikvmDir}/saxondotnet.snk"]
978
      fileTree(dir: "${buildDir}/n/bin/ee",
979
               include: "*.dll").each { dll ->
980
        args += ["-reference:${dll}"]
981
      }
982
      // This only runs on Windows, so make sure you use "\"
983
      args += ["${buildDir}\\n\\csharp\\cmd\\Query.cs",
984
               "${buildDir}\\n\\csharp\\cmd\\AssemblyInfo.cs"]
985

    
986
      exec {
987
        commandLine args
988
      }
989
    }
990
  }
991

    
992
  task een_csharpValidate(
993
    dependsOn: ["eenDll", "een_csharpApi", "hen_cmdAssemblyInfo"],
994
    description: "Compile Validate.exe for EE"
995
  ) {
996
    inputs.files("${buildDir}/n/build/dll/ee")
997
    inputs.files("${buildDir}/n/csharp/cmd")
998
    outputs.file("${buildDir}/n/bin/ee/Validate.exe")
999

    
1000
    doLast {
1001
      def args = [csharpCompiler,
1002
                  "-out:${buildDir}/n/bin/ee/Validate.exe",
1003
                  "-target:exe",
1004
                  "-keyfile:${ikvmDir}/saxondotnet.snk"]
1005
      fileTree(dir: "${buildDir}/n/bin/ee",
1006
               include: "*.dll").each { dll ->
1007
        args += ["-reference:${dll}"]
1008
      }
1009
      // This only runs on Windows, so make sure you use "\"
1010
      args += ["${buildDir}\\n\\csharp\\cmd\\Validate.cs",
1011
               "${buildDir}\\n\\csharp\\cmd\\AssemblyInfo.cs"]
1012

    
1013
      exec {
1014
        commandLine args
1015
      }
1016
    }
1017
  }
1018
}
1019

    
1020
task henProduct(
1021
  type: Copy,
1022
  dependsOn: ["hen_csharpApi", "hen_csharpTransform", "hen_csharpQuery"],
1023
  description: "Build Saxon HE for .NET"
1024
) {
1025
  from "${buildDir}/n/saxon9he-api.xml"
1026
  into "${buildDir}/n/bin/he"
1027
}
1028

    
1029
task penProduct(
1030
  type: Copy,
1031
  dependsOn: ["pen_csharpApi", "pen_csharpTransform", "pen_csharpQuery"],
1032
  description: "Build Saxon PE for .NET"
1033
) {
1034
  from "${buildDir}/n/saxon9pe-api.xml"
1035
  into "${buildDir}/n/bin/pe"
1036
}
1037

    
1038
task eenProduct(
1039
  type: Copy,
1040
  dependsOn: ["een_csharpApi", "een_csharpTransform", "een_csharpQuery", "een_csharpValidate"],
1041
  description: "Build Saxon EE for .NET"
1042
) {
1043
  from "${buildDir}/n/saxon9ee-api.xml"
1044
  into "${buildDir}/n/bin/ee"
1045
}
1046

    
1047
task dotNetProducts(
1048
  dependsOn: ["henProduct", "penProduct", "eenProduct"],
1049
  description: "Builds all of the .NET products"
1050
) {
1051
  // nop
1052
}
1053

    
1054
task dotNetInstallers(
1055
  dependsOn: ["henInstaller", "penInstaller", "eenInstaller"],
1056
  description: "Builds all of the .NET installers"
1057
) {
1058
  // nop
1059
}
(5-5/11)