Project

Profile

Help

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

he / build-n.gradle @ 8e6cebbc

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 "net/sf/saxon/Gizmo.java"
124
  exclude "**/ant/**"
125
  exclude "**/dom/**"
126
  exclude "**/dom4j/**"
127
  exclude "**/java/**"
128
  exclude "**/jaxp/**"
129
  exclude "**/jdom/**"
130
  exclude "**/jdom2/**"
131
  exclude "**/axiom/**"
132
  exclude "**/s9api/DOMDestination.java"
133
  exclude "**/sql/**"
134
  exclude "**/xom/**"
135
  exclude "**/xpath/**"
136
  exclude "**/xqj/**"
137
  exclude "**/stax/**"
138
  include "com/saxonica/**/*.java"
139
  exclude "com/saxonica/functions/extfn/cpp/*.java"
140
  exclude "com/saxonica/testdriver/**/*.java"
141
  exclude "net/sf/saxon/testdriver/**/*.java"
142
  exclude "com/saxonica/ee/jaxp/*.java"
143
  exclude "com/saxonica/js/**"
144
  exclude "com/saxonica/ee/domino/**/*.java"
145
  exclude "com/saxonica/config/JavaPlatformPE.java"
146
  exclude "com/saxonica/config/JavaPlatformEE.java"
147
  exclude "com/saxonica/config/JavaPlatformC.java"
148
  exclude "com/saxonica/config/ProfessionalXPathFactory.java"
149
  exclude "com/saxonica/config/EnterpriseXPathFactory.java"
150
  exclude "com/saxonica/config/ProfessionalTransformerFactory.java"
151
  exclude "com/saxonica/config/EnterpriseTransformerFactory.java"
152
  exclude "com/saxonica/config/StreamingTransformerFactory.java"
153
  exclude "com/saxonica/config/NativePlatformPE.java"
154
  exclude "**/xqj/**"
155
}
156

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

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

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

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

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

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

    
270
// ============================================================
271

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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