<commit_before>#! /bin/bash
. ./etc/set_traps.sh

INSTALL_DIR=/usr/local/IncludeOS/
export BUILD_DIR=$HOME/IncludeOS_build

export PREFIX=$INSTALL_DIR
export TARGET=i686-elf
export PATH="$PREFIX/bin:$PATH"
export build_dir=$HOME/cross-dev

# Multitask-parameter to make
export num_jobs=-j6

export binutils_version=2.25
export gcc_version=5.1.0
export newlib_version=2.2.0-1

export IncludeOS_src=`pwd`
export newlib_inc=$INSTALL_DIR/i686-elf/include
export llvm_src=llvm
export llvm_build=llvm_build
export clang_version=3.6

if [ ! -v do_newlib ]; then
    do_newlib=1
fi

if [ ! -v do_gcc ]; then
    do_gcc=1
fi


if [ ! -v do_includeos ]; then
    do_includeos=1
fi

# TODO: These should be determined by inspecting if local llvm repo is up-to-date
if [ ! -v install_llvm_dependencies ]; then
    export install_llvm_dependencies=1
fi

if [ ! -v download_llvm ]; then
    export download_llvm=1
fi



# TODO: Implement checks to see which steps can be skipped!


# BUILDING IncludeOS
PREREQS_BUILD="gcc g++ build-essential make nasm texinfo"

echo -e "\n\n >>> Trying to install prerequisites for *building* IncludeOS"
echo -e  "        Packages: $PREREQS_BUILD \n"
sudo apt-get install -y $PREREQS_BUILD

echo -e "\n\n >>> Trying to install Clang (it's a separate step to avoid dependency issues)"
sudo apt-get install -y clang-$clang_version clang++-$clang_version

#
# DEPRECATED: We're building with clang now. Keeping it until we've removed libgcc dependencies
#
# Get and build the actual toolchain
if [ ! -z $do_gcc ]; then
    echo -e "\n\n >>> GETTING / BUILDING CROSS COMPILER \n"
    ./etc/cross_compiler.sh
fi

mkdir -p $BUILD_DIR
cd $BUILD_DIR

if [ ! -z $do_newlib ]; then
    echo -e "\n\n >>> GETTING / BUILDING NEWLIB \n"
    $IncludeOS_src/etc/build_newlib.sh
fi


echo -e "\n\n >>> GETTING / BUILDING llvm / libc++ \n"
$IncludeOS_src/etc/build_llvm32.sh

echo -e "\n\n >>> INSTALLING libc++ \n"
sudo cp $BUILD_DIR/$llvm_build/lib/libc++.a $INSTALL_DIR/lib/


if [ ! -z $do_includeos ]; then
    # Build and install the vmbuilder 
    echo -e "\n >>> Installing vmbuilder"
    pushd $IncludeOS_src/vmbuild
    make 
    sudo cp vmbuild $INSTALL_DIR/
    popd
    
    echo -e "\n >>> Building IncludeOS"
    pushd $IncludeOS_src/src
    make $num_jobs
    
    echo -e "\n >>> Installing IncludeOS"
    sudo make install
    
    echo -e "\n >>> Linking IncludeOS test-service"
    sudo make $INSTALL_DIR/crt/crti.o
    sudo make $INSTALL_DIR/crt/crtn.o
    make test
    
    popd

    
    
    # RUNNING IncludeOS
    PREREQS_RUN="bridge-utils qemu-kvm"
    echo -e "\n\n >>> Trying to install prerequisites for *running* IncludeOS"
    echo -e   "        Packages: $PREREQS_RUN \n"
    sudo apt-get install -y $PREREQS_RUN
    
    # Set up the IncludeOS network bridge
    echo -e "\n\n >>> Create IncludeOS network bridge "`pwd`"\n"<commit_msg>Added back libgcc<commit_after>#! /bin/bash
. ./etc/set_traps.sh

INSTALL_DIR=IncludeOS_install
export BUILD_DIR=$HOME/IncludeOS_build

export PREFIX=$INSTALL_DIR
export TARGET=i686-elf
export PATH="$PREFIX/bin:$PATH"
export build_dir=$HOME/cross-dev

# Multitask-parameter to make
export num_jobs=-j6

export newlib_version=2.2.0-1

export IncludeOS_src=`pwd`
export newlib_inc=$INSTALL_DIR/i686-elf/include
export llvm_src=llvm
export llvm_build=llvm_build
export clang_version=3.6

# Options to skip steps
[ ! -v do_newlib ] && do_newlib=1
[ ! -v do_includeos ] &&  do_includeos=1
# TODO: These should be determined by inspecting if local llvm repo is up-to-date
[ ! -v install_llvm_dependencies ] &&  export install_llvm_dependencies=1
[ ! -v download_llvm ] && export download_llvm=1



# BUILDING IncludeOS
PREREQS_BUILD="build-essential make nasm texinfo clang-$clang_version clang++-$clang_version"

echo -e "\n\n >>> Trying to install prerequisites for *building* IncludeOS"
echo -e  "        Packages: $PREREQS_BUILD \n"
sudo apt-get install -y $PREREQS_BUILD

mkdir -p $BUILD_DIR
cd $BUILD_DIR

if [ ! -z $do_gcc ]; then
    echo -e "\n\n >>> GETTING / BUILDING GCC COMPILER (Required for libgcc / unwind / crt) \n"
    ./etc/cross_compiler.sh
fi

if [ ! -z $do_newlib ]; then
    echo -e "\n\n >>> GETTING / BUILDING NEWLIB \n"
    $IncludeOS_src/etc/build_newlib.sh
fi

echo -e "\n\n >>> GETTING / BUILDING llvm / libc++ \n"
$IncludeOS_src/etc/build_llvm32.sh

echo -e "\n\n >>> INSTALLING libc++ \n"
sudo cp $BUILD_DIR/$llvm_build/lib/libc++.a $INSTALL_DIR/lib/


if [ ! -z $do_includeos ]; then
    # Build and install the vmbuilder 
    echo -e "\n >>> Installing vmbuilder"
    pushd $IncludeOS_src/vmbuild
    make 
    sudo cp vmbuild $INSTALL_DIR/
    popd
    
    echo -e "\n >>> Building IncludeOS"
    pushd $IncludeOS_src/src
    make $num_jobs
    
    echo -e "\n >>> Installing IncludeOS"
    sudo make install
    
    echo -e "\n >>> Linking IncludeOS test-service"
    sudo make $INSTALL_DIR/crt/crti.o
    sudo make $INSTALL_DIR/crt/crtn.o
    make test
    
    popd
   
    
    # RUNNING IncludeOS
    PREREQS_RUN="bridge-utils qemu-kvm"
    echo -e "\n\n >>> Trying to install prerequisites for *running* IncludeOS"
    echo -e   "        Packages: $PREREQS_RUN \n"
    sudo apt-get install -y $PREREQS_RUN
    
    # Set up the IncludeOS network bridge
    echo -e "\n\n >>> Create IncludeOS network bridge "`pwd`"\n"
{'fraction_non_alphanumeric': 0.11488642763281397, 'fraction_numerical': 0.008447531443589262, 'mean_word_length': 3.2052091554853988, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 72, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3649253', 'n_tokens_mistral': 2052, 'n_tokens_neox': 1918, 'n_words': 540}