-
Notifications
You must be signed in to change notification settings - Fork 2
/
Rakefile
62 lines (52 loc) · 1.6 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
# -*- Mode: Ruby -*-
require 'rake/clean'
require 'fileutils'
DESTDIR = File.join(ENV['HOME'], 'Library', 'Scripts')
SRC = FileList['scripts/*.applescript']
SCPTSDIR = 'build'
SCPTS = SRC.collect { |s|
File.join(SCPTSDIR, s.sub(/scripts\/(.+)\.applescript$/, '\1.app'))
}
CLEAN.include(SCPTS)
CLEAN.include(SCPTSDIR)
verbose true
# Create directories for the build output
SCPTS.each do |s|
directory File.dirname(s)
end
directory DESTDIR
rule '.app' => lambda { |scpt| find_source(scpt) } do |t|
# Make sure the directory exists
Rake::Task[File.dirname(t.name)].invoke
# Compile execute-only (-x)
sh "osacompile -x -o '#{t.name}' '#{t.source}'"
end
# We want to build into a parallel directory structure, so this is used to go
# find the applescript
def find_source(scpt)
base = File.basename(scpt, '.app')
SRC.find { |s| File.basename(s, '.applescript') == base }
end
desc 'Compile the scripts as Applications'
task :compile => SCPTS do
end
desc "Install scripts to #{DESTDIR}."
task :install => [:compile] do
Rake::Task[DESTDIR].invoke
SCPTS.each do |s|
# Strip off SCPTSDIR, append to DESTDIR
d = File.join(DESTDIR, s.split(File::Separator)[1..-1])
# Make sure the directory exists
directory File.dirname(d)
Rake::Task[d].invoke
puts "cp #{s} #{d}" if verbose
FileUtils.cp_r(s, d)
end
end
desc "Install scripts to #{DESTDIR} and clean up."
task :installclean => [:install, :clean] do
end
task :default do
puts "run one of the following:"
sh "rake -T"
end