zerg_xcode 0.3.4 → 0.3.5

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.
Files changed (67) hide show
  1. data/CHANGELOG +2 -0
  2. data/Manifest +22 -14
  3. data/Rakefile +6 -0
  4. data/lib/zerg_xcode.rb +8 -3
  5. data/lib/zerg_xcode/builder/runner.rb +51 -0
  6. data/lib/zerg_xcode/builder/sdks.rb +34 -0
  7. data/lib/zerg_xcode/file_format/archiver.rb +15 -2
  8. data/lib/zerg_xcode/file_format/encoder.rb +15 -2
  9. data/lib/zerg_xcode/file_format/lexer.rb +15 -2
  10. data/lib/zerg_xcode/file_format/parser.rb +15 -2
  11. data/lib/zerg_xcode/file_format/paths.rb +15 -2
  12. data/lib/zerg_xcode/objects/pbx_build_file.rb +16 -3
  13. data/lib/zerg_xcode/objects/pbx_build_phase.rb +14 -2
  14. data/lib/zerg_xcode/objects/pbx_container_item_proxy.rb +14 -2
  15. data/lib/zerg_xcode/objects/pbx_group.rb +43 -3
  16. data/lib/zerg_xcode/objects/pbx_native_target.rb +15 -3
  17. data/lib/zerg_xcode/objects/pbx_project.rb +20 -4
  18. data/lib/zerg_xcode/objects/pbx_target_dependency.rb +15 -3
  19. data/lib/zerg_xcode/objects/xc_configuration_list.rb +14 -2
  20. data/lib/zerg_xcode/objects/xcode_object.rb +14 -3
  21. data/lib/zerg_xcode/plugins/addlibrary.rb +15 -2
  22. data/lib/zerg_xcode/plugins/core/core.rb +15 -6
  23. data/lib/zerg_xcode/plugins/help.rb +15 -2
  24. data/lib/zerg_xcode/plugins/import.rb +15 -2
  25. data/lib/zerg_xcode/plugins/irb.rb +16 -2
  26. data/lib/zerg_xcode/plugins/ls.rb +15 -2
  27. data/lib/zerg_xcode/plugins/lstargets.rb +16 -2
  28. data/lib/zerg_xcode/plugins/retarget.rb +15 -2
  29. data/lib/zerg_xcode/shortcuts.rb +10 -2
  30. data/test/builder/runner_test.rb +35 -0
  31. data/test/builder/sdk_test.rb +17 -0
  32. data/test/file_format/archiver_test.rb +6 -2
  33. data/test/file_format/encoder_test.rb +7 -3
  34. data/test/file_format/lexer_test.rb +7 -3
  35. data/test/file_format/parser_test.rb +6 -2
  36. data/test/file_format/path_test.rb +30 -24
  37. data/test/fixtures/ClosedLib/ClosedLib.xcodeproj/project.pbxproj +225 -0
  38. data/test/fixtures/ClosedLib/ClosedLib_Prefix.pch +7 -0
  39. data/test/fixtures/ClosedLib/ClosedNative.c +20 -0
  40. data/test/fixtures/ClosedLib/ClosedNative.h +12 -0
  41. data/{testdata → test/fixtures}/FlatTestApp/FlatTestApp.xcodeproj/project.pbxproj +0 -0
  42. data/{testdata → test/fixtures}/TestApp/TestApp.xcodeproj/project.pbxproj +0 -0
  43. data/{testdata → test/fixtures}/TestApp30.xcodeproj/project.pbxproj +0 -0
  44. data/{testdata → test/fixtures}/TestLib30.xcodeproj/project.pbxproj +0 -0
  45. data/{testdata → test/fixtures}/ZergSupport.xcodeproj/project.pbxproj +0 -0
  46. data/{testdata → test/fixtures}/project.pbxproj +0 -0
  47. data/{testdata → test/fixtures}/project.pbxproj.compat +0 -0
  48. data/test/objects/pbx_build_file_test.rb +7 -4
  49. data/test/objects/pbx_build_phase_test.rb +5 -2
  50. data/test/objects/pbx_container_item_proxy_test.rb +6 -2
  51. data/test/objects/pbx_group_test.rb +35 -3
  52. data/test/objects/pbx_native_target_test.rb +5 -2
  53. data/test/objects/pbx_project_test.rb +21 -9
  54. data/test/objects/pbx_target_dependency_test.rb +6 -2
  55. data/test/objects/xc_configuration_list_test.rb +5 -2
  56. data/test/objects/xcode_object_test.rb +5 -2
  57. data/test/plugins/addlibrary_test.rb +6 -3
  58. data/test/plugins/core/core_test.rb +5 -2
  59. data/test/plugins/helper.rb +4 -0
  60. data/test/plugins/import_test.rb +76 -72
  61. data/test/plugins/irb_test.rb +9 -4
  62. data/test/plugins/ls_test.rb +7 -4
  63. data/test/plugins/lstargets_test.rb +7 -4
  64. data/test/plugins/retarget_test.rb +7 -4
  65. data/test/shortcuts_test.rb +7 -3
  66. data/zerg_xcode.gemspec +6 -6
  67. metadata +32 -20
@@ -1,6 +1,16 @@
1
1
  # The root object in the Xcode object graph.
2
- class ZergXcode::Objects::PBXProject < ZergXcode::XcodeObject
3
- # Used to implement save!
2
+ #
3
+ # Author:: Victor Costan
4
+ # Copyright:: Copyright (C) 2009 Zergling.Net
5
+ # License:: MIT
6
+
7
+ # :nodoc: namespace
8
+ module ZergXcode::Objects
9
+
10
+
11
+ # The root object in the Xcode object graph.
12
+ class PBXProject < ZergXcode::XcodeObject
13
+ # Used to implement save! and to support builds.
4
14
  attr_accessor :source_filename
5
15
 
6
16
  # :nodoc: override to copy the new metadata
@@ -32,6 +42,10 @@ class ZergXcode::Objects::PBXProject < ZergXcode::XcodeObject
32
42
  def xref_name
33
43
  isa.to_s
34
44
  end
45
+
46
+ def find_group_named name
47
+ self["mainGroup"].find_group_named name
48
+ end
35
49
 
36
50
  # Container for the visitor that lists all files in a project.
37
51
  module FileVisitor
@@ -72,5 +86,7 @@ class ZergXcode::Objects::PBXProject < ZergXcode::XcodeObject
72
86
  end
73
87
  return path
74
88
  end
75
- end
76
- end
89
+ end # module ZergXcode::Objects::PBXProject::FileVisitor
90
+ end # class ZergXcode::Objects::PBXProject
91
+
92
+ end # namespace class ZergXcode::Objects
@@ -1,5 +1,15 @@
1
- # Expresses a target's dependency on another target.
2
- class ZergXcode::Objects::PBXTargetDependency < ZergXcode::XcodeObject
1
+ # A build target's dependency on another build target.
2
+ #
3
+ # Author:: Victor Costan
4
+ # Copyright:: Copyright (C) 2009 Zergling.Net
5
+ # License:: MIT
6
+
7
+ # :nodoc: namespace
8
+ module ZergXcode::Objects
9
+
10
+
11
+ # Expresses a build target's dependency on another build target.
12
+ class PBXTargetDependency < ZergXcode::XcodeObject
3
13
  PBXContainerItemProxy = ZergXcode::Objects::PBXContainerItemProxy
4
14
 
5
15
  # The target that this target depends on.
@@ -17,4 +27,6 @@ class ZergXcode::Objects::PBXTargetDependency < ZergXcode::XcodeObject
17
27
  def xref_name
18
28
  target.xref_name
19
29
  end
20
- end
30
+ end # class ZergXcode::Objects::PBXTargetDependency
31
+
32
+ end # namespace ZergXcode::Objects
@@ -1,7 +1,19 @@
1
1
  # The configurations associated with an object.
2
- class ZergXcode::Objects::XCConfigurationList < ZergXcode::XcodeObject
2
+ #
3
+ # Author:: Victor Costan
4
+ # Copyright:: Copyright (C) 2009 Zergling.Net
5
+ # License:: MIT
6
+
7
+ # :nodoc: namespace
8
+ module ZergXcode::Objects
9
+
10
+
11
+ # The configurations associated with an object.
12
+ class XCConfigurationList < ZergXcode::XcodeObject
3
13
  # :nodoc: override xref_name because there's always a single list in a context
4
14
  def xref_name
5
15
  isa.to_s
6
16
  end
7
- end
17
+ end # class ZergXcode::Objects::XCConfigurationList
18
+
19
+ end # namespace ZergXcode::Objects
@@ -1,5 +1,15 @@
1
- # Xcode objects
2
- class ZergXcode::XcodeObject
1
+ # Superclass for all the objects in an Xcode project object graph.
2
+ #
3
+ # Author:: Victor Costan
4
+ # Copyright:: Copyright (C) 2009 Zergling.Net
5
+ # License:: MIT
6
+
7
+ # :nodoc: namespace
8
+ module ZergXcode
9
+
10
+
11
+ # Superclass for all the objects in an Xcode project object graph.
12
+ class XcodeObject
3
13
  attr_accessor :version
4
14
  attr_accessor :archive_id
5
15
 
@@ -181,5 +191,6 @@ class ZergXcode::XcodeObject
181
191
  def copy_metadata(source)
182
192
  self.archive_id, self.version = source.archive_id, source.version
183
193
  end
184
- end
194
+ end # class ZergXcode::XcodeObject
185
195
 
196
+ end # namespace ZergXcode
@@ -1,4 +1,15 @@
1
- class ZergXcode::Plugins::Addlibrary
1
+ # Adds a library target as a dependence to another Xcode target.
2
+ #
3
+ # Author:: Victor Costan
4
+ # Copyright:: Copyright (C) 2009 Zergling.Net
5
+ # License:: MIT
6
+
7
+ # :nodoc: namespace
8
+ module ZergXcode::Plugins
9
+
10
+
11
+ # Adds a library target as a dependence to another Xcode target.
12
+ class Addlibrary
2
13
  include ZergXcode::Objects
3
14
 
4
15
  def help
@@ -118,4 +129,6 @@ END
118
129
  (setting.kind_of?(Enumerable) && setting.include?(option)))
119
130
  end
120
131
  end
121
- end
132
+ end # class ZergXcode::Plugins::Addlibrary
133
+
134
+ end # namespace ZergXcode::Plugins
@@ -1,6 +1,17 @@
1
+ # Plugin management logic.
2
+ #
3
+ # Author:: Victor Costan
4
+ # Copyright:: Copyright (C) 2009 Zergling.Net
5
+ # License:: MIT
6
+
1
7
  require 'set'
2
8
 
3
- module ZergXcode::Plugins
9
+ # :nodoc: namespace
10
+ module ZergXcode
11
+
12
+
13
+ # Plugin management logic.
14
+ module Plugins
4
15
  def self.all
5
16
  plugin_dir = File.join(File.dirname(__FILE__), '..')
6
17
  plugins = Dir.entries(plugin_dir).select { |entry|
@@ -19,7 +30,7 @@ module ZergXcode::Plugins
19
30
 
20
31
  def self.get(plugin_name)
21
32
  self.require plugin_name
22
- ZergXcode::Plugins.const_get(plugin_name.capitalize).new
33
+ Plugins.const_get(plugin_name.capitalize).new
23
34
  end
24
35
 
25
36
  def self.run(plugin_name, args)
@@ -29,8 +40,6 @@ module ZergXcode::Plugins
29
40
  def self.help(plugin_name)
30
41
  self.get(plugin_name).help
31
42
  end
32
- end
43
+ end # module ZergXcode::Plugins
33
44
 
34
- # :nodoc:
35
- module ZergXcode
36
- end
45
+ end # namespace ZergXcode
@@ -1,4 +1,15 @@
1
- class ZergXcode::Plugins::Help
1
+ # Displays the help strings for other plugins.
2
+ #
3
+ # Author:: Victor Costan
4
+ # Copyright:: Copyright (C) 2009 Zergling.Net
5
+ # License:: MIT
6
+
7
+ # :nodoc: namespace
8
+ module ZergXcode::Plugins
9
+
10
+
11
+ # Displays the help strings for other plugins.
12
+ class Help
2
13
  def help
3
14
  {:short => 'command-line usage instructions',
4
15
  :long => <<"END" }
@@ -27,4 +38,6 @@ END
27
38
  print helpstr
28
39
  helpstr
29
40
  end
30
- end
41
+ end # class ZergXcode::Plugins::Help
42
+
43
+ end # namespace ZergXcode::Plugins
@@ -1,7 +1,18 @@
1
+ # Imports the contents of an Xcode project into another Xcode project.
2
+ #
3
+ # Author:: Victor Costan
4
+ # Copyright:: Copyright (C) 2009 Zergling.Net
5
+ # License:: MIT
6
+
1
7
  require 'fileutils'
2
8
  require 'pathname'
3
9
 
4
- class ZergXcode::Plugins::Import
10
+ # :nodoc: namespace
11
+ module ZergXcode::Plugins
12
+
13
+
14
+ # Imports the contents of an Xcode project into another Xcode project.
15
+ class Import
5
16
  include ZergXcode::Objects
6
17
 
7
18
  def help
@@ -278,4 +289,6 @@ END
278
289
  mappings
279
290
  end
280
291
  private :cross_reference_enumerables
281
- end
292
+ end # class ZergXcode::Plugins::Import
293
+
294
+ end # namespace ZergXcode::Plugins
@@ -1,6 +1,17 @@
1
+ # Loads up an Xcode project and the ZergXcode library into an irb shell.
2
+ #
3
+ # Author:: Victor Costan
4
+ # Copyright:: Copyright (C) 2009 Zergling.Net
5
+ # License:: MIT
6
+
1
7
  require 'irb'
2
8
 
3
- class ZergXcode::Plugins::Irb
9
+ # :nodoc: namespace
10
+ module ZergXcode::Plugins
11
+
12
+
13
+ # Loads up an Xcode project and the ZergXcode library into an irb shell.
14
+ class Irb
4
15
  def help
5
16
  {:short => 'opens up a project in an interactive ruby shell',
6
17
  :long => <<"END" }
@@ -19,4 +30,7 @@ END
19
30
  "Use the 'quit' command if you're here by mistake.\n"
20
31
  IRB.start __FILE__
21
32
  end
22
- end
33
+ end # class ZergXcode::Plugins::Irb
34
+
35
+ end # namespace ZergXcode::Plugins
36
+
@@ -1,4 +1,15 @@
1
- class ZergXcode::Plugins::Ls
1
+ # Lists the files in an Xcode project.
2
+ #
3
+ # Author:: Victor Costan
4
+ # Copyright:: Copyright (C) 2009 Zergling.Net
5
+ # License:: MIT
6
+
7
+ # :nodoc: namespace
8
+ module ZergXcode::Plugins
9
+
10
+
11
+ # Lists the files in an Xcode project.
12
+ class Ls
2
13
  def help
3
14
  {:short => 'shows the files in a project',
4
15
  :long => <<"END" }
@@ -24,4 +35,6 @@ END
24
35
  [file[:path], file[:object]['lastKnownFileType']]
25
36
  end
26
37
  end
27
- end
38
+ end # class ZergXcode::Plugins::Ls
39
+
40
+ end # namespace ZergXcode::Plugins
@@ -1,4 +1,15 @@
1
- class ZergXcode::Plugins::Lstargets
1
+ # Lists the build targets in an Xcode project.
2
+ #
3
+ # Author:: Victor Costan
4
+ # Copyright:: Copyright (C) 2009 Zergling.Net
5
+ # License:: MIT
6
+
7
+ # :nodoc: namespace
8
+ module ZergXcode::Plugins
9
+
10
+
11
+ # Lists the build targets in an Xcode project.
12
+ class Lstargets
2
13
  def help
3
14
  {:short => 'shows the targets in a project',
4
15
  :long => <<"END" }
@@ -26,4 +37,7 @@ END
26
37
  [target['name'], target['productName'], target['productType']]
27
38
  end
28
39
  end
29
- end
40
+ end # class ZergXcode::Plugins::Lstargets
41
+
42
+ end # namespace ZergXcode::Plugins
43
+
@@ -1,4 +1,15 @@
1
- class ZergXcode::Plugins::Retarget
1
+ # Adds files to a build target, and removes them from all the other targets.
2
+ #
3
+ # Author:: Victor Costan
4
+ # Copyright:: Copyright (C) 2009 Zergling.Net
5
+ # License:: MIT
6
+
7
+ # :nodoc: namespace
8
+ module ZergXcode::Plugins
9
+
10
+
11
+ # Adds files to a build target, and removes them from all the other targets.
12
+ class Retarget
2
13
  include ZergXcode::Objects
3
14
 
4
15
  def help
@@ -83,4 +94,6 @@ END
83
94
  end
84
95
  end
85
96
  end
86
- end
97
+ end # class ZergXcode::Plugins::Retarget
98
+
99
+ end # namespace ZergXcode::Plugins
@@ -1,3 +1,11 @@
1
+ # Convenience methods for core ZergXcode functionality.
2
+ #
3
+ # Author:: Victor Costan
4
+ # Copyright:: Copyright (C) 2009 Zergling.Net
5
+ # License:: MIT
6
+
7
+
8
+ # :nodoc: namespace
1
9
  module ZergXcode
2
10
  # Reads an Xcode project from the filesystem.
3
11
  def self.load(path)
@@ -18,5 +26,5 @@ module ZergXcode
18
26
  # Instantiate a plug-in.
19
27
  def self.plugin(plugin_name)
20
28
  ZergXcode::Plugins.get(plugin_name)
21
- end
22
- end
29
+ end
30
+ end # namespace ZergXcode
@@ -0,0 +1,35 @@
1
+ # Author:: Victor Costan
2
+ # Copyright:: Copyright (C) 2009 Zergling.Net
3
+ # License:: MIT
4
+
5
+ require 'zerg_xcode'
6
+ require 'test/unit'
7
+
8
+ class RunnerTest < Test::Unit::TestCase
9
+ def setup
10
+ @project = ZergXcode.load 'test/fixtures/ClosedLib'
11
+ @configuration = 'Release'
12
+ @sdk = ZergXcode::Builder::Sdk.all.
13
+ select { |s| /iPhone .* 3\.0$/ =~ s[:name] }.first
14
+ @golden_build_path = 'test/fixtures/ClosedLib/build/Release-iphoneos'
15
+ @product = @golden_build_path + '/libClosedLib.a'
16
+ end
17
+
18
+ def teardown
19
+ ZergXcode::Builder::Runner.clean @project, @sdk, @configuration
20
+ end
21
+
22
+ def test_clean_build_clean
23
+ assert ZergXcode::Builder::Runner.clean(@project, @sdk, @configuration),
24
+ 'Initial clean failed'
25
+
26
+ build_path = ZergXcode::Builder::Runner.build @project, @sdk, @configuration
27
+ assert build_path, 'Build failed'
28
+ assert_equal @golden_build_path, build_path, 'Build returned incorrect path'
29
+ assert File.exist?(@product), 'Build product not found'
30
+
31
+ assert ZergXcode::Builder::Runner.clean(@project, @sdk, @configuration),
32
+ 'Post-build clean failed'
33
+ assert !File.exist?(@product), 'Build product not removed by clean'
34
+ end
35
+ end
@@ -0,0 +1,17 @@
1
+ # Author:: Victor Costan
2
+ # Copyright:: Copyright (C) 2009 Zergling.Net
3
+ # License:: MIT
4
+
5
+ require 'zerg_xcode'
6
+ require 'test/unit'
7
+
8
+ class SdkTest < Test::Unit::TestCase
9
+ def test_all
10
+ all_sdks = ZergXcode::Builder::Sdk.all
11
+ mac105 = { :group => 'Mac OS X SDKs', :name => 'Mac OS X 10.5',
12
+ :arg => 'macosx10.5' }
13
+ assert_operator all_sdks, :include?, mac105, 'MacOS 10.5 SDK included'
14
+
15
+ assert_operator all_sdks, :equal?, all_sdks, 'SDKs are cached'
16
+ end
17
+ end
@@ -1,5 +1,9 @@
1
- require 'test/unit'
1
+ # Author:: Victor Costan
2
+ # Copyright:: Copyright (C) 2009 Zergling.Net
3
+ # License:: MIT
4
+
2
5
  require 'zerg_xcode'
6
+ require 'test/unit'
3
7
 
4
8
  class ArchiverTest < Test::Unit::TestCase
5
9
  Parser = ZergXcode::Parser
@@ -27,7 +31,7 @@ class ArchiverTest < Test::Unit::TestCase
27
31
  }
28
32
  }
29
33
 
30
- @pbxdata = File.read 'testdata/project.pbxproj'
34
+ @pbxdata = File.read 'test/fixtures/project.pbxproj'
31
35
  end
32
36
 
33
37
  def test_archive_to_hash
@@ -1,10 +1,14 @@
1
- require 'test/unit'
1
+ # Author:: Victor Costan
2
+ # Copyright:: Copyright (C) 2009 Zergling.Net
3
+ # License:: MIT
4
+
2
5
  require 'zerg_xcode'
6
+ require 'test/unit'
3
7
 
4
8
  class EncoderTest < Test::Unit::TestCase
5
9
  def test_encoder
6
- pbxdata = File.read 'testdata/project.pbxproj'
7
- golden_encoded_proj = File.read 'testdata/project.pbxproj.compat'
10
+ pbxdata = File.read 'test/fixtures/project.pbxproj'
11
+ golden_encoded_proj = File.read 'test/fixtures/project.pbxproj.compat'
8
12
  proj = ZergXcode::Parser.parse pbxdata
9
13
  assert_equal golden_encoded_proj, ZergXcode::Encoder.encode(proj)
10
14
  end