blob: ba62fec9b3fd84ddc819fabb6bbbd394fb62dcc1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#!/bin/sh
# $1: Project name, filesystem safe
# $2: Project full path
# $3: Project name, namespace safe
# Generate Makefile
echo > $2/Makefile <<-EOF
LIBRARY = $1.so
OBJS = Class1.o
CXXFLAGS = -g -std=c++2a
all: \$(LIBRARY)
\$(LIBRARY): \$(OBJS)
\$(CXX) -shared -o \$@ \$(OBJS)
%.o: %.cpp
\$(CXX) \$(CXXFLAGS) -fPIC -o \$@ -c \$<
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 <stdio.h>
namespace $3 {
void Class1::hello()
{
printf("Hello friends! :^)\\n");
}
}
EOF
|