forked from Segs/Segs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreateProject.rb
107 lines (103 loc) · 3.59 KB
/
CreateProject.rb
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/env ruby
require 'pp'
require 'CMakeCreator.rb'
require 'SegsUtil.rb'
def show_usage()
print("usage:\nCreateProject name\n")
print("\tThis utility will create skeleton for the named project \n")
end
class Servers_Creator
def initialize(parent_cmake,prefix,*servers)
@prefix=prefix
@servers_arr=servers
Dir.mkdir_optional(File.join(parent_cmake.current_path,"Servers")) if @servers_arr.size>0
parent_cmake.add_subdir("Servers")
@cmake = CMakeFile.new("Servers",parent_cmake)
end
def create()
@servers_arr.each {|serv| create_server(serv) }
end
def create_server(serv)
@cmake.add_subdir(serv,@prefix,true)
serv_path = File.join(@cmake.current_path,serv)
Dir.mkdir_optional(serv_path)
Dir.mkdir_optional(File.join(serv_path,"src"))
Dir.mkdir_optional(File.join(serv_path,"include"))
Dir.mkdir_optional(File.join(serv_path,"docs"))
CMakeFile.new(serv,@cmake).create_component(@prefix+"_"+serv)
end
end
class Clients_Creator
def initialize(parent_cmake,prefix,*clients)
@prefix=prefix
@clients=clients
parent_cmake.add_subdir("Clients")
Dir.mkdir_optional(File.join(parent_cmake.current_path,"Clients")) if @clients.size>0
@cmake = CMakeFile.new("Clients",parent_cmake)
end
def create()
sub_dir = @cmake.current_path
@clients.each {|client| create_client(client) }
end
def create_client(name)
@cmake.add_subdir(name,@prefix,true)
path = File.join(@cmake.current_path,name)
Dir.mkdir_optional(path)
Dir.mkdir_optional(File.join(path,"src"))
Dir.mkdir_optional(File.join(path,"include"))
Dir.mkdir_optional(File.join(path,"docs"))
CMakeFile.new(name,@cmake).create_component(@prefix+"_"+name)
end
end
class Common_Creator
def initialize(parent_cmake,prefix,topname,*subs)
@prefix=prefix
@subs=subs
parent_cmake.add_subdir(topname)
Dir.mkdir_optional(File.join(parent_cmake.current_path,topname))
@cmake = CMakeFile.new(topname,parent_cmake)
end
def create()
sub_dir = @cmake.current_path
@subs.each {|sub| create_sub(sub) }
end
def create_sub(name)
@cmake.add_subdir(name,@prefix,true)
path = File.join(@cmake.current_path,name)
Dir.mkdir_optional(path)
Dir.mkdir_optional(File.join(path,"src"))
Dir.mkdir_optional(File.join(path,"include"))
Dir.mkdir_optional(File.join(path,"docs"))
CMakeFile.new(name,@cmake).create_component(@prefix+"_"+name)
end
end
class Data_Creator
def initialize(cmake,*servers)
@servers_arr=servers
@cmake = cmake
end
end
class Docs_Creator
def initialize(cmake,*servers)
@servers_arr=servers
@cmake = cmake
end
end
if(ARGV.size()!=1)
show_usage()
else
Dir.chdir("../Projects")
root_cmake = CMakeFile.new(".") # Top dir in Projects
project_dir = File.join(root_cmake.current_path,ARGV[0])
Dir.mkdir_optional(project_dir)
project_root = CMakeFile.new(project_dir,root_cmake)
root_cmake.add_subdir(ARGV[0],"",true)
sc = Servers_Creator.new(project_root,ARGV[0],"TestServer","LoginServer")
sc.create()
cc = Clients_Creator.new(project_root,ARGV[0],"CliClient","GuiClient")
cc.create()
Common_Creator.new(project_root,ARGV[0],"Common").create()
Common_Creator.new(project_root,ARGV[0],"Utilities").create()
Common_Creator.new(project_root,ARGV[0],"Data").create()
Common_Creator.new(project_root,ARGV[0],"Docs").create()
end