build scripts cleanup: obsolete unused methods from layouts.gant files are removed
[idea/community.git] / build / scripts / nsis_installer.gant
1 import com.intellij.openapi.util.SystemInfo
2
3 target(nsis: 'Build nsis windows installer') {
4   nsis_installer()
5 }
6
7 String p(String key) {
8   return getProperty(key)
9 }
10
11 def nsis_installer(pathsToInclude, stringsFile, pathsFile, outNamePrefix, includeToolsJar = true, associateIpr = true,
12                    system_selector = getProperty("system_selector"), failOnSignError = false, outFileName = null,
13                    boolean hasBundledJRE = false) {
14   // p.s: Groovy reevaluates default value of system_selector on each call, so it always uses actual property value.
15
16   if (outFileName == null) {
17     outFileName = "${outNamePrefix}${buildNumber}"
18   }
19
20   ant.taskdef(name: "nsis", classname: "com.intellij.internalUtilities.ant.NsiFiles", classpath: "${home}/community/build/lib/NsiFiles.jar")
21
22   def box = paths.sandbox
23   ant.mkdir(dir: "$box/bin")
24   ant.mkdir(dir: "$box/nsiconf")
25
26   if (!hasBundledJRE) {
27     ant.copy(todir: "$box/bin") {
28       fileset(dir: "${box}/jdk.win/jre") {
29         include(name: "**/msvcr71.dll")
30       }
31     }
32   }
33
34   ant.copy(todir: "$box/nsiconf") {
35     fileset(dir: "$home/community/build/conf/nsis") {
36       include(name: "*")
37       exclude(name: "version*")
38       exclude(name: "strings*")
39       exclude(name: "paths*")
40     }
41   }
42
43   if (isEap()) {
44     ant.copy(file: "$home/community/build/conf/nsis/version.eap.nsi",
45              tofile: "$box/nsiconf/version.nsi", overwrite: true)
46   }
47   else {
48     ant.copy(file: "$home/community/build/conf/nsis/version.nsi",
49              tofile: "$box/nsiconf/version.nsi", overwrite: true)
50   }
51   ant.copy(file: pathsFile, toFile: "$box/nsiconf/paths.nsi", overwrite: true)
52
53   ant.nsis(instfile: "$box/nsiconf/idea_win.nsh", uninstfile: "$box/nsiconf/unidea_win.nsh") {
54     pathsToInclude.each {
55       fileset(dir: it, includes: "**/*") {
56         exclude(name: "**/idea.properties")
57         exclude(name: "**/*.vmoptions")
58       }
59     }
60     fileset(dir: box, includes: "bin/msvcr71.dll")
61     if (!hasBundledJRE) {
62       fileset(dir: "${box}/jdk.win", includes: "jre/**/*")
63     }
64   }
65
66   ant.replace(file: "$stringsFile") {
67     replacefilter(token: "__VERSION_MAJOR__", value: p("component.version.major"))
68     replacefilter(token: "__VERSION_MINOR__", value: p("component.version.minor"))
69   }
70   ant.copy(file: stringsFile, toFile: "$box/nsiconf/strings.nsi", overwrite: true)
71
72   ant.replace(file: "$box/nsiconf/version.nsi") {
73     replacefilter(token: "__BUILD_NUMBER__", value: buildNumber)
74     replacefilter(token: "__VERSION_MAJOR__", value: p("component.version.major"))
75     replacefilter(token: "__VERSION_MINOR__", value: p("component.version.minor"))
76     replacefilter(token: "__PRODUCT_PATHS_SELECTOR__", value: system_selector)
77   }
78
79   ant.unzip(src: "$home/build/tools/NSIS.zip", dest: box)
80   if (SystemInfo.isWindows) {
81     ant.exec(command: "\"${box}/NSIS/makensis.exe\"" +
82                       " /DBASE_DIR=\"$home\"" +
83                       " /DCOMMUNITY_DIR=\"$home/community\"" +
84                       " /DIPR=\"${associateIpr}\"" +
85                       " /DOUT_FILE=\"${outFileName}\"" +
86                       " /DOUT_DIR=\"$paths.artifacts\"" +
87                       " \"${box}/nsiconf/idea.nsi\"")
88   }
89   else if (SystemInfo.isLinux) {
90     ant.exec(command: "makensis" +
91                       " '-X!AddPluginDir \"${box}/NSIS/Plugins\"'" +
92                       " '-X!AddIncludeDir \"${box}/NSIS/Include\"'" +
93                       " -DBASE_DIR=\"$home\"" +
94                       " -DCOMMUNITY_DIR=\"$home/community\"" +
95                       " -DIPR=\"${associateIpr}\"" +
96                       " -DOUT_FILE=\"${outFileName}\"" +
97                       " -DOUT_DIR=\"$paths.artifacts\"" +
98                       " \"${box}/nsiconf/idea.nsi\"")
99   }
100   
101
102   projectBuilder.stage("Signing binaries")
103   executeExternalAnt(["dirName": "${paths.artifacts}", "fileName": "${outFileName}.exe"], "$home/build/signBuild.xml")
104   projectBuilder.stage("Signing done")
105
106   return "${paths.artifacts}/${outFileName}.exe"
107 }