skipjack 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG +2 -0
- data/lib/skipjack/fsharp.rb +19 -4
- data/lib/skipjack/version.rb +1 -1
- data/skipjack.gemspec +1 -0
- data/spec/helpers.rb +10 -1
- data/spec/lib/skipjack/fsharp_spec.rb +47 -2
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 346e360f1203eaf442ccdbc7fd11459aaf177401
|
4
|
+
data.tar.gz: e219ec7484e6a1d6360bbf1cd60abae841a600bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f6ff2ad0d53c0d85b118be1a4637fa80f25c2a2bbd3f33ce95f8ee076b6380044ed86ae6bb3b44af85a509273183edd7d29015c3b6adb10819b7bf9f8c53d48
|
7
|
+
data.tar.gz: c740d7eb3781a01e22127aadb5b683e5d7cf5748a29d9b845b48faede73a933cb66be2f187634230d66e3d9985c6de65b1f38d629c66ea1669493263a783ad0b
|
data/CHANGELOG
ADDED
data/lib/skipjack/fsharp.rb
CHANGED
@@ -2,6 +2,7 @@ module Skipjack
|
|
2
2
|
class FSharpCompiler
|
3
3
|
attr_reader :target
|
4
4
|
attr_accessor :output_folder, :output_file
|
5
|
+
attr_writer :references
|
5
6
|
|
6
7
|
def initialize *args
|
7
8
|
@args = *args
|
@@ -21,20 +22,34 @@ module Skipjack
|
|
21
22
|
@source_files ||= []
|
22
23
|
end
|
23
24
|
|
24
|
-
def
|
25
|
-
|
25
|
+
def references
|
26
|
+
@references ||= []
|
27
|
+
end
|
28
|
+
|
29
|
+
def create_file_task
|
30
|
+
output_file_name = output_folder ? "#{output_folder}/#{output_file}" : output_file
|
31
|
+
dependencies = source_files
|
32
|
+
file_task = Rake::FileTask::define_task output_file_name => dependencies do |t|
|
26
33
|
if t.application.windows?
|
27
34
|
compiler = "fsc"
|
28
35
|
else
|
29
36
|
compiler = "fsharpc"
|
30
37
|
end
|
31
38
|
|
32
|
-
out =
|
39
|
+
out = "--out:#{output_file_name}"
|
33
40
|
src = source_files.join(" ")
|
34
|
-
|
41
|
+
refs = references.each {|r| r.prepend("--reference:") }
|
42
|
+
refs = refs.join(" ")
|
43
|
+
cmd = "#{compiler} #{refs} #{out} --target:#{target.to_s} #{src}"
|
35
44
|
raise "Error executing command" unless Kernel.system cmd
|
36
45
|
end
|
37
46
|
end
|
47
|
+
|
48
|
+
def create_task
|
49
|
+
task = Rake::Task::define_task *@args
|
50
|
+
file_task = create_file_task
|
51
|
+
task.enhance [file_task]
|
52
|
+
end
|
38
53
|
end
|
39
54
|
end
|
40
55
|
|
data/lib/skipjack/version.rb
CHANGED
data/skipjack.gemspec
CHANGED
data/spec/helpers.rb
CHANGED
@@ -5,7 +5,7 @@ module Helpers
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def expect_system_call
|
8
|
-
|
8
|
+
allow(Kernel).to receive(:system) do |args|
|
9
9
|
result = yield args
|
10
10
|
if result.nil? then
|
11
11
|
true
|
@@ -29,6 +29,7 @@ module Helpers
|
|
29
29
|
class CompilerOptions
|
30
30
|
attr_accessor :executable, :target, :out
|
31
31
|
attr_writer :source_files
|
32
|
+
attr_writer :references
|
32
33
|
|
33
34
|
def initialize
|
34
35
|
yield self if block_given?
|
@@ -37,6 +38,10 @@ module Helpers
|
|
37
38
|
def source_files
|
38
39
|
@source_files ||= []
|
39
40
|
end
|
41
|
+
|
42
|
+
def references
|
43
|
+
@reference ||= []
|
44
|
+
end
|
40
45
|
end
|
41
46
|
|
42
47
|
def parse_cmd cmd
|
@@ -54,6 +59,10 @@ module Helpers
|
|
54
59
|
c.out = m[1]
|
55
60
|
end
|
56
61
|
|
62
|
+
cmd.scan(/--reference:([^ ]*)/) do |m|
|
63
|
+
c.references << m[0]
|
64
|
+
end
|
65
|
+
|
57
66
|
c.source_files = args.select { |f| f[0] != '-' }
|
58
67
|
end
|
59
68
|
end
|
@@ -1,7 +1,10 @@
|
|
1
|
+
require 'fakefs/spec_helpers'
|
2
|
+
|
1
3
|
describe 'fsharp' do
|
4
|
+
include FakeFS::SpecHelpers
|
5
|
+
|
2
6
|
before :each do |example|
|
3
|
-
@app = Rake::Application.new
|
4
|
-
Rake.application = @app
|
7
|
+
@app = Rake.application = Rake::Application.new
|
5
8
|
|
6
9
|
# mock if we are running windows or not
|
7
10
|
windows = example.metadata[:windows]
|
@@ -25,6 +28,7 @@ describe 'fsharp' do
|
|
25
28
|
|
26
29
|
let :options do
|
27
30
|
invoke_fsc_task do |t|
|
31
|
+
t.output_file = "dummy.exe" # in case test doesn't set one up
|
28
32
|
@setup.call(t) if @setup
|
29
33
|
end
|
30
34
|
@opts
|
@@ -42,6 +46,18 @@ describe 'fsharp' do
|
|
42
46
|
end
|
43
47
|
end
|
44
48
|
|
49
|
+
describe "--reference: argument" do
|
50
|
+
before do |ex|
|
51
|
+
@setup = lambda do |t|
|
52
|
+
t.references = ["ref1.dll", "ref2.dll"]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
subject { options.references }
|
57
|
+
|
58
|
+
it { should eq ["ref1.dll", "ref2.dll"] }
|
59
|
+
end
|
60
|
+
|
45
61
|
describe "--target: argument" do
|
46
62
|
before do |ex|
|
47
63
|
@setup = lambda do |t|
|
@@ -63,6 +79,8 @@ describe 'fsharp' do
|
|
63
79
|
describe "source files" do
|
64
80
|
it "contains the passed sources" do
|
65
81
|
sources = ["source1.fs", "source2.fs"]
|
82
|
+
FileUtils.touch "source1.fs"
|
83
|
+
FileUtils.touch "source2.fs"
|
66
84
|
@setup = lambda do |t|
|
67
85
|
t.source_files = sources
|
68
86
|
end
|
@@ -88,6 +106,33 @@ describe 'fsharp' do
|
|
88
106
|
expect(options.out).to eq("p.exe")
|
89
107
|
end
|
90
108
|
end
|
109
|
+
|
110
|
+
describe "build optimization" do
|
111
|
+
context "build output is older than source files" do
|
112
|
+
it "calls the compiler", :focus => true do
|
113
|
+
FileUtils.touch('./p.exe')
|
114
|
+
FileUtils.touch('s.fs')
|
115
|
+
@setup = lambda do |t|
|
116
|
+
t.target = :exe
|
117
|
+
t.output_file = "p.exe"
|
118
|
+
t.source_files = ["s.fs"]
|
119
|
+
end
|
120
|
+
expect(options).to_not be_nil
|
121
|
+
end
|
122
|
+
end
|
123
|
+
context "build output is newer than source files" do
|
124
|
+
it "does not call the compiler", :focus => true do
|
125
|
+
FileUtils.touch('s.fs')
|
126
|
+
FileUtils.touch('./p.exe')
|
127
|
+
@setup = lambda do |t|
|
128
|
+
t.target = :exe
|
129
|
+
t.output_file = "p.exe"
|
130
|
+
t.source_files = ["s.fs"]
|
131
|
+
end
|
132
|
+
expect(options).to be_nil
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
91
136
|
end
|
92
137
|
|
93
138
|
describe "target type" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: skipjack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Strøiman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: fakefs
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rake
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -91,6 +105,7 @@ files:
|
|
91
105
|
- .gitignore
|
92
106
|
- .rspec
|
93
107
|
- .travis.yml
|
108
|
+
- CHANGELOG
|
94
109
|
- Gemfile
|
95
110
|
- Guardfile
|
96
111
|
- LICENSE
|