buildr-hx 0.0.17.pre → 0.0.18.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -3
- data/Gemfile.lock +9 -4
- data/VERSION +1 -1
- data/buildr-hx.gemspec +21 -1
- data/buildr-hx.iml +5 -2
- data/lib/buildr/hx/compiler/haxe_compiler_base.rb +131 -0
- data/lib/buildr/hx/compiler/hxas3.rb +16 -0
- data/lib/buildr/hx/compiler/hxcpp.rb +16 -0
- data/lib/buildr/hx/compiler/hxjs.rb +18 -0
- data/lib/buildr/hx/compiler/hxlib.rb +27 -0
- data/lib/buildr/hx/compiler/hxneko.rb +18 -0
- data/lib/buildr/hx/compiler/hxphp.rb +16 -0
- data/lib/buildr/hx/compiler/hxswf.rb +25 -0
- data/lib/buildr/hx/compiler/hxxml.rb +18 -0
- data/lib/buildr/hx/compiler.rb +40 -0
- data/lib/buildr/hx/core/haxe_lib.rb +64 -0
- data/lib/buildr/hx/core.rb +1 -0
- data/lib/buildr/hx/packaging/haxelib.rb +84 -0
- data/lib/buildr/hx/packaging/hxlib.rb +78 -0
- data/lib/buildr/hx/packaging.rb +27 -0
- data/lib/buildr/hx/test/base.rb +25 -0
- data/lib/buildr/hx/test/munit.rb +85 -0
- data/lib/buildr/hx/test.rb +4 -0
- data/lib/buildr/hx.rb +6 -0
- data/spec/hx/compiler/hxswf_spec.rb +9 -0
- data/spec/spec_helper.rb +1 -1
- metadata +22 -2
data/Gemfile
CHANGED
@@ -3,13 +3,14 @@ source "http://rubygems.org"
|
|
3
3
|
# Example:
|
4
4
|
# gem "activesupport", ">= 2.3.5"
|
5
5
|
|
6
|
+
gem "buildr", "~> 1.4.6"
|
7
|
+
|
6
8
|
# Add dependencies to develop your gem here.
|
7
9
|
# Include everything needed to run rake, tests, features, etc.
|
8
10
|
group :development do
|
9
|
-
gem "buildr", "~> 1.4.6"
|
10
11
|
gem "shoulda", ">= 0"
|
11
|
-
gem "bundler", "~> 1.
|
12
|
-
gem "jeweler", "~> 1.
|
12
|
+
gem "bundler", "~> 1.1.3"
|
13
|
+
gem "jeweler", "~> 1.8.3"
|
13
14
|
gem "simplecov", :require => false
|
14
15
|
gem "simplecov-rcov", :require => false
|
15
16
|
gem "rspec", "~> 2.1.0"
|
data/Gemfile.lock
CHANGED
@@ -31,10 +31,12 @@ GEM
|
|
31
31
|
hoe (2.3.3)
|
32
32
|
rake (>= 0.8.7)
|
33
33
|
rubyforge (>= 1.0.4)
|
34
|
-
jeweler (1.
|
35
|
-
bundler (~> 1.0
|
34
|
+
jeweler (1.8.3)
|
35
|
+
bundler (~> 1.0)
|
36
36
|
git (>= 1.2.5)
|
37
37
|
rake
|
38
|
+
rdoc
|
39
|
+
json (1.6.6)
|
38
40
|
json_pure (1.4.3)
|
39
41
|
minitar (0.5.3)
|
40
42
|
multi_json (1.0.3)
|
@@ -42,6 +44,8 @@ GEM
|
|
42
44
|
net-ssh (>= 2.0.9)
|
43
45
|
net-ssh (2.0.23)
|
44
46
|
rake (0.8.7)
|
47
|
+
rdoc (3.12)
|
48
|
+
json (~> 1.4)
|
45
49
|
rjb (1.3.3)
|
46
50
|
rspec (2.1.0)
|
47
51
|
rspec-core (~> 2.1.0)
|
@@ -65,12 +69,13 @@ GEM
|
|
65
69
|
|
66
70
|
PLATFORMS
|
67
71
|
ruby
|
72
|
+
x86-mingw32
|
68
73
|
|
69
74
|
DEPENDENCIES
|
70
75
|
buildr (~> 1.4.6)
|
71
|
-
bundler (~> 1.
|
76
|
+
bundler (~> 1.1.3)
|
72
77
|
ci_reporter (~> 1.6.5)
|
73
|
-
jeweler (~> 1.
|
78
|
+
jeweler (~> 1.8.3)
|
74
79
|
rspec (~> 2.1.0)
|
75
80
|
shoulda
|
76
81
|
simplecov
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.18.pre
|
data/buildr-hx.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "buildr-hx"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.18.pre"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Dominic Graefen"]
|
@@ -26,10 +26,30 @@ Gem::Specification.new do |s|
|
|
26
26
|
"VERSION",
|
27
27
|
"buildr-hx.gemspec",
|
28
28
|
"buildr-hx.iml",
|
29
|
+
"lib/buildr/hx.rb",
|
30
|
+
"lib/buildr/hx/compiler.rb",
|
31
|
+
"lib/buildr/hx/compiler/haxe_compiler_base.rb",
|
32
|
+
"lib/buildr/hx/compiler/hxas3.rb",
|
33
|
+
"lib/buildr/hx/compiler/hxcpp.rb",
|
34
|
+
"lib/buildr/hx/compiler/hxjs.rb",
|
35
|
+
"lib/buildr/hx/compiler/hxlib.rb",
|
36
|
+
"lib/buildr/hx/compiler/hxneko.rb",
|
37
|
+
"lib/buildr/hx/compiler/hxphp.rb",
|
38
|
+
"lib/buildr/hx/compiler/hxswf.rb",
|
39
|
+
"lib/buildr/hx/compiler/hxxml.rb",
|
40
|
+
"lib/buildr/hx/core.rb",
|
41
|
+
"lib/buildr/hx/core/haxe_lib.rb",
|
42
|
+
"lib/buildr/hx/packaging.rb",
|
43
|
+
"lib/buildr/hx/packaging/haxelib.rb",
|
44
|
+
"lib/buildr/hx/packaging/hxlib.rb",
|
45
|
+
"lib/buildr/hx/test.rb",
|
46
|
+
"lib/buildr/hx/test/base.rb",
|
47
|
+
"lib/buildr/hx/test/munit.rb",
|
29
48
|
"rake/jeweler.rb",
|
30
49
|
"rake/jeweler_prerelease_tasks.rb",
|
31
50
|
"rake/pre_release_gemspec.rb",
|
32
51
|
"rake/pre_release_to_git.rb",
|
52
|
+
"spec/hx/compiler/hxswf_spec.rb",
|
33
53
|
"spec/sandbox.rb",
|
34
54
|
"spec/spec_helper.rb"
|
35
55
|
]
|
data/buildr-hx.iml
CHANGED
@@ -2,8 +2,11 @@
|
|
2
2
|
<module type="RUBY_MODULE" version="4">
|
3
3
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
4
4
|
<exclude-output />
|
5
|
-
<content url="file://$MODULE_DIR$"
|
6
|
-
|
5
|
+
<content url="file://$MODULE_DIR$">
|
6
|
+
<sourceFolder url="file://$MODULE_DIR$/lib" isTestSource="false" />
|
7
|
+
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
|
8
|
+
</content>
|
9
|
+
<orderEntry type="jdk" jdkName="ruby-1.9.2-p290" jdkType="RUBY_SDK" />
|
7
10
|
<orderEntry type="sourceFolder" forTests="false" />
|
8
11
|
</component>
|
9
12
|
</module>
|
@@ -0,0 +1,131 @@
|
|
1
|
+
module Buildr
|
2
|
+
module Haxe
|
3
|
+
module Compiler
|
4
|
+
class HaxeCompilerBase < Buildr::Compiler::Base
|
5
|
+
|
6
|
+
COMPILE_OPTIONS = [:warnings, :debug, :args, :main, :output, :hxml, :resources, :flags]
|
7
|
+
|
8
|
+
def initialize(project, options)
|
9
|
+
super
|
10
|
+
options[:debug] = Buildr.options.debug if options[:debug].nil?
|
11
|
+
options[:warnings] ||= true
|
12
|
+
end
|
13
|
+
|
14
|
+
def compile(sources, target, dependencies)
|
15
|
+
check_options options, COMPILE_OPTIONS
|
16
|
+
@output = get_output_file(target)
|
17
|
+
is_test = is_test?(sources, target, dependencies)
|
18
|
+
args = ["haxe"]
|
19
|
+
sources += @project.compile.sources.map(&:to_s) if is_test
|
20
|
+
args += generate_source_args sources
|
21
|
+
args += generate_dependency_args dependencies
|
22
|
+
args += base_compiler_args
|
23
|
+
args += compiler_args if respond_to? :compiler_args
|
24
|
+
unless Buildr.application.options.dryrun
|
25
|
+
create_hxml args, is_test
|
26
|
+
appwd = Dir.pwd
|
27
|
+
Dir.chdir @project.base_dir
|
28
|
+
fail("Compilation failed!") unless sh args.join " "
|
29
|
+
Dir.chdir appwd
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def needed?(sources, target, dependencies)
|
34
|
+
return true unless File.exist? get_output_file(target)
|
35
|
+
source_files = Dir.glob(sources.collect { |source| "#{source}/**/*" })
|
36
|
+
dep_files = dependencies.collect { |dep|
|
37
|
+
File.directory?(dep) ? Dir.glob("#{dep}/**/*") : dep
|
38
|
+
}.flatten
|
39
|
+
maxtime = (source_files + dep_files).collect { |file| File.stat(file).mtime }.max || Time.at(0)
|
40
|
+
maxtime > File.stat(get_output_file(target)).mtime
|
41
|
+
end
|
42
|
+
|
43
|
+
protected
|
44
|
+
|
45
|
+
def base_compiler_args #:nodoc:
|
46
|
+
args = []
|
47
|
+
args << "-main #{options[:main]}"
|
48
|
+
args << '-debug' if options[:debug]
|
49
|
+
args += options[:resources].map{|id,path| "-resource #{path}@#{id.to_s}"} unless options[:resources].nil?
|
50
|
+
args += options[:flags].map{|flag| "-D #{flag.to_s}"} unless options[:flags].nil?
|
51
|
+
args + Array(options[:args])
|
52
|
+
end
|
53
|
+
|
54
|
+
def generate_source_args sources
|
55
|
+
sources.collect { |source| "-cp #{source}" }
|
56
|
+
end
|
57
|
+
|
58
|
+
def generate_dependency_args dependencies
|
59
|
+
args = []
|
60
|
+
dependencies.each { |dep|
|
61
|
+
spec = HaxeLib.path_to_spec(dep)
|
62
|
+
if spec
|
63
|
+
args << "-lib #{spec[:id]}:#{spec[:version]}"
|
64
|
+
#elsif File.extname(dep) == ".zip" && Buildr.zip(dep).contain?("haxelib.xml")
|
65
|
+
# xml = Zip::ZipFile.open(dep) { |zip| zip.file.read("haxelib.xml") }
|
66
|
+
# require 'rexml/document'
|
67
|
+
# doc = REXML::Document.new(xml)
|
68
|
+
# id = doc.root.attribute("name")
|
69
|
+
# version = doc.root.elements['version'].attribute("name")
|
70
|
+
# fail "Could not install #{id}:#{version}." unless install_haxelib_zip dep
|
71
|
+
# args << "-lib #{id}:#{version}"
|
72
|
+
elsif File.extname(dep) == ".swf"
|
73
|
+
args << "-swf-lib #{dep}"
|
74
|
+
elsif File.extname(dep) == ".hxlib"
|
75
|
+
args += File.read(dep).split("\n").map{ |dep|
|
76
|
+
dep.start_with?("-cp") ? "-cp #{File.join(root_project_dir, dep.gsub("-cp ", "").strip )}" : dep
|
77
|
+
}
|
78
|
+
end
|
79
|
+
}
|
80
|
+
args
|
81
|
+
end
|
82
|
+
|
83
|
+
def install_haxelib_zip zip
|
84
|
+
system "haxelib test #{zip}"
|
85
|
+
end
|
86
|
+
|
87
|
+
def is_test?(sources, target, dependencies)
|
88
|
+
test_task = @project.test.compile
|
89
|
+
sources==test_task.sources && dependencies==test_task.dependencies.collect { |dep| dep.to_s } && target==test_task.target.to_s
|
90
|
+
end
|
91
|
+
|
92
|
+
def get_output_file target
|
93
|
+
file = "#{@project.name.split(":").last}.#{self.class.packaging.to_s}"
|
94
|
+
file = options[:output] unless options[:output].nil?
|
95
|
+
File.join(target.to_s, file)
|
96
|
+
end
|
97
|
+
|
98
|
+
def create_hxml( args, is_test )
|
99
|
+
file = File.join(@project.base_dir, options[:hxml] || is_test ? "test.hxml" : "compile.hxml")
|
100
|
+
puts "Creating hxml '#{file}'"
|
101
|
+
with_path = ["cp", "swf-lib", "swf", "js", "as3", "cpp", "neko", "xml", "swf9", "resource"].map{|p|"-#{p}"}
|
102
|
+
File.open(file, 'w') {|f| f.write(
|
103
|
+
args.reject{|a| a == "haxe"}.
|
104
|
+
map{|a|
|
105
|
+
cmd = a.split(" ").first
|
106
|
+
if with_path.include? cmd
|
107
|
+
path = a.gsub(cmd,"").strip
|
108
|
+
path, id = path.split("@") if cmd == "-resource"
|
109
|
+
path = relative_path(path,@project.base_dir)
|
110
|
+
entry = "#{cmd} #{path}"
|
111
|
+
id.nil? ? entry : entry + "@#{id}"
|
112
|
+
else
|
113
|
+
a
|
114
|
+
end
|
115
|
+
}.
|
116
|
+
join("\n")
|
117
|
+
) }
|
118
|
+
end
|
119
|
+
|
120
|
+
def relative_path path, from
|
121
|
+
Pathname.new(path).relative_path_from(Pathname.new(from)).to_s
|
122
|
+
end
|
123
|
+
|
124
|
+
def root_project_dir
|
125
|
+
Buildr.application.instance_eval { find_rakefile_location.last }
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Buildr
|
2
|
+
module Haxe
|
3
|
+
module Compiler
|
4
|
+
class HXJS < HaxeCompilerBase
|
5
|
+
|
6
|
+
specify :language => :haxe,
|
7
|
+
:sources => :hx, :source_ext => :hx,
|
8
|
+
:target_ext => "js",
|
9
|
+
:packaging => :js
|
10
|
+
|
11
|
+
def compiler_args
|
12
|
+
[ "-js #{@output}" ]
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
require "pathname"
|
3
|
+
|
4
|
+
module Buildr
|
5
|
+
module Haxe
|
6
|
+
module Compiler
|
7
|
+
class HXLib < HaxeCompilerBase
|
8
|
+
|
9
|
+
specify :language => :haxe,
|
10
|
+
:sources => :hx, :source_ext => :hx,
|
11
|
+
:packaging => :hxlib
|
12
|
+
|
13
|
+
def compile(sources, target, dependencies)
|
14
|
+
dependency_list = (generate_dependency_args(dependencies) + generate_source_args(sources)).
|
15
|
+
reject{|dep| !( dep.start_with?("-cp") || dep.start_with?("-lib") ) }.
|
16
|
+
map{ |dep|
|
17
|
+
dep.start_with?("-cp") ? "-cp #{relative_path( dep.gsub("-cp ", "").strip, root_project_dir )}" : dep
|
18
|
+
}
|
19
|
+
file = get_output_file(target)
|
20
|
+
FileUtils.mkdir_p File.dirname(file)
|
21
|
+
File.open(file, 'w') {|f| f.write( dependency_list.join("\n") ) }
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Buildr
|
2
|
+
module Haxe
|
3
|
+
module Compiler
|
4
|
+
class HXNeko < HaxeCompilerBase
|
5
|
+
|
6
|
+
specify :language => :haxe,
|
7
|
+
:sources => :hx, :source_ext => :hx,
|
8
|
+
:target_ext => "n",
|
9
|
+
:packaging => :n
|
10
|
+
|
11
|
+
def compiler_args
|
12
|
+
[ "-neko #{@output}" ]
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Buildr
|
2
|
+
module Haxe
|
3
|
+
module Compiler
|
4
|
+
class HXSWF < HaxeCompilerBase
|
5
|
+
|
6
|
+
specify :language => :haxe,
|
7
|
+
:sources => :hx, :source_ext => :hx,
|
8
|
+
:target_ext => "swf",
|
9
|
+
:packaging => :swf
|
10
|
+
|
11
|
+
COMPILE_OPTIONS << :swfversion << :swfheader << :flashstrict << :apparat
|
12
|
+
|
13
|
+
def compiler_args
|
14
|
+
args = []
|
15
|
+
args << "-swf #{@output}"
|
16
|
+
args << "-swf-version #{options[:swfversion]}"
|
17
|
+
args << "-swf-header #{options[:swfheader]}" unless options[:swfheader].nil?
|
18
|
+
args << "--flash-strict" if options[:flashstrict]
|
19
|
+
args
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Buildr
|
2
|
+
module Haxe
|
3
|
+
module Compiler
|
4
|
+
class HXXML < HaxeCompilerBase
|
5
|
+
|
6
|
+
specify :language => :haxe,
|
7
|
+
:sources => :hx, :source_ext => :hx,
|
8
|
+
:target_ext => "xml",
|
9
|
+
:packaging => :xml
|
10
|
+
|
11
|
+
def compiler_args
|
12
|
+
[ "-xml #{@output}" ]
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2011 by Dominic Graefen / http://devboy.org
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
#
|
22
|
+
|
23
|
+
require File.dirname(__FILE__) + '/compiler/haxe_compiler_base'
|
24
|
+
require File.dirname(__FILE__) + '/compiler/hxswf'
|
25
|
+
require File.dirname(__FILE__) + '/compiler/hxjs'
|
26
|
+
require File.dirname(__FILE__) + '/compiler/hxneko'
|
27
|
+
require File.dirname(__FILE__) + '/compiler/hxphp'
|
28
|
+
require File.dirname(__FILE__) + '/compiler/hxxml'
|
29
|
+
require File.dirname(__FILE__) + '/compiler/hxas3'
|
30
|
+
require File.dirname(__FILE__) + '/compiler/hxcpp'
|
31
|
+
require File.dirname(__FILE__) + '/compiler/hxlib'
|
32
|
+
|
33
|
+
Buildr::Compiler << Buildr::Haxe::Compiler::HXSWF
|
34
|
+
Buildr::Compiler << Buildr::Haxe::Compiler::HXJS
|
35
|
+
Buildr::Compiler << Buildr::Haxe::Compiler::HXNeko
|
36
|
+
Buildr::Compiler << Buildr::Haxe::Compiler::HXPHP
|
37
|
+
Buildr::Compiler << Buildr::Haxe::Compiler::HXXML
|
38
|
+
Buildr::Compiler << Buildr::Haxe::Compiler::HXAS3
|
39
|
+
Buildr::Compiler << Buildr::Haxe::Compiler::HXCPP
|
40
|
+
Buildr::Compiler << Buildr::Haxe::Compiler::HXLib
|
@@ -0,0 +1,64 @@
|
|
1
|
+
class HaxeLib < Rake::FileTask
|
2
|
+
class << self
|
3
|
+
def home
|
4
|
+
`haxelib config`.chomp
|
5
|
+
end
|
6
|
+
|
7
|
+
def spec_to_path spec
|
8
|
+
id, version = spec.split(":")
|
9
|
+
fail("No version number provided for haxelib '#{id}'!") if version.nil?
|
10
|
+
File.join( home, id, version.gsub(".",",") )
|
11
|
+
end
|
12
|
+
|
13
|
+
def path_to_spec path
|
14
|
+
id, version = path.gsub(home,"").split(File::SEPARATOR)
|
15
|
+
return nil unless id && version && path.include?(home)
|
16
|
+
{:id => id, :version => version.gsub(",",".")}
|
17
|
+
end
|
18
|
+
|
19
|
+
def lookup spec
|
20
|
+
id, version = spec.split(":")
|
21
|
+
task = HaxeLib.define_task( spec_to_path spec )
|
22
|
+
task.id = id
|
23
|
+
task.version = version
|
24
|
+
task
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
attr_accessor :id, :version
|
29
|
+
|
30
|
+
def initialize(*args)
|
31
|
+
super
|
32
|
+
enhance do |task|
|
33
|
+
task.enhance do
|
34
|
+
if download_needed?
|
35
|
+
info "Downloading #{to_spec}"
|
36
|
+
download
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def download
|
43
|
+
fail( "Could not download #{to_spec}") unless system "haxelib install #{id} #{version}"
|
44
|
+
end
|
45
|
+
|
46
|
+
def download_needed?
|
47
|
+
!File.exists?(name)
|
48
|
+
end
|
49
|
+
|
50
|
+
def to_spec
|
51
|
+
"#{id}:#{version}"
|
52
|
+
end
|
53
|
+
|
54
|
+
def to_spec_hash
|
55
|
+
{:id => @id, :version => @version}
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
module Buildr
|
61
|
+
def haxelib spec
|
62
|
+
HaxeLib.lookup(spec)
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/core/haxe_lib'
|
@@ -0,0 +1,84 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2011 by Dominic Graefen / http://devboy.org
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
#
|
22
|
+
|
23
|
+
require 'buildr'
|
24
|
+
require "fileutils"
|
25
|
+
|
26
|
+
module Buildr
|
27
|
+
module Haxe
|
28
|
+
module Packaging
|
29
|
+
include Extension
|
30
|
+
|
31
|
+
class HaxelibTask < Buildr::ZipTask
|
32
|
+
|
33
|
+
def initialize(*args) #:nodoc:
|
34
|
+
super
|
35
|
+
enhance do
|
36
|
+
include *@project.compile.sources.collect { |src| File.join(src, "**", "*") }
|
37
|
+
xml = @project._("haxelib.xml")
|
38
|
+
File.open(xml, 'w') {|f| f.write(haxelib_xml) }
|
39
|
+
include xml
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
attr_accessor :url, :license, :tags, :user
|
44
|
+
|
45
|
+
protected
|
46
|
+
|
47
|
+
def associate(project)
|
48
|
+
@project = project
|
49
|
+
end
|
50
|
+
|
51
|
+
def haxelib_xml
|
52
|
+
buffer =''
|
53
|
+
xml = Builder::XmlMarkup.new(:target=>buffer, :indent => 2)
|
54
|
+
xml.project(:name => @project.name.gsub(":","-"), :url => url, :license => license) do
|
55
|
+
xml.description @project.comment
|
56
|
+
xml.version(@project.version, :name => @project.version)
|
57
|
+
@tags.each { |tag| xml.tag :v => tag }
|
58
|
+
xml.user :name => @user
|
59
|
+
haxelib_dependencies.each{ |dep| xml.depends :name => dep[:id], :version => dep[:version] }
|
60
|
+
end
|
61
|
+
buffer
|
62
|
+
end
|
63
|
+
|
64
|
+
def haxelib_dependencies
|
65
|
+
haxelib_deps = []
|
66
|
+
@project.compile.dependencies.each{ |dep| haxelib_deps << dep.to_spec_hash if dep.is_a? HaxeLib }
|
67
|
+
haxelib_deps
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
def package_as_haxelib(file_name)
|
73
|
+
HaxelibTask.define_task(file_name).tap do |haxelib|
|
74
|
+
haxelib.send :associate, self
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def package_as_haxelib_spec(spec)
|
79
|
+
spec.merge :type=>:zip
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2011 by Dominic Graefen / http://devboy.org
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
#
|
22
|
+
|
23
|
+
require 'buildr'
|
24
|
+
require 'fileutils'
|
25
|
+
|
26
|
+
module Buildr
|
27
|
+
module AS3
|
28
|
+
module Packaging
|
29
|
+
|
30
|
+
class HxlibTask < Rake::FileTask
|
31
|
+
|
32
|
+
include Extension
|
33
|
+
|
34
|
+
attr_accessor :target_hxlib, :src_hxlib
|
35
|
+
|
36
|
+
def initialize(*args) #:nodoc:
|
37
|
+
super
|
38
|
+
enhance do
|
39
|
+
fail "File not found: #{src_hxlib}" unless File.exists? src_hxlib
|
40
|
+
FileUtils.cp(src_hxlib, target_hxlib)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def needed?
|
45
|
+
return true unless File.exists?(target_hxlib)
|
46
|
+
File.stat(src_hxlib).mtime > File.stat(target_hxlib).mtime
|
47
|
+
end
|
48
|
+
|
49
|
+
first_time do
|
50
|
+
desc 'create hxlib package task'
|
51
|
+
Project.local_task('package_hxlib')
|
52
|
+
end
|
53
|
+
|
54
|
+
before_define do |project|
|
55
|
+
HxlibTask.define_task('package_hxlib').tap do |package_hxlib|
|
56
|
+
package_hxlib
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
def package_hxlib(&block)
|
63
|
+
task("package_hxlib").enhance &block
|
64
|
+
end
|
65
|
+
|
66
|
+
protected
|
67
|
+
|
68
|
+
def package_as_hxlib(file_name)
|
69
|
+
fail("Package types don't match! :hxlib vs. :#{compile.packaging.to_s}") unless compile.packaging == :hxlib
|
70
|
+
HxlibTask.define_task(file_name).tap do |hxlib|
|
71
|
+
hxlib.src_hxlib = File.join(compile.target.to_s, compile.options[:output] || "#{project.name.split(":").last}.#{compile.packaging.to_s}")
|
72
|
+
hxlib.target_hxlib = file_name
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2011 by Dominic Graefen / http://devboy.org
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
#
|
22
|
+
require File.dirname(__FILE__)+"/packaging/haxelib"
|
23
|
+
require File.dirname(__FILE__)+"/packaging/hxlib"
|
24
|
+
|
25
|
+
class Buildr::Project
|
26
|
+
include Buildr::Haxe::Packaging
|
27
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'buildr'
|
2
|
+
|
3
|
+
module Buildr
|
4
|
+
module Haxe
|
5
|
+
module Test
|
6
|
+
class TestFramework::Haxe < TestFramework::Base
|
7
|
+
|
8
|
+
class << self
|
9
|
+
|
10
|
+
def applies_to?(project) #:nodoc:
|
11
|
+
project.test.compile.language == :haxe
|
12
|
+
end
|
13
|
+
|
14
|
+
def dependencies
|
15
|
+
unless @dependencies
|
16
|
+
super
|
17
|
+
end
|
18
|
+
@dependencies
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'buildr'
|
2
|
+
require 'fileutils'
|
3
|
+
require "rexml/document"
|
4
|
+
|
5
|
+
module Buildr
|
6
|
+
module Haxe
|
7
|
+
module Test
|
8
|
+
|
9
|
+
class MUnit < TestFramework::Haxe
|
10
|
+
|
11
|
+
DEFAULT_VERSION = "0.9.2.1"
|
12
|
+
|
13
|
+
"src=test
|
14
|
+
bin=bin/test/build
|
15
|
+
report=bin/test/report
|
16
|
+
hxml=test.hxml
|
17
|
+
classPaths=lib"
|
18
|
+
|
19
|
+
def tests(dependencies) #:nodoc:
|
20
|
+
candidates = []
|
21
|
+
task.project.test.compile.sources.each do |source|
|
22
|
+
files = Dir["#{source}/**/*Test.hx"] + Dir["#{source}/**/*Tests.hx"]
|
23
|
+
files.each { |item|
|
24
|
+
if File.dirname(item) == source
|
25
|
+
candidates << File.basename(item, '.*')
|
26
|
+
else
|
27
|
+
candidates << "#{File.dirname(item).gsub!(source+"/", "").gsub!("/", ".")}.#{File.basename(item, '.*')}"
|
28
|
+
end
|
29
|
+
}
|
30
|
+
end
|
31
|
+
candidates
|
32
|
+
end
|
33
|
+
|
34
|
+
def run(tests, dependencies) #:nodoc:
|
35
|
+
|
36
|
+
unless Buildr.application.options.dryrun
|
37
|
+
create_munit_config
|
38
|
+
appwd = Dir.pwd
|
39
|
+
Dir.chdir task.project.base_dir
|
40
|
+
|
41
|
+
cmd = "haxelib run munit test"
|
42
|
+
cmd << " -browser #{options[:browser]}" unless options[:browser].nil?
|
43
|
+
cmd << " -keep-browser-alive" if options[:keepbrowseralive]
|
44
|
+
cmd << " -coverage" if options[:coverage]
|
45
|
+
|
46
|
+
fail "Problems...oh noes!" unless system cmd
|
47
|
+
|
48
|
+
Dir.chdir appwd
|
49
|
+
|
50
|
+
Dir[File.join(task.project.path_to(:reports, :munit),"**/TEST-*.xml")].each do |xml_report|
|
51
|
+
doc = REXML::Document.new File.new(xml_report)
|
52
|
+
name = doc.elements["testsuite"].attributes["name"]
|
53
|
+
failures = Integer(doc.elements["testsuite"].attributes["failures"])
|
54
|
+
errors = Integer(doc.elements["testsuite"].attributes["errors"])
|
55
|
+
tests -= [name] unless failures + errors == 0
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
tests
|
60
|
+
end
|
61
|
+
|
62
|
+
def create_munit_config
|
63
|
+
file = File.join(task.project.base_dir, ".munit")
|
64
|
+
puts "Creating munit config '#{file}'"
|
65
|
+
File.open(file, 'w') { |f| f.write(
|
66
|
+
"version=#{options[:version].nil? ? DEFAULT_VERSION : options[:version]}
|
67
|
+
src=#{task.project.path_to(:source, :test, :hx)}
|
68
|
+
bin=#{task.project.test.compile.target}
|
69
|
+
report=#{task.project.path_to(:reports, :munit)}
|
70
|
+
hxml=#{get_hxml_file}
|
71
|
+
classPaths=#{task.project.compile.sources.map(&:to_s).join(',')}"
|
72
|
+
) }
|
73
|
+
end
|
74
|
+
|
75
|
+
def get_hxml_file
|
76
|
+
file = "test.hxml"
|
77
|
+
file = task.project.test.compile.options[:hxml] unless task.project.test.compile.options[:hxml].nil?
|
78
|
+
File.join(task.project.base_dir, file)
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
data/lib/buildr/hx.rb
ADDED
data/spec/spec_helper.rb
CHANGED
@@ -44,7 +44,7 @@ unless defined?(SpecHelpers)
|
|
44
44
|
require path
|
45
45
|
end
|
46
46
|
#require 'buildr'
|
47
|
-
require File.dirname( __FILE__) + '/../lib/buildr/
|
47
|
+
require File.dirname( __FILE__) + '/../lib/buildr/hx'
|
48
48
|
# load ecj
|
49
49
|
#require 'buildr/java/ecj'
|
50
50
|
#Make ecj appear as a compiler that doesn't apply:
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: buildr-hx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.18.pre
|
5
5
|
prerelease: 7
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -172,10 +172,30 @@ files:
|
|
172
172
|
- VERSION
|
173
173
|
- buildr-hx.gemspec
|
174
174
|
- buildr-hx.iml
|
175
|
+
- lib/buildr/hx.rb
|
176
|
+
- lib/buildr/hx/compiler.rb
|
177
|
+
- lib/buildr/hx/compiler/haxe_compiler_base.rb
|
178
|
+
- lib/buildr/hx/compiler/hxas3.rb
|
179
|
+
- lib/buildr/hx/compiler/hxcpp.rb
|
180
|
+
- lib/buildr/hx/compiler/hxjs.rb
|
181
|
+
- lib/buildr/hx/compiler/hxlib.rb
|
182
|
+
- lib/buildr/hx/compiler/hxneko.rb
|
183
|
+
- lib/buildr/hx/compiler/hxphp.rb
|
184
|
+
- lib/buildr/hx/compiler/hxswf.rb
|
185
|
+
- lib/buildr/hx/compiler/hxxml.rb
|
186
|
+
- lib/buildr/hx/core.rb
|
187
|
+
- lib/buildr/hx/core/haxe_lib.rb
|
188
|
+
- lib/buildr/hx/packaging.rb
|
189
|
+
- lib/buildr/hx/packaging/haxelib.rb
|
190
|
+
- lib/buildr/hx/packaging/hxlib.rb
|
191
|
+
- lib/buildr/hx/test.rb
|
192
|
+
- lib/buildr/hx/test/base.rb
|
193
|
+
- lib/buildr/hx/test/munit.rb
|
175
194
|
- rake/jeweler.rb
|
176
195
|
- rake/jeweler_prerelease_tasks.rb
|
177
196
|
- rake/pre_release_gemspec.rb
|
178
197
|
- rake/pre_release_to_git.rb
|
198
|
+
- spec/hx/compiler/hxswf_spec.rb
|
179
199
|
- spec/sandbox.rb
|
180
200
|
- spec/spec_helper.rb
|
181
201
|
homepage: http://github.com/devboy/buildr-hx
|
@@ -193,7 +213,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
193
213
|
version: '0'
|
194
214
|
segments:
|
195
215
|
- 0
|
196
|
-
hash: -
|
216
|
+
hash: -1145822684990440887
|
197
217
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
198
218
|
none: false
|
199
219
|
requirements:
|