From fb1bab7c30a3c78be0b79abca95fa50be9307a42 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Thu, 11 May 2023 18:10:06 +0300 Subject: [PATCH] BuildSystem: add helper to create userspace programs --- userspace/create_program.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 userspace/create_program.sh diff --git a/userspace/create_program.sh b/userspace/create_program.sh new file mode 100755 index 00000000..d833a912 --- /dev/null +++ b/userspace/create_program.sh @@ -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