buildr-hx 0.0.15.pre → 0.0.16.pre

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1.pre
1
+ 0.0.16.pre
data/buildr-hx.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "buildr-hx"
8
- s.version = "0.0.15.pre"
8
+ s.version = "0.0.16.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"]
12
- s.date = "2012-03-28"
12
+ s.date = "2012-02-24"
13
13
  s.description = "Build like you code - now supporting haXe"
14
14
  s.email = "dominic @nospam@ devboy.org"
15
15
  s.extra_rdoc_files = [
@@ -26,19 +26,40 @@ 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
  ]
36
56
  s.homepage = "http://github.com/devboy/buildr-hx"
37
57
  s.licenses = ["MIT"]
38
58
  s.require_paths = ["lib"]
39
- s.rubygems_version = "1.8.21"
59
+ s.rubygems_version = "1.8.11"
40
60
  s.summary = "Buildr extension to allow haXe development."
41
61
  s.test_files = [
62
+ "spec/hx/compiler/hxswf_spec.rb",
42
63
  "spec/sandbox.rb",
43
64
  "spec/spec_helper.rb"
44
65
  ]
data/buildr-hx.iml CHANGED
@@ -5,6 +5,34 @@
5
5
  <content url="file://$MODULE_DIR$" />
6
6
  <orderEntry type="jdk" jdkName="RVM: ruby-1.9.2-p180" jdkType="RUBY_SDK" />
7
7
  <orderEntry type="sourceFolder" forTests="false" />
8
+ <orderEntry type="library" scope="PROVIDED" name="atoulme-Antwrap (v0.7.1, RVM: ruby-1.9.2-p180) [gem]" level="application" />
9
+ <orderEntry type="library" scope="PROVIDED" name="builder (v2.1.2, RVM: ruby-1.9.2-p180) [gem]" level="application" />
10
+ <orderEntry type="library" scope="PROVIDED" name="buildr (v1.4.6, RVM: ruby-1.9.2-p180) [gem]" level="application" />
11
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v1.0.21, RVM: ruby-1.9.2-p180) [gem]" level="application" />
12
+ <orderEntry type="library" scope="PROVIDED" name="ci_reporter (v1.6.5, RVM: ruby-1.9.2-p180) [gem]" level="application" />
13
+ <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.1.2, RVM: ruby-1.9.2-p180) [gem]" level="application" />
14
+ <orderEntry type="library" scope="PROVIDED" name="git (v1.2.5, RVM: ruby-1.9.2-p180) [gem]" level="application" />
15
+ <orderEntry type="library" scope="PROVIDED" name="highline (v1.5.1, RVM: ruby-1.9.2-p180) [gem]" level="application" />
16
+ <orderEntry type="library" scope="PROVIDED" name="hoe (v2.3.3, RVM: ruby-1.9.2-p180) [gem]" level="application" />
17
+ <orderEntry type="library" scope="PROVIDED" name="jeweler (v1.5.2, RVM: ruby-1.9.2-p180) [gem]" level="application" />
18
+ <orderEntry type="library" scope="PROVIDED" name="json_pure (v1.4.3, RVM: ruby-1.9.2-p180) [gem]" level="application" />
19
+ <orderEntry type="library" scope="PROVIDED" name="minitar (v0.5.3, RVM: ruby-1.9.2-p180) [gem]" level="application" />
20
+ <orderEntry type="library" scope="PROVIDED" name="multi_json (v1.0.3, RVM: ruby-1.9.2-p180) [gem]" level="application" />
21
+ <orderEntry type="library" scope="PROVIDED" name="net-sftp (v2.0.4, RVM: ruby-1.9.2-p180) [gem]" level="application" />
22
+ <orderEntry type="library" scope="PROVIDED" name="net-ssh (v2.0.23, RVM: ruby-1.9.2-p180) [gem]" level="application" />
23
+ <orderEntry type="library" scope="PROVIDED" name="rake (v0.8.7, RVM: ruby-1.9.2-p180) [gem]" level="application" />
24
+ <orderEntry type="library" scope="PROVIDED" name="rjb (v1.3.3, RVM: ruby-1.9.2-p180) [gem]" level="application" />
25
+ <orderEntry type="library" scope="PROVIDED" name="rspec (v2.1.0, RVM: ruby-1.9.2-p180) [gem]" level="application" />
26
+ <orderEntry type="library" scope="PROVIDED" name="rspec-core (v2.1.0, RVM: ruby-1.9.2-p180) [gem]" level="application" />
27
+ <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v2.1.0, RVM: ruby-1.9.2-p180) [gem]" level="application" />
28
+ <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v2.1.0, RVM: ruby-1.9.2-p180) [gem]" level="application" />
29
+ <orderEntry type="library" scope="PROVIDED" name="rubyforge (v2.0.3, RVM: ruby-1.9.2-p180) [gem]" level="application" />
30
+ <orderEntry type="library" scope="PROVIDED" name="rubyzip (v0.9.4, RVM: ruby-1.9.2-p180) [gem]" level="application" />
31
+ <orderEntry type="library" scope="PROVIDED" name="shoulda (v2.11.3, RVM: ruby-1.9.2-p180) [gem]" level="application" />
32
+ <orderEntry type="library" scope="PROVIDED" name="simplecov (v0.5.4, RVM: ruby-1.9.2-p180) [gem]" level="application" />
33
+ <orderEntry type="library" scope="PROVIDED" name="simplecov-html (v0.5.3, RVM: ruby-1.9.2-p180) [gem]" level="application" />
34
+ <orderEntry type="library" scope="PROVIDED" name="simplecov-rcov (v0.2.3, RVM: ruby-1.9.2-p180) [gem]" level="application" />
35
+ <orderEntry type="library" scope="PROVIDED" name="xml-simple (v1.0.12, RVM: ruby-1.9.2-p180) [gem]" level="application" />
8
36
  </component>
9
37
  </module>
10
38
 
@@ -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,16 @@
1
+ module Buildr
2
+ module Haxe
3
+ module Compiler
4
+ class HXAS3 < HaxeCompilerBase
5
+
6
+ specify :language => :haxe,
7
+ :sources => :hx, :source_ext => :hx
8
+
9
+ def compiler_args
10
+ [ "-as3 #{@output}" ]
11
+ end
12
+
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ module Buildr
2
+ module Haxe
3
+ module Compiler
4
+ class HXCPP < HaxeCompilerBase
5
+
6
+ specify :language => :haxe,
7
+ :sources => :hx, :source_ext => :hx
8
+
9
+ def compiler_args
10
+ [ "-cpp #{@output}" ]
11
+ end
12
+
13
+ end
14
+ end
15
+ end
16
+ 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,16 @@
1
+ module Buildr
2
+ module Haxe
3
+ module Compiler
4
+ class HXPHP < HaxeCompilerBase
5
+
6
+ specify :language => :haxe,
7
+ :sources => :hx, :source_ext => :hx
8
+
9
+ def compiler_args
10
+ [ "-php #{@output}" ]
11
+ end
12
+
13
+ end
14
+ end
15
+ end
16
+ 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,90 @@
1
+ require 'buildr'
2
+ require 'fileutils'
3
+ require 'pathname'
4
+ require "rexml/document"
5
+
6
+ module Buildr
7
+ module Haxe
8
+ module Test
9
+
10
+ class MUnit < TestFramework::Haxe
11
+
12
+ DEFAULT_VERSION = "0.9.2.1"
13
+
14
+ "src=test
15
+ bin=bin/test/build
16
+ report=bin/test/report
17
+ hxml=test.hxml
18
+ classPaths=lib"
19
+
20
+ def tests(dependencies) #:nodoc:
21
+ candidates = []
22
+ task.project.test.compile.sources.each do |source|
23
+ files = Dir["#{source}/**/*Test.hx"] + Dir["#{source}/**/*Tests.hx"]
24
+ files.each { |item|
25
+ if File.dirname(item) == source
26
+ candidates << File.basename(item, '.*')
27
+ else
28
+ candidates << "#{File.dirname(item).gsub!(source+"/", "").gsub!("/", ".")}.#{File.basename(item, '.*')}"
29
+ end
30
+ }
31
+ end
32
+ candidates
33
+ end
34
+
35
+ def run(tests, dependencies) #:nodoc:
36
+
37
+ unless Buildr.application.options.dryrun
38
+ create_munit_config
39
+ appwd = Dir.pwd
40
+ Dir.chdir task.project.base_dir
41
+
42
+ cmd = "haxelib run munit test"
43
+ cmd << " -browser #{options[:browser]}" unless options[:browser].nil?
44
+ cmd << " -keep-browser-alive" if options[:keepbrowseralive]
45
+ cmd << " -coverage" if options[:coverage]
46
+
47
+ fail "Problems...oh noes!" unless system cmd
48
+
49
+ Dir.chdir appwd
50
+
51
+ Dir[File.join(task.project.path_to(:reports, :munit),"**/TEST-*.xml")].each do |xml_report|
52
+ doc = REXML::Document.new File.new(xml_report)
53
+ name = doc.elements["testsuite"].attributes["name"]
54
+ failures = Integer(doc.elements["testsuite"].attributes["failures"])
55
+ errors = Integer(doc.elements["testsuite"].attributes["errors"])
56
+ tests -= [name] unless failures + errors == 0
57
+ end
58
+
59
+ end
60
+ tests
61
+ end
62
+
63
+ def create_munit_config
64
+ file = File.join(task.project.base_dir, ".munit")
65
+ puts "Creating munit config '#{file}'"
66
+ File.open(file, 'w') { |f| f.write(
67
+ "version=#{options[:version].nil? ? DEFAULT_VERSION : options[:version]}\n" +
68
+ "src=#{relative_path task.project.path_to(:source, :test, :hx), task.project.base_dir}\n" +
69
+ "bin=#{relative_path task.project.test.compile.target.to_s, task.project.base_dir}\n" +
70
+ "report=#{relative_path task.project.path_to(:reports, :munit), task.project.base_dir}\n" +
71
+ "hxml=#{relative_path get_hxml_file, task.project.base_dir}\n" +
72
+ "classPaths=#{task.project.compile.sources.map(&:to_s).map{|s| relative_path s, task.project.base_dir}.join(',')}"
73
+ ) }
74
+ end
75
+
76
+ def get_hxml_file
77
+ file = "test.hxml"
78
+ file = task.project.test.compile.options[:hxml] unless task.project.test.compile.options[:hxml].nil?
79
+ File.join(task.project.base_dir, file)
80
+ end
81
+
82
+ def relative_path path, from
83
+ Pathname.new(path).relative_path_from(Pathname.new(from)).to_s
84
+ end
85
+
86
+ end
87
+ end
88
+ end
89
+
90
+ end
@@ -0,0 +1,4 @@
1
+ require File.dirname(__FILE__)+"/test/base"
2
+ require File.dirname(__FILE__)+"/test/munit"
3
+
4
+ Buildr::TestFramework << Buildr::Haxe::Test::MUnit
data/lib/buildr/hx.rb ADDED
@@ -0,0 +1,6 @@
1
+ require 'buildr'
2
+
3
+ require File.dirname(__FILE__) + '/../buildr/hx/core'
4
+ require File.dirname(__FILE__) + '/../buildr/hx/compiler'
5
+ require File.dirname(__FILE__) + '/../buildr/hx/packaging'
6
+ require File.dirname(__FILE__) + '/../buildr/hx/test'
@@ -0,0 +1,9 @@
1
+ require File.dirname(__FILE__) + '/../../../spec/spec_helper'
2
+
3
+ describe Buildr::Haxe::Compiler::HXSWF do
4
+
5
+ it 'should report the language as :haxe' do
6
+ define('foo').compile.using(:hxswf).language.should eql(:haxe)
7
+ end
8
+
9
+ end
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/as3'
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.15.pre
4
+ version: 0.0.16.pre
5
5
  prerelease: 7
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-28 00:00:00.000000000 Z
12
+ date: 2012-02-24 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: buildr
16
- requirement: !ruby/object:Gem::Requirement
16
+ requirement: &2161024180 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,15 +21,10 @@ dependencies:
21
21
  version: 1.4.6
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ~>
28
- - !ruby/object:Gem::Version
29
- version: 1.4.6
24
+ version_requirements: *2161024180
30
25
  - !ruby/object:Gem::Dependency
31
26
  name: shoulda
32
- requirement: !ruby/object:Gem::Requirement
27
+ requirement: &2161023700 !ruby/object:Gem::Requirement
33
28
  none: false
34
29
  requirements:
35
30
  - - ! '>='
@@ -37,15 +32,10 @@ dependencies:
37
32
  version: '0'
38
33
  type: :development
39
34
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
35
+ version_requirements: *2161023700
46
36
  - !ruby/object:Gem::Dependency
47
37
  name: bundler
48
- requirement: !ruby/object:Gem::Requirement
38
+ requirement: &2161023180 !ruby/object:Gem::Requirement
49
39
  none: false
50
40
  requirements:
51
41
  - - ~>
@@ -53,15 +43,10 @@ dependencies:
53
43
  version: 1.0.0
54
44
  type: :development
55
45
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ~>
60
- - !ruby/object:Gem::Version
61
- version: 1.0.0
46
+ version_requirements: *2161023180
62
47
  - !ruby/object:Gem::Dependency
63
48
  name: jeweler
64
- requirement: !ruby/object:Gem::Requirement
49
+ requirement: &2161022660 !ruby/object:Gem::Requirement
65
50
  none: false
66
51
  requirements:
67
52
  - - ~>
@@ -69,15 +54,10 @@ dependencies:
69
54
  version: 1.5.2
70
55
  type: :development
71
56
  prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ~>
76
- - !ruby/object:Gem::Version
77
- version: 1.5.2
57
+ version_requirements: *2161022660
78
58
  - !ruby/object:Gem::Dependency
79
59
  name: simplecov
80
- requirement: !ruby/object:Gem::Requirement
60
+ requirement: &2161022120 !ruby/object:Gem::Requirement
81
61
  none: false
82
62
  requirements:
83
63
  - - ! '>='
@@ -85,15 +65,10 @@ dependencies:
85
65
  version: '0'
86
66
  type: :development
87
67
  prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
91
- - - ! '>='
92
- - !ruby/object:Gem::Version
93
- version: '0'
68
+ version_requirements: *2161022120
94
69
  - !ruby/object:Gem::Dependency
95
70
  name: simplecov-rcov
96
- requirement: !ruby/object:Gem::Requirement
71
+ requirement: &2161021640 !ruby/object:Gem::Requirement
97
72
  none: false
98
73
  requirements:
99
74
  - - ! '>='
@@ -101,15 +76,10 @@ dependencies:
101
76
  version: '0'
102
77
  type: :development
103
78
  prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
- requirements:
107
- - - ! '>='
108
- - !ruby/object:Gem::Version
109
- version: '0'
79
+ version_requirements: *2161021640
110
80
  - !ruby/object:Gem::Dependency
111
81
  name: rspec
112
- requirement: !ruby/object:Gem::Requirement
82
+ requirement: &2161021040 !ruby/object:Gem::Requirement
113
83
  none: false
114
84
  requirements:
115
85
  - - ~>
@@ -117,15 +87,10 @@ dependencies:
117
87
  version: 2.1.0
118
88
  type: :development
119
89
  prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
- requirements:
123
- - - ~>
124
- - !ruby/object:Gem::Version
125
- version: 2.1.0
90
+ version_requirements: *2161021040
126
91
  - !ruby/object:Gem::Dependency
127
92
  name: ci_reporter
128
- requirement: !ruby/object:Gem::Requirement
93
+ requirement: &2161020540 !ruby/object:Gem::Requirement
129
94
  none: false
130
95
  requirements:
131
96
  - - ~>
@@ -133,15 +98,10 @@ dependencies:
133
98
  version: 1.6.5
134
99
  type: :development
135
100
  prerelease: false
136
- version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
- requirements:
139
- - - ~>
140
- - !ruby/object:Gem::Version
141
- version: 1.6.5
101
+ version_requirements: *2161020540
142
102
  - !ruby/object:Gem::Dependency
143
103
  name: buildr
144
- requirement: !ruby/object:Gem::Requirement
104
+ requirement: &2161020060 !ruby/object:Gem::Requirement
145
105
  none: false
146
106
  requirements:
147
107
  - - ! '>='
@@ -149,12 +109,7 @@ dependencies:
149
109
  version: 1.4.6
150
110
  type: :runtime
151
111
  prerelease: false
152
- version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
- requirements:
155
- - - ! '>='
156
- - !ruby/object:Gem::Version
157
- version: 1.4.6
112
+ version_requirements: *2161020060
158
113
  description: Build like you code - now supporting haXe
159
114
  email: dominic @nospam@ devboy.org
160
115
  executables: []
@@ -172,10 +127,30 @@ files:
172
127
  - VERSION
173
128
  - buildr-hx.gemspec
174
129
  - buildr-hx.iml
130
+ - lib/buildr/hx.rb
131
+ - lib/buildr/hx/compiler.rb
132
+ - lib/buildr/hx/compiler/haxe_compiler_base.rb
133
+ - lib/buildr/hx/compiler/hxas3.rb
134
+ - lib/buildr/hx/compiler/hxcpp.rb
135
+ - lib/buildr/hx/compiler/hxjs.rb
136
+ - lib/buildr/hx/compiler/hxlib.rb
137
+ - lib/buildr/hx/compiler/hxneko.rb
138
+ - lib/buildr/hx/compiler/hxphp.rb
139
+ - lib/buildr/hx/compiler/hxswf.rb
140
+ - lib/buildr/hx/compiler/hxxml.rb
141
+ - lib/buildr/hx/core.rb
142
+ - lib/buildr/hx/core/haxe_lib.rb
143
+ - lib/buildr/hx/packaging.rb
144
+ - lib/buildr/hx/packaging/haxelib.rb
145
+ - lib/buildr/hx/packaging/hxlib.rb
146
+ - lib/buildr/hx/test.rb
147
+ - lib/buildr/hx/test/base.rb
148
+ - lib/buildr/hx/test/munit.rb
175
149
  - rake/jeweler.rb
176
150
  - rake/jeweler_prerelease_tasks.rb
177
151
  - rake/pre_release_gemspec.rb
178
152
  - rake/pre_release_to_git.rb
153
+ - spec/hx/compiler/hxswf_spec.rb
179
154
  - spec/sandbox.rb
180
155
  - spec/spec_helper.rb
181
156
  homepage: http://github.com/devboy/buildr-hx
@@ -193,7 +168,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
193
168
  version: '0'
194
169
  segments:
195
170
  - 0
196
- hash: 818588586932157269
171
+ hash: 2659228895798235121
197
172
  required_rubygems_version: !ruby/object:Gem::Requirement
198
173
  none: false
199
174
  requirements:
@@ -202,10 +177,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
202
177
  version: 1.3.1
203
178
  requirements: []
204
179
  rubyforge_project:
205
- rubygems_version: 1.8.21
180
+ rubygems_version: 1.8.11
206
181
  signing_key:
207
182
  specification_version: 3
208
183
  summary: Buildr extension to allow haXe development.
209
184
  test_files:
185
+ - spec/hx/compiler/hxswf_spec.rb
210
186
  - spec/sandbox.rb
211
187
  - spec/spec_helper.rb