summaryrefslogtreecommitdiffstats
path: root/mkspecs/features/functions.prf
blob: b7509d4d0ed762ef4f92ba301316d2782a4ea23b (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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
include($$QTWEBENGINE_ROOT/src/buildtools/config/support.pri)

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(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) {
    isEmpty(QMAKE_NINJA) {
        src_3rd_party_dir = $$absolute_path("$${getChromiumSrcDir()}/../", "$$QTWEBENGINE_ROOT")
        out = $$shadowed($$absolute_path(ninja/ninja, $$src_3rd_party_dir))
        win32: out = $${out}.exe
        QMAKE_NINJA = $$out
    }
    return($$QMAKE_NINJA)
}

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

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

defineReplace(gnWebEngineArgs) {
    linux {
        include($$QTWEBENGINE_ROOT/src/buildtools/config/linux.pri)
        include($$QTWEBENGINE_ROOT/src/core/config/linux.pri)
    }
    macos {
        include($$QTWEBENGINE_ROOT/src/buildtools/config/mac_osx.pri)
        include($$QTWEBENGINE_ROOT/src/core/config/mac_osx.pri)
    }
    win32 {
        include($$QTWEBENGINE_ROOT/src/buildtools/config/windows.pri)
        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(gnPdfArgs) {
    linux: include($$QTWEBENGINE_ROOT/src/buildtools/config/linux.pri)
    macos: include($$QTWEBENGINE_ROOT/src/buildtools/config/mac_osx.pri)
    ios: include($$QTWEBENGINE_ROOT/src/pdf/config/ios.pri)
    win32: include($$QTWEBENGINE_ROOT/src/buildtools/config/windows.pri)
    include($$QTWEBENGINE_ROOT/src/pdf/config/common.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)
}

defineReplace(pkgConfigHostExecutable) {
    wrapper_name = $$OUT_PWD/pkg-config-host_wrapper.sh
    wrapper_cmd = $$QMAKE_PKG_CONFIG_HOST
    isEmpty(wrapper_cmd): wrapper_cmd = pkg-config
    wrapper_content = \
        "$$LITERAL_HASH!/bin/sh" \
        "unset PKG_CONFIG_LIBDIR" \
        "unset PKG_CONFIG_SYSROOT_DIR" \
        "exec $$wrapper_cmd \"$@\""
    !build_pass:!write_file($$wrapper_name, wrapper_content, exe): error()
    QMAKE_DISTCLEAN += $$wrapper_name
    export(QMAKE_DISTCLEAN)
    return($$system_quote($$system_path($$wrapper_name)))
}