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

Conversation

arajkumar
Copy link
Contributor

@arajkumar arajkumar commented Nov 13, 2018

Currently JavaFX uses build tools{MSVC, GCC, Clang, CMake,..etc} from standard system paths. Adding prefix to each of those tools would help to have a custom build tools without disturbing standard tools.

This fix provides a new gradle property named BUILD_TOOLS_DOWNLOAD_SCRIPT, which could be used to point to a supplement gradle file which can have the logic to setup the custom toolchain.

In additional to provisioning toolchain prefix, this patch also has changes to javafx.web module to workaround "command line is too long" issue on windows when custom toolchain path length is long.

@johanvos johanvos requested a review from tiainen November 27, 2018 11:11
@arajkumar
Copy link
Contributor Author

@tiainen , do you have any comments for this PR?

Copy link
Collaborator

@kevinrushforth kevinrushforth left a comment

Choose a reason for hiding this comment

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

I did full test builds (including media and webkit) on all three platforms, both with and without setting BUILD_TOOLS_DOWNLOAD_SCRIPT to a script that defines toolchainDir. I ran into one problem on Windows when using the default toolchain with VS2017 installed in the default location:

> Task :web:compileNativeWin
python: can't open file 'Tools/Scripts/update-vswhere.py': [Errno 2] No such file or directory
+  cmake -DPORT="Java" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 15 2017 Win64" -DCMAKE_GENERATOR_TOOLSET="host=x64" -DSHOW_BINDINGS_GENERATION_PROGRESS=1 -DENABLE_EXPERIMENTAL_FEATURES=ON  -DENABLE_TOOLS=1 -DCMAKE_C_COMPILER=C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.10.25017/bin/HostX64/x64/cl.exe -DJAVAFX_RELEASE_VERSION=12 "rt\modules\javafx.web\src\main\native"
sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0: `cmake -DPORT="Java" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 15 2017 Win64" -DCMAKE_GENERATOR_TOOLSET="host=x64" -DSHOW_BINDINGS_GENERATION_PROGRESS=1 -DENABLE_EXPERIMENTAL_FEATURES=ON  -DENABLE_TOOLS=1 -DCMAKE_C_COMPILER=C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.10.25017/bin/HostX64/x64/cl.exe -DJAVAFX_RELEASE_VERSION=12 "rt\modules\javafx.web\src\main\native"'

> Task :web:compileNativeWin FAILED

FAILURE: Build failed with an exception.

* Where:
Build file 'rt\build.gradle' line: 3200

* What went wrong:
Execution failed for task ':web:compileNativeWin'.
> Process 'command 'perl'' finished with non-zero exit value 1

It looks like a problem of not escaping a file path that includes spaces or special chars -- a ( in this case.

@@ -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.

@tiainen
Copy link
Contributor

tiainen commented Nov 29, 2018

I have no further comments. I've had a look through the changes and they look okay to me. Only valuable feedback would be to do what Kevin has already done.

@arajkumar
Copy link
Contributor Author

Thanks @kevinrushforth & @tiainen for reviewing this PR.

@kevinrushforth , yes the failure is due to space in file path.

@arajkumar
Copy link
Contributor Author

@kevinrushforth Addressed the review comments in the new commit. Please take a look. Thanks.

Copy link
Collaborator

@kevinrushforth kevinrushforth left a comment

Choose a reason for hiding this comment

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

Looks good now. All testing is done.

String msvcRedstDir = (IS_64
? "$WINDOWS_VS_VSINSTALLDIR/VC/Redist/MSVC/$msvcRedistVer/x64"
: "$WINDOWS_VS_VSINSTALLDIR/VC/Redist/MSVC/$msvcRedistVer/x86")
def msvcRedstDir

Choose a reason for hiding this comment

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

I think msvcRedstDir can be still string ? I see that msvcRedstDir is not used outside of win.gradle and no need to be a def?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see that msvcRedstDir is not used outside of win.gradle and no need to be a def?

def defines a local variable, so I see no problem with this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, as @kevinrushforth mentioned, it is nothing to do with the scope, it is almost equvalent to C++ auto / Java's var.

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

Choose a reason for hiding this comment

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

I think winSdkDllDir can be a string..


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") {

Choose a reason for hiding this comment

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

if you are replacing 150 with "WINDOWS_CRT_VER", you can do this at all places like if (WINDOWS_VS_VER == WINDOWS_CRT_VER) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are multiple versions need to be considered, 1. VS version, 2. CRT version & 3. DLL version. What we are comparing here is VS version, it should be kept as it is, otherwise it may cause issues when using older VS variants.

: "$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) {

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.

@@ -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 ?

@@ -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 ?

@arajkumar arajkumar merged commit 55e55c3 into javafxports:develop Dec 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants