From 65fa72dd9a2eab3148063db8116f623fed14ae7a Mon Sep 17 00:00:00 2001
From: Joerg Bornemann <joerg.bornemann@qt.io>
Date: Thu, 23 Mar 2017 14:32:41 +0100
Subject: [PATCH] Add gnuwin32\bin directory to PATH on Windows

This is necessary for finding gperf, bison, yacc, etc. on Windows.
Works only if the gnuwin32 directory is on the same level as the
qtwebengine root directory, which is the case with a qt checkout.

This is a port of 09e53e79 which did the same for the gyp build.

Change-Id: Icd75c44605ba07269f721cd3b9877463c43f8beb
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
---
 src/core/gn_run.pro | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/src/core/gn_run.pro b/src/core/gn_run.pro
index 28d42aa13..5e4438248 100644
--- a/src/core/gn_run.pro
+++ b/src/core/gn_run.pro
@@ -14,9 +14,24 @@ defineReplace(runGn) {
 
 qtConfig(debug_and_release): CONFIG += debug_and_release build_all
 
-build_pass|!debug_and_release {
+qtConfig(system-ninja) {
+    QT_TOOL.ninja.binary = ninja
+} else {
+    QT_TOOL.ninja.binary = $$ninjaPath()
+}
+
+win32 {
+    # Add the gnuwin32/bin subdir of qt5.git to PATH. Needed for calling bison and friends.
+    gnuwin32path.name = PATH
+    gnuwin32path.value = $$shell_path($$clean_path($$QTWEBENGINE_ROOT/../gnuwin32/bin))
+    gnuwin32path.CONFIG += prepend
+    exists($$gnuwin32path.value): QT_TOOL_ENV = gnuwin32path
+}
 
-    ninja_binary = ninja
+qtPrepareTool(NINJA, ninja)
+QT_TOOL_ENV =
+
+build_pass|!debug_and_release {
     gn_binary = gn
 
     runninja.target = run_ninja
@@ -34,17 +49,13 @@ build_pass|!debug_and_release {
         gn_binary = $$shell_quote($$shell_path($$gnPath()))
     }
 
-    !qtConfig(system-ninja) {
-        ninja_binary = $$shell_quote($$shell_path($$ninjaPath()))
-    }
-
     gn_args = $$shell_quote($$gn_args)
     gn_src_root = $$shell_quote($$shell_path($$QTWEBENGINE_ROOT/$$getChromiumSrcDir()))
     gn_build_root = $$shell_quote($$shell_path($$OUT_PWD/$$getConfigDir()))
     rungn.commands = $$runGn($$gn_binary gen $$gn_build_root --args=$$gn_args --root=$$gn_src_root)
     QMAKE_EXTRA_TARGETS += rungn
 
-    runninja.commands = $$ninja_binary \$\(NINJAFLAGS\) -C $$shell_quote($$OUT_PWD/$$getConfigDir()) QtWebEngineCore
+    runninja.commands = $$NINJA \$\(NINJAFLAGS\) -C $$shell_quote($$OUT_PWD/$$getConfigDir()) QtWebEngineCore
     runninja.depends += rungn
     QMAKE_EXTRA_TARGETS += runninja
 
-- 
GitLab