pitivi-env 2.99 KB
Newer Older
1 2
#!/bin/bash

3 4
# Script which must be sourced to setup the development environment.

5 6 7 8
# This has to be the first command because BASH_SOURCE[0] gets changed.
SCRIPT=${BASH_SOURCE[0]:-$0}

[[ "${BASH_SOURCE[0]}" == "$0" ]] \
9
    && echo "This script should not be executed but sourced like:" \
10
    && echo "    $ . $0" \
11
    && echo \
12 13
    && exit 1

dg1727's avatar
dg1727 committed
14
SCRIPT_DIR=$(dirname $(realpath $SCRIPT))
15
export PITIVI_REPO_DIR=$(realpath $SCRIPT_DIR/..)
dg1727's avatar
dg1727 committed
16
export FLATPAK_ENVPATH=$(realpath $PITIVI_REPO_DIR/..)
17
export CURRENT_GST=$FLATPAK_ENVPATH
18
export PATH="$FLATPAK_ENVPATH/bin/:$PATH"
19

20
# Use ptvenv for entering or running commands in the sandbox.
21
alias ptvenv="$PITIVI_REPO_DIR/build/flatpak/pitivi-flatpak"
22

23
echo "Setting up the build dir of the sandbox in $FLATPAK_ENVPATH/pitivi-prefix"
24
ptvenv --init
25

26
if [ "$?" = "0" ]
27
then
28
    echo "Sandbox ready."
29

30
    echo "Setting up aliases so configuring, building takes place in the sandbox..."
31 32 33 34 35 36 37

    # Meson sets up the build directory where ninja works.
    # Consider using `setup` instead of `meson`, see below.
    alias meson="ptvenv meson"

    # Normally, Pitivi's mesonbuild/ directory is created when
    # initializing or updating (recreating) the Flatpak sandbox.
38
    # The initialization happens above, look for `ptvenv --init`.
39 40 41 42
    # The updating happens when you run `ptvenv --update`.
    # You can also create it manually if you deleted it by mistake.
    # This should also be used when building dependent projects
    # such as GES, etc.
43
    alias setup="mkdir mesonbuild; ptvenv meson mesonbuild/ --prefix=/app --libdir=lib -Ddisable_gtkdoc=true -Ddisable_doc=true"
44 45 46 47 48

    # Ninja builds the buildable parts of the project.
    alias ninja="ptvenv ninja"

    # We could get rid of these, but some devs like them.
49 50
    alias build="ptvenv ninja -C mesonbuild/"
    alias binstall="ptvenv ninja -C mesonbuild/ install"
51
    alias ptvtests="ptvenv gst-validate-launcher $PITIVI_REPO_DIR/tests/ptv_testsuite.py"
52

53
    # Prefer to run some binaries in the sandbox.
54
    for i in `$PITIVI_REPO_DIR/build/flatpak/pitivi-flatpak -q ls /app/bin/`
55
    do
56
        alias $i="ptvenv $i"
57 58
    done

dg1727's avatar
dg1727 committed
59
    alias pitivi="ptvenv $PITIVI_REPO_DIR/bin/pitivi"
60

61
    echo "Installing our pre-commit git hook, for doing clean commits..."
62 63 64
    rm -f .git/hooks/pre-commit
    ln -s ../../pre-commit.hook .git/hooks/pre-commit

65 66 67 68 69 70 71
    # Update the prompt to indicate this is the Pitivi dev env,
    # unless PS1 has already been modified.
    PS1_PREFIX="(ptv-flatpak)"
    if [[ $PS1 != *"$PS1_PREFIX"* ]]
    then
        export PS1="$PS1_PREFIX $PS1"
    fi
72 73 74 75 76 77 78

    echo "===================================================================="
    echo "                   BATTLECRUISER OPERATIONAL                        "
    echo "                          >(°)__/                                   "
    echo "                           (_~_/                                    "
    echo "                         ~~~~~~~~~~~~                               "
    echo "===================================================================="
79
fi