echinoidea 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -26,6 +26,18 @@ Then run `echinoidea`.
26
26
  echinoidea -o [OUTPUT_DIRECTORY]
27
27
  ```
28
28
 
29
+ `-t Android` for Android project
30
+
31
+ ```
32
+ echinoidea -o [OUTPUT_DIRECTORY] -t Android
33
+ ```
34
+
35
+ To enable loggings, use `-l` option
36
+
37
+ ```
38
+ echinoidea -o [OUTPUT_DIRECTORY] -l
39
+ ```
40
+
29
41
  ## Contributing
30
42
 
31
43
  1. Fork it
@@ -8,6 +8,7 @@ opt = OptionParser.new
8
8
 
9
9
  OPTS = {}
10
10
  opt.on('-d') {|v| OPTS[:d] = v}
11
+ opt.on('-l') {|v| OPTS[:l] = v}
11
12
  opt.on('-o VAL') {|v| OPTS[:o] = v }
12
13
  opt.on('-t VAL') {|v| OPTS[:t] = v }
13
14
  opt.parse!(ARGV)
@@ -17,6 +18,10 @@ if OPTS[:o] == nil || OPTS[:o] == ""
17
18
  exit
18
19
  end
19
20
 
21
+ if OPTS[:l]
22
+ puts "Options: " + OPTS.to_s
23
+ end
24
+
20
25
  current_dir = Dir::pwd
21
26
 
22
27
  if !Echinoidea::project_root_directory?(current_dir)
@@ -36,7 +41,7 @@ end
36
41
  # load config
37
42
  config = YAML.load_file([current_dir, "echinoidea.yml"].join("/"))
38
43
 
39
- builder = Echinoidea::Builder.new(current_dir, config)
44
+ builder = Echinoidea::Builder.new(current_dir, config, OPTS[:l])
40
45
  builder.output_directory = OPTS[:o]
41
46
  builder.build_target = OPTS[:t] if OPTS[:t]
42
47
  builder.debug_mode = true if OPTS[:d]
@@ -2,25 +2,35 @@ require 'echinoidea/version'
2
2
 
3
3
  class Echinoidea::Builder
4
4
  attr_reader :class_name, :config, :file_path
5
- attr_accessor :build_target, :debug_mode, :output_directory, :scenes
5
+ attr_accessor :build_target, :debug_mode, :loggings_enabled, :output_directory, :scenes
6
+
7
+ def log(message)
8
+ puts message if @loggings_enabled
9
+ end
6
10
 
7
11
  def self.unique_builder_class_name
8
12
  "ECBuilder#{Time.now.strftime('%y%m%d%H%M%S')}"
9
13
  end
10
14
 
11
- def initialize(root_directory, config)
15
+ def initialize(root_directory, config, loggings_enabled = false)
12
16
  @class_name = self.class.unique_builder_class_name
13
17
  @root_directory = root_directory
14
18
  @config = config
15
19
  @build_target = "iPhone" # Default build target
16
20
  @debug_mode = false
21
+ @loggings_enabled = true if loggings_enabled == true
22
+
23
+ log "Initializing builder"
24
+ log " root_directory: #{root_directory}"
25
+ log " config: #{config}"
17
26
  end
18
27
 
19
28
  def file_path
20
- [@root_directory, "Assets", "Editor", "#{@class_name}.cs"].join("/")
29
+ [@root_directory, "Assets", "Editor", "#{@class_name}.cs"].join("/").gsub(" ", " ")
21
30
  end
22
31
 
23
32
  def write_to_file
33
+ log "Write a batch build script to: #{self.file_path}"
24
34
  # Thanks to: http://ameblo.jp/principia-ca/entry-11010391965.html
25
35
  File.open(self.file_path,'w'){|f|
26
36
  scenes = @config['scenes'].map{|scene| "\"#{scene}\""}.join(",")
@@ -41,6 +51,14 @@ class Echinoidea::Builder
41
51
 
42
52
  player_settings_opts_string = player_settings_opts.map{|k,v| "PlayerSettings.#{k} = #{v};"}.join("\n")
43
53
 
54
+ build_opts = @build_target == "iPhone" ? "SymlinkLibraries" : "None"
55
+
56
+ log " class_name: #{@class_name}"
57
+ log " build_opts: #{build_opts}"
58
+ log " scenes: #{scenes}"
59
+ log " output_directory: #{output_directory}"
60
+ log " build_target: #{@build_target}"
61
+
44
62
  f.write "using UnityEngine;
45
63
  using UnityEditor;
46
64
  using System.Collections;
@@ -49,7 +67,7 @@ public class #{@class_name}
49
67
  public static void Build()
50
68
  {
51
69
  #{player_settings_opts_string}
52
- BuildOptions opt = BuildOptions.SymlinkLibraries;
70
+ BuildOptions opt = BuildOptions.#{build_opts};
53
71
 
54
72
  string[] scenes = {#{scenes}};
55
73
  BuildPipeline.BuildPlayer(scenes, \"#{@output_directory}\", BuildTarget.#{@build_target}, opt);
@@ -60,12 +78,20 @@ public class #{@class_name}
60
78
  end
61
79
  def remove_files
62
80
  File.delete(self.file_path)
63
- File.delete("#{self.file_path}.meta")
81
+ begin
82
+ File.delete("#{self.file_path}.meta")
83
+ rescue
84
+ puts "Failed to delete meta file. #{self.file_path}.meta"
85
+ end
64
86
  end
65
87
 
66
88
  def run_unity_command
67
89
  opts = debug_mode ? "" : "-quit -batchMode"
68
- `/Applications/Unity/Unity.app/Contents/MacOS/Unity #{opts} -executeMethod #{@class_name}.Build -projectPath #{@root_directory}`
90
+ project_path = @root_directory.gsub(" ", "\\ ")
91
+ command = "/Applications/Unity/Unity.app/Contents/MacOS/Unity #{opts} -executeMethod #{@class_name}.Build -projectPath #{project_path}"
92
+ log "Running unity.app..."
93
+ log " #{command}"
94
+ `#{command}`
69
95
  end
70
96
 
71
97
  def run
@@ -1,3 +1,3 @@
1
1
  module Echinoidea
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: echinoidea
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-12 00:00:00.000000000 Z
12
+ date: 2012-11-14 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: echinoidea is a command line unity project build helper.
15
15
  email: