-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathRakefile
110 lines (88 loc) · 2.2 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
require 'rake/clean'
require 'find'
# helpers
def build_riml_path(dirs, pattern = /.*\.riml$/)
libs = []
dirs.each do |dir|
Find.find(dir) do |path|
if path =~ pattern
libs << File.dirname(path)
end
end
end
libs.uniq.join(':')
end
# misc config
VERBOSE = ENV['VERBOSE'] || false
DEBUG = ENV['DEBUG'] || false
# build paths
BUILD_DIR = 'build'
# source paths
LIB_DIR = 'lib'
LIB_DIRS = build_riml_path([LIB_DIR])
PLUGIN_SOURCE = "#{LIB_DIR}/ember_plugin.riml"
PLUGIN_OUTPUT = "#{BUILD_DIR}/ember_plugin.vim"
# output paths
APP_SOURCE = "#{LIB_DIR}/ember.riml"
APP_OUTPUT = "#{BUILD_DIR}/ember.vim"
# test paths
TEST_DIR = 'spec'
TEST_LIB_DIRS = build_riml_path([TEST_DIR])
# speckle paths
SPECKLE_LIB_DIRS = "#{LIB_DIRS}:#{TEST_LIB_DIRS}"
# vim destinations
PLUGIN_DEST = "plugin/ember.vim"
APP_DEST = "autoload/ember.vim"
# clean task config
CLEAN.include("#{BUILD_DIR}/**/*.vim")
CLEAN.include("#{BUILD_DIR}/**/*.log")
CLEAN.include(PLUGIN_DEST)
CLEAN.include(APP_DEST)
CLOBBER.include(BUILD_DIR)
# tek riml
if ENV.has_key?('RIML_DIR')
RIML_EXEC = "#{ENV['RIML_DIR']}/bin/riml"
else
RIML_EXEC = "bundle exec riml"
end
desc 'Default task :test'
task :default => :test
desc 'Build files and folders'
task :build do
verbose VERBOSE do
mkdir_p BUILD_DIR
end
end
desc 'Compile plugin'
task :compile_plugin => :build do
sh "#{RIML_EXEC} -c #{PLUGIN_SOURCE} -I #{LIB_DIRS} -o #{BUILD_DIR}"
end
desc 'Compile app'
task :compile_app => :build do
sh "#{RIML_EXEC} -c #{APP_SOURCE} -I #{LIB_DIRS} -o #{BUILD_DIR}"
end
desc 'Compile all'
task :compile => [:compile_plugin, :compile_app]
desc 'Run all tests'
task :test => [:build] do
sh "bundle exec speckle -a #{TEST_DIR} -I #{SPECKLE_LIB_DIRS} -r fivemat"
end
desc 'Move compiled files into vim directories'
task :dist => [:compile] do
move_to PLUGIN_OUTPUT, PLUGIN_DEST
move_to APP_OUTPUT, APP_DEST
end
desc 'Make a new release'
task :release => :dist
def move_to(from, to)
to_dir = File.dirname(to)
to_name = File.basename(to)
from_name = File.basename(from)
mkdir_p to_dir
mv from, to_dir
new_from = "#{to_dir}/#{from_name}"
new_to = "#{to_dir}/#{to_name}"
unless new_from == new_to
mv new_from, new_to
end
end