<commit_before># This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

set(INSTALL_FULLDIR ${CMAKE_INSTALL_PREFIX}/share/haka/lua)
set(LUAJIT_DIR "external/luajit/src")

set(LUAJIT_CFLAGS -fPIC -DLUAJIT_ENABLE_LUA52COMPAT)
set(LUAJIT_CCDEBUG "")
set(LUAJIT_MAKE_OPT CFLAGS="${LUAJIT_CFLAGS}" CCDEBUG="${LUAJIT_CCDEBUG}" PREFIX=${INSTALL_FULLDIR} )

if(NOT ${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64")
	# Force external unwinding
	# Otherwise we get conflicts: when doing a pthread_cancel, the cancel request
	# is caught by luajit on a pcall and the system ends up in corrupted state.
	# WARNING: When enabling this all C code need to be compiled with funwind-tables
	# (or -fexceptions), see luajit/src/lj_err.c for more details.
	set(LUAJIT_CFLAGS ${LUAJIT_CFLAGS} -funwind-tables -DLUAJIT_UNWIND_EXTERNAL)
endif()

if(CMAKE_BUILD_TYPE STREQUAL Debug)
	set(LUAJIT_CFLAGS ${LUAJIT_CFLAGS} -O0 -g -DLUA_USE_APICHECK) # -DLUAJIT_USE_GDBJIT -DLUA_USE_ASSERT
	set(LUAJIT_CCDEBUG ${LUAJIT_CCDEBUG} -g)
elseif(CMAKE_BUILD_TYPE STREQUAL Memcheck)
	set(LUAJIT_CFLAGS ${LUAJIT_CFLAGS} -O0 -g -DLUAJIT_USE_VALGRIND -DLUA_USE_APICHECK) # -DLUAJIT_USE_GDBJIT
	set(LUAJIT_CCDEBUG ${LUAJIT_CCDEBUG} -g)
elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
	set(LUAJIT_CFLAGS ${LUAJIT_CFLAGS} -g)
	set(LUAJIT_CCDEBUG ${LUAJIT_CCDEBUG} -g)
else()
	set(LUAJIT_CFLAGS ${LUAJIT_CFLAGS} -O2)
endif()

execute_process(COMMAND mkdir -p ${CMAKE_BINARY_DIR}/${LUAJIT_DIR})<commit_msg>Fix luajit build<commit_after># This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

set(INSTALL_FULLDIR ${CMAKE_INSTALL_PREFIX}/share/haka/lua)
set(LUAJIT_DIR "external/luajit/src")

set(LUAJIT_CFLAGS -fPIC -DLUAJIT_ENABLE_LUA52COMPAT)
set(LUAJIT_CCDEBUG "")

if(NOT ${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64")
	# Force external unwinding
	# Otherwise we get conflicts: when doing a pthread_cancel, the cancel request
	# is caught by luajit on a pcall and the system ends up in corrupted state.
	# WARNING: When enabling this all C code need to be compiled with funwind-tables
	# (or -fexceptions), see luajit/src/lj_err.c for more details.
	set(LUAJIT_CFLAGS ${LUAJIT_CFLAGS} -funwind-tables -DLUAJIT_UNWIND_EXTERNAL)
endif()

if(CMAKE_BUILD_TYPE STREQUAL Debug)
	set(LUAJIT_CFLAGS ${LUAJIT_CFLAGS} -O0 -g -DLUA_USE_APICHECK) # -DLUAJIT_USE_GDBJIT -DLUA_USE_ASSERT
	set(LUAJIT_CCDEBUG ${LUAJIT_CCDEBUG} -g)
elseif(CMAKE_BUILD_TYPE STREQUAL Memcheck)
	set(LUAJIT_CFLAGS ${LUAJIT_CFLAGS} -O0 -g -DLUAJIT_USE_VALGRIND -DLUA_USE_APICHECK) # -DLUAJIT_USE_GDBJIT
	set(LUAJIT_CCDEBUG ${LUAJIT_CCDEBUG} -g)
elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
	set(LUAJIT_CFLAGS ${LUAJIT_CFLAGS} -g)
	set(LUAJIT_CCDEBUG ${LUAJIT_CCDEBUG} -g)
else()
	set(LUAJIT_CFLAGS ${LUAJIT_CFLAGS} -O2)
endif()

set(LUAJIT_MAKE_OPT CFLAGS="${LUAJIT_CFLAGS}" CCDEBUG="${LUAJIT_CCDEBUG}" PREFIX=${INSTALL_FULLDIR} )

execute_process(COMMAND mkdir -p ${CMAKE_BINARY_DIR}/${LUAJIT_DIR})
{'fraction_non_alphanumeric': 0.10496894409937889, 'fraction_numerical': 0.008074534161490683, 'mean_word_length': 6.189732142857143, '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': '5910166', 'n_tokens_mistral': 1380, 'n_tokens_neox': 1337, 'n_words': 299}