Skip to content

Commit bd1e5e2

Browse files
Documented custom CMake functions
1 parent 7757490 commit bd1e5e2

4 files changed

Lines changed: 41 additions & 1 deletion

File tree

miosix/cmake/AddProcess.cmake

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,15 @@
2323
# You should have received a copy of the GNU General Public License
2424
# along with this program; if not, see <http://www.gnu.org/licenses/>
2525

26-
# Function to link the Miosix libraries to a target and register the build command
26+
# Function to create a Miosix process
27+
#
28+
# miosix_add_process(<target> <source1> <source2> ...)
29+
#
30+
# What is does:
31+
# - Create an executable target with the given sources
32+
# - Link the libraries required by processes
33+
# - Tell the linker to produce a map file
34+
# - Run strip and mx-postlinker on the executable
2735
function(miosix_add_process TARGET SOURCES)
2836
# Define the executable with its sources
2937
add_executable(${TARGET} ${SOURCES})

miosix/cmake/AddRomfsImage.cmake

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,20 @@ ExternalProject_Add(buildromfs
3232
INSTALL_COMMAND "" # Skip install
3333
)
3434

35+
# Create a target that builds the romfs image and combines it the kernel into a single binary image
36+
#
37+
# miosix_add_romfs_image(
38+
# IMAGE_NAME <name>
39+
# KERNEL <kernel>
40+
# DIR_NAME <dir_name>
41+
# PROCESSES <process1> <process2> ...
42+
# )
43+
#
44+
# What it does:
45+
# - Copies all processes binaries to a single directory named <dir_name>
46+
# - Creates a romfs image with of the directory <dir_name>
47+
# - Combines the kernel and the romfs image into a single binary image
48+
# - Registers a custom target (named <dir_name>) with to run the above steps
3549
function(miosix_add_romfs_image)
3650
cmake_parse_arguments(ROMFS "" "IMAGE_NAME;KERNEL;DIR_NAME" "PROCESSES" ${ARGN})
3751

miosix/cmake/CreateProcessesDir.cmake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@
2323
# You should have received a copy of the GNU General Public License
2424
# along with this program; if not, see <http://www.gnu.org/licenses/>
2525

26+
# Copies processes binaries into a single directory
27+
#
28+
# miosix_create_processes_dir(
29+
# DIR_NAME <dir_name>
30+
# PROCESSES <process1> <process2> ...
31+
# )
32+
#
33+
# This function addresses two use cases:
34+
# - When you need to build a romfs image, you need all processes into a single directory
35+
# - If you want to load processes on to an SD card for example, is useful to have all processes grouped togheter
2636
function(miosix_create_processes_dir)
2737
cmake_parse_arguments(PROCS "" "DIR_NAME" "PROCESSES" ${ARGN})
2838

miosix/cmake/LinkTarget.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ function(miosix_add_program_target TARGET)
4040
endfunction()
4141

4242
# Function to link the Miosix libraries to a target and register the build command
43+
#
44+
# miosix_link_target(<target>)
45+
#
46+
# What it does:
47+
# - Links the Miosix libraries to the target
48+
# - Tells the linker to generate the map file
49+
# - Registers custom targets to create the hex and bin files (${TARGET}_bin and ${TARGET}_hex)
50+
# - Registers a custom target to flash the program to the board (${TARGET}_program)
4351
function(miosix_link_target TARGET)
4452
if (NOT TARGET miosix)
4553
message(FATAL_ERROR "The board you selected is not supported")

0 commit comments

Comments
 (0)