<commit_before>#!/bin/bash

for OPTION in $@
do
    case $OPTION in
    linux)
        if [[ ! -z "$OS" ]]; then echo "OS cannot be set twice"; exit 1; fi
        OS=linux
    ;;

    mingw64)
        if [[ ! -z "$OS" ]]; then echo "OS cannot be set twice"; exit 1; fi
        OS=mingw64
    ;;

    osx)
        if [[ ! -z "$OS" ]]; then echo "OS cannot be set twice"; exit 1; fi
        OS=osx
    ;;

    debug)
        if [[ ! -z "$BUILD_TYPE" ]]; then echo "Build type cannot be set twice"; exit 2; fi
        BUILD_TYPE=debug
        OPTIONS="DEBUG=1 $OPTIONS"
    ;;

    release)
        if [[ ! -z "$BUILD_TYPE" ]]; then echo "Build type cannot be set twice"; exit 2; fi
        BUILD_TYPE=release
    ;;

    *)
        OPTIONS="$OPTIONS $OPTION"
    esac
done


# Set target platform parameters
case $OS in
linux)
;;

mingw64)
    if [[ -z "$QMAKE_PATH" ]]; then QMAKE_PATH="/usr/x86_64-w64-mingw32/host/bin/"; fi
    SPEC="-spec win32-g++"
;;

osx)
;;

*)
    echo "You must specify between linux, mingw64, and osx."
    exit
esac

# Use release as default build type
if [[ -z "$BUILD_TYPE" ]]
then
    BUILD_TYPE=release
fi

if [[ -z $(git diff --shortstat) ]]
then
    COMMIT_HASH=$(git rev-parse HEAD)
else
    COMMIT_HASH="N/A"
fi

echo "Building using commit hash $COMMIT_HASH..."
echo "#pragma once" > BuildInfo.h.tmp
echo "#define COMMIT_HASH \"$COMMIT_HASH\"" >> BuildInfo.h.tmp

if [[ ! -f BuildInfo.h ]]
then
    touch BuildInfo.h
fi

if [[ -z $(diff BuildInfo.h BuildInfo.h.tmp) ]]
then
    rm BuildInfo.h.tmp
else
    mv BuildInfo.h.tmp BuildInfo.h
fi

CURRENT_DIR=$(pwd)

set -x
set -e

cd deps/logger
make OS=$OS $OPTIONS
SYSROOT=../../sysroot make install

cd ../Signals
SYSROOT=../../sysroot make install

cd ../stdutils
SYSROOT=../../sysroot make install

cd ../CoinCore
make OS=$OS $OPTIONS
SYSROOT=../../sysroot make install

cd ../CoinQ
make OS=$OS $OPTIONS
SYSROOT=../../sysroot make install

cd ../CoinDB
make lib OS=$OS $OPTIONS
SYSROOT=../../sysroot make install_lib

cd $CURRENT_DIR
${QMAKE_PATH}qmake $SPEC CONFIG+=$BUILD_TYPE && make $OPTIONS

if [[ "$OS" == "osx" ]]
then
    if [[ -e build/$BUILD_TYPE/CoinVault.app/Contents/Resources/qt.conf ]]
    then
        rm build/$BUILD_TYPE/CoinVault.app/Contents/Resources/qt.conf
    fi
    ${MACDEPLOYQT_PATH}macdeployqt $(find ./build/$BUILD_TYPE -name *.app)
fi<commit_msg>build-all.sh script automatically detects target and has tools_only option<commit_after>#!/bin/bash

for OPTION in $@
do
    case $OPTION in
    linux)
        if [[ ! -z "$OS" ]]; then echo "OS cannot be set twice"; exit 1; fi
        OS=linux
    ;;

    mingw64)
        if [[ ! -z "$OS" ]]; then echo "OS cannot be set twice"; exit 1; fi
        OS=mingw64
    ;;

    osx)
        if [[ ! -z "$OS" ]]; then echo "OS cannot be set twice"; exit 1; fi
        OS=osx
    ;;

    debug)
        if [[ ! -z "$BUILD_TYPE" ]]; then echo "Build type cannot be set twice"; exit 2; fi
        BUILD_TYPE=debug
        OPTIONS="DEBUG=1 $OPTIONS"
    ;;

    release)
        if [[ ! -z "$BUILD_TYPE" ]]; then echo "Build type cannot be set twice"; exit 2; fi
        BUILD_TYPE=release
    ;;

    tools_only)
        tools_only=true
    ;;

    *)
        OPTIONS="$OPTIONS $OPTION"
    esac
done

if [[ -z "$OS" ]]
then
    UNAME_S=$(uname -s)
    if [[ "$UNAME_S" == "Linux" ]]
    then
        OS=linux
    elif [[ "$UNAME_S" == "Darwin" ]]
    then
        OS=osx
    fi
fi

# Set target platform parameters
case $OS in
linux)
;;

mingw64)
    if [[ -z "$QMAKE_PATH" ]]; then QMAKE_PATH="/usr/x86_64-w64-mingw32/host/bin/"; fi
    SPEC="-spec win32-g++"
;;

osx)
;;

*)
    echo "You must specify between linux, mingw64, and osx."
    exit
esac

# Use release as default build type
if [[ -z "$BUILD_TYPE" ]]
then
    BUILD_TYPE=release
fi

if [[ -z $(git diff --shortstat) ]]
then
    COMMIT_HASH=$(git rev-parse HEAD)
else
    COMMIT_HASH="N/A"
fi

echo "Building using commit hash $COMMIT_HASH..."
echo "#pragma once" > BuildInfo.h.tmp
echo "#define COMMIT_HASH \"$COMMIT_HASH\"" >> BuildInfo.h.tmp

if [[ ! -f BuildInfo.h ]]
then
    touch BuildInfo.h
fi

if [[ -z $(diff BuildInfo.h BuildInfo.h.tmp) ]]
then
    rm BuildInfo.h.tmp
else
    mv BuildInfo.h.tmp BuildInfo.h
fi

CURRENT_DIR=$(pwd)

set -x
set -e

cd deps/logger
make OS=$OS $OPTIONS
SYSROOT=../../sysroot make install

cd ../Signals
SYSROOT=../../sysroot make install

cd ../stdutils
SYSROOT=../../sysroot make install

cd ../CoinCore
make OS=$OS $OPTIONS
SYSROOT=../../sysroot make install

cd ../CoinQ
make OS=$OS $OPTIONS
SYSROOT=../../sysroot make install

cd ../CoinDB
make lib OS=$OS $OPTIONS
SYSROOT=../../sysroot make install_lib

if [ $tools_only ]
then
    make tools OS=$OS $OPTIONS
    set +x
    echo
    echo "All dependencies built."
    echo
    echo "To install coindb, run the following commands:"
    echo "  $ cd deps/CoinDB"
    echo "  $ sudo make install_tools"
    echo
    exit
fi

cd $CURRENT_DIR
${QMAKE_PATH}qmake $SPEC CONFIG+=$BUILD_TYPE && make $OPTIONS

if [[ "$OS" == "osx" ]]
then
    if [[ -e build/$BUILD_TYPE/CoinVault.app/Contents/Resources/qt.conf ]]
    then
        rm build/$BUILD_TYPE/CoinVault.app/Contents/Resources/qt.conf
    fi
    ${MACDEPLOYQT_PATH}macdeployqt $(find ./build/$BUILD_TYPE -name *.app)
fi
{'fraction_non_alphanumeric': 0.1507290285930695, 'fraction_numerical': 0.009089187653853437, 'mean_word_length': 2.5425888665325287, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '287618', 'n_tokens_mistral': 2019, 'n_tokens_neox': 1909, 'n_words': 572}