<commit_before>#!/bin/bash

echo "****  Pulse Build  ****"
echo

SOURCEDIR=$1
SPLUGINFOLDER=$2
SPLUGIN=$3
BUILDDIR=$SOURCEDIR/build
PLUGINDIR=plugin
BINDIR=$BUILDDIR/bin
COLLECTORDIR=$BUILDDIR/$PLUGINDIR/collector
PUBLISHERDIR=$BUILDDIR/$PLUGINDIR/publisher
PROCESSORDIR=$BUILDDIR/$PLUGINDIR/processor

# Clean build bin dir
rm -rf $BINDIR/*

# Make dir
mkdir -p $BINDIR
mkdir -p $COLLECTORDIR
mkdir -p $PUBLISHERDIR
mkdir -p $PROCESSORDIR

# Binaries
#
echo "Source Dir = $SOURCEDIR"
echo "$SPLUGIN"
echo "$SPLUGINFOLDER"
echo " Building Pulse Agent"	
go build -ldflags "-X main.gitversion `git describe --always`" -o $BINDIR/pulse-agent . || exit 1

if [ "$SPLUGIN" ] && [ -n "$SPLUGINFOLDER" ]
then
	echo " Building Plugin: $SPLUGIN"
	# Built-in single plugin building
	cd $SOURCEDIR/plugin/$SPLUGINFOLDER/
	target=./$SPLUGIN/
	destination=$BUILDDIR/$PLUGINDIR/$SPLUGINFOLDER/$SPLUGIN
	echo "    $SPLUGIN => $destination"	
	go build -o $destination $target || exit 2
	cd $SOURCEDIR
else
	# Clean build
	rm -rf $COLLECTORDIR/*
	echo " Building Collector Plugin(s)"
	# Built-in Collector Plugin building
	cd $SOURCEDIR/$PLUGINDIR/collector
	for d in *; do
		if [[ -d $d ]]; then
			echo "    $d => $COLLECTORDIR/$d"		
			go build -o $COLLECTORDIR/$d ./$d/ || exit 2
			# chmod -x ../../$COLLECTORDIR/$d / for testing non-executable builds
		fi
	done
	
	# Publisher build
	rm -rf $PUBLISHERDIR/*
	echo " Building Publisher Plugin(s)"
	cd $SOURCEDIR/$PLUGINDIR/publisher
	for d in *; do
		if [[ -d $d ]]; then
			echo "    $d => $PUBLISHERDIR/$d"		
			go build -o $PUBLISHERDIR/$d ./$d/ || exit 2
			# chmod -x ../../$PUBLISHERDIR/$d / for testing non-executable builds
		fi
	done
	
	# Processor build
	rm -rf $PROCESSORDIR/*
	echo " Building Processor Plugin(s)"
	cd $SOURCEDIR/$PLUGINDIR/processor
	for d in *; do
		if [[ -d $d ]]; then
			echo "    $d => $PROCESSORDIR/$d"		
			go build -o $PROCESSORDIR/$d ./$d/ || exit 2
			# chmod -x ../../$PROCESSORDIR/$d / for testing non-executable builds
		fi
	done

	cd $SOURCEDIR

	# Built-in Publisher Plugin building
fi



echo
echo "*******************"<commit_msg>Smaller binaries * Disables CGO and some other things<commit_after>#!/bin/bash

GITVERSION=`git describe --always`
SOURCEDIR=$1
SPLUGINFOLDER=$2
SPLUGIN=$3
BUILDDIR=$SOURCEDIR/build
PLUGINDIR=plugin
BINDIR=$BUILDDIR/bin
COLLECTORDIR=$BUILDDIR/$PLUGINDIR/collector
PUBLISHERDIR=$BUILDDIR/$PLUGINDIR/publisher
PROCESSORDIR=$BUILDDIR/$PLUGINDIR/processor
BUILDCMD='go build -a -ldflags "-w"'

echo
echo "****  Pulse Build ($GITVERSION)  ****"
echo

# Disable CGO for builds
export CGO_ENABLED=0

# Clean build bin dir
rm -rf $BINDIR/*

# Make dir
mkdir -p $BINDIR
mkdir -p $COLLECTORDIR
mkdir -p $PUBLISHERDIR
mkdir -p $PROCESSORDIR

# Binaries
#
echo "Source Dir = $SOURCEDIR"
echo " Building Pulse Agent"	
go build -ldflags "-w -X main.gitversion $GITVERSION" -o $BINDIR/pulse-agent . || exit 1

if [ "$SPLUGIN" ] && [ -n "$SPLUGINFOLDER" ]
then
	echo " Building Plugin: $SPLUGIN"
	# Built-in single plugin building
	cd $SOURCEDIR/plugin/$SPLUGINFOLDER/
	target=./$SPLUGIN/
	destination=$BUILDDIR/$PLUGINDIR/$SPLUGINFOLDER/$SPLUGIN
	echo "    $SPLUGIN => $destination"	
	$BUILDCMD -o $destination $target || exit 2
	cd $SOURCEDIR
else
	# Clean build
	rm -rf $COLLECTORDIR/*
	echo " Building Collector Plugin(s)"
	# Built-in Collector Plugin building
	cd $SOURCEDIR/$PLUGINDIR/collector
	for d in *; do
		if [[ -d $d ]]; then
			echo "    $d => $COLLECTORDIR/$d"		
			$BUILDCMD -o $COLLECTORDIR/$d ./$d/ || exit 2
		fi
	done
	
	# Publisher build
	rm -rf $PUBLISHERDIR/*
	echo " Building Publisher Plugin(s)"
	cd $SOURCEDIR/$PLUGINDIR/publisher
	for d in *; do
		if [[ -d $d ]]; then
			echo "    $d => $PUBLISHERDIR/$d"		
			$BUILDCMD -o $PUBLISHERDIR/$d ./$d/ || exit 2
		fi
	done
	
	# Processor build
	rm -rf $PROCESSORDIR/*
	echo " Building Processor Plugin(s)"
	cd $SOURCEDIR/$PLUGINDIR/processor
	for d in *; do
		if [[ -d $d ]]; then
			echo "    $d => $PROCESSORDIR/$d"		
			$BUILDCMD -o $PROCESSORDIR/$d ./$d/ || exit 2			
		fi
	done

	cd $SOURCEDIR
fi

echo
echo "*******************"
{'fraction_non_alphanumeric': 0.15107212475633527, 'fraction_numerical': 0.004142300194931774, 'mean_word_length': 3.556048834628191, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '2528165', 'n_tokens_mistral': 1765, 'n_tokens_neox': 1653, 'n_words': 423}