1 /*
  2  * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation. Amazon designates this
  8  * particular file as subject to the "Classpath" exception as provided
  9  * by Oracle in the LICENSE file that accompanied this code.
 10  *
 11  * This code is distributed in the hope that it will be useful, but WITHOUT
 12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 14  * version 2 for more details (a copy is included in the LICENSE file that
 15  * accompanied this code).
 16  *
 17  * You should have received a copy of the GNU General Public License version
 18  * 2 along with this work; if not, write to the Free Software Foundation,
 19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 20  */
 21 
 22 dependencies {
 23     compile project(path: ':openjdksrc', configuration: 'archives')
 24     compile project(path: ':prebuild', configuration: 'cacerts')
 25 }
 26 
 27 def imageDir = "$buildRoot/build/${project.jdkImageName}/images"
 28 def jdkResultingImage = "${imageDir}/jdk"
 29 def testResultingImage = "${imageDir}/test"
 30 
 31 // deps
 32 def depsMap = [:]
 33 project.configurations.compile.getFiles().each { depsMap[it.getName()] = it }
 34 
 35 task copySource(type: Copy) {
 36     dependsOn project.configurations.compile
 37     from tarTree(depsMap[sourceTar])
 38     into buildRoot
 39 }
 40 
 41 
 42 task configureBuild(type: Exec) {
 43     dependsOn copySource
 44     workingDir buildRoot
 45 
 46     // Platform specific flags
 47     def command = ['bash', 'configure',
 48            "--with-cacerts-file=${depsMap[caCerts]}",
 49            "--with-boot-jdk=${project.getProperty('bootjdk_dir')}",
 50            "--with-zlib=bundled"
 51     ]
 52     // Common flags
 53     command += project.correttoCommonFlags
 54     commandLine command.flatten()
 55 }
 56 
 57 task executeBuild(type: Exec) {
 58     dependsOn configureBuild
 59     workingDir buildRoot
 60     commandLine 'make', 'images'
 61     outputs.dir jdkResultingImage
 62 }
 63 
 64 task createTestImage(type: Exec) {
 65     dependsOn executeBuild
 66     workingDir "$buildRoot"
 67     commandLine 'make','test-image'
 68 }
 69 
 70 task packageTestImage(type: Zip) {
 71     dependsOn createTestImage
 72     archiveFileName = "${project.correttoTestImageArchiveName}.zip"
 73     from(testResultingImage) {
 74         include '**'
 75     }
 76     into project.correttoTestImageArchiveName
 77 }
 78 
 79 task packageDebugSymbols(type: Zip) {
 80     dependsOn packageTestImage
 81     archiveFileName = "${project.correttoDebugSymbolsArchiveName}.zip"
 82 
 83     from(jdkResultingImage) {
 84         include 'bin/*.diz'
 85         include 'lib/*.diz'
 86         include 'lib/server/*.diz'
 87         into project.correttoDebugSymbolsArchiveName
 88     }
 89 }
 90 
 91 task packageBuildResults(type: Zip) {
 92     dependsOn packageDebugSymbols
 93     archiveFileName = "unsigned-jdk-image.zip"
 94 
 95     from(jdkResultingImage) {
 96         exclude 'demo'
 97         exclude '**/*.diz'
 98     }
 99 
100     from(buildRoot) {
101         include project.rootFiles
102     }
103 }
104 
105 build.dependsOn packageBuildResults
106 
107 artifacts {
108     archives packageBuildResults
109 }