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

JDK-8211307: Add prefix to build tools paths #283

Merged
merged 4 commits into from
Dec 4, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can toolchainDir be String instead of def ?

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can toolchainDir be String instead of def ?

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
51 changes: 29 additions & 22 deletions buildSrc/win.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,30 @@ WIN.modLibDest = "lib"

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 Down Expand Up @@ -133,7 +137,9 @@ ext.WINDOWS_NATIVE_COMPILE_ENVIRONMENT = [
];
def msvcVer = System.getenv("MSVC_VER") ?: "14.10.25017"
def msvcBinDir = ""
if (winVsVer == 150) {
if (hasProperty('toolchainDir')) {
msvcBinDir = "$WINDOWS_VS_VSINSTALLDIR/VC/bin/${IS_64 ? 'x64' : 'x86'}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The msvcRedstDir will likely need similar treatment (i.e., a different directory when using toolchainDir).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly. I will fix it.

} else if (winVsVer == 150) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can compare with WINDOWS_CRT_VER ?

Copy link
Collaborator

@kevinrushforth kevinrushforth Dec 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can compare with WINDOWS_CRT_VER ?

This would be an intrusive and possibly risky change. Let's leave it as is for now.

msvcBinDir = (IS_64
? "$WINDOWS_VS_VSINSTALLDIR/VC/Tools/MSVC/$msvcVer/bin/HostX64/x64"
: "$WINDOWS_VS_VSINSTALLDIR/VC/Tools/MSVC/$msvcVer/bin/HostX86/x86")
Expand All @@ -155,7 +161,6 @@ if (!file(cygpath("$winSdkBinDir/RC.Exe")).exists()) {
winSdkBinDir += "/" + (IS_64 ? "x64" : "x86")
}
}
println "winSdkBinDir=$winSdkBinDir"

ext.RC = cygpath("$winSdkBinDir/rc.exe")
def rcCompiler = RC
Expand Down Expand Up @@ -427,6 +432,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
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ function(GENERATE_BINDINGS target)
set(binding_generator ${WEBCORE_DIR}/bindings/scripts/generate-bindings-all.pl)
set(idl_attributes_file ${WEBCORE_DIR}/bindings/scripts/IDLAttributes.json)
set(idl_files_list ${CMAKE_CURRENT_BINARY_DIR}/idl_files_${target}.tmp)
set(idl_include_list ${CMAKE_CURRENT_BINARY_DIR}/idl_include_${target}.tmp)
set(_supplemental_dependency)

set(content)
Expand All @@ -80,6 +81,7 @@ function(GENERATE_BINDINGS target)
--generator ${arg_GENERATOR}
--outputDir ${arg_DESTINATION}
--idlFilesList ${idl_files_list}
--includeDirsList ${idl_include_list}
--preprocessor "${CODE_GENERATOR_PREPROCESSOR}"
--idlAttributesFile ${idl_attributes_file}
)
Expand All @@ -90,13 +92,17 @@ function(GENERATE_BINDINGS target)
if (PROCESSOR_COUNT)
list(APPEND args --numOfJobs ${PROCESSOR_COUNT})
endif ()
set(include_dir)
foreach (i IN LISTS arg_IDL_INCLUDES)
if (IS_ABSOLUTE ${i})
list(APPEND args --include ${i})
set(f ${i})
else ()
list(APPEND args --include ${CMAKE_CURRENT_SOURCE_DIR}/${i})
set(f ${CMAKE_CURRENT_SOURCE_DIR}/${i})
endif ()
set(include_dir "${include_dir}${f}\n")
endforeach ()
file(WRITE ${idl_include_list} ${include_dir})

foreach (i IN LISTS arg_PP_EXTRA_OUTPUT)
list(APPEND args --ppExtraOutput ${i})
endforeach ()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@
my $numOfJobs = 1;
my $idlAttributesFile;
my $showProgress;
my $includeDirsList;

GetOptions('include=s@' => \@idlDirectories,
GetOptions('includeDirsList=s' => \$includeDirsList,
'outputDir=s' => \$outputDirectory,
'idlFilesList=s' => \$idlFilesList,
'generator=s' => \$generator,
Expand All @@ -69,6 +70,10 @@
@idlFiles = map { (my $path = $_) =~ s/\r?\n?$//; CygwinPathIfNeeded($path) } <$fh>;
close($fh) or die;

open(my $dh, '<', $includeDirsList) or die "Cannot open $includeDirsList";
@idlDirectories = map { (my $path = $_) =~ s/\r?\n?$//; CygwinPathIfNeeded($path) } <$dh>;
close($dh) or die;

my %oldSupplements;
my %newSupplements;
if ($supplementalDependencyFile) {
Expand All @@ -94,7 +99,7 @@
'--preprocessor', $preprocessor,
'--idlAttributesFile', $idlAttributesFile,
'--write-dependencies');
push @args, map { ('--include', $_) } @idlDirectories;
push @args, map { ('--includeDirsList', $_) } $includeDirsList;
push @args, '--supplementalDependencyFile', $supplementalDependencyFile if $supplementalDependencyFile;

my %directoryCache;
Expand Down
Loading