-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathRakefile
executable file
·77 lines (50 loc) · 2.21 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
require 'rake'
require_relative 'common'
require_relative 'unity_helper'
require_relative 'unity_project'
include Common
namespace :lunar do
task :init do
$bin_release_unity = resolve_path '/Applications/Unity5/Unity.app/Contents/MacOS/Unity'
$dir_builder = File.expand_path '.'
$dir_publisher_project = resolve_path "#{$dir_builder}/PublisherProject"
$dir_publisher_project_assets = resolve_path "#{$dir_publisher_project}/Assets"
$dir_out = File.expand_path 'temp'
$dir_out_packages = "#{$dir_out}/packages"
$dir_project = resolve_path File.expand_path('../Project')
$dir_project_assets = resolve_path "#{$dir_project}/Assets"
$dir_project_assets_plugins_unity = resolve_path "#{$dir_project_assets}/LunarPlugin"
$dir_project_assets_editor = resolve_path "#{$dir_project_assets_plugins_unity}/Editor"
def extract_package_version(dir_project)
file_version = resolve_path "#{dir_project}/Assets/LunarPlugin/Scripts/LPVersion.cs" # fixme: embed in configuration
source = File.read file_version
source =~ /VERSION\s+=\s+"(\d+\.\d+.\d+b?)"/
return not_nil $1
end
$package_version = extract_package_version $dir_project
end
task :clean => [:init] do
FileUtils.rm_rf $dir_out
FileUtils.makedirs $dir_out
end
task :list_package_files => [:init] do
$package_files = UnityHelper.list_package_assets $dir_project
# TODO: add readme file
end
desc 'Exports Unity package for standalone distribution (outside Asset Store)'
task :export_unity_package => [:init, :list_package_files] do
file_package = "#{$dir_out_packages}/lunar-#{$package_version}.unitypackage"
print_header "Exporting package: #{file_package}..."
package_files = not_nil $package_files
project = UnityProject.new $dir_project
project.export_unity_package file_package, package_files
end
desc 'Prepares publisher project'
task :prepare_publisher_project => [:export_unity_package] do
package = resolve_path Dir["#{$dir_out_packages}/lunar-*.unitypackage"].first
print_header 'Preparing publisher project...'
project = UnityProject.new $dir_publisher_project, $bin_release_unity
project.import_package package
project.open
end
end