forked from NREL/gbxml-to-openstudio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
88 lines (72 loc) · 3.87 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
require 'bundler'
require 'rake/testtask'
Bundler.setup
# DLM: this is needed if we want to use standards and workflow gem from bundle Gemfile rather than embedded
# we can remove these variables before calling the CLI in minitest_helper.rb to use the embedded CLI
if ENV['BUNDLE_GEMFILE']
if ENV['BUNDLE_PATH'].nil?
ENV['BUNDLE_PATH'] = ENV['GEM_HOME']
end
end
require 'rake'
require 'fileutils'
task default: 'test'
Rake::TestTask.new do |t|
t.pattern = "test/gbxml_hvac_import/test*.rb"
end
desc 'Build Installer'
task :build_installer do
require 'fileutils'
root_dir = File.join(File.dirname(__FILE__))
staging_dir = File.join(root_dir, 'installer_staging')
os_install_dir = 'C:\openstudio-3.4.0'
openstudio_cli = File.join(os_install_dir, 'bin', 'openstudio.exe')
energyplus_dir = 'C:\EnergyPlusV22-1-0-python'
unless File.exists?(os_install_dir)
puts "#{os_install_dir} does not exist"
exit 1
end
FileUtils.rm_rf(staging_dir) if File.exists?(staging_dir)
FileUtils.mkdir_p(staging_dir)
FileUtils.cp(File.join(root_dir, 'CHANGELOG.md'), File.join(staging_dir, 'CHANGELOG.md'))
FileUtils.mkdir_p(File.join(staging_dir, 'bin'))
FileUtils.cp(openstudio_cli, File.join(staging_dir, 'bin', 'openstudio.exe'))
FileUtils.cp(File.join(os_install_dir, 'bin', 'concrt140.dll'), File.join(staging_dir, 'bin', 'concrt140.dll'))
FileUtils.cp(File.join(os_install_dir, 'bin', 'msvcp140.dll'), File.join(staging_dir, 'bin', 'msvcp140.dll'))
FileUtils.cp(File.join(os_install_dir, 'bin', 'msvcp140_1.dll'), File.join(staging_dir, 'bin', 'msvcp140_1.dll'))
FileUtils.cp(File.join(os_install_dir, 'bin', 'msvcp140_2.dll'), File.join(staging_dir, 'bin', 'msvcp140_2.dll'))
FileUtils.cp(File.join(os_install_dir, 'bin', 'msvcp140_codecvt_ids.dll'), File.join(staging_dir, 'bin', 'msvcp140_codecvt_ids.dll'))
FileUtils.cp(File.join(os_install_dir, 'bin', 'vcruntime140.dll'), File.join(staging_dir, 'bin', 'vcruntime140.dll'))
FileUtils.cp(File.join(os_install_dir, 'bin', 'vcruntime140_1.dll'), File.join(staging_dir, 'bin', 'vcruntime140_1.dll'))
FileUtils.mkdir_p(File.join(staging_dir, 'EnergyPlus'))
(%w[Energy+.idd Energy+.schema.epJSON energyplus.exe energyplusapi.dll ExpandObjects.exe] +
Dir.glob('api-ms*.dll', base: energyplus_dir) +
Dir.glob('msvc*.dll', base: energyplus_dir) +
Dir.glob('ucrt*.dll', base: energyplus_dir) +
Dir.glob('vcomp*.dll', base: energyplus_dir) +
Dir.glob('vcruntime*.dll', base: energyplus_dir)
).each { |f| FileUtils.cp(File.join(energyplus_dir, f), File.join(staging_dir, 'EnergyPlus', f)) }
FileUtils.cp_r(File.join(energyplus_dir, 'pyenergyplus'), File.join(staging_dir, 'EnergyPlus', 'pyenergyplus'))
FileUtils.cp_r(File.join(root_dir, 'measures'), File.join(staging_dir, 'measures'))
FileUtils.cp_r(File.join(root_dir, 'seeds'), File.join(staging_dir, 'seeds'))
FileUtils.cp_r(File.join(root_dir, 'weather'), File.join(staging_dir, 'weather'))
FileUtils.cp_r(File.join(root_dir, 'workflows'), File.join(staging_dir, 'workflows'))
FileUtils.rm(File.join(staging_dir, 'workflows', 'RegressionTesting.osw'))
# TODO: update copyright on measures, see openstudio-measures repo for example
# TODO: need to add a license and copyright to this repo, install those as well
# TODO: run MSI creation script
# TODO: sign and version MSI
end
desc 'Update measure.xml files in measure directory'
task :update_measure_xmls do
require 'fileutils'
require 'openstudio'
puts 'Updating measure.xml for all measures in the repository.'
# get measures in repo
measures_directory = File.join(File.dirname(__FILE__), 'measures')
# run OpenStudio command line measure update for measures directory
cli_path = OpenStudio.getOpenStudioCLI
cmd = "\"#{cli_path}\" measure --update_all \"#{measures_directory}\""
system(cmd)
puts "Updated measure.xml files for measures in measure directory (#{measures_directory})"
end