Project

Profile

Help

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

he / build-n.gradle @ 4ae20fb4

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
  dependsOn: ["hej_featureKeys"],
21
  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
  dependsOn: ["hec_featureKeys"],
53
  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
  dependsOn: ["hec_featureKeys"],
116
  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
  exclude "net/sf/saxon/Gizmo.java"
127
  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
  archiveBaseName = "saxon9he"
381
  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
  archiveBaseName = "saxon9pe"
400
  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
  archiveBaseName = "saxon9ee"
444
  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
        .replace("@@COPYRIGHT_YEAR@@", "2020")
530
    }
531
  }
532

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

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

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

    
568
  commandLine ikvmCommand
569
  doFirst {
570
    mkdir "${buildDir}/n/bin/he"
571
  }
572
}
573

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

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

    
603
  commandLine ikvmCommand
604
  doFirst {
605
    mkdir "${buildDir}/n/bin/pe"
606
  }
607
}
608

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

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

    
643
  commandLine ikvmCommand
644
  doFirst {
645
    mkdir "${buildDir}/n/bin/ee"
646
  }
647
}
648

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

    
658
// ============================================================
659
// Tasks to rejar Xerces and Resolver for .NET
660

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

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

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

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

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

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

    
772
      exec {
773
        commandLine args
774
      }
775
    }
776
  }
777

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

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

    
799
      exec {
800
        commandLine args
801
      }
802
    }
803
  }
804

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

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

    
826
      exec {
827
        commandLine args
828
      }
829
    }
830
  }
831

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

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

    
854
      exec {
855
        commandLine args
856
      }
857
    }
858
  }
859

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

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

    
881
      exec {
882
        commandLine args
883
      }
884
    }
885
  }
886

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

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

    
908
      exec {
909
        commandLine args
910
      }
911
    }
912
  }
913

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

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

    
936
      exec {
937
        commandLine args
938
      }
939
    }
940
  }
941

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

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

    
963
      exec {
964
        commandLine args
965
      }
966
    }
967
  }
968

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

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

    
990
      exec {
991
        commandLine args
992
      }
993
    }
994
  }
995

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

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

    
1017
      exec {
1018
        commandLine args
1019
      }
1020
    }
1021
  }
1022
}
1023

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

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

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

    
1051
task dotNetProducts(
1052
  dependsOn: ["henProduct", "penProduct", "eenProduct"],
1053
  description: "Builds all of the .NET products"
1054
) {
1055
  // nop
1056
}
1057

    
1058
task dotNetInstallers(
1059
  dependsOn: ["henInstaller", "penInstaller", "eenInstaller"],
1060
  description: "Builds all of the .NET installers"
1061
) {
1062
  // nop
1063
}
(6-6/12)