pitivi-env 3.07 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 10 11
    && echo "This script should not be executed but sourced like:" \
    && echo "    $ source $0" \
    && echo \
12 13
    && exit 1

14
SCRIPT_DIR=$(dirname $(realpath $SCRIPT))
15
export PITIVI_REPO_DIR=$(realpath $SCRIPT_DIR/..)
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 prefix for the sandbox..."
24
# This builds the local flatpak repo if it is not yet built.
25
ptvenv --init
26 27
if [ "$?" = "0" ];
then
28 29 30
    echo Sandbox ready.

    echo Setting up aliases etc. so configuring, building takes place in the sandbox...
31 32 33 34 35 36 37 38 39 40 41 42

    # 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.
    # The initialization happens above, look for `ptvenv echo`.
    # 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. For example "python3".
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

59
    alias pitivi="ptvenv $PITIVI_REPO_DIR/bin/pitivi"
60

61 62
    # Enter the Python virtual env to have specific dev tools,
    # such as git-phab, pre-commit, etc.
63
    source $PITIVI_REPO_DIR/build/flatpak/pyvenv/bin/activate
64

65
    # Install our pre-commit git hook, for doing clean commits.
66 67 68 69
    rm -f .git/hooks/pre-commit
    ln -s ../../pre-commit.hook .git/hooks/pre-commit

    # Update the prompt to indicate this is the Pitivi dev env.
70
    export PS1="(ptv-flatpak) $PS1"
71 72 73 74 75 76 77

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