BuildSystem: add helper to create userspace programs

This commit is contained in:
Bananymous 2023-05-11 18:10:06 +03:00
parent 177b205c48
commit bbaf1223f3
1 changed files with 34 additions and 0 deletions

34
userspace/create_program.sh Executable file
View File

@ -0,0 +1,34 @@
#!/bin/sh
set -e
PROGRAM_NAME=$1
mkdir $PROGRAM_NAME
cat > $PROGRAM_NAME/CMakeLists.txt << EOF
cmake_minimum_required(VERSION 3.26)
project($PROGRAM_NAME CXX)
set(SOURCES
main.cpp
)
add_executable($PROGRAM_NAME \${SOURCES})
target_compile_options($PROGRAM_NAME PUBLIC -O2 -g)
add_dependencies($PROGRAM_NAME libc-install)
target_link_options($PROGRAM_NAME PUBLIC -nodefaultlibs -lc)
add_custom_target($PROGRAM_NAME-install
COMMAND cp \${CMAKE_CURRENT_BINARY_DIR}/$PROGRAM_NAME \${BANAN_BIN}/
DEPENDS $PROGRAM_NAME
)
EOF
cat > $PROGRAM_NAME/main.cpp << EOF
int main()
{
}
EOF