<commit_before>#
# This file is part of GreatFET
#

enable_language(C CXX ASM)

include(${CMAKE_CURRENT_LIST_DIR}/../cmake/dfu-util.cmake)

SET(PATH_GREATFET ${CMAKE_CURRENT_LIST_DIR}/../..)
SET(PATH_GREATFET_FIRMWARE ${PATH_GREATFET}/firmware)
SET(PATH_GREATFET_FIRMWARE_COMMON ${PATH_GREATFET_FIRMWARE}/common)
SET(LIBOPENCM3 ${PATH_GREATFET_FIRMWARE}/libopencm3)

execute_process(
	COMMAND git log -n 1 --format=%h
	WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
	RESULT_VARIABLE GIT_VERSION_FOUND
	ERROR_QUIET
	OUTPUT_VARIABLE GIT_VERSION
	OUTPUT_STRIP_TRAILING_WHITESPACE
)
if (GIT_VERSION_FOUND)
	set(VERSION "unknown")
else (GIT_VERSION_FOUND)
	set(VERSION ${GIT_VERSION})
endif (GIT_VERSION_FOUND)

if(NOT DEFINED BOARD)
	set(BOARD GREATFET_ONE)
endif()

if(BOARD STREQUAL "GREATFET_ONE")
	set(MCU_PARTNO LPC4330)
endif()

if(BOARD STREQUAL "NXP_XPLORER")
	set(MCU_PARTNO LPC4330)
endif()

if(BOARD STREQUAL "RAD1O_BADGE")
	set(MCU_PARTNO LPC4330)
	set(BUILD_OUTPUT_TYPE "L0ADABLE")
endif()

if(NOT DEFINED SRC_M0)
	set(SRC_M0 "${PATH_GREATFET_FIRMWARE_COMMON}/m0_sleep.c")
endif(NOT DEFINED SRC_M0)

SET(GREATFET_OPTS "-D${BOARD} -DLPC43XX -D${MCU_PARTNO} -D'VERSION_STRING=\"git-${VERSION}\"'")

if(BUILD_OUTPUT_TYPE STREQUAL "L0ADABLE")
	SET(LDSCRIPT_M4 "-T${PATH_GREATFET_FIRMWARE_COMMON}/${MCU_PARTNO}_M4_memory_l0adable.ld -T${PATH_GREATFET_FIRMWARE_COMMON}/LPC43xx_l0adable.ld")
else()
	SET(LDSCRIPT_M4 "-T${PATH_GREATFET_FIRMWARE_COMMON}/${MCU_PARTNO}_M4_memory.ld -Tlibopencm3_lpc43xx_rom_to_ram.ld -T${PATH_GREATFET_FIRMWARE_COMMON}/LPC43xx_M4_M0_image_from_text.ld")
endif()

SET(LDSCRIPT_M4_DFU "-T${PATH_GREATFET_FIRMWARE_COMMON}/${MCU_PARTNO}_M4_memory.ld -Tlibopencm3_lpc43xx.ld -T${PATH_GREATFET_FIRMWARE_COMMON}/LPC43xx_M4_M0_image_from_text.ld")

SET(LDSCRIPT_M0 "-T${PATH_GREATFET_FIRMWARE_COMMON}/LPC43xx_M0_memory.ld -Tlibopencm3_lpc43xx_m0.ld")

SET(CFLAGS_COMMON "-Os -g3 -Wall -Wextra ${GREATFET_OPTS} ${COMMON_FLAGS} -fno-common -MD")
SET(LDFLAGS_COMMON "-nostartfiles -Wl,--gc-sections")

if(V STREQUAL "1")
	SET(LDFLAGS_COMMON "${LDFLAGS_COMMON} -Wl,--print-gc-sections")
endif()

SET(CPUFLAGS_M0 "-mthumb -mcpu=cortex-m0 -mfloat-abi=soft")
SET(CFLAGS_M0 "-std=gnu99 ${CFLAGS_COMMON} ${CPUFLAGS_M0} -DLPC43XX_M0")
SET(CXXFLAGS_M0 "-std=gnu++0x ${CFLAGS_COMMON} ${CPUFLAGS_M0} -DLPC43XX_M0")
SET(LDFLAGS_M0 "${LDFLAGS_COMMON} ${CPUFLAGS_M0} ${LDSCRIPT_M0} -Xlinker -Map=m0.map")

SET(CPUFLAGS_M4 "-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16")
SET(CFLAGS_M4 "-std=gnu99 ${CFLAGS_COMMON} ${CPUFLAGS_M4} -DLPC43XX_M4")
SET(CXXFLAGS_M4 "-std=gnu++0x ${CFLAGS_COMMON} ${CPUFLAGS_M4} -DLPC43XX_M4")<commit_msg>Remove reference to nonexistant CMake variable `COMMON_FLAGS`<commit_after>#
# This file is part of GreatFET
#

enable_language(C CXX ASM)

include(${CMAKE_CURRENT_LIST_DIR}/../cmake/dfu-util.cmake)

SET(PATH_GREATFET ${CMAKE_CURRENT_LIST_DIR}/../..)
SET(PATH_GREATFET_FIRMWARE ${PATH_GREATFET}/firmware)
SET(PATH_GREATFET_FIRMWARE_COMMON ${PATH_GREATFET_FIRMWARE}/common)
SET(LIBOPENCM3 ${PATH_GREATFET_FIRMWARE}/libopencm3)

execute_process(
	COMMAND git log -n 1 --format=%h
	WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
	RESULT_VARIABLE GIT_VERSION_FOUND
	ERROR_QUIET
	OUTPUT_VARIABLE GIT_VERSION
	OUTPUT_STRIP_TRAILING_WHITESPACE
)
if (GIT_VERSION_FOUND)
	set(VERSION "unknown")
else (GIT_VERSION_FOUND)
	set(VERSION ${GIT_VERSION})
endif (GIT_VERSION_FOUND)

if(NOT DEFINED BOARD)
	set(BOARD GREATFET_ONE)
endif()

if(BOARD STREQUAL "GREATFET_ONE")
	set(MCU_PARTNO LPC4330)
endif()

if(BOARD STREQUAL "NXP_XPLORER")
	set(MCU_PARTNO LPC4330)
endif()

if(BOARD STREQUAL "RAD1O_BADGE")
	set(MCU_PARTNO LPC4330)
	set(BUILD_OUTPUT_TYPE "L0ADABLE")
endif()

if(NOT DEFINED SRC_M0)
	set(SRC_M0 "${PATH_GREATFET_FIRMWARE_COMMON}/m0_sleep.c")
endif(NOT DEFINED SRC_M0)

SET(GREATFET_OPTS "-D${BOARD} -DLPC43XX -D${MCU_PARTNO} -D'VERSION_STRING=\"git-${VERSION}\"'")

if(BUILD_OUTPUT_TYPE STREQUAL "L0ADABLE")
	SET(LDSCRIPT_M4 "-T${PATH_GREATFET_FIRMWARE_COMMON}/${MCU_PARTNO}_M4_memory_l0adable.ld -T${PATH_GREATFET_FIRMWARE_COMMON}/LPC43xx_l0adable.ld")
else()
	SET(LDSCRIPT_M4 "-T${PATH_GREATFET_FIRMWARE_COMMON}/${MCU_PARTNO}_M4_memory.ld -Tlibopencm3_lpc43xx_rom_to_ram.ld -T${PATH_GREATFET_FIRMWARE_COMMON}/LPC43xx_M4_M0_image_from_text.ld")
endif()

SET(LDSCRIPT_M4_DFU "-T${PATH_GREATFET_FIRMWARE_COMMON}/${MCU_PARTNO}_M4_memory.ld -Tlibopencm3_lpc43xx.ld -T${PATH_GREATFET_FIRMWARE_COMMON}/LPC43xx_M4_M0_image_from_text.ld")

SET(LDSCRIPT_M0 "-T${PATH_GREATFET_FIRMWARE_COMMON}/LPC43xx_M0_memory.ld -Tlibopencm3_lpc43xx_m0.ld")

SET(CFLAGS_COMMON "-Os -g3 -Wall -Wextra ${GREATFET_OPTS} -fno-common -MD")
SET(LDFLAGS_COMMON "-nostartfiles -Wl,--gc-sections")

if(V STREQUAL "1")
	SET(LDFLAGS_COMMON "${LDFLAGS_COMMON} -Wl,--print-gc-sections")
endif()

SET(CPUFLAGS_M0 "-mthumb -mcpu=cortex-m0 -mfloat-abi=soft")
SET(CFLAGS_M0 "-std=gnu99 ${CFLAGS_COMMON} ${CPUFLAGS_M0} -DLPC43XX_M0")
SET(CXXFLAGS_M0 "-std=gnu++0x ${CFLAGS_COMMON} ${CPUFLAGS_M0} -DLPC43XX_M0")
SET(LDFLAGS_M0 "${LDFLAGS_COMMON} ${CPUFLAGS_M0} ${LDSCRIPT_M0} -Xlinker -Map=m0.map")

SET(CPUFLAGS_M4 "-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16")
SET(CFLAGS_M4 "-std=gnu99 ${CFLAGS_COMMON} ${CPUFLAGS_M4} -DLPC43XX_M4")
SET(CXXFLAGS_M4 "-std=gnu++0x ${CFLAGS_COMMON} ${CPUFLAGS_M4} -DLPC43XX_M4")
{'fraction_non_alphanumeric': 0.13955672426746807, 'fraction_numerical': 0.035687453042824946, 'mean_word_length': 8.149484536082474, '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': '4024051', 'n_tokens_mistral': 2629, 'n_tokens_neox': 2491, 'n_words': 316}