Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

build.gradle 6.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. // Global settings
  2. project.ext {
  3. // Source JRE used for compilation, etc
  4. if (!project.hasProperty('jre')) {
  5. jre = System.getProperty('java.home')
  6. }
  7. os = Os.current()
  8. arch = Arch.current()
  9. if (!project.hasProperty('targetJre')) {
  10. targetJre = jre
  11. }
  12. }
  13. def targetJreFile = file(targetJre)
  14. def jreFile = file(jre)
  15. // HotSpot itself
  16. project('hotspot') {
  17. task clean(type: InvokeMake) {
  18. onlyIf { file('hotspot').exists() }
  19. args 'clean'
  20. }
  21. task prepareJvm {
  22. onlyIf { jreFile != targetJreFile }
  23. doLast {
  24. ant.copy(todir: targetJreFile) {
  25. fileset(dir: jreFile)
  26. }
  27. ant.chmod(file: new File(targetJreFile, 'bin/java'), perm: '0755')
  28. }
  29. }
  30. task clone(description: 'Clone HotSpot repository') {
  31. onlyIf { !file('hotspot').exists() }
  32. doLast {
  33. exec {
  34. workingDir '..'
  35. executable 'hg'
  36. args 'clone', hotspotRepository
  37. }
  38. }
  39. }
  40. task patch(description: 'Patch HotSpot sources', dependsOn: clone) << {
  41. exec {
  42. executable 'hg'
  43. args 'pull'
  44. }
  45. exec {
  46. executable 'hg'
  47. args 'update', '-C', '-r', hotspotTag
  48. }
  49. new ByteArrayOutputStream().withStream { os ->
  50. exec {
  51. workingDir 'hotspot'
  52. executable 'hg'
  53. args 'status'
  54. standardOutput os
  55. }
  56. def str = os.toString()
  57. def matcher = str =~ /(?m)^\?\s+(.*)$/
  58. matcher.each {
  59. ant.delete(file: new File(file('hotspot'), it[1]))
  60. }
  61. }
  62. // Use hg import since ant.patchfile requires 'patch' to be installed
  63. exec {
  64. executable 'hg'
  65. args 'import', '--no-commit', "../patches/dcevm-${hotspotTag}.patch"
  66. }
  67. }
  68. task compileFastdebug(type: InvokeMake) {
  69. args 'STRIP_POLICY=no_strip'
  70. args 'ZIP_DEBUGINFO_FILES=0'
  71. args 'ENABLE_FULL_DEBUG_SYMBOLS=1'
  72. args 'fastdebug'
  73. }
  74. task compileProduct(type: InvokeMake) {
  75. args 'ENABLE_FULL_DEBUG_SYMBOLS=0'
  76. args 'product'
  77. }
  78. compileFastdebug.mustRunAfter patch
  79. compileProduct.mustRunAfter patch
  80. // Install given kind of DCEVM into destination JRE
  81. ['Product', 'Fastdebug'].each { k ->
  82. task("install${k}", dependsOn: [prepareJvm, "compile${k}"]) << {
  83. def installPath = new File(new File(targetJreFile, arch == Arch.X86 ? os.installPath32 : os.installPath64), jvmName)
  84. logger.info("Installing DCEVM runtime into JRE with JVM name '${jvmName}' and kind '${k.toLowerCase()}' at ${installPath}")
  85. ant.copy(todir: installPath, overwrite: true) {
  86. fileset(dir: "build/${os.buildPath}/${os.buildPath}_${arch.buildArch}_${compiler}/${k.toLowerCase()}",
  87. includes: 'libjvm.so,libjsig.so,jvm.dll,jsig.dll,libjvm.dylib,libjsig.dylib')
  88. }
  89. }
  90. }
  91. }
  92. // Java projects for testing DCEVM
  93. def setup(prjs, closure) {
  94. prjs.each { prj ->
  95. project(prj, closure)
  96. }
  97. }
  98. setup(['agent', 'framework', 'tests-java7', 'tests-java8'], {
  99. apply plugin: 'java'
  100. apply plugin: 'idea'
  101. repositories {
  102. mavenCentral()
  103. }
  104. })
  105. project('agent') {
  106. jar {
  107. manifest {
  108. from "src/main/java/META-INF/MANIFEST.MF"
  109. }
  110. }
  111. }
  112. project('framework') {
  113. dependencies {
  114. compile project(':agent')
  115. compile group: 'asm', name: 'asm-all', version: '3.3.+'
  116. compile files(System.getProperty("java.home") + '/../lib/tools.jar')
  117. }
  118. }
  119. project('tests-java8') {
  120. sourceCompatibility = 1.8
  121. targetCompatibility = 1.8
  122. }
  123. setup(['tests-java7', 'tests-java8'], {
  124. dependencies {
  125. compile project(':framework')
  126. testCompile group: 'junit', name: 'junit', version: '4.11'
  127. }
  128. test {
  129. executable new File(targetJreFile, 'bin/java')
  130. jvmArgs "-XXaltjvm=${jvmName}"
  131. jvmArgs '-javaagent:../agent/build/libs/agent.jar'
  132. if (arch == Arch.X86_64) {
  133. jvmArgs(project.oops == "compressed" ? '-XX:+UseCompressedOops' : "-XX:-UseCompressedOops")
  134. }
  135. jvmArgs "-XX:TraceRedefineClasses=${traceRedefinition}"
  136. ignoreFailures = true
  137. outputs.upToDateWhen { false }
  138. exclude '**/*Suite.class'
  139. }
  140. test.dependsOn project(':hotspot').tasks[kind == 'fastdebug' ? 'installFastdebug' : 'installProduct']
  141. })
  142. enum Arch {
  143. X86(["i386", "i486", "i586", "x86"], 'i486', 32),
  144. X86_64(["x86_64", "x64", "amd64"], 'amd64', 64)
  145. final List<String> names
  146. final String buildArch
  147. final int bits
  148. Arch(List<String> names, String buildArch, int bits) {
  149. this.names = names
  150. this.buildArch = buildArch
  151. this.bits = bits
  152. }
  153. static Arch find(String token) {
  154. Arch res = values().find({ v -> v.names.contains(token) })
  155. return res
  156. }
  157. static Arch current() {
  158. return find(System.getProperty("os.arch"))
  159. }
  160. }
  161. enum Os {
  162. MAC('bsd', 'lib', 'lib'),
  163. WINDOWS('windows', 'bin', 'bin'),
  164. UNIX('linux', 'lib/i386', 'lib/amd64')
  165. final String buildPath;
  166. final String installPath32;
  167. final String installPath64;
  168. Os(String buildPath, String installPath32, String installPath64) {
  169. this.buildPath = buildPath
  170. this.installPath32 = installPath32
  171. this.installPath64 = installPath64
  172. }
  173. static Os current() {
  174. return values().find { os -> org.apache.tools.ant.taskdefs.condition.Os.isFamily(os.name().toLowerCase()) }
  175. }
  176. }
  177. // Helper task to run make targets against hotspot
  178. class InvokeMake extends org.gradle.api.tasks.Exec {
  179. InvokeMake() {
  180. logging.captureStandardOutput LogLevel.INFO
  181. if (project.rootProject.os != Os.WINDOWS) {
  182. commandLine 'make', '-C', 'make'
  183. } else {
  184. // Using launcher script
  185. commandLine 'cmd', '/c', '..\\build.cmd'
  186. environment ARCH: project.rootProject.arch == Arch.X86 ? 'x86' : 'x64'
  187. }
  188. args 'OPENJDK=true'
  189. args "HOTSPOT_BUILD_VERSION=dcevmlight-${project.rootProject.buildNumber}"
  190. args "ARCH_DATA_MODEL=${project.rootProject.arch.bits}"
  191. args "ALT_BOOTDIR=${project.rootProject.jre.replace('\\', '/')}/.."
  192. // Replacing backslashes is essential for Windows!
  193. args 'COMPILER_WARNINGS_FATAL=false' // Clang is very serious about warnings
  194. args 'HOTSPOT_BUILD_JOBS=4'
  195. }
  196. }