-
Notifications
You must be signed in to change notification settings - Fork 65
/
Rakefile
56 lines (44 loc) · 1.25 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
# -*- ruby -*-
require 'bundler/gem_tasks'
require 'rake/testtask'
Rake::TestTask.new do |t|
t.test_files = FileList['test/**/test_*.rb']
end
task :validate_protos do
res = system("./scripts/validate_protos.rb")
if !res
raise "Couldn't load all protos"
end
end
def proto_files
Dir["lib/google/ads/google_ads/v*/**/*.rb"]
end
def newest_of(files)
files.map { |fn| File.mtime(fn) }.max
end
def newest_proto_file
newest_of(proto_files)
end
def factory_files
["lib/google/ads/google_ads/factories.rb"] + Dir["lib/google/ads/google_ads/factories/**/*.rb"]
end
def newest_factory_file
newest_of(factory_files)
end
def factories_are_recent?
return false unless File.exist?(factory_files.first)
newest_factory_file > newest_proto_file
end
task :codegen => [:copy_third_party_code] do |t|
`./scripts/codegen.sh` unless factories_are_recent?
end
task :copy_third_party_code do |t|
`cp third_party/rspec/caller_filter.rb lib/google/ads/google_ads/deprecation.rb`
end
task :file_permissions do |t|
# Recursively add read permissions to users, groups, and others
`chmod -R ugo+r .`
end
task :copy_code => [:copy_third_party_code]
task :build => [:copy_code, :codegen, :validate_protos, :file_permissions]
task :test => [:copy_code, :codegen]