[gnome-builder] make: Add C++ make template
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] make: Add C++ make template
- Date: Thu, 10 Mar 2022 05:15:27 +0000 (UTC)
commit ee296bfc1527077efe237c081dfde99540d04117
Author: carnage-mode <beta-stage tutanota com>
Date: Thu Mar 10 05:15:23 2022 +0000
make: Add C++ make template
src/plugins/make/make.gresource.xml | 1 +
src/plugins/make/make_plugin.py | 20 ++++++++++++++------
src/plugins/make/resources/Makefile | 14 +++++++++++++-
src/plugins/make/resources/main.cpp | 12 ++++++++++++
4 files changed, 40 insertions(+), 7 deletions(-)
---
diff --git a/src/plugins/make/make.gresource.xml b/src/plugins/make/make.gresource.xml
index d4facf356..3b4574cbc 100644
--- a/src/plugins/make/make.gresource.xml
+++ b/src/plugins/make/make.gresource.xml
@@ -3,6 +3,7 @@
<gresource prefix="/plugins/make_plugin">
<file compressed="true">resources/Makefile</file>
<file compressed="true">resources/main.c</file>
+ <file compressed="true">resources/main.cpp</file>
<file compressed="true">resources/.gitignore</file>
</gresource>
</gresources>
diff --git a/src/plugins/make/make_plugin.py b/src/plugins/make/make_plugin.py
index 54f3e9912..64c26969c 100644
--- a/src/plugins/make/make_plugin.py
+++ b/src/plugins/make/make_plugin.py
@@ -288,12 +288,20 @@ class MakeTemplateBase(Ide.TemplateBase, Ide.ProjectTemplate):
'exec_name': name,
}
- files = {
- 'resources/.gitignore': '.gitignore',
- 'resources/Makefile': 'Makefile',
- 'resources/main.c': '%(exec_name)s.c',
- }
- self.prepare_files(files)
+ if self.language == 'c':
+ files = {
+ 'resources/.gitignore': '.gitignore',
+ 'resources/Makefile': 'Makefile',
+ 'resources/main.c': '%(exec_name)s.c',
+ }
+ self.prepare_files(files)
+ elif self.language == 'c++':
+ files = {
+ 'resources/.gitignore': '.gitignore',
+ 'resources/Makefile': 'Makefile',
+ 'resources/main.cpp': '%(exec_name)s.cpp',
+ }
+ self.prepare_files(files)
modes = {}
diff --git a/src/plugins/make/resources/Makefile b/src/plugins/make/resources/Makefile
index 22735a6f1..859dd34b3 100644
--- a/src/plugins/make/resources/Makefile
+++ b/src/plugins/make/resources/Makefile
@@ -1,12 +1,25 @@
all: {{exec_name}}
+{{if language == "c"}}
WARNINGS = -Wall
DEBUG = -ggdb -fno-omit-frame-pointer
OPTIMIZE = -O2
+{{else if language == "c++"}}
+WARNINGS = -Wall -Weffc++ -Wextra -Wsign-conversion -pedantic-errors
+DEBUG = -ggdb -fno-omit-frame-pointer
+OPTIMIZE = -O2
+STANDARD = -std=c++2a
+{{end}}
+
+{{if language == "c"}}
{{exec_name}}: Makefile {{exec_name}}.c
$(CC) -o $@ $(WARNINGS) $(DEBUG) $(OPTIMIZE) {{exec_name}}.c
+{{else if language == "c++"}}
+{{exec_name}}: Makefile {{exec_name}}.cpp
+ $(CXX) -o $@ $(WARNINGS) $(DEBUG) $(OPTIMIZE) $(STANDARD) {{exec_name}}.cpp
+{{end}}
clean:
rm -f {{exec_name}}
@@ -20,4 +33,3 @@ install:
run:
./{{exec_name}}
-
diff --git a/src/plugins/make/resources/main.cpp b/src/plugins/make/resources/main.cpp
new file mode 100644
index 000000000..d7fade965
--- /dev/null
+++ b/src/plugins/make/resources/main.cpp
@@ -0,0 +1,12 @@
+{{include "license.cpp"}}
+
+
+#include <iostream>
+#include <cstdlib>
+
+int
+main ()
+{
+ std::cout << "Hello, World!\n";
+ return EXIT_SUCCESS;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]