-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmodule.py
More file actions
74 lines (53 loc) · 1.45 KB
/
Copy pathmodule.py
File metadata and controls
74 lines (53 loc) · 1.45 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import sys
import os
ns = sys.argv[1]
module_name = sys.argv[2]
try:
os.mkdir("./include/" + module_name)
except OSError as err:
print(err)
# hpp
try:
fhpp = open("./include/" + module_name + ".hpp", "x")
content = f'''#pragma once
#include "common/framework.h"
using namespace {ns}::{module_name};
'''
fhpp.write(content)
fhpp.close()
except OSError as err:
print(err)
try:
os.mkdir("./modules/" + module_name)
except OSError as err:
print(err)
try:
os.mkdir("./modules/" + module_name + "/src")
except OSError as err:
print(err)
# cmake
try:
fcmake = open("./modules/" + module_name + "/CMakeLists.txt", "x")
content = f'''# CMakeList.txt : Top-level CMake project file, do global configuration
# and include sub-projects here.
#
cmake_minimum_required (VERSION 3.14)
cmake_policy(SET CMP0091 NEW)
project({module_name})
set(CMAKE_AUTOMOC ON)
aux_source_directory(${{CMAKE_CURRENT_SOURCE_DIR}}/src SOURCES)
file(GLOB HEADERS ${{CMAKE_SOURCE_DIR}}/include/${{PROJECT_NAME}}/*.h)
add_library(${{PROJECT_NAME}} STATIC ${{SOURCES}} ${{HEADERS}})
find_package(Boost REQUIRED COMPONENTS serialization log)
find_package(Qt5Gui CONFIG REQUIRED)
target_include_directories(${{PROJECT_NAME}} PRIVATE
${{CMAKE_SOURCE_DIR}}/include
${{Boost_INCLUDE_DIRS}}
${{Qt5Gui_INCLUDE_DIRS}}
${{Qt5Gui_PRIVATE_INCLUDE_DIRS}}
)
'''
fcmake.write(content)
fcmake.close()
except OSError as err:
print(err)