<commit_before>cmake_minimum_required(VERSION 3.5)

project(mouros VERSION 0.0.1 LANGUAGES C)


set(ENABLE_DIAGNOSTICS OFF CACHE BOOL "Enable MourOS diagnostics")


if(NOT DEFINED CHIP_FAMILY)
    message(FATAL_ERROR "A STM32 chip family must be defined. -DCHIP_FAMILY=...\nAllowed families are: STM32F0, STM32F4")
endif()

if(NOT (CHIP_FAMILY STREQUAL "STM32F0" OR CHIP_FAMILY STREQUAL "STM32F4"))
    message(FATAL_ERROR "Unknown CHIP_FAMILY: ${CHIP_FAMILY}\nAllowed families are: STM32F0, STM32F4")
endif()






add_library(${PROJECT_NAME} STATIC
    "${CMAKE_CURRENT_LIST_DIR}/src/char_buffer.c"
    "${CMAKE_CURRENT_LIST_DIR}/src/mailbox.c"
    "${CMAKE_CURRENT_LIST_DIR}/src/scheduler.c"
    "${CMAKE_CURRENT_LIST_DIR}/src/sync.c"
    "${CMAKE_CURRENT_LIST_DIR}/src/syscalls.c"
    "${CMAKE_CURRENT_LIST_DIR}/src/tasks.c"
)

target_compile_definitions(${PROJECT_NAME} PUBLIC "${CHIP_FAMILY}")

target_include_directories(${PROJECT_NAME} PUBLIC "${CMAKE_CURRENT_LIST_DIR}/include")
target_include_directories(${PROJECT_NAME} PUBLIC "${CMAKE_INSTALL_PREFIX}/include")

# Link with libopencm3
string(TOLOWER "${CHIP_FAMILY}" CHIP_FAMILY_LCASE)
target_link_libraries(${PROJECT_NAME} PUBLIC "${CMAKE_INSTALL_PREFIX}/lib/libopencm3_${CHIP_FAMILY_LCASE}.a")


# Generate diagnostic functions
add_custom_command(OUTPUT "${CMAKE_CURRENT_LIST_DIR}/src/diag/diag.c" "${CMAKE_CURRENT_LIST_DIR}/src/diag/diag.h"
                   COMMAND "${CMAKE_CURRENT_LIST_DIR}/libsrc/common-stm32/binlog/generate_binlog.py" "diag_config.json" "diag"
                   MAIN_DEPENDENCY "${CMAKE_CURRENT_LIST_DIR}/src/diag/diag_config.json"
                   WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/src/diag")

set_source_files_properties("${CMAKE_CURRENT_LIST_DIR}/src/diag/diag.c" PROPERTIES GENERATED TRUE)


if(ENABLE_DIAGNOSTICS)
    target_compile_definitions(${PROJECT_NAME} PUBLIC "DIAG_ENABLE")
    target_sources(${PROJECT_NAME} PRIVATE "${CMAKE_CURRENT_LIST_DIR}/src/diag/diag.c")
endif()


target_compile_options(${PROJECT_NAME} 
    PUBLIC "-mthumb" 
           "-fsigned-char" 
           "-ffunction-sections" 
           "-fdata-sections"
    PRIVATE "-Og"
            "-Wunused" 
            "-Wuninitialized" 
            "-Wall" 
            "-Wextra" 
            "-Wmissing-declarations" 
            "-Wconversion" 
            "-Wpointer-arith" 
            "-Wshadow" 
            "-Wlogical-op" 
            "-Waggregate-return" 
            "-Wfloat-equal")


if(CHIP_FAMILY STREQUAL "STM32F0")
    
    target_compile_options(${PROJECT_NAME} 
        PUBLIC "-mcpu=cortex-m0")

elseif(CHIP_FAMILY STREQUAL "STM32F4")
    
    target_compile_options(${PROJECT_NAME} 
        PUBLIC "-mcpu=cortex-m4f"
               "-mfloat-abi=hard"
               "-mfpu=fpv4-sp-d16")
endif()




install(TARGETS ${PROJECT_NAME}
    ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib"
)

install(DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/include" DESTINATION "${CMAKE_INSTALL_PREFIX}/include")


<commit_msg>Added '-g' flag to debug builds<commit_after>cmake_minimum_required(VERSION 3.5)

project(mouros VERSION 0.0.1 LANGUAGES C)


set(ENABLE_DIAGNOSTICS OFF CACHE BOOL "Enable MourOS diagnostics")


if(NOT DEFINED CHIP_FAMILY)
    message(FATAL_ERROR "A STM32 chip family must be defined. -DCHIP_FAMILY=...\nAllowed families are: STM32F0, STM32F4")
endif()

if(NOT (CHIP_FAMILY STREQUAL "STM32F0" OR CHIP_FAMILY STREQUAL "STM32F4"))
    message(FATAL_ERROR "Unknown CHIP_FAMILY: ${CHIP_FAMILY}\nAllowed families are: STM32F0, STM32F4")
endif()






add_library(${PROJECT_NAME} STATIC
    "${CMAKE_CURRENT_LIST_DIR}/src/char_buffer.c"
    "${CMAKE_CURRENT_LIST_DIR}/src/mailbox.c"
    "${CMAKE_CURRENT_LIST_DIR}/src/scheduler.c"
    "${CMAKE_CURRENT_LIST_DIR}/src/sync.c"
    "${CMAKE_CURRENT_LIST_DIR}/src/syscalls.c"
    "${CMAKE_CURRENT_LIST_DIR}/src/tasks.c"
)

target_compile_definitions(${PROJECT_NAME} PUBLIC "${CHIP_FAMILY}")

target_include_directories(${PROJECT_NAME} PUBLIC "${CMAKE_CURRENT_LIST_DIR}/include")
target_include_directories(${PROJECT_NAME} PUBLIC "${CMAKE_INSTALL_PREFIX}/include")

# Link with libopencm3
string(TOLOWER "${CHIP_FAMILY}" CHIP_FAMILY_LCASE)
target_link_libraries(${PROJECT_NAME} PUBLIC "${CMAKE_INSTALL_PREFIX}/lib/libopencm3_${CHIP_FAMILY_LCASE}.a")


# Generate diagnostic functions
add_custom_command(OUTPUT "${CMAKE_CURRENT_LIST_DIR}/src/diag/diag.c" "${CMAKE_CURRENT_LIST_DIR}/src/diag/diag.h"
                   COMMAND "${CMAKE_CURRENT_LIST_DIR}/libsrc/common-stm32/binlog/generate_binlog.py" "diag_config.json" "diag"
                   MAIN_DEPENDENCY "${CMAKE_CURRENT_LIST_DIR}/src/diag/diag_config.json"
                   WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/src/diag")

set_source_files_properties("${CMAKE_CURRENT_LIST_DIR}/src/diag/diag.c" PROPERTIES GENERATED TRUE)


if(ENABLE_DIAGNOSTICS)
    target_compile_definitions(${PROJECT_NAME} PUBLIC "DIAG_ENABLE")
    target_sources(${PROJECT_NAME} PRIVATE "${CMAKE_CURRENT_LIST_DIR}/src/diag/diag.c")
endif()


target_compile_options(${PROJECT_NAME} 
    PUBLIC "-mthumb" 
           "-fsigned-char" 
           "-ffunction-sections" 
           "-fdata-sections"
    PRIVATE "-Og"
            "-Wunused" 
            "-Wuninitialized" 
            "-Wall" 
            "-Wextra" 
            "-Wmissing-declarations" 
            "-Wconversion" 
            "-Wpointer-arith" 
            "-Wshadow" 
            "-Wlogical-op" 
            "-Waggregate-return" 
            "-Wfloat-equal"
            "$<$<CONFIG:Debug>:-g>")


if(CHIP_FAMILY STREQUAL "STM32F0")
    
    target_compile_options(${PROJECT_NAME} 
        PUBLIC "-mcpu=cortex-m0")

elseif(CHIP_FAMILY STREQUAL "STM32F4")
    
    target_compile_options(${PROJECT_NAME} 
        PUBLIC "-mcpu=cortex-m4f"
               "-mfloat-abi=hard"
               "-mfpu=fpv4-sp-d16")
endif()




install(TARGETS ${PROJECT_NAME}
    ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib"
)

install(DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/include" DESTINATION "${CMAKE_INSTALL_PREFIX}/include")



{'fraction_non_alphanumeric': 0.12685827552031714, 'fraction_numerical': 0.013214403700033036, 'mean_word_length': 3.7194076383476227, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1300155', 'n_tokens_mistral': 2387, 'n_tokens_neox': 2175, 'n_words': 292}