From fd68e9f1ace923326cd9b2b3a8a33962a7015375 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kleines=20Filmr=C3=B6llchen?= Date: Tue, 7 Mar 2023 23:14:58 +0100 Subject: [PATCH] Base: Split out cpp-library template files into actual files These were part of the postcreate script previously, but with the new powers of sed, we can text-replace the library name and make changing them much more convenient. --- .../devel/templates/cpp-library.postcreate | 35 +++---------------- .../devel/templates/cpp-library/Class1.cpp | 11 ++++++ Base/res/devel/templates/cpp-library/Class1.h | 10 ++++++ 3 files changed, 25 insertions(+), 31 deletions(-) create mode 100644 Base/res/devel/templates/cpp-library/Class1.cpp create mode 100644 Base/res/devel/templates/cpp-library/Class1.h diff --git a/Base/res/devel/templates/cpp-library.postcreate b/Base/res/devel/templates/cpp-library.postcreate index af1aee3a2d..34c8e8d82c 100644 --- a/Base/res/devel/templates/cpp-library.postcreate +++ b/Base/res/devel/templates/cpp-library.postcreate @@ -4,6 +4,10 @@ # $2: Project full path # $3: Project name, namespace safe +# FIXME: Use a single sed command once we support that. +sed -i "s/\\\$LibName/$3/g" $2/Class1.h +sed -i "s/\\\$LibName/$3/g" $2/Class1.cpp + # Generate Makefile echo > $2/Makefile <<-EOF LIBRARY = $1.so @@ -22,34 +26,3 @@ clean: rm \$(OBJS) \$(LIBRARY) EOF - -# Generate 'Class1' header file -echo > $2/Class1.h <<-EOF -#pragma once - -namespace $3 { - -class Class1 { -public: - void hello(); -}; - -} - -EOF - -# Generate 'Class1' source file -echo > $2/Class1.cpp <<-EOF -#include "Class1.h" -#include - -namespace $3 { - -void Class1::hello() -{ - printf("Hello friends! :^)\\n"); -} - -} - -EOF diff --git a/Base/res/devel/templates/cpp-library/Class1.cpp b/Base/res/devel/templates/cpp-library/Class1.cpp new file mode 100644 index 0000000000..b858db0082 --- /dev/null +++ b/Base/res/devel/templates/cpp-library/Class1.cpp @@ -0,0 +1,11 @@ +#include "Class1.h" +#include + +namespace $LibName { + +void Class1::hello() +{ + out("Hello friends! :^)\n"); +} + +} diff --git a/Base/res/devel/templates/cpp-library/Class1.h b/Base/res/devel/templates/cpp-library/Class1.h new file mode 100644 index 0000000000..587c9623e2 --- /dev/null +++ b/Base/res/devel/templates/cpp-library/Class1.h @@ -0,0 +1,10 @@ +#pragma once + +namespace $LibName { + +class Class1 { +public: + void hello(); +}; + +}