middleman-core 3.0.0.alpha.7 → 3.0.0.alpha.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. data/features/preview_changes.feature +12 -1
  2. data/lib/middleman-core/base.rb +1 -1
  3. data/lib/middleman-core/cli/server.rb +1 -1
  4. data/lib/middleman-core/core_extensions/file_watcher.rb +2 -0
  5. data/lib/middleman-core/core_extensions/front_matter.rb +0 -1
  6. data/lib/middleman-core/core_extensions/rendering.rb +8 -1
  7. data/lib/middleman-core/renderers/erb.rb +10 -0
  8. data/lib/middleman-core/step_definitions/middleman_steps.rb +10 -8
  9. data/lib/middleman-core/step_definitions/server_steps.rb +4 -3
  10. data/lib/middleman-core/vendor/rb-fsevent-0.4.3.1/LICENSE +20 -0
  11. data/lib/middleman-core/vendor/rb-fsevent-0.4.3.1/README.rdoc +254 -0
  12. data/lib/middleman-core/vendor/rb-fsevent-0.4.3.1/ext/extconf.rb +61 -0
  13. data/lib/middleman-core/vendor/rb-fsevent-0.4.3.1/ext/fsevent/fsevent_watch.c +226 -0
  14. data/lib/middleman-core/vendor/rb-fsevent-0.4.3.1/lib/rb-fsevent/fsevent.rb +105 -0
  15. data/lib/middleman-core/vendor/rb-fsevent-0.4.3.1/lib/rb-fsevent/version.rb +3 -0
  16. data/lib/middleman-core/vendor/rb-fsevent-0.4.3.1/lib/rb-fsevent.rb +2 -0
  17. data/lib/middleman-core/vendor/rb-inotify-0.8.8/.yardopts +4 -0
  18. data/lib/middleman-core/vendor/rb-inotify-0.8.8/MIT-LICENSE +20 -0
  19. data/lib/middleman-core/vendor/rb-inotify-0.8.8/README.md +66 -0
  20. data/lib/middleman-core/vendor/rb-inotify-0.8.8/Rakefile +54 -0
  21. data/lib/middleman-core/vendor/rb-inotify-0.8.8/VERSION +1 -0
  22. data/lib/middleman-core/vendor/rb-inotify-0.8.8/lib/rb-inotify/event.rb +139 -0
  23. data/lib/middleman-core/vendor/rb-inotify-0.8.8/lib/rb-inotify/native/flags.rb +89 -0
  24. data/lib/middleman-core/vendor/rb-inotify-0.8.8/lib/rb-inotify/native.rb +31 -0
  25. data/lib/middleman-core/vendor/rb-inotify-0.8.8/lib/rb-inotify/notifier.rb +308 -0
  26. data/lib/middleman-core/vendor/rb-inotify-0.8.8/lib/rb-inotify/watcher.rb +83 -0
  27. data/lib/middleman-core/vendor/rb-inotify-0.8.8/lib/rb-inotify.rb +17 -0
  28. data/lib/middleman-core/vendor/rb-inotify-0.8.8/rb-inotify.gemspec +53 -0
  29. data/lib/middleman-core/version.rb +1 -1
  30. data/lib/middleman-core/{guard.rb → watcher.rb} +62 -58
  31. data/lib/middleman-core.rb +1 -1
  32. data/middleman-core.gemspec +1 -1
  33. metadata +29 -10
@@ -15,4 +15,15 @@ Feature: Preview Changes
15
15
  """
16
16
  When I go to "/content.html"
17
17
  Then I should see "Hola Mundo"
18
-
18
+
19
+ Scenario: A template is removed during preview
20
+ Given the Server is running at "preview-app"
21
+ And the file "source/a-page.html.erb" has the contents
22
+ """
23
+ Hello World
24
+ """
25
+ When I go to "/a-page.html"
26
+ Then I should see "Hello World"
27
+ And the file "source/a-page.html.erb" is removed
28
+ When I go to "/a-page.html"
29
+ Then I should see "File Not Found"
@@ -213,7 +213,7 @@ class Middleman::Base
213
213
  # Add Builder Callbacks
214
214
  register Middleman::CoreExtensions::Builder
215
215
 
216
- # Add Guard Callbacks
216
+ # Add Watcher Callbacks
217
217
  register Middleman::CoreExtensions::FileWatcher
218
218
 
219
219
  # Activate Data package
@@ -43,7 +43,7 @@ module Middleman::Cli
43
43
  }
44
44
 
45
45
  puts "== The Middleman is loading"
46
- Middleman::Guard.start(params)
46
+ Middleman::Watcher.start(params)
47
47
  end
48
48
  end
49
49
 
@@ -61,6 +61,7 @@ module Middleman::CoreExtensions::FileWatcher
61
61
  # @param [String] path The file that changed
62
62
  # @return [void]
63
63
  def file_did_change(path)
64
+ return if ::Middleman::Watcher.ignore_list.any? { |r| path.match(r) }
64
65
  file_changed.each do |callback, matcher|
65
66
  next if path.match(%r{^#{build_dir}/})
66
67
  next if !matcher.nil? && !path.match(matcher)
@@ -73,6 +74,7 @@ module Middleman::CoreExtensions::FileWatcher
73
74
  # @param [String] path The file that was deleted
74
75
  # @return [void]
75
76
  def file_did_delete(path)
77
+ return if ::Middleman::Watcher.ignore_list.any? { |r| path.match(r) }
76
78
  file_deleted.each do |callback, matcher|
77
79
  next if path.match(%r{^#{build_dir}/})
78
80
  next unless matcher.nil? || path.match(matcher)
@@ -91,7 +91,6 @@ module Middleman::CoreExtensions::FrontMatter
91
91
  file = File.expand_path(file, @app.root)
92
92
  content = File.read(file)
93
93
 
94
- # @app.logger.debug :frontmatter_update, Time.now, file if @app.logging?
95
94
  result = parse_front_matter(content)
96
95
 
97
96
  if result
@@ -1,3 +1,10 @@
1
+ # Shutup Tilt Warnings
2
+ class Tilt::Template
3
+ def warn(*args)
4
+ # Kernel.warn(*args)
5
+ end
6
+ end
7
+
1
8
  module Middleman::CoreExtensions::Rendering
2
9
  class << self
3
10
  def registered(app)
@@ -244,4 +251,4 @@ module Middleman::CoreExtensions::Rendering
244
251
  end
245
252
  end
246
253
  end
247
- end
254
+ end
@@ -1,16 +1,26 @@
1
+ # ERb renderer
1
2
  module Middleman::Renderers::ERb
3
+
4
+ # Setup extension
2
5
  class << self
6
+
7
+ # once registered
3
8
  def registered(app)
9
+ # Setup a default ERb engine
4
10
  app.set :erb_engine, :erb
5
11
  app.set :erb_engine_prefix, ::Tilt
6
12
 
13
+ # After config
7
14
  app.after_configuration do
15
+ # Find the user's prefered engine
16
+ # Convert symbols to classes
8
17
  if erb_engine.is_a? Symbol
9
18
  engine = engine.to_s
10
19
  engine = engine == "erb" ? "ERB" : engine.camelize
11
20
  erb_engine = erb_engine_prefix.const_get("#{engine}Template")
12
21
  end
13
22
 
23
+ # Tell Tilt to use the preferred engine
14
24
  ::Tilt.prefer(erb_engine)
15
25
  end
16
26
  end
@@ -1,15 +1,17 @@
1
- require "fileutils"
2
-
3
- Given /^a project at "([^\"]*)"$/ do |dirname|
4
- @target = File.join(PROJECT_ROOT_PATH, "fixtures", dirname)
5
- end
6
-
7
1
  Then /^the file "([^\"]*)" has the contents$/ do |path, contents|
8
- file_path = File.expand_path(path, @target)
9
- File.open(file_path, 'w') { |f| f.write(contents) }
2
+ write_file(path, contents)
10
3
  step %Q{the file "#{path}" did change}
11
4
  end
12
5
 
6
+ Then /^the file "([^\"]*)" is removed$/ do |path|
7
+ step %Q{I remove the file "#{path}"}
8
+ step %Q{the file "#{path}" did delete}
9
+ end
10
+
13
11
  Then /^the file "([^\"]*)" did change$/ do |path|
14
12
  @server_inst.file_did_change(path)
13
+ end
14
+
15
+ Then /^the file "([^\"]*)" did delete$/ do |path|
16
+ @server_inst.file_did_delete(path)
15
17
  end
@@ -22,9 +22,10 @@ Given /^current environment is "([^\"]*)"$/ do |env|
22
22
  end
23
23
 
24
24
  Given /^the Server is running at "([^\"]*)"$/ do |app_path|
25
- step %Q{a project at "#{app_path}"}
25
+ step %Q{a fixture app "#{app_path}"}
26
+
27
+ root_dir = File.expand_path(current_dir)
26
28
 
27
- root_dir = File.join(PROJECT_ROOT_PATH, "fixtures", app_path)
28
29
  if File.exists?(File.join(root_dir, "source"))
29
30
  ENV["MM_SOURCE"] = "source"
30
31
  else
@@ -32,7 +33,7 @@ Given /^the Server is running at "([^\"]*)"$/ do |app_path|
32
33
  end
33
34
 
34
35
  initialize_commands = @initialize_commands || []
35
- initialize_commands.unshift lambda {
36
+ initialize_commands.unshift lambda {
36
37
  set :root, root_dir
37
38
  set :environment, @current_env || :development
38
39
  set :show_exceptions, false
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Thibaud Guillaume-Gentil
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,254 @@
1
+ = rb-fsevent
2
+
3
+ Very simple & usable Mac OSX FSEvents API
4
+
5
+ - RubyCocoa not required!
6
+ - Signals are working (really)
7
+ - Tested on MRI 1.8.7 & 1.9.2
8
+ - Tested on JRuby 1.6.3
9
+
10
+ == Install
11
+
12
+ gem install rb-fsevent
13
+
14
+ == Usage
15
+
16
+ === Singular path
17
+
18
+ require 'rb-fsevent'
19
+
20
+ fsevent = FSEvent.new
21
+ fsevent.watch Dir.pwd do |directories|
22
+ puts "Detected change inside: #{directories.inspect}"
23
+ end
24
+ fsevent.run
25
+
26
+ === Multiple paths
27
+
28
+ require 'rb-fsevent'
29
+
30
+ paths = ['/tmp/path/one', '/tmp/path/two', Dir.pwd]
31
+
32
+ fsevent = FSEvent.new
33
+ fsevent.watch paths do |directories|
34
+ puts "Detected change inside: #{directories.inspect}"
35
+ end
36
+ fsevent.run
37
+
38
+ === Multiple paths and additional options as a Hash
39
+
40
+ require 'rb-fsevent'
41
+
42
+ paths = ['/tmp/path/one', '/tmp/path/two', Dir.pwd]
43
+ options = {:latency => 1.5, :no_defer => true }
44
+
45
+ fsevent = FSEvent.new
46
+ fsevent.watch paths, options do |directories|
47
+ puts "Detected change inside: #{directories.inspect}"
48
+ end
49
+ fsevent.run
50
+
51
+ === Multiple paths and additional options as an Array
52
+
53
+ require 'rb-fsevent'
54
+
55
+ paths = ['/tmp/path/one', '/tmp/path/two', Dir.pwd]
56
+ options = ['--latency', 1.5, '--no-defer']
57
+
58
+ fsevent = FSEvent.new
59
+ fsevent.watch paths, options do |directories|
60
+ puts "Detected change inside: #{directories.inspect}"
61
+ end
62
+ fsevent.run
63
+
64
+ == Options
65
+
66
+ When defining options using a hash or hash-like object, it gets checked for validity and converted to the appropriate fsevent_watch commandline arguments array when the FSEvent class is instantiated. This is obviously the safest and preferred method of passing in options.
67
+
68
+ You may, however, choose to pass in an array of commandline arguments as your options value and it will be passed on, unmodified, to the fsevent_watch binary when called.
69
+
70
+ So far, the following options are supported...
71
+
72
+ - :latency => 0.5 # in seconds
73
+ - :no_defer => true
74
+ - :watch_root => true
75
+ - :since_when => 18446744073709551615 # an FSEventStreamEventId
76
+
77
+ === Latency
78
+
79
+ The :latency parameter determines how long the service should wait after the first event before passing that information along to the client. If your latency is set to 4 seconds, and 300 changes occur in the first three, then the callback will be fired only once. If latency is set to 0.1 in the exact same scenario, you will see that callback fire somewhere closer to between 25 and 30 times.
80
+
81
+ Setting a higher latency value allows for more effective temporal coalescing, resulting in fewer callbacks and greater overall efficiency... at the cost of apparent responsiveness. Setting this to a reasonably high value (and NOT setting :no_defer) is particularly well suited for background, daemon, or batch processing applications.
82
+
83
+ Implementation note: It appears that FSEvents will only coalesce events from a maximum of 32 distinct subpaths, making the above completely accurate only when events are to fewer than 32 subpaths. Creating 300 files in one directory, for example, or 30 files in 10 subdirectories, but not 300 files within 300 subdirectories. In the latter case, you may receive 31 callbacks in one go after the latency period. As this appears to be an implementation detail, the number could potentially differ across OS revisions. It is entirely possible that this number is somehow configurable, but I have not yet discovered an accepted method of doing so.
84
+
85
+ === NoDefer
86
+
87
+ The :no_defer option changes the behavior of the latency parameter completely. Rather than waiting for $latency period of time before sending along events in an attempt to coalesce a potential deluge ahead of time, that first event is sent along to the client immediately and is followed by a $latency period of silence before sending along any additional events that occurred within that period.
88
+
89
+ This behavior is particularly useful for interactive applications where that feeling of apparent responsiveness is most important, but you still don't want to get overwhelmed by a series of events that occur in rapid succession.
90
+
91
+ === WatchRoot
92
+
93
+ The :watch_root option allows for catching the scenario where you start watching "~/src/demo_project" and either it is later renamed to "~/src/awesome_sauce_3000" or the path changes in such a manner that the original directory is now at "~/clients/foo/iteration4/demo_project".
94
+
95
+ Unfortunately, while this behavior is somewhat supported in the fsevent_watch binary built as part of this project, support for passing across detailed metadata is not (yet). As a result, you would not receive the appropriate RootChanged event and be able to react appropriately. Also, since the C code doesn't open watched directories and retain that file descriptor as part of path-specific callback metadata, we are unable to issue an F_GETPATH fcntl() to determine the directory's new path.
96
+
97
+ Please do not use this option until proper support is added in an upcoming (planned) release.
98
+
99
+ === SinceWhen
100
+
101
+ The FSEventStreamEventId passed in to :since_when is used as a base for reacting to historic events. Unfortunately, not only is the metadata for transitioning from historic to live events not currently passed along, but it is incorrectly passed as a change event on the root path, and only per-host event streams are currently supported. When using per-host event streams, the event IDs are not guaranteed to be unique or contiguous when shared volumes (firewire/USB/net/etc) are used on multiple macs.
102
+
103
+ Please do not use this option until proper support is added in an upcoming (planned) release, unless it's acceptable for you to receive that one fake event that's handled incorrectly when events transition from historical to live. Even in that scenario, there's no metadata available for determining the FSEventStreamEventId of the last received event.
104
+
105
+ WARNING: passing in 0 as the parameter to :since_when will return events for every directory modified since "the beginning of time".
106
+
107
+ == Debugging output
108
+
109
+ If the gem is installed with the environment variable FWDEBUG set to the string "true", then fsevent_watch will be built with its various DEBUG sections defined, and the output to STDERR is truly verbose (and hopefully helpful in debugging your application and not just fsevent_watch itself). If enough people find this to be directly useful when developing code that makes use of rb-fsevent, then it wouldn't be hard to clean this up and make it a feature enabled by a commandline argument instead. Until somebody files an issue, however, I will assume otherwise.
110
+
111
+ append_path called for: /tmp/moo/cow/
112
+ resolved path to: /private/tmp/moo/cow
113
+
114
+ config.sinceWhen 18446744073709551615
115
+ config.latency 0.300000
116
+ config.flags 00000000
117
+ config.paths
118
+ /private/tmp/moo/cow
119
+
120
+ FSEventStreamRef @ 0x100108540:
121
+ allocator = 0x7fff705a4ee0
122
+ callback = 0x10000151e
123
+ context = {0, 0x0, 0x0, 0x0, 0x0}
124
+ numPathsToWatch = 1
125
+ pathsToWatch = 0x7fff705a4ee0
126
+ pathsToWatch[0] = '/private/tmp/moo/cow'
127
+ latestEventId = -1
128
+ latency = 300000 (microseconds)
129
+ flags = 0x00000000
130
+ runLoop = 0x0
131
+ runLoopMode = 0x0
132
+
133
+
134
+ FSEventStreamCallback fired!
135
+ numEvents: 32
136
+ event path: /private/tmp/moo/cow/1/a/
137
+ event flags: 00000000
138
+ event ID: 1023767
139
+ event path: /private/tmp/moo/cow/1/b/
140
+ event flags: 00000000
141
+ event ID: 1023782
142
+ event path: /private/tmp/moo/cow/1/c/
143
+ event flags: 00000000
144
+ event ID: 1023797
145
+ event path: /private/tmp/moo/cow/1/d/
146
+ event flags: 00000000
147
+ event ID: 1023812
148
+ event path: /private/tmp/moo/cow/1/e/
149
+ event flags: 00000000
150
+ event ID: 1023827
151
+ event path: /private/tmp/moo/cow/1/f/
152
+ event flags: 00000000
153
+ event ID: 1023842
154
+ event path: /private/tmp/moo/cow/1/g/
155
+ event flags: 00000000
156
+ event ID: 1023857
157
+ event path: /private/tmp/moo/cow/1/h/
158
+ event flags: 00000000
159
+ event ID: 1023872
160
+ event path: /private/tmp/moo/cow/1/i/
161
+ event flags: 00000000
162
+ event ID: 1023887
163
+ event path: /private/tmp/moo/cow/1/j/
164
+ event flags: 00000000
165
+ event ID: 1023902
166
+ event path: /private/tmp/moo/cow/1/k/
167
+ event flags: 00000000
168
+ event ID: 1023917
169
+ event path: /private/tmp/moo/cow/1/l/
170
+ event flags: 00000000
171
+ event ID: 1023932
172
+ event path: /private/tmp/moo/cow/1/m/
173
+ event flags: 00000000
174
+ event ID: 1023947
175
+ event path: /private/tmp/moo/cow/1/n/
176
+ event flags: 00000000
177
+ event ID: 1023962
178
+ event path: /private/tmp/moo/cow/1/o/
179
+ event flags: 00000000
180
+ event ID: 1023977
181
+ event path: /private/tmp/moo/cow/1/p/
182
+ event flags: 00000000
183
+ event ID: 1023992
184
+ event path: /private/tmp/moo/cow/1/q/
185
+ event flags: 00000000
186
+ event ID: 1024007
187
+ event path: /private/tmp/moo/cow/1/r/
188
+ event flags: 00000000
189
+ event ID: 1024022
190
+ event path: /private/tmp/moo/cow/1/s/
191
+ event flags: 00000000
192
+ event ID: 1024037
193
+ event path: /private/tmp/moo/cow/1/t/
194
+ event flags: 00000000
195
+ event ID: 1024052
196
+ event path: /private/tmp/moo/cow/1/u/
197
+ event flags: 00000000
198
+ event ID: 1024067
199
+ event path: /private/tmp/moo/cow/1/v/
200
+ event flags: 00000000
201
+ event ID: 1024082
202
+ event path: /private/tmp/moo/cow/1/w/
203
+ event flags: 00000000
204
+ event ID: 1024097
205
+ event path: /private/tmp/moo/cow/1/x/
206
+ event flags: 00000000
207
+ event ID: 1024112
208
+ event path: /private/tmp/moo/cow/1/y/
209
+ event flags: 00000000
210
+ event ID: 1024127
211
+ event path: /private/tmp/moo/cow/1/z/
212
+ event flags: 00000000
213
+ event ID: 1024142
214
+ event path: /private/tmp/moo/cow/1/
215
+ event flags: 00000000
216
+ event ID: 1024145
217
+ event path: /private/tmp/moo/cow/2/a/
218
+ event flags: 00000000
219
+ event ID: 1024160
220
+ event path: /private/tmp/moo/cow/2/b/
221
+ event flags: 00000000
222
+ event ID: 1024175
223
+ event path: /private/tmp/moo/cow/2/c/
224
+ event flags: 00000000
225
+ event ID: 1024190
226
+ event path: /private/tmp/moo/cow/2/d/
227
+ event flags: 00000000
228
+ event ID: 1024205
229
+ event path: /private/tmp/moo/cow/2/e/
230
+ event flags: 00000000
231
+ event ID: 1024220
232
+
233
+ == Note about FFI
234
+
235
+ rb-fsevent doesn't use {ruby-ffi}[http://github.com/ffi/ffi] anymore because it sadly doesn't allow for catching Signals. You can still see the code in the {ffi branch}[http://github.com/thibaudgg/rb-fsevent/tree/ffi].
236
+
237
+ == Development
238
+
239
+ - Source hosted at {GitHub}[http://github.com/thibaudgg/rb-fsevent]
240
+ - Report issues/Questions/Feature requests on {GitHub Issues}[http://github.com/thibaudgg/rb-fsevent/issues]
241
+
242
+ Pull requests are quite welcome! Please ensure that your commits are in a topic branch for each individual changeset than can be reasonably isolated. It is also important to ensure that your changes are well tested... whether that means new tests, modified tests, or fixing a scenario where the existing tests currently fail. If you have rvm and the required rubies currently installed, we have a helper task for running the testsuite in all of them:
243
+
244
+ rake spec:portability
245
+
246
+ The list of tested RVM targets is currently:
247
+
248
+ %w[1.8.6 1.8.7 1.9.2 jruby-head]
249
+
250
+ == Authors
251
+
252
+ - {Thibaud Guillaume-Gentil}[http://github.com/thibaudgg]
253
+ - {Travis Tilley}[http://github.com/ttilley]
254
+
@@ -0,0 +1,61 @@
1
+ # Workaround to make Rubygems believe it builds a native gem
2
+ require 'mkmf'
3
+ create_makefile('none')
4
+
5
+ # TODO: determine whether we really need to be working around instead of with mkmf
6
+
7
+ if `uname -s`.chomp != 'Darwin'
8
+ puts "Warning! Only Darwin (Mac OS X) systems are supported, nothing will be compiled"
9
+ else
10
+ begin
11
+ xcode_path = %x[xcode-select -print-path].to_s.strip!
12
+ rescue Errno::ENOENT
13
+ end
14
+
15
+ raise "Could not find a suitable Xcode installation" unless xcode_path
16
+
17
+ gem_root = File.expand_path(File.join('..'))
18
+ darwin_version = `uname -r`.to_i
19
+ sdk_version = { 9 => '10.5', 10 => '10.6', 11 => '10.7' }[darwin_version]
20
+
21
+ raise "Only Darwin systems greater than 8 (Mac OS X 10.5+) are supported" unless sdk_version
22
+
23
+ core_flags = %W{
24
+ -isysroot #{xcode_path}/SDKs/MacOSX#{sdk_version}.sdk
25
+ -mmacosx-version-min=#{sdk_version} -mdynamic-no-pic -std=gnu99
26
+ }
27
+
28
+ cflags = core_flags + %w{-Os -pipe}
29
+
30
+ wflags = %w{
31
+ -Wmissing-prototypes -Wreturn-type -Wmissing-braces -Wparentheses -Wswitch
32
+ -Wunused-function -Wunused-label -Wunused-parameter -Wunused-variable
33
+ -Wunused-value -Wuninitialized -Wunknown-pragmas -Wshadow
34
+ -Wfour-char-constants -Wsign-compare -Wnewline-eof -Wconversion
35
+ -Wshorten-64-to-32 -Wglobal-constructors -pedantic
36
+ }
37
+
38
+ ldflags = %w{
39
+ -dead_strip -framework CoreServices
40
+ }
41
+
42
+ cc_opts = core_flags + ldflags
43
+
44
+ cc_opts += %w{
45
+ -D DEBUG=true
46
+ } if ENV['FWDEBUG'] == "true"
47
+
48
+ cc_bin = `which clang || which gcc`.to_s.strip!
49
+
50
+ compile_command = "CFLAGS='#{cflags.join(' ')} #{wflags.join(' ')}' #{cc_bin} #{cc_opts.join(' ')} -o '#{gem_root}/bin/fsevent_watch' fsevent/fsevent_watch.c"
51
+
52
+ STDERR.puts(compile_command)
53
+
54
+ # Compile the actual fsevent_watch binary
55
+ system "mkdir -p #{File.join(gem_root, 'bin')}"
56
+ system compile_command
57
+
58
+ unless File.executable?("#{gem_root}/bin/fsevent_watch")
59
+ raise "Compilation of fsevent_watch failed (see README)"
60
+ end
61
+ end