Skip to content
This repository has been archived by the owner on Jun 24, 2021. It is now read-only.

Commit

Permalink
JDK-8211307: Add prefix to build tools paths (#283)
Browse files Browse the repository at this point in the history
* Provide an infrastruture to supply custom toolchain paths to FX build system
  • Loading branch information
arajkumar authored Dec 4, 2018
1 parent efbf0b4 commit 55e55c3
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 77 deletions.
41 changes: 22 additions & 19 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,10 @@ ext.IS_COMPILE_HARFBUZZ = Boolean.parseBoolean(COMPILE_HARFBUZZ)
defineProperty("COMPILE_PARFAIT", "false")
ext.IS_COMPILE_PARFAIT = Boolean.parseBoolean(COMPILE_PARFAIT)

// BUILD_TOOLS_DOWNLOAD_SCRIPT specifies a path of a gradle script which downloads
// required build tools.
defineProperty("BUILD_TOOLS_DOWNLOAD_SCRIPT", "")

// Define the SWT.jar that we are going to have to download during the build process based
// on what platform we are compiling from (not based on our target).
ext.SWT_FILE_NAME = IS_MAC ? "org.eclipse.swt.cocoa.macosx.x86_64_3.105.3.v20170228-0512" :
Expand Down Expand Up @@ -687,7 +691,7 @@ void fetchExternalTools(String configName, List packages, File destdir, boolean
def String basename = pkgname.substring(0,pkgname.lastIndexOf("."))
def File pkgdir = file("$destdir/$basename")

if (pkgname.endsWith(".tgz")) {
if (pkgname.endsWith(".tgz") || pkgname.endsWith("tar.gz")) {
if (IS_LINUX || IS_MAC) {
// use native tar to support symlinks
pkgdir.mkdirs()
Expand All @@ -709,7 +713,7 @@ void fetchExternalTools(String configName, List packages, File destdir, boolean
} else {
throw new GradleException("Unhandled package type for compile package ${pkgname}")
}
srcball.deleteOnExit();
srcball.delete();
}
} else {
logger.quiet "all tool packages are present $packages"
Expand Down Expand Up @@ -759,7 +763,8 @@ void ant(String conf, // platform configuration
"INCLUDE" : WINDOWS_VS_INCLUDE,
"LIB" : WINDOWS_VS_LIB,
"LIBPATH" : WINDOWS_VS_LIBPATH,
"DXSDK_DIR" : WINDOWS_DXSDK_DIR
"DXSDK_DIR" : WINDOWS_DXSDK_DIR,
"PATH" : WINDOWS_VS_PATH
]);
commandLine "cmd", "/c", ant, "-Dbuild.compiler=javac1.7"
} else {
Expand Down Expand Up @@ -1080,6 +1085,11 @@ void commonModuleSetup(Project p, List<String> moduleChain) {
}
}

if (BUILD_TOOLS_DOWNLOAD_SCRIPT != "") {
println "Include build tools download script:${BUILD_TOOLS_DOWNLOAD_SCRIPT}"
apply from: BUILD_TOOLS_DOWNLOAD_SCRIPT
}

// Now we need to define the native compilation tasks. The set of parameters to
// native compilation depends on the target platform (and also to some extent what platform
// you are compiling on). These settings are contained in various gradle files
Expand Down Expand Up @@ -3190,26 +3200,14 @@ project(":web") {
exec {
workingDir("$webkitOutputDir")
def cmakeArgs = "-DENABLE_TOOLS=1"
cmakeArgs = " $cmakeArgs -DCMAKE_C_COMPILER='${webkitProperties.compiler}'"
if (t.name == "win") {
String parfaitPath = IS_COMPILE_PARFAIT ? System.getenv().get("PARFAIT_PATH") + ";" : "";
Map environmentSettings = new HashMap(WINDOWS_NATIVE_COMPILE_ENVIRONMENT)
environmentSettings["PATH"] = parfaitPath + "$WINDOWS_VS_PATH"
/* To build with ICU:
1. Download http://javaweb.us.oracle.com/jcg/fx-webrevs/RT-17164/WebKitLibrariesICU.zip
and unzip it to WebKitLibraries folder.
2. Copy DLLs from
WebKitLibrariesICU.zip\WebKitLibraries\import\runtime
to %windir%\system32
3. Uncomment the line below
*/
// args("--icu-unicode")

// To enable ninja build on Windows
environment(WINDOWS_NATIVE_COMPILE_ENVIRONMENT + ['CC' : 'cl', 'CXX' : 'cl'])
environment(WINDOWS_NATIVE_COMPILE_ENVIRONMENT)
} else if (t.name == "mac") {
cmakeArgs = "-DCMAKE_OSX_DEPLOYMENT_TARGET=$MACOSX_MIN_VERSION -DCMAKE_OSX_SYSROOT=$MACOSX_SDK_PATH"
cmakeArgs = " $cmakeArgs -DCMAKE_OSX_DEPLOYMENT_TARGET=$MACOSX_MIN_VERSION -DCMAKE_OSX_SYSROOT=$MACOSX_SDK_PATH"
} else if (t.name == "linux") {
cmakeArgs = "-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_C_COMPILER=${webkitProperties.compiler}"
cmakeArgs = " $cmakeArgs -DCMAKE_SYSTEM_NAME=Linux"
if (IS_64) {
cmakeArgs = "$cmakeArgs -DCMAKE_SYSTEM_PROCESSOR=x86_64"
} else {
Expand All @@ -3230,9 +3228,14 @@ project(":web") {
environment([
"COMPILE_PARFAIT" : "true"
])
environment "PATH", System.env.PARFAIT_PATH + File.pathSeparator + environment.PATH
cmakeArgs = "-DCMAKE_C_COMPILER=parfait-gcc -DCMAKE_CXX_COMPILER=parfait-g++"
}

if (project.hasProperty('toolsPath')) {
environment "PATH", toolsPath + File.pathSeparator + environment.PATH
}

environment([
"JAVA_HOME" : JDK_HOME,
"WEBKIT_OUTPUTDIR" : webkitOutputDir,
Expand Down
29 changes: 18 additions & 11 deletions buildSrc/linux.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ if (IS_DEBUG_NATIVE) {
linkFlags += "-g"
}

def toolchainDir
if (hasProperty('toolchainDir')) {
toolchainDir = ext.toolchainDir + "/"
} else {
toolchainDir = ""
}

def gtk2CCFlags = [ ];
def gtk3CCFlags = [ "-Wno-deprecated-declarations" ];
def gtk2LinkFlags = [ ];
Expand All @@ -73,14 +80,14 @@ setupTools("linux_gtk2",
{ propFile ->
ByteArrayOutputStream results1 = new ByteArrayOutputStream();
exec {
commandLine("pkg-config", "--cflags", "gtk+-2.0", "gthread-2.0", "xtst")
commandLine("${toolchainDir}pkg-config", "--cflags", "gtk+-2.0", "gthread-2.0", "xtst")
setStandardOutput(results1);
}
propFile << "cflagsGTK2=" << results1.toString().trim() << "\n";

ByteArrayOutputStream results3 = new ByteArrayOutputStream();
exec {
commandLine("pkg-config", "--libs", "gtk+-2.0", "gthread-2.0", "xtst")
commandLine("${toolchainDir}pkg-config", "--libs", "gtk+-2.0", "gthread-2.0", "xtst")
setStandardOutput(results3);
}
propFile << "libsGTK2=" << results3.toString().trim() << "\n";
Expand All @@ -101,15 +108,15 @@ setupTools("linux_gtk3",
{ propFile ->
ByteArrayOutputStream results2 = new ByteArrayOutputStream();
exec {
commandLine("pkg-config", "--cflags", "gtk+-3.0", "gthread-2.0", "xtst")
commandLine("${toolchainDir}pkg-config", "--cflags", "gtk+-3.0", "gthread-2.0", "xtst")
setStandardOutput(results2);
ignoreExitValue(true)
}
propFile << "cflagsGTK3=" << results2.toString().trim() << "\n";

ByteArrayOutputStream results4 = new ByteArrayOutputStream();
exec {
commandLine("pkg-config", "--libs", "gtk+-3.0", "gthread-2.0", "xtst")
commandLine("${toolchainDir}pkg-config", "--libs", "gtk+-3.0", "gthread-2.0", "xtst")
setStandardOutput(results4);
ignoreExitValue(true)
}
Expand All @@ -135,14 +142,14 @@ setupTools("linux_pango_tools",
{ propFile ->
ByteArrayOutputStream results = new ByteArrayOutputStream();
exec {
commandLine "pkg-config", "--cflags", "pangoft2"
commandLine "${toolchainDir}pkg-config", "--cflags", "pangoft2"
standardOutput = results
}
propFile << "cflags=" << results.toString().trim() << "\n";

results = new ByteArrayOutputStream();
exec {
commandLine "pkg-config", "--libs", "pangoft2"
commandLine "${toolchainDir}pkg-config", "--libs", "pangoft2"
standardOutput = results
}
propFile << "libs=" << results.toString().trim();
Expand All @@ -166,14 +173,14 @@ setupTools("linux_freetype_tools",
{ propFile ->
ByteArrayOutputStream results = new ByteArrayOutputStream();
exec {
commandLine "pkg-config", "--cflags", "freetype2"
commandLine "${toolchainDir}pkg-config", "--cflags", "freetype2"
standardOutput = results
}
propFile << "cflags=" << results.toString().trim() << "\n";

results = new ByteArrayOutputStream();
exec {
commandLine "pkg-config", "--libs", "freetype2"
commandLine "${toolchainDir}pkg-config", "--libs", "freetype2"
standardOutput = results
}
propFile << "libs=" << results.toString().trim();
Expand All @@ -190,8 +197,8 @@ setupTools("linux_freetype_tools",
}
)

def compiler = IS_COMPILE_PARFAIT ? "parfait-gcc" : "gcc";
def linker = IS_COMPILE_PARFAIT ? "parfait-g++" : "g++";
def compiler = IS_COMPILE_PARFAIT ? "parfait-gcc" : "${toolchainDir}gcc";
def linker = IS_COMPILE_PARFAIT ? "parfait-g++" : "${toolchainDir}g++";

LINUX.glass = [:]
LINUX.glass.variants = ["glass", "glassgtk2"]
Expand Down Expand Up @@ -307,7 +314,7 @@ LINUX.fontPango.lib = "javafx_font_pango"
LINUX.media = [:]
LINUX.media.compiler = compiler
LINUX.media.linker = linker
LINUX.media.ar = "ar"
LINUX.media.ar = "${toolchainDir}ar"

LINUX.webkit = [:]
LINUX.webkit.compiler = compiler
Expand Down
20 changes: 16 additions & 4 deletions buildSrc/mac.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ defineProperty("MACOSX_MIN_VERSION", "10.10");
setupTools("mac_tools",
{ propFile ->
propFile << ""
if (!file(defaultSdkPath).isDirectory()) {
if (project.hasProperty('setupMacTools')) {
setupMacTools(propFile)
} else if (!file(defaultSdkPath).isDirectory()) {
// Get list of all macosx sdks
ByteArrayOutputStream results = new ByteArrayOutputStream();
exec {
Expand Down Expand Up @@ -126,9 +128,15 @@ def linkFlags = [
"-framework", "Security",
"-dynamiclib", "-lobjc"].flatten();

def toolchainDir
if (hasProperty('toolchainDir')) {
toolchainDir = ext.toolchainDir + "/"
} else {
toolchainDir = ""
}

def compiler = IS_COMPILE_PARFAIT ? "parfait-clang" : "clang";
def linker = IS_COMPILE_PARFAIT ? "parfait-clang++" : "clang++";
def compiler = IS_COMPILE_PARFAIT ? "parfait-clang" : "${toolchainDir}clang";
def linker = IS_COMPILE_PARFAIT ? "parfait-clang++" : "${toolchainDir}clang++";

MAC.glass = [:]
MAC.glass.javahInclude = [
Expand Down Expand Up @@ -208,4 +216,8 @@ MAC.media.compiler = "${compiler} ${ccBaseFlags.join(" ")}"
//MAC.media.ccFlags = ccBaseFlags
MAC.media.linker = "${linker} ${commonParams.join(" ")}"
//MAC.media.linkFlags = commonParams
MAC.media.ar = "libtool"
MAC.media.ar = "${toolchainDir}libtool"

MAC.webkit = [:]
MAC.webkit.compiler = compiler
MAC.webkit.linker = linker
79 changes: 44 additions & 35 deletions buildSrc/win.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,34 @@ WIN.library = { name -> return "${name}.dll" as String }
WIN.libDest = "bin"
WIN.modLibDest = "lib"

def CPU_BITS = IS_64 ? "x64" : "x86"

setupTools("windows_tools",
{ propFile ->
// Create the properties file
ByteArrayOutputStream results = new ByteArrayOutputStream();
String winsdkDir = System.getenv().get("WINSDK_DIR");
exec({
environment([
"WINSDKPATH" : winsdkDir == null ? "" : winsdkDir,
"CONF" : "/$CONF", // TODO does this mean the generated properties must be reset when in a different configuration?
"VCARCH" : IS_64 ? "amd64" : "x86",
"SDKARCH" : IS_64 ? "/x64" : "/x86",
]);
commandLine("cmd", "/q", "/c", "buildSrc\\genVSproperties.bat");
setStandardOutput(results);
});
BufferedReader reader = new BufferedReader(new StringReader(results.toString().trim()));
reader.readLine();
reader.readLine();
String line;
while ((line = reader.readLine()) != null && !line.startsWith("######")) {
line = line.replace("\\", "/").replace("/@@ENDOFLINE@@", "").replace("@@ENDOFLINE@@", "").replace("//", "/").replace("windows.vs.", "WINDOWS_VS_");
propFile << line << "\r\n";
if (project.hasProperty('setupWinTools')) {
setupWinTools(propFile)
} else {
// Create the properties file
ByteArrayOutputStream results = new ByteArrayOutputStream();
String winsdkDir = System.getenv().get("WINSDK_DIR");
exec({
environment([
"WINSDKPATH" : winsdkDir == null ? "" : winsdkDir,
"CONF" : "/$CONF", // TODO does this mean the generated properties must be reset when in a different configuration?
"VCARCH" : IS_64 ? "amd64" : "x86",
"SDKARCH" : IS_64 ? "/x64" : "/x86",
]);
commandLine("cmd", "/q", "/c", "buildSrc\\genVSproperties.bat");
setStandardOutput(results);
});
BufferedReader reader = new BufferedReader(new StringReader(results.toString().trim()));
reader.readLine();
reader.readLine();
String line;
while ((line = reader.readLine()) != null && !line.startsWith("######")) {
line = line.replace("\\", "/").replace("/@@ENDOFLINE@@", "").replace("@@ENDOFLINE@@", "").replace("//", "/").replace("windows.vs.", "WINDOWS_VS_");
propFile << line << "\r\n";
}
}
},
{ properties ->
Expand All @@ -75,6 +81,7 @@ setupTools("windows_tools",
defineProperty("WINDOWS_DXSDK_DIR", properties, System.getenv().get("DXSDK_DIR"))
defineProperty("WINDOWS_VS_INCLUDE", properties, "$WINDOWS_VS_VCINSTALLDIR/INCLUDE;" + "$WINDOWS_SDK_DIR/include;")
defineProperty("WINDOWS_VS_VER", properties, "150")
defineProperty("WINDOWS_CRT_VER", properties, "150")
defineProperty("WINDOWS_VS_LIB", properties, "$WINDOWS_VS_VCINSTALLDIR/LIB;" + "$WINDOWS_SDK_DIR/lib;")
defineProperty("WINDOWS_VS_LIBPATH", properties, "$WINDOWS_VS_VCINSTALLDIR/LIB;")
def parfaitPath = IS_COMPILE_PARFAIT ? System.getenv().get("PARFAIT_PATH") + ";" : "";
Expand Down Expand Up @@ -133,10 +140,10 @@ ext.WINDOWS_NATIVE_COMPILE_ENVIRONMENT = [
];
def msvcVer = System.getenv("MSVC_VER") ?: "14.10.25017"
def msvcBinDir = ""
if (winVsVer == 150) {
msvcBinDir = (IS_64
? "$WINDOWS_VS_VSINSTALLDIR/VC/Tools/MSVC/$msvcVer/bin/HostX64/x64"
: "$WINDOWS_VS_VSINSTALLDIR/VC/Tools/MSVC/$msvcVer/bin/HostX86/x86")
if (hasProperty('toolchainDir')) {
msvcBinDir = "$WINDOWS_VS_VSINSTALLDIR/VC/bin/$CPU_BITS"
} else if (winVsVer == 150) {
msvcBinDir = "$WINDOWS_VS_VSINSTALLDIR/VC/Tools/MSVC/$msvcVer/bin/Host${CPU_BITS}/$CPU_BITS"
} else if (winVsVer <= 120) {
msvcBinDir = (IS_64
? "$WINDOWS_VS_VSINSTALLDIR/VC/BIN/amd64"
Expand All @@ -146,16 +153,15 @@ def compiler = IS_COMPILE_PARFAIT ? "cl.exe" : cygpath("$msvcBinDir/cl.exe")
def linker = IS_COMPILE_PARFAIT ? "link.exe" : cygpath("$msvcBinDir/link.exe")
def winSdkBinDir = "$WINDOWS_SDK_DIR/Bin"
if (WINDOWS_VS_VER != "100") {
winSdkBinDir += "/" + (IS_64 ? "x64" : "x86")
winSdkBinDir += "/$CPU_BITS"
}

if (!file(cygpath("$winSdkBinDir/RC.Exe")).exists()) {
winSdkBinDir = "$WINDOWS_SDK_DIR/Bin/$WINDOWS_SDK_VERSION"
if (WINDOWS_VS_VER != "100") {
winSdkBinDir += "/" + (IS_64 ? "x64" : "x86")
winSdkBinDir += "/$CPU_BITS"
}
}
println "winSdkBinDir=$winSdkBinDir"

ext.RC = cygpath("$winSdkBinDir/rc.exe")
def rcCompiler = RC
Expand All @@ -173,20 +179,21 @@ ext.MC = cygpath("$winSdkBinDir/mt.exe")
if (!file(RC).exists()) throw new GradleException("FAIL: cannot find RC: " + RC)
if (!file(FXC).exists()) throw new GradleException("FAIL: cannot find FXC: " + FXC)

def msvcRedistVer = System.getenv("MSVC_REDIST_VER") ?: "14.10.25008"
String msvcRedstDir = (IS_64
? "$WINDOWS_VS_VSINSTALLDIR/VC/Redist/MSVC/$msvcRedistVer/x64"
: "$WINDOWS_VS_VSINSTALLDIR/VC/Redist/MSVC/$msvcRedistVer/x86")
def msvcRedstDir
if (hasProperty('toolchainDir')) {
msvcRedstDir = "$WINDOWS_VS_VSINSTALLDIR/VC/Redist/$CPU_BITS"
} else {
def msvcRedistVer = System.getenv("MSVC_REDIST_VER") ?: "14.10.25008"
msvcRedstDir = "$WINDOWS_VS_VSINSTALLDIR/VC/Redist/MSVC/$msvcRedistVer/$CPU_BITS"
}

String winSdkDllDir = (IS_64
? "$WINDOWS_VS_WINSDKDLLINSTALLDIR/x64"
: "$WINDOWS_VS_WINSDKDLLINSTALLDIR/x86")
def winSdkDllDir = "$WINDOWS_VS_WINSDKDLLINSTALLDIR/$CPU_BITS"

def WINDOWS_DLL_VER = WINDOWS_VS_VER
ext.MSVCR = null
ext.MSVCP = null

def windowsCRTVer = System.getenv("WINDOWS_CRT_VER") ?: "150"
def windowsCRTVer = System.getenv("WINDOWS_CRT_VER") ?: WINDOWS_CRT_VER
if (WINDOWS_VS_VER == "150") {
WINDOWS_DLL_VER = "140"
ext.MSVCR = cygpath("${msvcRedstDir}/Microsoft.VC${windowsCRTVer}.CRT/vcruntime${WINDOWS_DLL_VER}.dll")
Expand Down Expand Up @@ -427,6 +434,8 @@ WIN.media.linker = IS_COMPILE_PARFAIT ? "${parfaitPath}/parfait-link.exe" : "lin
WIN.media.ar = IS_COMPILE_PARFAIT ? "${parfaitPath}/parfait-lib.exe" : "lib.exe";

WIN.webkit = [:]
WIN.webkit.compiler = compiler
WIN.webkit.linker = linker
WIN.webkit.rcCompiler = rcCompiler
WIN.webkit.rcSource = defaultRcSource
WIN.webkit.rcFlags = ["/d", "JFX_FNAME=jfxwebkit.dll", "/d", "JFX_INTERNAL_NAME=webkit", rcFlags].flatten();
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ elseif (APPLE)
platform/cf/CFURLExtras.cpp
)
# find_library(OPENGL_LIBRARY OpenGL)
find_library(ACCELERATE_LIBRARY accelerate)
find_library(ACCELERATE_LIBRARY Accelerate)
list(APPEND WebCore_LIBRARIES
${ACCELERATE_LIBRARY}
# ${OPENGL_LIBRARY}
Expand Down
Loading

0 comments on commit 55e55c3

Please sign in to comment.