-
Notifications
You must be signed in to change notification settings - Fork 22
/
pebble-sdk.rb.template
101 lines (79 loc) · 3.26 KB
/
pebble-sdk.rb.template
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
require 'curses'
class PebbleSdk < Formula
class Version < ::Version
def <=> (other)
mine = ::Version.new(self.to_s.sub('dp', 'alpha'))
other = ::Version.new(other.to_s.sub('dp', 'alpha'))
mine <=> other
end
end
homepage 'https://developer.pebble.com'
url "https://sdk.getpebble.com/download/__PEBBLE_SDK_VERSION__?source=homebrew"
sha256 "__PEBBLE_SDK_SHA256__"
version PebbleSdk::Version.new("__PEBBLE_SDK_VERSION__")
depends_on 'freetype' => :recommended
depends_on 'pebble-toolchain'
depends_on 'boost-python'
depends_on 'glib'
depends_on 'pixman'
__PEBBLE_SDK_REQUIREMENTS__
def cancel_install
Curses.close_screen
puts "To use the Pebble SDK, you must agree to the Pebble Terms of Use and Pebble Developer License."
puts "Cancelling installation of Pebble SDK..."
end
def check_license_agreement
Curses.noecho
Curses.init_screen
Curses.addstr("To use the Pebble SDK, you must agree to the following:\n\nPEBBLE TERMS OF USE\nhttps://developer.pebble.com/legal/terms-of-use\n\nPEBBLE DEVELOPER LICENSE\nhttps://developer.pebble.com/legal/sdk-license\n\nDo you accept the Pebble Terms of Use and the Pebble Developer License (y/n)? ")
loop do
case Curses.getch
when 'y'
break
when 'n'
cancel_install
exit
end
end
Curses.close_screen
end
def install
check_license_agreement
inreplace 'bin/pebble' do |s|
# This replacement fixes a path that gets messed up because of the
# bin.env_script_all_files call (which relocates actual pebble.py script
# to libexec/, causing problems with the absolute path expected below).
s.gsub! /^script_path = .*?$/m, "script_path = '#{libexec}/../pebble-tool/pebble.py'"
# This replacement removes environment settings that were needed only
# if installation was done with the official script
s.gsub! /^local_python_env.*?=.*?\(.*?\)$/m, ""
s.gsub! /^process = subprocess\.Popen\(args, shell=False, env=local_python_env\)/, "process = subprocess.Popen(args, shell=False)"
end
ENV["PYTHONPATH"] = lib+"python2.7/site-packages"
ENV.prepend_create_path 'PYTHONPATH', libexec+'lib/python2.7/site-packages'
ENV.prepend_create_path "PATH", libexec/"bin"
install_args = [ "setup.py", "install", "--prefix=#{libexec}" ]
%w[__PEBBLE_SDK_REQUIREMENTS_LIST__].each do |r|
resource(r).stage { system "python", *install_args }
end
doc.install %w[Documentation Examples README.txt]
prefix.install %w[Pebble bin pebble-tool requirements.txt version.txt]
ln_s "#{HOMEBREW_PREFIX}/Cellar/pebble-toolchain/2.0/arm-cs-tools", "#{prefix}"
bin.env_script_all_files(libexec+'bin', :PYTHONPATH => ENV['PYTHONPATH'])
end
test do
system bin/'pebble', 'new-project', 'test'
cd 'test' do
# We have to remove the default /usr/local/include from the CPATH
# because the toolchain has -Werror=poison-system-directories set
ENV['CPATH'] = ''
system bin/'pebble', 'build'
end
end
def caveats; <<-EOS.undent
Documentation can be found online at https://developer.pebble.com/docs or in
#{doc}
Examples can be found online at https://github.com/pebble-examples
EOS
end
end