-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 97d4fc3
Showing
8 changed files
with
694 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
* text | ||
|
||
*.bmp binary | ||
*.dll binary | ||
*.gif binary | ||
*.jpg binary | ||
*.png binary | ||
*.snk binary | ||
*.exe binary | ||
|
||
*.ascx text | ||
*.cd text | ||
*.cmd text | ||
*.coffee text | ||
*.config text | ||
*.cs text diff=csharp | ||
*.csproj text merge=union | ||
*.cshtml text | ||
*.css text | ||
*.dtd text | ||
*.edmx text | ||
*.htm text | ||
*.html text | ||
*.js text | ||
*.json text | ||
*.msbuild text | ||
*.nuspec text | ||
*.resx text | ||
*.ruleset text | ||
*.StyleCop text | ||
*.targets text | ||
*.tt text | ||
*.txt text | ||
*.vb text | ||
*.vbhtml text | ||
*.vbproj text merge=union | ||
*.vbs text | ||
*.wsf text | ||
*.xml text | ||
*.xunit text | ||
|
||
*.sln text eol=crlf merge=union |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# build-scripts | ||
|
||
Collection of rake tasks used during build. | ||
|
||
## Code of conduct | ||
Everyone interacting in the Open Systems Pharmacology community (codebases, issue trackers, chat rooms, mailing lists etc...) is expected to follow the Open Systems Pharmacology [code of conduct](https://github.com/Open-Systems-Pharmacology/Suite/blob/master/CODE_OF_CONDUCT.md). | ||
|
||
## Contribution | ||
We encourage contribution to the Open Systems Pharmacology community. Before getting started please read the [contribution guidelines](https://github.com/Open-Systems-Pharmacology/Suite/blob/master/CONTRIBUTING.md). If you are contributing code, please be familiar with the [coding standard](https://github.com/Open-Systems-Pharmacology/Suite/blob/master/CODING_STANDARD.md). | ||
|
||
## License | ||
build-scripts is released under the [GPLv2 License](LICENSE). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
class String | ||
# colorization | ||
def colorize(color_code) | ||
"\e[#{color_code}m#{self}\e[0m" | ||
end | ||
|
||
def red | ||
colorize(31) | ||
end | ||
|
||
def green | ||
colorize(32) | ||
end | ||
|
||
def yellow | ||
colorize(33) | ||
end | ||
|
||
def blue | ||
colorize(34) | ||
end | ||
|
||
def pink | ||
colorize(35) | ||
end | ||
|
||
def light_blue | ||
colorize(36) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
require 'fileutils' | ||
require_relative 'colorize' | ||
|
||
#DSL to allow copying files defined under source_dir into target_dir | ||
#Example: | ||
# => copy_dependencies source_dir, target_dir do | ||
# => copy_file 'native', 'dll' | ||
# => copy_native_dll | ||
# => end | ||
|
||
def copy_depdencies(source_dir, target_dir, &block) | ||
dependecyManager = DependencyManager.new(source_dir, target_dir) | ||
dependecyManager.instance_eval(&block) | ||
dependecyManager.perform_file_copy | ||
end | ||
|
||
class DependencyManager | ||
def initialize(source_dir, target_dir) | ||
@source_dir = source_dir; | ||
@target_dir = target_dir; | ||
end | ||
|
||
def dependencies | ||
@dependencies ||= [] | ||
end | ||
|
||
#copy files defined by file filters relative to source_dir | ||
#Example: | ||
# => copy_file '**/native/*.dll' | ||
def copy_file(*filters) | ||
add_dep filters.map{|filter| File.join(@source_dir, filter)} | ||
end | ||
|
||
#copy files with file_extensions (either single or array) | ||
#Example: | ||
# => copy_files 'native', ['dll', 'lib'] | ||
# This call is equivalent to | ||
# => copy_file '**/native/**/*.dll' | ||
# => copy_file '**/native/**/*.lib' | ||
def copy_files(subfolder, file_extensions) | ||
retrieve_file_extensions(file_extensions) do |file_extension| | ||
copy_file File.join('**', subfolder,'**', "*.#{file_extension}") | ||
end | ||
end | ||
|
||
#DSL internal method only called at the end of the copy_dependencies process | ||
#See http://ruby-doc.org/core-1.9.3/Dir.html#method-c-glob for glob documentation | ||
def perform_file_copy | ||
retrieve_target_dir do |target_dir| | ||
FileUtils.mkdir_p target_dir | ||
copy_depdencies_to target_dir | ||
end | ||
end | ||
|
||
#Allow for meta programming and supports method starting with copy and having two sub parameters | ||
#Example: | ||
# => copy_native_dll | ||
# => copy_native_lib | ||
def method_missing(method_name, *args) | ||
match = method_name.to_s.match(/^copy_(\w+)_(\w+)/) | ||
if(match) | ||
copy_files match[1], match[2] | ||
else | ||
super | ||
end | ||
end | ||
|
||
private | ||
|
||
def copy_depdencies_to(target_dir) | ||
dependencies.each do |dep| | ||
Dir.glob(dep).each do |f| | ||
puts "Copying #{f} to #{target_dir}".green | ||
FileUtils.copy f, target_dir | ||
end | ||
end | ||
end | ||
|
||
def add_dep(dependencies_to_add) | ||
dependencies_to_add.each {|dep| dependencies << dep} | ||
end | ||
|
||
def retrieve_file_extensions(file_extensions,&block) | ||
yield_to_block file_extensions, &block | ||
end | ||
|
||
def retrieve_target_dir(&block) | ||
yield_to_block @target_dir, &block | ||
end | ||
|
||
def yield_to_block(params, &block) | ||
if(params.respond_to? :each) | ||
params.each(&block) | ||
else | ||
yield params | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
require 'securerandom' | ||
require_relative 'utils' | ||
require_relative 'wix' | ||
|
||
namespace :setup do | ||
desc "Performs the required steps to create a setup" | ||
task :create, [:src_dir, :setup_dir, :deploy_dir, :product_name, :product_version, :harvest_ignored_files, :suite_name, :setup_files, :solution_dir, :manufacturer] do |task, args| | ||
@deploy_dir = File.join(args.setup_dir, 'deploy'); | ||
@harvest_dir = File.join(@deploy_dir, 'harvest'); | ||
@product_version = args.product_version | ||
@product_name = args.product_name | ||
@manufacturer = args.manufacturer | ||
@suite_name = args.suite_name | ||
@harvest_ignored_files = args.harvest_ignored_files || [] | ||
@setup_files = args.setup_files || [] | ||
@solution_dir = args.solution_dir; | ||
|
||
create_deploy_dir | ||
copy_src_files args.src_dir | ||
|
||
harvest_app | ||
|
||
copy_setup_files args.setup_files | ||
Rake::Task['setup:create_setup'].invoke | ||
end | ||
|
||
desc "Creates the setup: requirement: all setup dependencies should have been copied to the deploy folder" | ||
task :create_setup => [:set_variables_for_setup, :run_light] | ||
|
||
desc "Copy the files required to launch the setup in the deploy folder." | ||
task :set_variables_for_setup do | ||
@variables = {} | ||
@variables[:ProductId] = Utils.uuid.to_s | ||
@variables[:DeployDir] = @deploy_dir | ||
@variables[:SuiteName] = @suite_name | ||
@variables[:ProductName] =@product_name | ||
@variables[:ProductVersion] = @product_version | ||
@variables[:Manufacturer] = @manufacturer | ||
release_version_split= @product_version.split('.') | ||
release_version = "#{release_version_split[0]}.#{release_version_split[1]}" | ||
@variables[:ProductReleaseVersion] = release_version | ||
@variables[:ProductFullName] = "#{@product_name} #{release_version}" | ||
end | ||
|
||
desc "Runs the candle executable as first step of the setup process" | ||
task :run_candle do | ||
all_wxs = Dir.glob("#{@deploy_dir}/*.wxs") | ||
all_variables = @variables.each.collect do |k, v| | ||
"-d#{k}=#{v}" | ||
end | ||
all_options = %W[-ext WixUIExtension -ext WixNetFxExtension -o #{@deploy_dir}/] | ||
Utils.run_cmd(Wix.candle, all_wxs + all_variables + all_options) | ||
end | ||
|
||
desc "Runs the light command that actually creates the msi package" | ||
task :run_light => [:run_candle] do | ||
all_wixobj = Dir.glob("#{@deploy_dir}/*.wixobj") | ||
all_options = %W[-o #{@deploy_dir}/#{@product_name}.#{@product_version}.msi -nologo -ext WixUIExtension -ext WixNetFxExtension -spdb -b #{@deploy_dir}/ -cultures:en-us] | ||
Utils.run_cmd(Wix.light, all_wixobj + all_options) | ||
end | ||
|
||
private | ||
def harvest_app | ||
@harvest_ignored_files.each do |file| | ||
FileUtils.rm File.join(@harvest_dir, file) | ||
end | ||
|
||
Rake::Task[:heat].execute OpenStruct.new(source_directory: @harvest_dir, component_name: 'App', output_dir: @deploy_dir) | ||
end | ||
|
||
def create_deploy_dir | ||
FileUtils.rm_rf @deploy_dir | ||
FileUtils.mkdir_p @deploy_dir | ||
FileUtils.mkdir_p @harvest_dir | ||
end | ||
|
||
def copy_src_files(src_dir) | ||
src_files = File.join(src_dir, '*.*') | ||
copy_to_deploy_dir src_files | ||
copy_to_target_dir src_files, @harvest_dir, %w[pdb, xml] | ||
end | ||
|
||
def copy_setup_files(setup_files) | ||
setup_files.each do |file| | ||
copy_to_deploy_dir File.join(@solution_dir, file) | ||
end | ||
end | ||
|
||
def copy_to_deploy_dir(source) | ||
copy_to_target_dir source, @deploy_dir | ||
end | ||
|
||
def copy_to_target_dir(source, target_dir, ignored_extensions=[]) | ||
Dir.glob source do |file| | ||
copy file, target_dir, verbose: false unless file_should_be_ignored(file, ignored_extensions) | ||
end | ||
end | ||
|
||
def file_should_be_ignored(file, ignored_extensions) | ||
ignored_extensions.any? { |ext| file.include? ext } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
require 'securerandom' | ||
|
||
module Utils | ||
def self.update_go_diagram_license(file, license) | ||
replacement = { | ||
'{Environment.GetEnvironmentVariable("GO_DIAGRAM_KEY")}' => license | ||
} | ||
|
||
Dir.glob("./**/#{file}").each do |f| | ||
replace_tokens replacement, f | ||
end | ||
end | ||
|
||
def self.replace_tokens(replacement,file) | ||
content = File.read(file) | ||
|
||
replacement.each do |token,value| | ||
content.gsub!(token,value) if value | ||
end | ||
|
||
File.open(file, "w") { |f| f.write content } | ||
end | ||
|
||
def self.run_cmd(command, command_line) | ||
Rake::Task[:run_cmd].execute(OpenStruct.new(:command => command, :command_line => command_line)) | ||
end | ||
|
||
def self.uuid | ||
SecureRandom.uuid | ||
end | ||
|
||
def self.join(path1, path2) | ||
File.join(path1,path2).tr '/', '\\' | ||
end | ||
end | ||
|
||
task :run_cmd, [:command, :command_line] do |cmd, args| | ||
sh(args.command, *args.command_line) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require_relative 'utils' | ||
|
||
module Wix | ||
def self.heat | ||
Utils.join(wix_bin,'heat.exe') | ||
end | ||
|
||
def self.candle | ||
Utils.join( wix_bin,'candle.exe') | ||
end | ||
|
||
def self.light | ||
Utils.join( wix_bin,'light.exe') | ||
end | ||
|
||
def self.wix_bin | ||
Utils.join(ENV['WIX'] || 'C:/Program Files (x86)/WiX Toolset v3.10', 'bin') | ||
end | ||
end | ||
|
||
|
||
desc "Create a wxs package." | ||
task :heat, [:source_directory, :component_name, :output_dir, :install_dir] do |t, args| | ||
raise "Source directory missing. Use format heat[source_directory, component_name]" unless args.source_directory | ||
raise "Component name is missing. Use format heat[source_directory, component_name]" unless args.component_name | ||
output_dir = args.output_dir || args.source_directory | ||
output = File.join(output_dir, args.component_name + '.wxs') | ||
install_dir = args.install_dir || 'INSTALLDIR' | ||
command_line = %W[dir #{args.source_directory} -cg #{args.component_name} -dr #{install_dir} -gg -scom -srd -sreg -out #{output}] | ||
|
||
Utils.run_cmd(Wix.heat, command_line) | ||
|
||
replacement = {'SourceDir' => '$(var.DeployDir)'}; | ||
Utils.replace_tokens replacement, output | ||
end |