aboutsummaryrefslogtreecommitdiffstats
path: root/tests/wpt/web-platform-tests/css/build-css-testsuites.sh
blob: 5cb26179b8dbe4423885bcc7c8d687bab224df91 (plain) (blame)
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
#!/usr/bin/env sh
set -ex

SCRIPT_DIR=$(cd $(dirname "$0") && pwd -P)
WPT_ROOT=$SCRIPT_DIR/..
cd $WPT_ROOT

main() {
    cd $WPT_ROOT/css

    if [ -z $VENV ]; then
        VENV=tools/_virtualenv
    fi

    # Create the virtualenv
    if [ ! -d $VENV ]; then
        if [ -z $PYTHON ]; then
            command -v python
            if [ $? -eq 0 ]; then
                if [ `python -c 'import sys; print(sys.version[0:3])'` == "2.7" ]; then
                    PYTHON=python
                fi
            fi
        fi

        if [ -z $PYTHON ]; then
            command -v python2
            if [ $? -eq 0 ]; then
                PYTHON=python2
            fi
        fi

        if [ -z $PYTHON ]; then
            echo "Please ensure Python 2.7 is installed"
            exit 1
        fi

        # The maximum Unicode code point is U+10FFFF = 1114111
        if [ `$PYTHON -c 'import sys; print(sys.maxunicode)'` != "1114111" ]; then
            echo "UCS-4 support for Python is required"
            exit 1
        fi

        virtualenv -p $PYTHON $VENV || { echo "Please ensure virtualenv is installed"; exit 2; }
    fi

    # Install dependencies
    $VENV/bin/pip install -r requirements.txt

    # Run the build script
    $VENV/bin/python tools/build.py "$@"
}

main "$@"