-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CMake: eliminate
family.cmake
/CMakeLists.txt
split.
While it served a purpose (granting the ability to build `.bba` files separately from the rest of nextpnr), it made things excessively convoluted, especially around paths. This commit removes the ability to pre-generate chip databases. As far as I know, I was the primary user of that feature. It can be added back if there is demand for it. In exchange the per-family `CMakeLists.txt` files are now much easier to understand.
- Loading branch information
1 parent
5382146
commit 3844c2a
Showing
22 changed files
with
474 additions
and
649 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
include(TestBigEndian) | ||
|
||
test_big_endian(IS_BIG_ENDIAN) | ||
if (IS_BIG_ENDIAN) | ||
set(BBASM_ENDIAN_FLAG "--be") | ||
else() | ||
set(BBASM_ENDIAN_FLAG "--le") | ||
endif() | ||
|
||
# Example usage (note the `.new`, used for atomic updates): | ||
# | ||
# add_bba_produce_command( | ||
# COMMAND ${Python_EXECUTABLE} | ||
# ${CMAKE_CURRENT_SOURCE_DIR}/chipdb.py | ||
# -o ${CMAKE_CURRENT_BINARY_DIR}/chipdb-hx8k.bba.new | ||
# OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/chipdb-hx8k.bba | ||
# INPUTS ${CMAKE_CURRENT_SOURCE_DIR}/chipdb.py | ||
# ) | ||
# | ||
# Paths must be absolute. | ||
# | ||
function(add_bba_produce_command) | ||
cmake_parse_arguments(arg "" "OUTPUT" "COMMAND;INPUTS" ${ARGN}) | ||
|
||
cmake_path(GET arg_OUTPUT PARENT_PATH arg_OUTPUT_DIR) | ||
file(MAKE_DIRECTORY ${arg_OUTPUT_DIR}) | ||
|
||
list(GET arg_COMMAND 0 arg_EXECUTABLE) | ||
|
||
add_custom_command( | ||
OUTPUT | ||
${arg_OUTPUT} | ||
COMMAND | ||
${arg_COMMAND} | ||
COMMAND | ||
${CMAKE_COMMAND} -E rename # atomic update | ||
${arg_OUTPUT}.new | ||
${arg_OUTPUT} | ||
DEPENDS | ||
${arg_EXECUTABLE} | ||
${arg_INPUTS} | ||
$ENV{SERIALIZE_BBA_PRODUCE_COMMAND} | ||
VERBATIM | ||
) | ||
|
||
if (BBASM_SERIALIZE) | ||
set(ENV{SERIALIZE_BBA_PRODUCE_COMMAND} ${arg_OUTPUT}) | ||
endif() | ||
|
||
endfunction() | ||
|
||
# Example usage: | ||
# | ||
# add_bba_compile_command( | ||
# TARGET chipdb-ice40 | ||
# OUTPUT ${CMAKE_BINARY_DIR}/chipdb/ice40/chipdb-1k.bin | ||
# INPUT ${CMAKE_CURRENT_BINARY_DIR}/chipdb-1k.bba | ||
# IDENT ice40/chipdb-1k.bba | ||
# MODE binary | ||
# ) | ||
# | ||
# Paths must be absolute. | ||
# | ||
function(add_bba_compile_command) | ||
cmake_parse_arguments(arg "" "TARGET;OUTPUT;INPUT;IDENT;MODE" "" ${ARGN}) | ||
|
||
cmake_path(GET arg_OUTPUT PARENT_PATH arg_OUTPUT_DIR) | ||
file(MAKE_DIRECTORY ${arg_OUTPUT_DIR}) | ||
|
||
if (arg_MODE STREQUAL "binary" OR arg_MODE STREQUAL "resource") | ||
|
||
add_custom_command( | ||
OUTPUT | ||
${arg_OUTPUT} | ||
COMMAND | ||
bbasm ${BBASM_ENDIAN_FLAG} | ||
${arg_INPUT} | ||
${arg_OUTPUT}.new | ||
COMMAND | ||
${CMAKE_COMMAND} -E rename # atomic update | ||
${arg_OUTPUT}.new | ||
${arg_OUTPUT} | ||
DEPENDS | ||
bbasm | ||
${arg_INPUT} | ||
VERBATIM | ||
) | ||
|
||
if (arg_MODE STREQUAL "resource") | ||
|
||
file(WRITE ${arg_OUTPUT}.rc | ||
"${arg_IDENT} RCDATA \"${arg_OUTPUT}\"") | ||
|
||
target_sources( | ||
${arg_TARGET} PRIVATE | ||
${arg_OUTPUT}.rc | ||
) | ||
|
||
else() | ||
|
||
target_sources( | ||
${arg_TARGET} PRIVATE | ||
${arg_OUTPUT} | ||
) | ||
|
||
endif() | ||
|
||
elseif (arg_MODE STREQUAL "embed") | ||
|
||
add_custom_command( | ||
OUTPUT | ||
${arg_OUTPUT}.cc | ||
${arg_OUTPUT} | ||
COMMAND | ||
bbasm ${BBASM_ENDIAN_FLAG} --e | ||
${arg_INPUT} | ||
${arg_OUTPUT}.cc.new | ||
${arg_OUTPUT}.new | ||
COMMAND | ||
${CMAKE_COMMAND} -E rename # atomic update | ||
${arg_OUTPUT}.cc.new | ||
${arg_OUTPUT}.cc | ||
COMMAND | ||
${CMAKE_COMMAND} -E rename # atomic update | ||
${arg_OUTPUT}.new | ||
${arg_OUTPUT} | ||
DEPENDS | ||
bbasm | ||
${arg_INPUT} | ||
VERBATIM | ||
) | ||
|
||
target_sources( | ||
${arg_TARGET} PRIVATE | ||
${arg_OUTPUT}.cc | ||
) | ||
|
||
elseif (arg_MODE STREQUAL "string") | ||
|
||
add_custom_command( | ||
OUTPUT | ||
${arg_OUTPUT}.cc | ||
COMMAND | ||
bbasm ${BBASM_ENDIAN_FLAG} --c | ||
${arg_INPUT} | ||
${arg_OUTPUT}.cc.new | ||
COMMAND | ||
${CMAKE_COMMAND} -E rename # atomic update | ||
${arg_OUTPUT}.cc.new | ||
${arg_OUTPUT}.cc | ||
DEPENDS | ||
bbasm | ||
${arg_INPUT} | ||
VERBATIM | ||
) | ||
|
||
target_sources( | ||
${arg_TARGET} PRIVATE | ||
${arg_OUTPUT}.cc | ||
) | ||
|
||
endif() | ||
|
||
endfunction() |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
find_program (GOWIN_BBA_EXECUTABLE gowin_bba) | ||
message(STATUS "gowin_bba executable: ${GOWIN_BBA_EXECUTABLE}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
set(icestorm_default_install_prefix ${CMAKE_INSTALL_PREFIX}) | ||
if (DEFINED ICEBOX_ROOT) # for compatibility with old build scripts | ||
message(WARNING "-DICEBOX_ROOT= is deprecated, use -DICESTORM_INSTALL_PREFIX=${ICEBOX_ROOT} instead") | ||
get_filename_component(dir ${ICEBOX_ROOT} DIRECTORY) | ||
get_filename_component(dir ${dir} DIRECTORY) | ||
set(icestorm_default_install_prefix ${dir}) | ||
elseif (DEFINED ENV{ICESTORM_INSTALL_PREFIX}) | ||
set(icestorm_default_install_prefix $ENV{ICESTORM_INSTALL_PREFIX}) | ||
endif() | ||
set(ICESTORM_INSTALL_PREFIX ${icestorm_default_install_prefix} CACHE STRING | ||
"IceStorm install prefix") | ||
message(STATUS "IceStorm install prefix: ${ICESTORM_INSTALL_PREFIX}") | ||
|
||
if (NOT ICEBOX_DATADIR) | ||
set(ICEBOX_DATADIR ${ICESTORM_INSTALL_PREFIX}/share/icebox) | ||
endif() | ||
message(STATUS "icebox data directory: ${ICEBOX_DATADIR}") | ||
|
||
return(PROPAGATE ICEBOX_DATADIR) |
Oops, something went wrong.