-
Notifications
You must be signed in to change notification settings - Fork 0
/
rakefile
executable file
·42 lines (35 loc) · 1.73 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
# You'll need to provide the following environment variables:
#
# FSHARP_COMPILER_EXE The path to fsc.exe.
# FSHARP_PROJECT The path to the Visual Studio fsproj file
# FSHARP_DLL The destination dll name (passed to fsc.exe as the -o option)
# MONO The location of mono. The default is "/Library/Frameworks/Mono.framework/Versions/2.4.2.3/bin/mono"
#
# Sample:
#
# rake FSHARP_PROJECT=/Users/jamesmoore/dev/FSharpEvents/FSharpEvents/FSharpEvents.fsproj FSHARP_COMPILER_EXE=/Users/jamesmoore/dev/FSharp-1.9.7.8/bin/fsc.exe FSHARP_DLL=fsharp.dll
require 'rubygems'
require 'nokogiri'
require 'rake/clean'
require 'pathname'
def extract_files_from_fsproj fsproj_filename
n = Nokogiri::XML File.open fsproj_filename
n.css('ItemGroup Compile').map { |i| i['Include'] }
end
visual_studio_project_file = ENV['FSHARP_PROJECT']
files = extract_files_from_fsproj visual_studio_project_file
files = files.map {|f| f.gsub('\\', '/')}
files = files.map {|f| Pathname.new(visual_studio_project_file).dirname + f}
current_directory = Pathname.new `pwd`
files = files.map {|f| f.relative_path_from(current_directory)}
files = files.map {|f| f.to_s}
fsharp = ENV["FSHARP_COMPILER_EXE"] || "fsc.exe"
monotouch_dll = ENV["MONOTOUCH_DLL_OPTION"] || "-r:/Developer/MonoTouch/usr/lib/mono/2.1/monotouch.dll"
fsharp_options = " --target:library --warn:3 --warnaserror:76 --noframework "
mono = ENV['MONO'] || "/Library/Frameworks/Mono.framework/Versions/2.4.2.3/bin/mono"
fsharp_src_files = FileList.new(*files)
combined_object_file = ENV["FSHARP_DLL"] || "fsharp.dll"
file combined_object_file => fsharp_src_files do |t|
sh "#{mono} #{fsharp} #{fsharp_options} #{monotouch_dll} -o #{combined_object_file} #{t.prerequisites.join " "}"
end
task :default => combined_object_file