forked from gsscoder/commandline
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile.rb
More file actions
130 lines (112 loc) · 4.25 KB
/
Copy pathRakefile.rb
File metadata and controls
130 lines (112 loc) · 4.25 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
PRODUCT = "Command Line Parser Library"
DESCRIPTION = "The Command Line Parser Library offers to CLR applications a clean and concise API for manipulating command line arguments and related tasks."
VERSION = "1.9.71.2"
INF_VERSION = "1.9.71-stable"
AUTHOR = "Giacomo Stelluti Scala"
COPYRIGHT = "Copyright (c) 2005 - 2013 " + AUTHOR
LICENSE_URL = "https://raw.github.com/gsscoder/commandline/master/doc/LICENSE"
PROJECT_URL = "https://github.com/gsscoder/commandline"
require 'albacore'
task :default => [:build, :test]
if RUBY_VERSION =~ /^1\.8/
class Dir
class << self
def exists? (path)
File.directory?(path)
end
alias_method :exist?, :exists?
end
end
end
def is_nix
!RUBY_PLATFORM.match("linux|darwin").nil?
end
def to_win_path(nix_path)
nix_path.gsub("/", "\\")
end
def invoke_runtime(cmd)
command = cmd
if is_nix()
command = "mono --runtime=v4.0 #{cmd}"
end
command
end
CONFIGURATION = "Release"
BUILD_DIR = File.expand_path("build")
OUTPUT_DIR = "#{BUILD_DIR}/out"
SOURCE_DIR = File.expand_path("src")
NUGET_DIR = File.expand_path("nuget")
LIB_DIR = "#{SOURCE_DIR}/libcmdline"
PJ_OUTPUT_DIR ="#{LIB_DIR}/bin/Release"
LIB_ASM = "CommandLine.dll"
LIB_XML = "CommandLine.xml"
msbuild :build_msbuild do |b|
b.properties :configuration => CONFIGURATION, "OutputPath" => OUTPUT_DIR
b.targets :Build
b.solution = "CommandLine.sln"
end
task :build_mdtool do
mdtool = "mdtool build -c:#{CONFIGURATION} CommandLine.sln"
sh "#{mdtool}"
FileUtils.mkdir_p "#{OUTPUT_DIR}"
FileUtils.cp_r Dir.glob("#{SOURCE_DIR}/tests/bin/#{CONFIGURATION}/*"), "#{OUTPUT_DIR}"
end
#task :build35_mdtool do
# mdtool = "mdtool build -c:#{CONFIGURATION} src/libcmdline/CommandLine35.csproj"
# sh "#{mdtool}"
# FileUtils.mkdir_p "#{OUTPUT_DIR}/NET35"
# FileUtils.cp_r Dir.glob("#{SOURCE_DIR}/tests/bin/#{CONFIGURATION}/NET35/*"), "#{OUTPUT_DIR}/NET35"
#end
msbuild :build35_msbuild do |b|
b.properties :configuration => CONFIGURATION, "OutputPath" => "#{OUTPUT_DIR}/NET35"
b.targets :Build
b.solution = "src/libcmdline/CommandLine35.csproj"
end
task :build => :clean do |b|
build_task = is_nix() ? "build_mdtool" : "build_msbuild"
Rake::Task[build_task].invoke
end
task :test => :build do
xunit = invoke_runtime("packages/xunit.runners.1.9.1/tools/xunit.console.clr4.exe")
sh "#{xunit} #{OUTPUT_DIR}/CommandLine.Tests.dll"
end
assemblyinfo :assemblyinfo do |a|
a.product_name = PRODUCT
#a.description = DESCRIPTION
a.version = a.file_version = VERSION
a.copyright = COPYRIGHT
a.custom_attributes :AssemblyInformationalVersion => INF_VERSION, :NeutralResourcesLanguage => "en-US"
a.output_file = "src/SharedAssemblyInfo.cs"
a.namespaces "System.Resources"
end
nuspec :nuget_nuspec do |nuspec|
nuspec.id = "CommandLineParser"
nuspec.version = INF_VERSION.end_with?("stable") ? VERSION[0..-3] : INF_VERSION
nuspec.authors = AUTHOR
nuspec.owners = AUTHOR
nuspec.description = DESCRIPTION
nuspec.title = PRODUCT
nuspec.projectUrl = PROJECT_URL
nuspec.licenseUrl = LICENSE_URL
nuspec.requireLicenseAcceptance = "false"
nuspec.copyright = COPYRIGHT
nuspec.tags = "command line argument option parser parsing library syntax shell"
nuspec.iconUrl = "https://github.com/gsscoder/commandline/raw/master/art/CommandLine.png"
nuspec.file to_win_path("#{PJ_OUTPUT_DIR}/NET35/#{LIB_ASM}"), to_win_path("lib/net35/#{LIB_ASM}")
nuspec.file to_win_path("#{PJ_OUTPUT_DIR}/NET35/#{LIB_XML}"), to_win_path("lib/net35/#{LIB_XML}")
nuspec.file to_win_path("#{PJ_OUTPUT_DIR}/#{LIB_ASM}"), to_win_path("lib/net40/#{LIB_ASM}")
nuspec.file to_win_path("#{PJ_OUTPUT_DIR}/#{LIB_XML}"), to_win_path("lib/net40/#{LIB_XML}")
nuspec.file to_win_path("#{PJ_OUTPUT_DIR}/#{LIB_ASM}"), to_win_path("lib/net45/#{LIB_ASM}")
nuspec.file to_win_path("#{PJ_OUTPUT_DIR}/#{LIB_XML}"), to_win_path("lib/net45/#{LIB_XML}")
nuspec.file to_win_path("#{NUGET_DIR}/readme.txt"), "readme.txt"
nuspec.output_file = "#{NUGET_DIR}/CommandLine.nuspec"
end
task :clean do
FileUtils.rm_rf BUILD_DIR
FileUtils.rm_rf "src/libcmdline/bin"
FileUtils.rm_rf "src/libcmdline/obj"
FileUtils.rm_rf "src/tests/bin"
FileUtils.rm_rf "src/tests/obj"
FileUtils.rm_rf "src/demo/bin"
FileUtils.rm_rf "src/demo/obj"
end