<commit_before># Assumed to run from tinyara/os directory
# TODO:
#   1. Get the code from the git repo
#   2. Patch the code using the additional changes
#   3. Build the code with the necessary flags

set -x

extract_flags() {
	if [ -e ${TOPDIR}/include/tinyara/config.h ]; then
		echo `cat ${TOPDIR}/include/tinyara/config.h | grep -w "$1"  | cut -d " " -f 3`
	fi
}

export IOTIVITY_BASE="${TOPDIR}/../external/iotivity"
CONFIG_IOTIVITY_RELEASE_VERSION='1.2-rel'
IOTIVITY_RELEASE_VERSION=$(echo "$CONFIG_IOTIVITY_RELEASE_VERSION" | sed 's/"//g')
export TINYARA_BUILD_DIR="${TOPDIR}"
export IOTIVITY_BUILD_DIR="${IOTIVITY_BASE}/iotivity_${IOTIVITY_RELEASE_VERSION}"
export IOTIVITY_PATCH_DIR="${IOTIVITY_BASE}/patches/${IOTIVITY_RELEASE_VERSION}"

#if [ ! -d ${IOTIVITY_BUILD_DIR} ]; then
#	git clone https://gerrit.iotivity.org/gerrit/iotivity ${IOTIVITY_BUILD_DIR}
#fi

#if [ ! -d ${IOTIVITY_BUILD_DIR}/extlibs/tinycbor/tinycbor ]; then
#	git clone https://github.com/01org/tinycbor.git ${IOTIVITY_BUILD_DIR}/extlibs/tinycbor/tinycbor
#fi

if [ ! -d ${IOTIVITY_BUILD_DIR}/extlibs/mbedtls/mbedtls ]; then
	mkdir -p ${IOTIVITY_BUILD_DIR}/extlibs/mbedtls/mbedtls/include
	ln -s ${TINYARA_BUILD_DIR}/include/tls ${IOTIVITY_BUILD_DIR}/extlibs/mbedtls/mbedtls/include/mbedtls
fi

#if [ ! -f ${IOTIVITY_BUILD_DIR}/tinyara_patch.lock ]; then
#	cd ${IOTIVITY_BUILD_DIR}
#	touch ${IOTIVITY_BUILD_DIR}/tinyara_patch.lock
#	git checkout ${IOTIVITY_RELEASE_VERSION}

	#Apply the Patch
#	git am ${IOTIVITY_PATCH_DIR}/0001-tinyara-iotivity-${IOTIVITY_RELEASE_VERSION}.patch

	cd ${TINYARA_BUILD_DIR}
#fi

# Set build parameters
CONFIG_ENABLE_IOTIVITY=`extract_flags "CONFIG_ENABLE_IOTIVITY"`
if [ -z ${CONFIG_ENABLE_IOTIVITY} ]; then CONFIG_ENABLE_IOTIVITY=0; fi

CONFIG_IOTIVITY_RELEASE=`extract_flags "CONFIG_IOTIVITY_RELEASE"`
if [ -z ${CONFIG_IOTIVITY_RELEASE} ]; then CONFIG_IOTIVITY_RELEASE=0; fi

CONFIG_IOTIVITY_LOGGING=`extract_flags "CONFIG_IOTIVITY_LOGGING"`
if [ -z ${CONFIG_IOTIVITY_LOGGING} ]; then CONFIG_IOTIVITY_LOGGING=0; fi

CONFIG_ENABLE_IOTIVITY_SECURED=`extract_flags "CONFIG_ENABLE_IOTIVITY_SECURED"`
if [ -z ${CONFIG_ENABLE_IOTIVITY_SECURED} ]; then CONFIG_ENABLE_IOTIVITY_SECURED=0; fi

CONFIG_ENABLE_IOTIVITY_CLOUD=`extract_flags "CONFIG_ENABLE_IOTIVITY_CLOUD"`
if [ -z ${CONFIG_ENABLE_IOTIVITY_CLOUD} ]; then CONFIG_ENABLE_IOTIVITY_CLOUD=0; fi

CONFIG_EXAMPLES_IOTIVITY=`extract_flags "CONFIG_EXAMPLES_IOTIVITY"`
if [ -z ${CONFIG_EXAMPLES_IOTIVITY} ]; then CONFIG_EXAMPLES_IOTIVITY=0; fi<commit_msg>Fix wrong path in build_iotivity.sh<commit_after># Assumed to run from tinyara/os directory
# TODO:
#   1. Get the code from the git repo
#   2. Patch the code using the additional changes
#   3. Build the code with the necessary flags

set -x

extract_flags() {
	if [ -e ${TOPDIR}/include/tinyara/config.h ]; then
		echo `cat ${TOPDIR}/include/tinyara/config.h | grep -w "$1"  | cut -d " " -f 3`
	fi
}

export IOTIVITY_BASE="${TOPDIR}/../external/iotivity"
CONFIG_IOTIVITY_RELEASE_VERSION='1.2-rel'
IOTIVITY_RELEASE_VERSION=$(echo "$CONFIG_IOTIVITY_RELEASE_VERSION" | sed 's/"//g')
export TINYARA_BUILD_DIR="${TOPDIR}"
export IOTIVITY_BUILD_DIR="${IOTIVITY_BASE}/iotivity_${IOTIVITY_RELEASE_VERSION}"
export IOTIVITY_PATCH_DIR="${IOTIVITY_BASE}/patches/${IOTIVITY_RELEASE_VERSION}"

#if [ ! -d ${IOTIVITY_BUILD_DIR} ]; then
#	git clone https://gerrit.iotivity.org/gerrit/iotivity ${IOTIVITY_BUILD_DIR}
#fi

#if [ ! -d ${IOTIVITY_BUILD_DIR}/extlibs/tinycbor/tinycbor ]; then
#	git clone https://github.com/01org/tinycbor.git ${IOTIVITY_BUILD_DIR}/extlibs/tinycbor/tinycbor
#fi

if [ ! -d ${IOTIVITY_BUILD_DIR}/extlibs/mbedtls/mbedtls ]; then
	mkdir -p ${IOTIVITY_BUILD_DIR}/extlibs/mbedtls/mbedtls/include
	ln -s ${TINYARA_BUILD_DIR}/../external/include/mbedtls ${IOTIVITY_BUILD_DIR}/extlibs/mbedtls/mbedtls/include/mbedtls
fi

#if [ ! -f ${IOTIVITY_BUILD_DIR}/tinyara_patch.lock ]; then
#	cd ${IOTIVITY_BUILD_DIR}
#	touch ${IOTIVITY_BUILD_DIR}/tinyara_patch.lock
#	git checkout ${IOTIVITY_RELEASE_VERSION}

	#Apply the Patch
#	git am ${IOTIVITY_PATCH_DIR}/0001-tinyara-iotivity-${IOTIVITY_RELEASE_VERSION}.patch

	cd ${TINYARA_BUILD_DIR}
#fi

# Set build parameters
CONFIG_ENABLE_IOTIVITY=`extract_flags "CONFIG_ENABLE_IOTIVITY"`
if [ -z ${CONFIG_ENABLE_IOTIVITY} ]; then CONFIG_ENABLE_IOTIVITY=0; fi

CONFIG_IOTIVITY_RELEASE=`extract_flags "CONFIG_IOTIVITY_RELEASE"`
if [ -z ${CONFIG_IOTIVITY_RELEASE} ]; then CONFIG_IOTIVITY_RELEASE=0; fi

CONFIG_IOTIVITY_LOGGING=`extract_flags "CONFIG_IOTIVITY_LOGGING"`
if [ -z ${CONFIG_IOTIVITY_LOGGING} ]; then CONFIG_IOTIVITY_LOGGING=0; fi

CONFIG_ENABLE_IOTIVITY_SECURED=`extract_flags "CONFIG_ENABLE_IOTIVITY_SECURED"`
if [ -z ${CONFIG_ENABLE_IOTIVITY_SECURED} ]; then CONFIG_ENABLE_IOTIVITY_SECURED=0; fi

CONFIG_ENABLE_IOTIVITY_CLOUD=`extract_flags "CONFIG_ENABLE_IOTIVITY_CLOUD"`
if [ -z ${CONFIG_ENABLE_IOTIVITY_CLOUD} ]; then CONFIG_ENABLE_IOTIVITY_CLOUD=0; fi

CONFIG_EXAMPLES_IOTIVITY=`extract_flags "CONFIG_EXAMPLES_IOTIVITY"`
if [ -z ${CONFIG_EXAMPLES_IOTIVITY} ]; then CONFIG_EXAMPLES_IOTIVITY=0; fi
{'fraction_non_alphanumeric': 0.1245067087608524, 'fraction_numerical': 0.00749802683504341, 'mean_word_length': 6.798461538461538, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, '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': '7641158', 'n_tokens_mistral': 2097, 'n_tokens_neox': 2034, 'n_words': 331}