<commit_before>cmake_minimum_required(VERSION 3.5)
project(chipdb-gowin NONE)

set(ALL_GOWIN_DEVICES GW1N-1 GW1N-4 GW1N-9 GW1NS-2)
set(GOWIN_DEVICES ${ALL_GOWIN_DEVICES} CACHE STRING
    "Include support for these Gowin devices (available: ${ALL_GOWIN_DEVICES})")
message(STATUS "Enabled Gowin devices: ${GOWIN_DEVICES}")

find_program (GOWIN_BBA_EXECUTABLE gowin_bba)
message(STATUS "gowin_bba executable: ${GOWIN_BBA_EXECUTABLE}")

if(DEFINED GOWIN_CHIPDB)
    add_custom_target(chipdb-gowin-bbas ALL)
else()
    find_package(PythonInterp 3.6 REQUIRED)

    # shared among all families
    set(SERIALIZE_CHIPDBS TRUE CACHE BOOL
        "Serialize device data preprocessing to minimize memory use")

    set(all_device_bbas)
    file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/chipdb)
    foreach(device ${GOWIN_DEVICES})
        if(NOT device IN_LIST ALL_GOWIN_DEVICES)
            message(FATAL_ERROR "Device ${device} is not a supported Gowin device")
        endif()

        set(device_bba chipdb/chipdb-${device}.bba)
        add_custom_command(
            OUTPUT ${device_bba}
            COMMAND ${GOWIN_BBA_EXECUTABLE} -d ${device} -i ${CMAKE_CURRENT_SOURCE_DIR}/constids.inc -o ${device_bba}.new
            # atomically update
            COMMAND ${CMAKE_COMMAND} -E rename ${device_bba}.new ${device_bba}
            DEPENDS
                ${GOWIN_BBA_EXECUTABLE}
                ${PREVIOUS_CHIPDB_TARGET}
                ${CMAKE_CURRENT_SOURCE_DIR}/constids.inc
            VERBATIM)
        list(APPEND all_device_bbas ${device_bba})
        if(SERIALIZE_CHIPDBS)<commit_msg>remove generic leftover in gowin<commit_after>cmake_minimum_required(VERSION 3.5)
project(chipdb-gowin NONE)

set(ALL_GOWIN_DEVICES GW1N-1 GW1N-4 GW1N-9 GW1NS-2)
set(GOWIN_DEVICES ${ALL_GOWIN_DEVICES} CACHE STRING
    "Include support for these Gowin devices (available: ${ALL_GOWIN_DEVICES})")
message(STATUS "Enabled Gowin devices: ${GOWIN_DEVICES}")

find_program (GOWIN_BBA_EXECUTABLE gowin_bba)
message(STATUS "gowin_bba executable: ${GOWIN_BBA_EXECUTABLE}")

if(DEFINED GOWIN_CHIPDB)
    add_custom_target(chipdb-gowin-bbas ALL)
else()
    # shared among all families
    set(SERIALIZE_CHIPDBS TRUE CACHE BOOL
        "Serialize device data preprocessing to minimize memory use")

    set(all_device_bbas)
    file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/chipdb)
    foreach(device ${GOWIN_DEVICES})
        if(NOT device IN_LIST ALL_GOWIN_DEVICES)
            message(FATAL_ERROR "Device ${device} is not a supported Gowin device")
        endif()

        set(device_bba chipdb/chipdb-${device}.bba)
        add_custom_command(
            OUTPUT ${device_bba}
            COMMAND ${GOWIN_BBA_EXECUTABLE} -d ${device} -i ${CMAKE_CURRENT_SOURCE_DIR}/constids.inc -o ${device_bba}.new
            # atomically update
            COMMAND ${CMAKE_COMMAND} -E rename ${device_bba}.new ${device_bba}
            DEPENDS
                ${GOWIN_BBA_EXECUTABLE}
                ${PREVIOUS_CHIPDB_TARGET}
                ${CMAKE_CURRENT_SOURCE_DIR}/constids.inc
            VERBATIM)
        list(APPEND all_device_bbas ${device_bba})
        if(SERIALIZE_CHIPDBS)
{'fraction_non_alphanumeric': 0.09214692843571881, 'fraction_numerical': 0.006966434452184927, 'mean_word_length': 3.461864406779661, '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': '4471126', 'n_tokens_mistral': 1142, 'n_tokens_neox': 1112, 'n_words': 212}