This repository has been archived by the owner on Sep 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathRakefile
164 lines (129 loc) · 4.31 KB
/
Rakefile
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
require 'fileutils'
require 'JSON'
task :default => :all
task :all => [:win32, :win64, :macosx] do
FileUtils.rm_rf "./IGD_Groundhog/src/Radiance"
end
task :doc => [:clean] do
puts `yardoc ./IGD_Groundhog/src/*.rb ./IGD_Groundhog/src/Scripts/*.rb - ./Readme.md`
FileUtils.rm_rf("IGD_Groundhog/doc")
FileUtils.cp_r("doc","IGD_Groundhog/doc")
end
task :clean do
FileUtils.rm(Dir["IGD_Groundhog/Examples/*.skb"])
FileUtils.rm(Dir["*.rbz"])
FileUtils.rm_rf("doc")
end
def sketchup_plugin_dir(os,v)
if os == "macosx" then
return "#{ENV["HOME"]}/Library/Application Support/SketchUp #{v}/SketchUp/Plugins"
else
return "#{ENV["UserProfile"].gsub("\\","/")}/AppData/Roaming/SketchUp/SketchUp #{v}/SketchUp/Plugins"
end
end
task :test,[:os, :suv] => [:compile_ui] do |t, args|
radiance_version = "Radiance/#{args[:os]}/Radiance"
radiance_version = "Radiance/macosx/usr/local/radiance" if args[:os] == "macosx"
# Replace the Radiance version in Groundhog
FileUtils.rm_rf("./IGD_Groundhog/src/Radiance")
FileUtils.cp_r radiance_version, "./IGD_Groundhog/src/Radiance"
# Remove the groundhog version in Sketchup Plugin directory
FileUtils.rm_rf "#{sketchup_plugin_dir(args[:os],args[:suv])}/IGD_Groundhog.rb"
FileUtils.rm_rf "#{sketchup_plugin_dir(args[:os],args[:suv])}/IGD_Groundhog"
# Move the new one
FileUtils.cp_r "IGD_Groundhog.rb","#{sketchup_plugin_dir(args[:os],args[:suv])}/IGD_Groundhog.rb"
FileUtils.cp_r "IGD_Groundhog","#{sketchup_plugin_dir(args[:os],args[:suv])}/IGD_Groundhog"
# Final clean
FileUtils.rm_rf("./IGD_Groundhog/src/Radiance")
end
def this_os
if RUBY_PLATFORM.include? "darwin" then
return "macosx"
else
return "win"
end
end
def compress(os)
radiance_version = "Radiance/#{os}/Radiance"
radiance_version = "Radiance/macosx/usr/local/radiance" if os == "macosx"
FileUtils.rm_rf("./IGD_Groundhog/src/Radiance")
FileUtils.cp_r radiance_version, "./IGD_Groundhog/src/Radiance"
File.open("listfile.txt",'w'){|w|
w.puts "IGD_Groundhog.rb"
w.puts "IGD_Groundhog"
}
puts `7z a -tzip Groundhog_#{os}.rbz @listfile.txt -x!.yardoc -x!*.DS_Store`
FileUtils.rm "listfile.txt"
end
task :win64 => [:clean, :add_build_date, :compile_ui] do
compress("win64")
end
task :win32 => [:clean, :add_build_date, :compile_ui] do
compress("win32")
end
task :macosx => [:clean, :add_build_date, :compile_ui] do
compress("macosx")
end
task :add_build_date do
File.open("IGD_Groundhog/built",'w'){|file|
file.puts Time.now
}
end
@ui_src = "./ui-src"
def change_ui_version(version)
File.open("#{@ui_src}/ts/version.ts",'w'){ |f|
f.puts "export = '#{version}';"
}
end
def compile_ui(version)
return
change_ui_version(version)
warn `tsc --p #{@ui_src}`
warn `browserify #{@ui_src}/js/main.js --standalone DesignAssistant -o ./IGD_Groundhog/src/html/js/design_assistant_#{version}.js`
File.open("./IGD_Groundhog/src/html/design_assistant_#{version}.html",'w'){|file|
file.puts "<!DOCTYPE html>
<html>
<head>
<title>Design assistant</title>
<meta charset='UTF-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'/>
<link href='css/jquery-ui.css' rel='stylesheet'>
<link href='css/groundhog-ui.css' rel='stylesheet'>
<link rel='stylesheet' href='css/spectrum.css' />
</head>
<body>"
selected = "location"
sections = ["location","materials","luminaires","photosensors","objectives","calculate","report"] #"observers",
# Create the tabs
file.puts "<div id='sidenav'>"
sections.each{|section|
file.puts "<p #{selected == section ? "class = 'selected'" : ''} href='##{section}'>#{section.capitalize}</p>"
}
file.puts "</div>"
# add the actual sections
sections.each{|section|
file.puts File.readlines("#{@ui_src}/ts/#{section}/template.html")
}
file.puts "
<script src='js/JQuery/jquery-3.0.0.js'></script>
<script src='js/jQueryUI/jquery-ui.js'></script>
<script src='js/Spectrum/spectrum.js'></script>
<script src='js/groundhog-ui.js'></script>
<script src='js/design_assistant_#{version}.js'></script>
<script>
var DesignAssistant = new DesignAssistant();
DesignAssistant.update();
</script>
</body>
</html>
"
}
end
task :test_ui do
compile_ui("debug")
end
task :compile_ui do
["web_dialog"].each{|version|
compile_ui(version)
}
end