<commit_before>#! /usr/bin/env bash

set -o errexit -o nounset -o pipefail -o xtrace

: ${PREFIX:="."}

declare -a SRC
SRC=(htable rng utils pairs store acc rotate query)

CFLAGS="-g -O3 -march=native -pipe -std=gnu11 -D_GNU_SOURCE"
CFLAGS="$CFLAGS -I${PREFIX}/src"

CFLAGS="$CFLAGS -Werror -Wall -Wextra"
CFLAGS="$CFLAGS -Wundef"
CFLAGS="$CFLAGS -Wcast-align"
CFLAGS="$CFLAGS -Wwrite-strings"
CFLAGS="$CFLAGS -Wunreachable-code"
CFLAGS="$CFLAGS -Wformat=2"
CFLAGS="$CFLAGS -Wswitch-enum"
CFLAGS="$CFLAGS -Wswitch-default"
CFLAGS="$CFLAGS -Winit-self"
CFLAGS="$CFLAGS -Wno-strict-aliasing"
CFLAGS="$CFLAGS -fno-strict-aliasing"

OBJ=""
for src in "${SRC[@]}"; do
    gcc -c -o "$src.o" "${PREFIX}/src/$src.c" $CFLAGS
    OBJ="$OBJ $src.o"
done
ar rcs librill.a $OBJ

gcc -o rill_load "${PREFIX}/src/rill_load.c" librill.a $CFLAGS
gcc -o rill_dump "${PREFIX}/src/rill_dump.c" librill.a $CFLAGS
gcc -o rill_query "${PREFIX}/src/rill_query.c" librill.a $CFLAGS
gcc -o rill_historical_dump "${PREFIX}/src/rill_historical_dump.c" librill.a $CFLAGS
gcc -o rill_rotate "${PREFIX}/src/rill_rotate.c" librill.a $CFLAGS

gcc -o test_coder "${PREFIX}/test/coder_test.c" librill.a $CFLAGS && ./test_coder
gcc -o test_indexer "${PREFIX}/test/indexer_test.c" librill.a $CFLAGS && ./test_indexer
gcc -o test_rotate "${PREFIX}/test/rotate_test.c" librill.a $CFLAGS<commit_msg>Add more flexible compile options<commit_after>#! /usr/bin/env bash

set -o errexit -o nounset -o pipefail -o xtrace

: ${PREFIX:="."}

declare -a SRC
SRC=(htable rng utils pairs store acc rotate query)
CC=${OTHERC:-gcc}

CFLAGS="-g -O3 -march=native -pipe -std=gnu11 -D_GNU_SOURCE"
CFLAGS="$CFLAGS -I${PREFIX}/src"

CFLAGS="$CFLAGS -Werror -Wall -Wextra"
CFLAGS="$CFLAGS -Wundef"
CFLAGS="$CFLAGS -Wcast-align"
CFLAGS="$CFLAGS -Wwrite-strings"
CFLAGS="$CFLAGS -Wunreachable-code"
CFLAGS="$CFLAGS -Wformat=2"
CFLAGS="$CFLAGS -Wswitch-enum"
CFLAGS="$CFLAGS -Wswitch-default"
CFLAGS="$CFLAGS -Winit-self"
CFLAGS="$CFLAGS -Wno-strict-aliasing"
CFLAGS="$CFLAGS -fno-strict-aliasing"
CFLAGS="$CFLAGS -Wno-implicit-fallthrough"

OBJ=""
for src in "${SRC[@]}"; do
    $CC -c -o "$src.o" "${PREFIX}/src/$src.c" $CFLAGS
    OBJ="$OBJ $src.o"
done
ar rcs librill.a $OBJ

$CC -o rill_load "${PREFIX}/src/rill_load.c" librill.a $CFLAGS
$CC -o rill_dump "${PREFIX}/src/rill_dump.c" librill.a $CFLAGS
$CC -o rill_query "${PREFIX}/src/rill_query.c" librill.a $CFLAGS
$CC -o rill_historical_dump "${PREFIX}/src/rill_historical_dump.c" librill.a $CFLAGS
$CC -o rill_rotate "${PREFIX}/src/rill_rotate.c" librill.a $CFLAGS

$CC -o test_indexer "${PREFIX}/test/indexer_test.c" librill.a $CFLAGS && ./test_indexer
$CC -o test_coder "${PREFIX}/test/coder_test.c" librill.a $CFLAGS && ./test_coder
$CC -o test_rotate "${PREFIX}/test/rotate_test.c" librill.a $CFLAGS
{'fraction_non_alphanumeric': 0.18279186004998216, 'fraction_numerical': 0.002856122813280971, 'mean_word_length': 4.813278008298755, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6285962', 'n_tokens_mistral': 1177, 'n_tokens_neox': 1121, 'n_words': 256}