summaryrefslogtreecommitdiffstats
path: root/mkspecs/features/functions.prf
blob: 3b9a400b1204f96dfa40305096dc66f0a6e79f9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
defineReplace(getConfigDir) {
  CONFIG(release, debug|release):return("release")
  return("debug")
}

defineReplace(getChromiumSrcDir) {
  exists($$QTWEBENGINE_ROOT/.git): git_chromium_src_dir = $$system("git config qtwebengine.chromiumsrcdir")
  # Fall back to the snapshot path if git does not know about chromium sources (i.e. init-repository.py has not been used)
  isEmpty(git_chromium_src_dir): git_chromium_src_dir = "src/3rdparty/chromium"
  return($$git_chromium_src_dir)
}

defineReplace(extractCFlag) {
    CFLAGS = $$QMAKE_CC $$QMAKE_CFLAGS
    OPTION = $$find(CFLAGS, $$1)
    OPTION = $$split(OPTION, =)
    return ($$member(OPTION, 1))
}

defineReplace(which) {
  out = $$1
  win32 {
    command = $$split(out, " ")
    executable = $$first(command)
    # Return the first match only
    out = $$system("((for /f \"usebackq delims=\" %i in (`where $$executable 2^> NUL`) do @if not defined _endwhich (@echo %i & set _endwhich=true)) & set _endwhich=)")
    isEmpty(out) {
      message($$executable not found)
      out = $$executable
    }
    for(arg, command): !equals(arg, $$executable): out += $$arg
  } else:unix {
    command = $$split(out, " ")
    executable = $$first(command)
    out = $$system("which $$executable 2>/dev/null")
    isEmpty(out) {
      message($$executable not found)
      out = $$executable
    }
    for(arg, command): !equals(arg, $$executable): out += $$arg
  }
  return($$out)
}

# Returns the unquoted path to the python executable.
defineReplace(pythonPath) {
    isEmpty(QMAKE_PYTHON2) {
        # Fallback for building QtWebEngine with Qt < 5.8
        QMAKE_PYTHON2 = python
    }
    return($$QMAKE_PYTHON2)
}

# Returns the python executable for use with shell / make targets.
defineReplace(pythonPathForShell) {
    return($$shell_quote($$shell_path($$pythonPath())))
}

# Returns the python executable for use with $$system()
defineReplace(pythonPathForSystem) {
    return($$system_quote($$system_path($$pythonPath())))
}

defineReplace(ninjaPath) {
    src_3rd_party_dir = $$absolute_path("$${getChromiumSrcDir()}/../", "$$QTWEBENGINE_ROOT")
    out = $$shadowed($$absolute_path(ninja/ninja, $$src_3rd_party_dir))
    win32: out = $${out}.exe
    return($$out)
}

defineReplace(gnPath) {
    src_3rd_party_dir = $$absolute_path("$${getChromiumSrcDir()}/../", "$$QTWEBENGINE_ROOT")
    out = $$shadowed($$absolute_path(chromium/tools/gn/out/Release/gn, $$src_3rd_party_dir))

    win32: out = $${out}.exe
    return($$out)
}

defineReplace(gnArgs) {
    linux {
        qtConfig(webengine-embedded-build): include($$QTWEBENGINE_ROOT/src/core/config/embedded_linux.pri)
        else: include($$QTWEBENGINE_ROOT/src/core/config/desktop_linux.pri)
    }
    macos: include($$QTWEBENGINE_ROOT/src/core/config/mac_osx.pri)
    win32: include($$QTWEBENGINE_ROOT/src/core/config/windows.pri)
    isEmpty(gn_args): error(No gn_args found please make sure you have valid configuration.)
    return($$gn_args)
}

defineReplace(gnArch) {
    qtArch = $$1
    contains(qtArch, "i386"): return(x86)
    contains(qtArch, "x86_64"): return(x64)
    contains(qtArch, "arm"): return(arm)
    contains(qtArch, "arm64"): return(arm64)
    contains(qtArch, "mips"): return(mipsel)
    contains(qtArch, "mips64"): return(mips64el)
    return(unknown)
}

defineReplace(gnOS) {
    macos: return(mac)
    win32: return(win)
    linux: return(linux)
    error(Unsupported platform)
    return(unknown)
}

defineTest(isDeveloperBuild) {
    qtConfig(private_tests): return(true) # enabled for developer-build
    return(false)
}

defineTest(skipBuild) {
    skipBuildReason = "$$skipBuildReason $${EOL}$$1"
    export(skipBuildReason)
}