ubb 0.0.1p1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/ubb +18 -134
- data/lib/{Build.cs → assets/UbbBuild.cs} +12 -19
- data/lib/ubb/version.rb +1 -1
- data/lib/ubb.rb +74 -12
- data/ubb.gemspec +1 -0
- metadata +19 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d33000db9895bb667d213bbbccb063746b79467f
|
4
|
+
data.tar.gz: 859ae44cf28afc33df44f78b216cb300c292dbe3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b6f17837f3719d0d3c6d3959080531f8b7c1898e79467e59470de217891d45acd2906a034bfbc1ace1ec4fbd8357177e0343b60e4dc436949e40ceae560bcd5
|
7
|
+
data.tar.gz: 878ccfce2035fc603587fc2b112e0dccefc5ba540e06022dbe98d9e404c1355039d9656e75e81a8e9062016bc2a0d48f79eae3910d3be3c780d7fbc9a0d77a98
|
data/bin/ubb
CHANGED
@@ -1,149 +1,33 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
LIB_PATH =
|
2
|
+
LIB_PATH = File.expand_path("../../lib", __FILE__)
|
3
3
|
$:.unshift LIB_PATH
|
4
|
+
|
5
|
+
#require 'rubygems'
|
6
|
+
require 'commander/import'
|
4
7
|
require 'ubb'
|
5
8
|
require 'optparse'
|
6
9
|
require 'fileutils'
|
7
10
|
require 'erb'
|
8
11
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
"import" => :task_import_package,
|
16
|
-
"build" => :task_build,
|
17
|
-
}
|
18
|
-
|
19
|
-
class AppError < StandardError
|
20
|
-
attr_reader :status
|
21
|
-
def initialize(msg, status)
|
22
|
-
super(msg)
|
23
|
-
@status = status
|
24
|
-
end
|
12
|
+
$unity_app_path = "/Applications/Unity/Unity.app/Contents/MacOS/Unity"
|
13
|
+
dirs = Dir.glob("**/Assets")
|
14
|
+
dirs.each do |d|
|
15
|
+
d = d.sub(/(\/)?Assets$/, '')
|
16
|
+
if Dir.exist?("#{d}/ProjectSettings")
|
17
|
+
$project_path = File.expand_path(d)
|
25
18
|
end
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
def initialize()
|
30
|
-
@unity_app_path = "/Applications/Unity/Unity.app/Contents/MacOS/Unity"
|
31
|
-
@project = ''
|
32
|
-
@output = ''
|
33
|
-
@options = {
|
34
|
-
:f => nil,
|
35
|
-
:build_path => "/../project",
|
36
|
-
}
|
37
|
-
end
|
38
|
-
def execute(argv)
|
39
|
-
@task = ''
|
40
|
-
@task = argv.shift if TASKS.keys.include?(argv[0])
|
41
|
-
parse(argv)
|
42
|
-
unless @task.empty?
|
43
|
-
self.method(TASKS[@task]).call
|
44
|
-
end
|
45
|
-
|
46
|
-
#ubbfilename = @options[:f] || 'Ubbfile'
|
47
|
-
#if File.exist?(ubbfilename)
|
48
|
-
# ubb = UbbFile.new
|
49
|
-
# ubb.parse(ubbfilename)
|
50
|
-
#else
|
51
|
-
# raise 'ERROR'
|
52
|
-
#end
|
53
|
-
end
|
54
|
-
|
55
|
-
|
56
|
-
def parse(argv)
|
57
|
-
OptionParser.new do |opt|
|
58
|
-
opt.on("--unity-app-path UNITY_APP_PATH") { |f| @unity_app_path = f }
|
59
|
-
opt.on("--project PROJECT_PATH") { |f| @project = f }
|
60
|
-
opt.on("-f UBBFILE") { |f| @options[:f] = f }
|
61
|
-
opt.on("-o OUTPUTFILE") { |f| @output = f }
|
62
|
-
opt.parse!(argv)
|
63
|
-
end
|
64
|
-
@project = find_project_path if @project.empty?
|
65
|
-
@assets_path = "#{@project}/Assets"
|
66
|
-
@editor_path = "#{@assets_path}/Editor"
|
67
|
-
@argv = argv
|
68
|
-
end
|
69
|
-
|
70
|
-
|
71
|
-
def find_project_path
|
72
|
-
dirs = Dir.glob("**/Assets")
|
73
|
-
return nil if dirs.empty?
|
74
|
-
File.expand_path(dirs[0].sub(/(\/)?Assets$/, ''))
|
75
|
-
end
|
76
|
-
def sh(cmd)
|
77
|
-
print "exec: #{cmd}\n"
|
78
|
-
system cmd
|
79
|
-
if $? != 0
|
80
|
-
raise AppError.new("SHELL ERROR", $?.to_i)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
def has_editor?
|
84
|
-
Dir.exist?(@editor_path)
|
85
|
-
end
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
def task_showlog
|
90
|
-
log = '~/Library/Logs/Unity/Editor.log'
|
91
|
-
sh "less #{log}"
|
92
|
-
end
|
93
|
-
|
94
|
-
|
95
|
-
# export unitypackage
|
96
|
-
#sh "#{UNITY_APP} -batchmode -projectPath #{PROJECT_PATH} -exportPackage Assets/#{EDITOR_ROOT} Assets/#{PLUGINS_ROOT} #{ADDITIONAL_EXPORT_PATH} ../#{UNITYPACKAGE_PATH} -quit"
|
97
|
-
def task_export_package()
|
98
|
-
raise 'specify output' if @output.empty?
|
99
|
-
@output += ".unitypackage" if @output !~ /\.unitypackage$/
|
100
|
-
paths = @argv.map { |pt| "Assets/#{pt}" }.join(' ')
|
101
|
-
output = File.expand_path(@output)
|
102
|
-
sh "#{@unity_app_path} -batchmode -projectPath #{@project} -exportPackage #{paths} #{output} -quit"
|
103
|
-
#p self
|
104
|
-
end
|
105
|
-
# import unitypackage
|
106
|
-
#sh "#{UNITY_APP} -batchmode -projectPath #{File.expand_path(PROJECT_PATH)} -importPackage #{latest} -quit"
|
107
|
-
def task_import_package()
|
108
|
-
raise 'specify unitypackage file' if @argv.size == 0
|
109
|
-
raise 'too many unitypackage files' if @argv.size > 1
|
110
|
-
input = @argv.shift
|
111
|
-
raise "does not exist #{input}" unless File.exist?(@argv)
|
112
|
-
sh "#{@unity_app_path} -batchmode -projectPath #{@project} -importPackage #{input} -quit"
|
113
|
-
end
|
114
|
-
# build
|
115
|
-
#$UNITY_APP_DIR -batchmode -projectPath $UNITY_PROJECT_PATH -quit -executeMethod Build.PerformiOSBuild $ADDITIONAL_OPTS -logFile UnityBuildLog.txt
|
116
|
-
def task_build()
|
117
|
-
raise 'specify output' if @output.empty?
|
118
|
-
begin
|
119
|
-
he = has_editor?
|
120
|
-
mkdir_p @editor_path unless he
|
121
|
-
cs = File.read("#{LIB_PATH}/Build.cs")
|
122
|
-
output = File.expand_path(@output)
|
123
|
-
csfile = File.open("#{@editor_path}/Build.cs", "w+")
|
124
|
-
csfile.write(ERB.new(cs).result binding)
|
125
|
-
csfile.flush
|
126
|
-
sh "#{@unity_app_path} -batchmode -projectPath #{@project} -quit -executeMethod Build.PerformiOSBuild -target DEV"
|
127
|
-
ensure
|
128
|
-
unless he
|
129
|
-
rm_rf @editor_path
|
130
|
-
rm_f "#{@editor_path}.meta"
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
19
|
end
|
141
20
|
|
21
|
+
program :version, Ubb::VERSION
|
22
|
+
program :description, 'Unity Batch Build helper'
|
23
|
+
program :help_formatter, :compact
|
142
24
|
|
25
|
+
global_option('--verbose', 'VERBOSE') { $verbose = true }
|
26
|
+
global_option('-p', '--project PATH', 'specify Unity project path') { |path| $project_path = path }
|
27
|
+
global_option('-u', '--unity PATH', 'specify Unity application path') { |path| $unity_app_path = path }
|
143
28
|
|
29
|
+
default_command :help
|
144
30
|
|
31
|
+
always_trace!
|
145
32
|
|
146
33
|
|
147
|
-
|
148
|
-
App.new.execute(ARGV)
|
149
|
-
|
@@ -17,7 +17,7 @@ public class Build {
|
|
17
17
|
static void PerformBuild() {
|
18
18
|
Debug.Log("build start");
|
19
19
|
string[] scenes = GetAllScenes();
|
20
|
-
update_symbols();
|
20
|
+
//update_symbols();
|
21
21
|
string error = BuildPipeline.BuildPlayer(scenes, "build.apk", BuildTarget.Android, BuildOptions.None);
|
22
22
|
if (string.IsNullOrEmpty(error)) {
|
23
23
|
Debug.Log("build end");
|
@@ -30,6 +30,7 @@ public class Build {
|
|
30
30
|
}
|
31
31
|
// iOS
|
32
32
|
public static void PerformiOSBuild() {
|
33
|
+
BuildTargetGroup group = BuildTargetGroup.iOS;
|
33
34
|
Debug.Log("build start");
|
34
35
|
string[] scenes = GetAllScenes();
|
35
36
|
BuildOptions opt = BuildOptions.SymlinkLibraries;
|
@@ -56,14 +57,13 @@ public class Build {
|
|
56
57
|
PlayerSettings.iOS.scriptCallOptimization = ScriptCallOptimizationLevel.FastButNoExceptions;
|
57
58
|
break;
|
58
59
|
}
|
59
|
-
push_symbols();
|
60
|
+
push_symbols(group);
|
60
61
|
//
|
61
|
-
update_symbols();
|
62
|
+
update_symbols(group);
|
62
63
|
BuildTarget buildTarget = BuildTarget.iOS;
|
63
|
-
//string path = Path.GetFullPath(Application.dataPath + "/../project");
|
64
64
|
string error = BuildPipeline.BuildPlayer(scenes, _buildPath, buildTarget, opt);
|
65
65
|
//
|
66
|
-
pop_symbols();
|
66
|
+
pop_symbols(group);
|
67
67
|
//
|
68
68
|
if (string.IsNullOrEmpty(error)) {
|
69
69
|
Debug.Log("build end");
|
@@ -93,28 +93,21 @@ public class Build {
|
|
93
93
|
}
|
94
94
|
return argv;
|
95
95
|
}
|
96
|
-
private static void push_symbols() {
|
97
|
-
|
98
|
-
_bakDefines = PlayerSettings.GetScriptingDefineSymbolsForGroup(tg);
|
96
|
+
private static void push_symbols(BuildTargetGroup group) {
|
97
|
+
_bakDefines = PlayerSettings.GetScriptingDefineSymbolsForGroup(group);
|
99
98
|
}
|
100
|
-
private static void pop_symbols() {
|
101
|
-
|
102
|
-
if (string.IsNullOrEmpty(_bakDefines)) {
|
103
|
-
PlayerSettings.SetScriptingDefineSymbolsForGroup(tg, null);
|
104
|
-
} else {
|
105
|
-
PlayerSettings.SetScriptingDefineSymbolsForGroup(tg, _bakDefines);
|
106
|
-
}
|
99
|
+
private static void pop_symbols(BuildTargetGroup group) {
|
100
|
+
PlayerSettings.SetScriptingDefineSymbolsForGroup(group, _bakDefines);
|
107
101
|
}
|
108
|
-
private static void update_symbols() {
|
109
|
-
BuildTargetGroup tg = EditorUserBuildSettings.selectedBuildTargetGroup;
|
102
|
+
private static void update_symbols(BuildTargetGroup group) {
|
110
103
|
List<string> symbols = get_argv("-symbol");
|
111
|
-
string defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(
|
104
|
+
string defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(group);
|
112
105
|
Debug.Log(string.Format("OLD: {0}", defines));
|
113
106
|
foreach (string sym in symbols) {
|
114
107
|
defines += string.Format(";{0}", sym);
|
115
108
|
}
|
116
109
|
Debug.Log(string.Format("NEW: {0}", defines));
|
117
|
-
PlayerSettings.SetScriptingDefineSymbolsForGroup(
|
110
|
+
PlayerSettings.SetScriptingDefineSymbolsForGroup(group, defines);
|
118
111
|
}
|
119
112
|
private static Target get_target() {
|
120
113
|
List<string> tgts = get_argv("-target");
|
data/lib/ubb/version.rb
CHANGED
data/lib/ubb.rb
CHANGED
@@ -2,22 +2,84 @@ require "ubb/version"
|
|
2
2
|
|
3
3
|
|
4
4
|
module Ubb
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
def self.sh(cmd)
|
6
|
+
print "exec: #{cmd}\n"
|
7
|
+
system cmd
|
8
|
+
if $? != 0
|
9
|
+
raise "ERROR: #{$?.to_i}"
|
9
10
|
end
|
10
|
-
|
11
|
-
def ubb(v)
|
12
|
-
p v
|
13
|
-
end
|
14
|
-
|
15
|
-
|
16
|
-
|
17
11
|
end
|
12
|
+
def self.editor_path
|
13
|
+
"#{$project_path}/Assets/Editor"
|
14
|
+
end
|
15
|
+
def self.has_editor?
|
16
|
+
Dir.exist?(self.editor_path)
|
17
|
+
end
|
18
|
+
end
|
18
19
|
|
20
|
+
command :showlog do |c|
|
21
|
+
c.syntax = 'ubb showlog'
|
22
|
+
c.summary = 'show Unity Editor log'
|
23
|
+
c.action do |args, options|
|
24
|
+
log = '~/Library/Logs/Unity/Editor.log'
|
25
|
+
Ubb.sh "less #{log}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
alias_command :log, :showlog
|
19
29
|
|
30
|
+
command :export do |c|
|
31
|
+
c.syntax = 'ubb export [options]'
|
32
|
+
c.summary = 'export .unitypackage'
|
33
|
+
c.description = 'hoge'
|
34
|
+
c.example 'export some folders to unitypackage', 'ubb export --project path/to/unityproject --output some.unitypackage Plugins/Something Resources/Something'
|
35
|
+
c.option '--output FILENAME', String, 'specify .unitypackage name'
|
36
|
+
c.action do |args, options|
|
37
|
+
raise 'specify output filename' if options.output.nil?
|
38
|
+
output = (options.output !~ /\.unitypackage$/)? options.output + ".unitypackage" : options.output
|
39
|
+
output = File.expand_path(output)
|
40
|
+
paths = args.map { |pt| "Assets/#{pt}" }.join(' ')
|
41
|
+
Ubb.sh "#{$unity_app_path} -batchmode -projectPath #{$project_path} -exportPackage #{paths} #{output} -quit"
|
42
|
+
end
|
43
|
+
end
|
20
44
|
|
45
|
+
command :import do |c|
|
46
|
+
c.syntax = 'ubb import [package]'
|
47
|
+
c.summary = 'import .unitypackage'
|
48
|
+
c.description = 'hoge'
|
49
|
+
c.example 'import some unitypackage', 'ubb import --project path/to/unityproject some.unitypackage'
|
50
|
+
c.action do |args, options|
|
51
|
+
raise 'specify unitypackage file' if args.size == 0
|
52
|
+
raise 'too many unitypackage files' if args.size > 1
|
53
|
+
input = args[0]
|
54
|
+
raise "#{input} does not exist" unless File.exist?(input)
|
55
|
+
Ubb.sh "#{$unity_app_path} -batchmode -projectPath #{$project_path} -importPackage #{input} -quit"
|
56
|
+
end
|
57
|
+
end
|
21
58
|
|
22
|
-
|
59
|
+
command :build do |c|
|
60
|
+
c.option '--output PATH', String, 'specify output path'
|
61
|
+
c.action do |args, options|
|
62
|
+
raise 'specify output path' if options.output.nil?
|
63
|
+
begin
|
64
|
+
output = File.expand_path(options.output)
|
65
|
+
has = Ubb.has_editor?
|
66
|
+
editor_path = Ubb.editor_path
|
67
|
+
FileUtils.mkdir_p editor_path unless has
|
68
|
+
src = "#{LIB_PATH}/assets/UbbBuild.cs"
|
69
|
+
dst = "#{editor_path}/UbbBuild.cs"
|
70
|
+
raise 'build script has already existed' if File.exist?(dst)
|
71
|
+
cs = File.read(src)
|
72
|
+
csfile = File.open(dst, "w+")
|
73
|
+
csfile.write(ERB.new(cs).result binding)
|
74
|
+
csfile.flush
|
75
|
+
Ubb.sh "#{$unity_app_path} -batchmode -projectPath #{$project_path} -quit -executeMethod Build.PerformiOSBuild -target DEV"
|
76
|
+
ensure
|
77
|
+
FileUtils.rm_f "#{editor_path}/UbbBuild.cs"
|
78
|
+
FileUtils.rm_f "#{editor_path}/UbbBuild.cs.meta"
|
79
|
+
unless has
|
80
|
+
FileUtils.rm_rf editor_path
|
81
|
+
FileUtils.rm_f "#{editor_path}.meta"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
23
85
|
end
|
data/ubb.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ubb
|
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
|
- fum1h1ro
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: commander
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '4.3'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '4.3'
|
55
69
|
description: Helping batch build from Unity Editor
|
56
70
|
email:
|
57
71
|
- fumihiro@gmail.com
|
@@ -68,7 +82,7 @@ files:
|
|
68
82
|
- README.md
|
69
83
|
- Rakefile
|
70
84
|
- bin/ubb
|
71
|
-
- lib/
|
85
|
+
- lib/assets/UbbBuild.cs
|
72
86
|
- lib/ubb.rb
|
73
87
|
- lib/ubb/version.rb
|
74
88
|
- spec/spec_helper.rb
|
@@ -90,9 +104,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
90
104
|
version: '0'
|
91
105
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
106
|
requirements:
|
93
|
-
- - "
|
107
|
+
- - ">="
|
94
108
|
- !ruby/object:Gem::Version
|
95
|
-
version:
|
109
|
+
version: '0'
|
96
110
|
requirements: []
|
97
111
|
rubyforge_project:
|
98
112
|
rubygems_version: 2.4.5
|