summaryrefslogtreecommitdiffstats
path: root/bin/qt-configure-module.in
blob: 690fc0147826a80bc997cd77abec779e4922a05c (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
#!/bin/sh
set -eu

script_dir_path=`dirname $0`
script_dir_path=`(cd "$script_dir_path"; pwd)`

# the current directory is the "build tree" or "object tree"
outpath=`pwd`
outpathPrefix=$outpath

SAVED_IFS=$IFS
IFS='
'

optfile=""
determineOptFilePath()
{
> "${outpathPrefix}/config.redo.in"
set -f  # suppress globbing in for loop
for i in "$@"; do
    if [ x"$i" = x"-top-level" ]; then
        continue
    fi
    case $i in
        -redo|--redo)
            optfile=${outpathPrefix}/config.opt
            if ! test -f "$optfile"; then
                echo >&2 "No config.opt present - cannot redo configuration."
                exit 1
            fi
            ;;
        *)
            # If redo-ing, write the rest of parameters into the config.redo.in file
            echo \"$i\" >> "${outpathPrefix}/config.redo.in"
            ;;
    esac
done
}

printUsage()
{
    cat <<EOF
Usage: qt-configure-module <module-source-dir> [options]

To display the available options for a Qt module, run
qt-configure-module <module-source-dir> -help
EOF
}

if [ "$#" -lt 1 ]; then
    printUsage
    exit 1
fi
module_root=$1
# This ensures the repo path does not end up in the config.opt file.
shift

if [ ! -f "$module_root/CMakeLists.txt" ]; then
    echo >&2 "Error: $module_root is not a valid Qt module source directory."
    printUsage
    exit 1
fi

determineOptFilePath "$@"

optfilepath=${outpathPrefix}/config.opt
opttmpfilepath=${outpathPrefix}/config.opt.in

redofilepath=${outpathPrefix}/config.redo.last
redotmpfilepath=${outpathPrefix}/config.redo.in

qt_cmake_private_path="$script_dir_path/../@INSTALL_LIBEXECDIR@"

fresh_requested_arg=
if [ -z "$optfile" ]; then   # only write optfile if not currently redoing
    > "$opttmpfilepath"
    > "$redotmpfilepath"

    for arg in "$@"; do echo \"$arg\" >> "$opttmpfilepath"; done

    "$qt_cmake_private_path/qt-cmake-private" -DIN_FILE="${opttmpfilepath}" \
        -DOUT_FILE="${optfilepath}" \
        -P "$script_dir_path/@__relative_path_to_cmake_scripts_dir@/QtWriteArgsFile.cmake"
else
    # Rewriting config.opt into config.opt.in anyway. Allows for direct manipulation of config.opt
    > "$opttmpfilepath"
    for arg in `cat $optfile`; do echo \"$arg\" >> "$opttmpfilepath"; done

    "$qt_cmake_private_path/qt-cmake-private" -DIN_FILE="${opttmpfilepath}" \
        -DREDO_FILE="${redotmpfilepath}" -DOUT_FILE="${redofilepath}" \
        -P "$script_dir_path/@__relative_path_to_cmake_scripts_dir@/QtWriteArgsFile.cmake"
    optfilepath=${redofilepath}
    fresh_requested_arg=-DFRESH_REQUESTED=TRUE
fi

cmake_script_path="$script_dir_path/@__relative_path_to_cmake_scripts_dir@/QtProcessConfigureArgs.cmake"
"$qt_cmake_private_path/qt-cmake-private" -DOPTFILE=$optfilepath -DMODULE_ROOT="$module_root" \
    -DCMAKE_COMMAND="$qt_cmake_private_path/qt-cmake-private" -P "$cmake_script_path"

IFS=$SAVED_IFS