-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathrakefile.rb
More file actions
211 lines (173 loc) · 6.01 KB
/
Copy pathrakefile.rb
File metadata and controls
211 lines (173 loc) · 6.01 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
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
require_relative 'scripts/setup'
require_relative 'scripts/copy-dependencies'
require_relative 'scripts/utils'
require_relative 'scripts/coverage'
require_relative 'src/Db/db'
require 'ostruct'
task :cover do
filter = []
filter << "+[PKSim.Core]*"
filter << "+[PKSim.Assets]*"
filter << "+[PKSim.Presentation]*"
filter << "+[PKSim.Infrastructure]*"
#exclude namespaces that are tested from applications
# filter << "-[OSPSuite.Infrastructure.Serialization]OSPSuite.Infrastructure.Serialization.ORM*"
# filter << "-[OSPSuite.Presentation]OSPSuite.Presentation.MenuAndBars*"
# filter << "-[OSPSuite.Presentation]OSPSuite.Presentation.Presenters.ContextMenus*"
targetProjects = [
"PKSim.Tests.csproj",
"PKSim.R.Tests.csproj",
"PKSim.UI.Tests.csproj",
];
Coverage.cover(filter, targetProjects)
end
task :create_setup, [:product_version, :configuration] do |t, args|
src_dir = src_dir_for(args.configuration)
relative_src_dir = relative_src_dir_for(args.configuration)
#Ignore files from automatic harvesting that will be installed specifically
harvest_ignored_files = [
'PKSim.exe',
'PKSimDB.sqlite',
'PKSimTemplateDBSystem.TemplateDBSystem',
'templates.json'
]
#Files required for setup creation only and that will not be harvested automatically
setup_files = [
"#{relative_src_dir}/ChartLayouts/**/*.{wxs,xml}",
"#{relative_src_dir}/TeXTemplates/**/*.*",
'examples/*.txt',
'src/PKSim.UI/Resources/*.ico',
'Open Systems Pharmacology Suite License.pdf',
'documentation/*.pdf',
'dimensions/*.xml',
'pkparameters/*.xml',
'setup/setup.wxs',
'setup/**/*.{msm,rtf,bmp}'
]
Rake::Task['setup:create'].execute(OpenStruct.new(
solution_dir: solution_dir,
src_dir: src_dir,
setup_dir: setup_dir,
product_name: product_name,
product_version: args.product_version,
harvest_ignored_files: harvest_ignored_files,
suite_name: suite_name,
setup_files: setup_files,
manufacturer: manufacturer
))
end
task :create_portable_setup, [:product_version, :configuration, :package_name] do |t, args|
src_dir = src_dir_for(args.configuration)
relative_src_dir = relative_src_dir_for(args.configuration)
# Copy folder structure so that the portable setups works as expected
FileUtils.mkdir_p setup_temp_dir
FileUtils.copy_entry File.join(src_dir, 'TeXTemplates'), File.join(setup_temp_dir, 'TeXTemplates')
FileUtils.copy_entry File.join(src_dir, 'ChartLayouts'), File.join(setup_temp_dir, 'ChartLayouts')
dst_dir = File.join(setup_temp_dir, 'runtimes', 'win-x64', 'native')
FileUtils.mkdir_p(dst_dir)
FileUtils.copy_entry File.join(src_dir, 'runtimes', 'win-x64', 'native'), dst_dir
#Files required for setup creation only and that will not be harvested automatically
setup_files = [
'Open Systems Pharmacology Suite License.pdf',
'documentation/*.pdf',
'dimensions/*.xml',
'pkparameters/*.xml',
'setup/**/*.{rtf}'
]
setup_folders = [
'examples/*.md',
"#{setup_temp_dir}/**/*.*",
]
Rake::Task['setup:create_portable'].execute(OpenStruct.new(
solution_dir: solution_dir,
src_dir: src_dir_for(args.configuration),
setup_dir: setup_dir,
product_name: product_name,
product_version: args.product_version,
suite_name: suite_name,
setup_files: setup_files,
setup_folders: setup_folders,
package_name: args.package_name,
))
end
task :create_local_nuget_r do
nuget_repo = "../OSPSuite.Core/nuget_repo"
FileUtils.rm_f Dir.glob("#{nuget_repo}/PKSim.*.nupkg")
version_id = "13.0.0-" + generate_code(5)
puts("Your PKSim version is " + version_id.red)
abort("dotnet pack failed") unless system("dotnet", "pack", "PKSim.sln", "--no-build", "--no-restore", "-o", nuget_repo, "-p:PackageVersion=" + version_id, "--configuration", "Debug")
update_ospsuite_r_pksim(version_id)
build_dependency_manager
end
task :update_go_license, [:file_path, :license] do |t, args|
Utils.update_go_diagram_license args.file_path, args.license
end
task :postclean do |t, args|
packages_dir = src_dir_for("Debug")
all_users_dir = ENV['ALLUSERSPROFILE']
all_users_application_dir = File.join(all_users_dir, manufacturer, product_name, '13.0')
copy_dependencies solution_dir, all_users_application_dir do
copy_dimensions_xml
copy_pkparameters_xml
end
copy_dependencies solution_dir, all_users_application_dir do
copy_file 'src/Db/PKSimDB.sqlite'
copy_file 'src/Db/TemplateDB/PKSimTemplateDBSystem.templateDBSystem'
end
copy_dependencies packages_dir, File.join(all_users_application_dir, 'ChartLayouts') do
copy_files 'ChartLayouts', 'xml'
end
copy_dependencies packages_dir, File.join(all_users_application_dir, 'TeXTemplates', 'StandardTemplate') do
copy_files 'StandardTemplate', '*'
end
end
task :db_pre_commit do
Rake::Task['db:dump'].execute();
Rake::Task['db:diff'].execute();
end
private
def relative_src_dir_for(configuration)
File.join( 'src', 'PKSim', 'bin', configuration, 'net10.0-windows')
end
def src_dir_for(configuration)
File.join(solution_dir, relative_src_dir_for(configuration))
end
def solution_dir
File.dirname(__FILE__)
end
def manufacturer
'Open Systems Pharmacology'
end
def product_name
'PK-Sim'
end
def suite_name
'Open Systems Pharmacology Suite'
end
def setup_dir
File.join(solution_dir, 'setup')
end
def setup_temp_dir
File.join(setup_dir, 'temp')
end
def generate_code(number)
charset = Array('A'..'Z') + Array('a'..'z')
Array.new(number) { charset.sample }.join
end
def find_token(file, regex)
file_content = File.read(file)
matches = file_content.match(regex)
return nil if matches.nil?
matches[1]
end
def update_ospsuite_r_pksim(version_id)
puts("updating OSPSuite-R with PKSim.R")
csproj = "../OSPSuite-R/shared/DependencyManager/src/DependencyManager.csproj"
token = find_token(csproj, /<PackageReference Include="PKSim.R" Version="([^"]*)"/)
return if token.nil?
Utils.replace_tokens({token => version_id}, csproj)
end
def build_dependency_manager
puts("building DependencyManager")
abort("dotnet build failed") unless system("dotnet", "build", "../OSPSuite-R/shared/DependencyManager/DependencyManager.sln", "--configuration", "Debug")
end