ubb 0.0.1p1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7062533508ef6ae22567edb15f155cdc99a4cc77
4
+ data.tar.gz: be95b1172b992b73164f140137d2d0137d6a8b45
5
+ SHA512:
6
+ metadata.gz: 8c83b00af9a22e0e1fc8b8a9eb8d438e6d1537a0d106d047c8d31440187e39a43d80feb2b04461242ce854b3d7f824017b7aacea13dd2601493e8f50bffb0d81
7
+ data.tar.gz: 791a34278bec15f2846f88a02a8148602b19a28f0399cdf4e43bf9ecd020392381ba7a5d743c3de6ce3414b8ab05221cd9d5c991c5de71159ae39066955b8f6f
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ubb.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 fum1h1ro
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,76 @@
1
+ # Ubb
2
+
3
+ Helper for Unity batch build.
4
+
5
+ [![Gem Version](https://badge.fury.io/rb/ubb.svg)](http://badge.fury.io/rb/ubb)
6
+
7
+
8
+ ## Description
9
+
10
+ Unity Editor からビルドしたりパッケージを入出力する時に使うツールです。
11
+
12
+
13
+ ## Installation
14
+
15
+ Add this line to your application's Gemfile:
16
+
17
+ ```ruby
18
+ gem 'ubb'
19
+ ```
20
+
21
+ And then execute:
22
+
23
+ $ bundle
24
+
25
+ Or install it yourself as:
26
+
27
+ $ gem install ubb
28
+
29
+ ## Usage
30
+
31
+ ```
32
+ $ ubb export -o hoge.unitypackage Plugins/hoge
33
+ $ ubb import hoge.unitypackage
34
+ ```
35
+
36
+ Unity のプロジェクトフォルダは、明示的に指定されなければカレントディレクトリ以下で、最初に見つかったものを自動的に選択します。
37
+ 明示的に指定するには `--project PATH` オプションを使用してください。
38
+
39
+
40
+
41
+ ### export
42
+
43
+ 指定したフォルダ及びファイルを .unitypackage としてエクスポートします。
44
+
45
+ ```
46
+ ubb export -o '出力ファイル名' 'パッケージに含むファイル名(フォルダ可&複数指定可)'
47
+ ```
48
+
49
+ ### import
50
+
51
+ 指定した .unitypackage をプロジェクトにインポートします。
52
+
53
+ ```
54
+ ubb import 'パッケージファイル名'
55
+ ```
56
+
57
+ ### build
58
+
59
+ (開発中)
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+
68
+
69
+
70
+ ## Contributing
71
+
72
+ 1. Fork it ( https://github.com/fum1h1ro/ubb/fork )
73
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
74
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
75
+ 4. Push to the branch (`git push origin my-new-feature`)
76
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
data/bin/ubb ADDED
@@ -0,0 +1,149 @@
1
+ #!/usr/bin/env ruby
2
+ LIB_PATH = "#{File.expand_path(File.dirname(__FILE__))}/../lib"
3
+ $:.unshift LIB_PATH
4
+ require 'ubb'
5
+ require 'optparse'
6
+ require 'fileutils'
7
+ require 'erb'
8
+
9
+ class App
10
+ include FileUtils
11
+ include Ubb
12
+ TASKS = {
13
+ "showlog" => :task_showlog,
14
+ "export" => :task_export_package,
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
25
+ 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
+ end
141
+
142
+
143
+
144
+
145
+
146
+
147
+
148
+ App.new.execute(ARGV)
149
+
data/lib/Build.cs ADDED
@@ -0,0 +1,128 @@
1
+ using UnityEngine;
2
+ using System.Collections;
3
+ using System.Collections.Generic;
4
+ using System.IO;
5
+ using UnityEditor;
6
+
7
+ public class Build {
8
+ enum Target {
9
+ Unknown,
10
+ Development,
11
+ Release,
12
+ Final,
13
+ }
14
+ private static string _bakDefines;
15
+ private static string _buildPath = "<%= output %>";
16
+ // Android
17
+ static void PerformBuild() {
18
+ Debug.Log("build start");
19
+ string[] scenes = GetAllScenes();
20
+ update_symbols();
21
+ string error = BuildPipeline.BuildPlayer(scenes, "build.apk", BuildTarget.Android, BuildOptions.None);
22
+ if (string.IsNullOrEmpty(error)) {
23
+ Debug.Log("build end");
24
+ EditorApplication.Exit(0);
25
+ } else {
26
+ // build failed
27
+ Debug.Log(error);
28
+ EditorApplication.Exit(1);
29
+ }
30
+ }
31
+ // iOS
32
+ public static void PerformiOSBuild() {
33
+ Debug.Log("build start");
34
+ string[] scenes = GetAllScenes();
35
+ BuildOptions opt = BuildOptions.SymlinkLibraries;
36
+ Target tgt = (UnityEditorInternal.InternalEditorUtility.inBatchMode) ? get_target() : Target.Development;
37
+ if (tgt == Target.Unknown) {
38
+ Debug.LogError("TARGET UNKNOWN");
39
+ EditorApplication.Exit(1);
40
+ }
41
+ switch (tgt) {
42
+ case Target.Development:
43
+ opt |= BuildOptions.Development;
44
+ PlayerSettings.strippingLevel = StrippingLevel.Disabled;
45
+ PlayerSettings.iOS.scriptCallOptimization = ScriptCallOptimizationLevel.SlowAndSafe;
46
+ break;
47
+ case Target.Release:
48
+ //opt |= BuildOptions.Development;
49
+ //PlayerSettings.strippingLevel = StrippingLevel.StripByteCode; // リフレクション使ってる箇所で死ぬ
50
+ PlayerSettings.strippingLevel = StrippingLevel.Disabled;
51
+ PlayerSettings.iOS.scriptCallOptimization = ScriptCallOptimizationLevel.FastButNoExceptions;
52
+ break;
53
+ case Target.Final:
54
+ //PlayerSettings.strippingLevel = StrippingLevel.StripByteCode;
55
+ PlayerSettings.strippingLevel = StrippingLevel.Disabled;
56
+ PlayerSettings.iOS.scriptCallOptimization = ScriptCallOptimizationLevel.FastButNoExceptions;
57
+ break;
58
+ }
59
+ push_symbols();
60
+ //
61
+ update_symbols();
62
+ BuildTarget buildTarget = BuildTarget.iOS;
63
+ //string path = Path.GetFullPath(Application.dataPath + "/../project");
64
+ string error = BuildPipeline.BuildPlayer(scenes, _buildPath, buildTarget, opt);
65
+ //
66
+ pop_symbols();
67
+ //
68
+ if (string.IsNullOrEmpty(error)) {
69
+ Debug.Log("build end");
70
+ EditorApplication.Exit(0);
71
+ } else {
72
+ // build failed
73
+ Debug.Log(error);
74
+ EditorApplication.Exit(1);
75
+ }
76
+ }
77
+ private static string[] GetAllScenes() {
78
+ string[] allScene = new string[EditorBuildSettings.scenes.Length];
79
+ int i = 0;
80
+ foreach (EditorBuildSettingsScene scene in EditorBuildSettings.scenes) {
81
+ allScene[i++] = scene.path;
82
+ }
83
+ return allScene;
84
+ }
85
+ private static List<string> get_argv(string name) {
86
+ string[] args = System.Environment.GetCommandLineArgs();
87
+ List<string> argv = new List<string>();
88
+ for (int i = 0; i < args.Length; ++i) {
89
+ string v = args[i];
90
+ if (v == name && i < args.Length - 1) {
91
+ argv.Add(args[i+1]);
92
+ }
93
+ }
94
+ return argv;
95
+ }
96
+ private static void push_symbols() {
97
+ BuildTargetGroup tg = EditorUserBuildSettings.selectedBuildTargetGroup;
98
+ _bakDefines = PlayerSettings.GetScriptingDefineSymbolsForGroup(tg);
99
+ }
100
+ private static void pop_symbols() {
101
+ BuildTargetGroup tg = EditorUserBuildSettings.selectedBuildTargetGroup;
102
+ if (string.IsNullOrEmpty(_bakDefines)) {
103
+ PlayerSettings.SetScriptingDefineSymbolsForGroup(tg, null);
104
+ } else {
105
+ PlayerSettings.SetScriptingDefineSymbolsForGroup(tg, _bakDefines);
106
+ }
107
+ }
108
+ private static void update_symbols() {
109
+ BuildTargetGroup tg = EditorUserBuildSettings.selectedBuildTargetGroup;
110
+ List<string> symbols = get_argv("-symbol");
111
+ string defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(tg);
112
+ Debug.Log(string.Format("OLD: {0}", defines));
113
+ foreach (string sym in symbols) {
114
+ defines += string.Format(";{0}", sym);
115
+ }
116
+ Debug.Log(string.Format("NEW: {0}", defines));
117
+ PlayerSettings.SetScriptingDefineSymbolsForGroup(tg, defines);
118
+ }
119
+ private static Target get_target() {
120
+ List<string> tgts = get_argv("-target");
121
+ foreach (string t in tgts) {
122
+ if (t == "DEV") return Target.Development;
123
+ if (t == "REL") return Target.Release;
124
+ if (t == "FNL") return Target.Final;
125
+ }
126
+ return Target.Unknown;
127
+ }
128
+ }
@@ -0,0 +1,3 @@
1
+ module Ubb
2
+ VERSION = "0.0.1p1"
3
+ end
data/lib/ubb.rb ADDED
@@ -0,0 +1,23 @@
1
+ require "ubb/version"
2
+
3
+
4
+ module Ubb
5
+ class UbbFile
6
+ def parse(filename)
7
+ s = File.read(filename)
8
+ eval(s)
9
+ end
10
+
11
+ def ubb(v)
12
+ p v
13
+ end
14
+
15
+
16
+
17
+ end
18
+
19
+
20
+
21
+
22
+
23
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'ubb'
data/spec/ubb_spec.rb ADDED
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ubb do
4
+ it 'has a version number' do
5
+ expect(Ubb::VERSION).not_to be nil
6
+ end
7
+
8
+ it 'does something useful' do
9
+ expect(false).to eq(true)
10
+ end
11
+ end
data/ubb.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ubb/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ubb"
8
+ spec.version = Ubb::VERSION
9
+ spec.authors = ["fum1h1ro"]
10
+ spec.email = ["fumihiro@gmail.com"]
11
+ spec.summary = %q{Unity Batch Build Helper}
12
+ spec.description = %q{Helping batch build from Unity Editor}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib", "bin"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec"
24
+ end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ubb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1p1
5
+ platform: ruby
6
+ authors:
7
+ - fum1h1ro
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Helping batch build from Unity Editor
56
+ email:
57
+ - fumihiro@gmail.com
58
+ executables:
59
+ - ubb
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - ".rspec"
65
+ - ".travis.yml"
66
+ - Gemfile
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - bin/ubb
71
+ - lib/Build.cs
72
+ - lib/ubb.rb
73
+ - lib/ubb/version.rb
74
+ - spec/spec_helper.rb
75
+ - spec/ubb_spec.rb
76
+ - ubb.gemspec
77
+ homepage: ''
78
+ licenses:
79
+ - MIT
80
+ metadata: {}
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ - bin
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">"
94
+ - !ruby/object:Gem::Version
95
+ version: 1.3.1
96
+ requirements: []
97
+ rubyforge_project:
98
+ rubygems_version: 2.4.5
99
+ signing_key:
100
+ specification_version: 4
101
+ summary: Unity Batch Build Helper
102
+ test_files:
103
+ - spec/spec_helper.rb
104
+ - spec/ubb_spec.rb