rb-fsevent 0.4.3.1 → 0.9.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
data/ext/rakefile.rb ADDED
@@ -0,0 +1,47 @@
1
+ # vim: fileencoding=UTF-8 nobomb sw=2 ts=2 et
2
+
3
+ XCODEBUILD = '/usr/bin/xcodebuild'
4
+ XCCONFIG = File.expand_path('rb-fsevent.xcconfig')
5
+
6
+ namespace :xcode do
7
+ $target = 'fsevent_watch'
8
+ $configuration = ENV['FWDEBUG'] ? 'Debug' : 'Release'
9
+
10
+ def xcb(action, extra='')
11
+ command = [
12
+ XCODEBUILD,
13
+ "-target", $target,
14
+ "-configuration", $configuration,
15
+ action,
16
+ "-xcconfig", XCCONFIG,
17
+ extra
18
+ ].join(' ')
19
+
20
+ Dir.chdir 'fsevent_watch' do
21
+ results = `#{command}`
22
+ STDERR.puts results
23
+ raise "xcodebuild failure" unless $?.success?
24
+ end
25
+ end
26
+
27
+ desc 'run xcodebuild clean'
28
+ task :clean do
29
+ xcb 'clean'
30
+ end
31
+
32
+ desc 'run xcodebuild build'
33
+ task :build => :clean do
34
+ xcb 'build'
35
+ end
36
+
37
+ desc 'run xcodebuild install'
38
+ task :install => :build do
39
+ xcb 'install', "DEPLOYMENT_LOCATION='YES'"
40
+ end
41
+
42
+ task :remove_turds do
43
+ rm_rf File.join('fsevent_watch', 'build')
44
+ end
45
+ end
46
+
47
+ task :default => ['xcode:install', 'xcode:remove_turds']
@@ -0,0 +1,19 @@
1
+ // settings in this file will override those defined in the xcode project
2
+
3
+ // - deployment -
4
+ INSTALL_MODE_FLAG = u+w,go-w,a+rX
5
+ MACOSX_DEPLOYMENT_TARGET =
6
+ DSTROOT = ../../
7
+ INSTALL_PATH = /bin
8
+ SKIP_INSTALL = NO
9
+
10
+ // - build locations -
11
+ SYMROOT = build
12
+ OBJROOT = $(SYMROOT)
13
+
14
+ // - architectures -
15
+ ARCHS = $(NATIVE_ARCH_ACTUAL)
16
+ SDKROOT =
17
+
18
+ // - build options -
19
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0
@@ -1,3 +1,3 @@
1
1
  class FSEvent
2
- VERSION = "0.4.3.1"
2
+ VERSION = "0.9.0.pre1"
3
3
  end
metadata CHANGED
@@ -1,122 +1,97 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rb-fsevent
3
- version: !ruby/object:Gem::Version
4
- hash: 97
5
- prerelease:
6
- segments:
7
- - 0
8
- - 4
9
- - 3
10
- - 1
11
- version: 0.4.3.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.0.pre1
5
+ prerelease: 6
12
6
  platform: ruby
13
- authors:
7
+ authors:
14
8
  - Thibaud Guillaume-Gentil
15
9
  - Travis Tilley
16
10
  autorequire:
17
11
  bindir: bin
18
12
  cert_chain: []
19
-
20
- date: 2011-08-18 00:00:00 Z
21
- dependencies:
22
- - !ruby/object:Gem::Dependency
13
+ date: 2011-09-29 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
23
16
  name: bundler
24
- prerelease: false
25
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: &70275072823900 !ruby/object:Gem::Requirement
26
18
  none: false
27
- requirements:
19
+ requirements:
28
20
  - - ~>
29
- - !ruby/object:Gem::Version
30
- hash: 3
31
- segments:
32
- - 1
33
- - 0
34
- - 10
21
+ - !ruby/object:Gem::Version
35
22
  version: 1.0.10
36
23
  type: :development
37
- version_requirements: *id001
38
- - !ruby/object:Gem::Dependency
39
- name: rspec
40
24
  prerelease: false
41
- requirement: &id002 !ruby/object:Gem::Requirement
25
+ version_requirements: *70275072823900
26
+ - !ruby/object:Gem::Dependency
27
+ name: rspec
28
+ requirement: &70275068753800 !ruby/object:Gem::Requirement
42
29
  none: false
43
- requirements:
30
+ requirements:
44
31
  - - ~>
45
- - !ruby/object:Gem::Version
46
- hash: 27
47
- segments:
48
- - 2
49
- - 5
50
- - 0
32
+ - !ruby/object:Gem::Version
51
33
  version: 2.5.0
52
34
  type: :development
53
- version_requirements: *id002
54
- - !ruby/object:Gem::Dependency
55
- name: guard-rspec
56
35
  prerelease: false
57
- requirement: &id003 !ruby/object:Gem::Requirement
36
+ version_requirements: *70275068753800
37
+ - !ruby/object:Gem::Dependency
38
+ name: guard-rspec
39
+ requirement: &70275064571020 !ruby/object:Gem::Requirement
58
40
  none: false
59
- requirements:
41
+ requirements:
60
42
  - - ~>
61
- - !ruby/object:Gem::Version
62
- hash: 9
63
- segments:
64
- - 0
65
- - 1
66
- - 9
43
+ - !ruby/object:Gem::Version
67
44
  version: 0.1.9
68
45
  type: :development
69
- version_requirements: *id003
46
+ prerelease: false
47
+ version_requirements: *70275064571020
70
48
  description: FSEvents API with Signals catching (without RubyCocoa)
71
- email:
49
+ email:
72
50
  - thibaud@thibaud.me
73
51
  - ttilley@gmail.com
74
52
  executables: []
75
-
76
- extensions:
77
- - ext/extconf.rb
53
+ extensions:
54
+ - ext/rakefile.rb
78
55
  extra_rdoc_files: []
79
-
80
- files:
56
+ files:
81
57
  - lib/rb-fsevent/fsevent.rb
82
58
  - lib/rb-fsevent/version.rb
83
59
  - lib/rb-fsevent.rb
84
- - ext/extconf.rb
85
- - ext/fsevent/fsevent_watch.c
60
+ - ext/fsevent_watch/fsevent_watch/cli.c
61
+ - ext/fsevent_watch/fsevent_watch/cli.h
62
+ - ext/fsevent_watch/fsevent_watch/common.h
63
+ - ext/fsevent_watch/fsevent_watch/compat.h
64
+ - ext/fsevent_watch/fsevent_watch/main.c
65
+ - ext/fsevent_watch/fsevent_watch/TSICTString.c
66
+ - ext/fsevent_watch/fsevent_watch/TSICTString.h
67
+ - ext/fsevent_watch/fsevent_watch.xcodeproj/project.pbxproj
68
+ - ext/fsevent_watch/LICENSE
69
+ - ext/rakefile.rb
70
+ - ext/rb-fsevent.xcconfig
86
71
  - LICENSE
87
72
  - README.rdoc
88
73
  homepage: http://rubygems.org/gems/rb-fsevent
89
74
  licenses: []
90
-
91
75
  post_install_message:
92
76
  rdoc_options: []
93
-
94
- require_paths:
77
+ require_paths:
95
78
  - lib
96
- required_ruby_version: !ruby/object:Gem::Requirement
79
+ required_ruby_version: !ruby/object:Gem::Requirement
97
80
  none: false
98
- requirements:
99
- - - ">="
100
- - !ruby/object:Gem::Version
101
- hash: 3
102
- segments:
103
- - 0
104
- version: "0"
105
- required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ! '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
86
  none: false
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- hash: 3
111
- segments:
112
- - 0
113
- version: "0"
87
+ requirements:
88
+ - - ! '>'
89
+ - !ruby/object:Gem::Version
90
+ version: 1.3.1
114
91
  requirements: []
115
-
116
92
  rubyforge_project: rb-fsevent
117
- rubygems_version: 1.8.8
93
+ rubygems_version: 1.8.10
118
94
  signing_key:
119
95
  specification_version: 3
120
96
  summary: Very simple & usable FSEvents API
121
97
  test_files: []
122
-
data/ext/extconf.rb DELETED
@@ -1,61 +0,0 @@
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
@@ -1,226 +0,0 @@
1
- #include <stdio.h>
2
- #include <stdlib.h>
3
- #include <unistd.h>
4
-
5
- #include <CoreServices/CoreServices.h>
6
-
7
-
8
- // Structure for storing metadata parsed from the commandline
9
- static struct {
10
- FSEventStreamEventId sinceWhen;
11
- CFTimeInterval latency;
12
- FSEventStreamCreateFlags flags;
13
- CFMutableArrayRef paths;
14
- } config = {
15
- (UInt64) kFSEventStreamEventIdSinceNow,
16
- (double) 0.3,
17
- (UInt32) kFSEventStreamCreateFlagNone,
18
- NULL
19
- };
20
-
21
- // Prototypes
22
- static void append_path(const char *path);
23
- static inline void parse_cli_settings(int argc, const char *argv[]);
24
- static void callback(FSEventStreamRef streamRef,
25
- void *clientCallBackInfo,
26
- size_t numEvents,
27
- void *eventPaths,
28
- const FSEventStreamEventFlags eventFlags[],
29
- const FSEventStreamEventId eventIds[]);
30
-
31
-
32
- // Resolve a path and append it to the CLI settings structure
33
- // The FSEvents API will, internally, resolve paths using a similar scheme.
34
- // Performing this ahead of time makes things less confusing, IMHO.
35
- static void append_path(const char *path)
36
- {
37
- #ifdef DEBUG
38
- fprintf(stderr, "\n");
39
- fprintf(stderr, "append_path called for: %s\n", path);
40
- #endif
41
-
42
- char fullPath[PATH_MAX];
43
-
44
- if (realpath(path, fullPath) == NULL) {
45
- #ifdef DEBUG
46
- fprintf(stderr, " realpath not directly resolvable from path\n");
47
- #endif
48
-
49
- if (path[0] != '/') {
50
- #ifdef DEBUG
51
- fprintf(stderr, " passed path is not absolute\n");
52
- #endif
53
- size_t len;
54
- getcwd(fullPath, sizeof(fullPath));
55
- #ifdef DEBUG
56
- fprintf(stderr, " result of getcwd: %s\n", fullPath);
57
- #endif
58
- len = strlen(fullPath);
59
- fullPath[len] = '/';
60
- strlcpy(&fullPath[len + 1], path, sizeof(fullPath) - (len + 1));
61
- } else {
62
- #ifdef DEBUG
63
- fprintf(stderr, " assuming path does not YET exist\n");
64
- #endif
65
- strlcpy(fullPath, path, sizeof(fullPath));
66
- }
67
- }
68
-
69
- #ifdef DEBUG
70
- fprintf(stderr, " resolved path to: %s\n", fullPath);
71
- fprintf(stderr, "\n");
72
- fflush(stderr);
73
- #endif
74
-
75
- CFStringRef pathRef = CFStringCreateWithCString(kCFAllocatorDefault,
76
- fullPath,
77
- kCFStringEncodingUTF8);
78
- CFArrayAppendValue(config.paths, pathRef);
79
- CFRelease(pathRef);
80
- }
81
-
82
- // Parse commandline settings
83
- static inline void parse_cli_settings(int argc, const char *argv[])
84
- {
85
- config.paths = CFArrayCreateMutable(NULL,
86
- (CFIndex)0,
87
- &kCFTypeArrayCallBacks);
88
-
89
- for (int i = 1; i < argc; i++) {
90
- if (strcmp(argv[i], "--since-when") == 0) {
91
- config.sinceWhen = strtoull(argv[++i], NULL, 0);
92
- } else if (strcmp(argv[i], "--latency") == 0) {
93
- config.latency = strtod(argv[++i], NULL);
94
- } else if (strcmp(argv[i], "--no-defer") == 0) {
95
- config.flags |= kFSEventStreamCreateFlagNoDefer;
96
- } else if (strcmp(argv[i], "--watch-root") == 0) {
97
- config.flags |= kFSEventStreamCreateFlagWatchRoot;
98
- } else if (strcmp(argv[i], "--ignore-self") == 0) {
99
- #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
100
- config.flags |= kFSEventStreamCreateFlagIgnoreSelf;
101
- #else
102
- fprintf(stderr, "MacOSX10.6.sdk is required for --ignore-self\n");
103
- #endif
104
- } else {
105
- append_path(argv[i]);
106
- }
107
- }
108
-
109
- if (CFArrayGetCount(config.paths) == 0) {
110
- append_path(".");
111
- }
112
-
113
- #ifdef DEBUG
114
- fprintf(stderr, "config.sinceWhen %llu\n", config.sinceWhen);
115
- fprintf(stderr, "config.latency %f\n", config.latency);
116
- fprintf(stderr, "config.flags %#.8x\n", config.flags);
117
- fprintf(stderr, "config.paths\n");
118
-
119
- long numpaths = CFArrayGetCount(config.paths);
120
-
121
- for (long i = 0; i < numpaths; i++) {
122
- char path[PATH_MAX];
123
- CFStringGetCString(CFArrayGetValueAtIndex(config.paths, i),
124
- path,
125
- PATH_MAX,
126
- kCFStringEncodingUTF8);
127
- fprintf(stderr, " %s\n", path);
128
- }
129
-
130
- fprintf(stderr, "\n");
131
- fflush(stderr);
132
- #endif
133
- }
134
-
135
- static void callback(FSEventStreamRef streamRef,
136
- void *clientCallBackInfo,
137
- size_t numEvents,
138
- void *eventPaths,
139
- const FSEventStreamEventFlags eventFlags[],
140
- const FSEventStreamEventId eventIds[])
141
- {
142
- char **paths = eventPaths;
143
-
144
- #ifdef DEBUG
145
- fprintf(stderr, "\n");
146
- fprintf(stderr, "FSEventStreamCallback fired!\n");
147
- fprintf(stderr, " numEvents: %lu\n", numEvents);
148
-
149
- for (size_t i = 0; i < numEvents; i++) {
150
- fprintf(stderr, " event path: %s\n", paths[i]);
151
- fprintf(stderr, " event flags: %#.8x\n", eventFlags[i]);
152
- fprintf(stderr, " event ID: %llu\n", eventIds[i]);
153
- }
154
-
155
- fprintf(stderr, "\n");
156
- fflush(stderr);
157
- #endif
158
-
159
- for (size_t i = 0; i < numEvents; i++) {
160
- fprintf(stdout, "%s", paths[i]);
161
- fprintf(stdout, ":");
162
- }
163
-
164
- fprintf(stdout, "\n");
165
- fflush(stdout);
166
- }
167
-
168
- int main(int argc, const char *argv[])
169
- {
170
- /*
171
- * a subprocess will initially inherit the process group of its parent. the
172
- * process group may have a control terminal associated with it, which would
173
- * be the first tty device opened by the group leader. typically the group
174
- * leader is your shell and the control terminal is your login device. a
175
- * subset of signals triggered on the control terminal are sent to all members
176
- * of the process group, in large part to facilitate sane and consistent
177
- * cleanup (ex: control terminal was closed).
178
- *
179
- * so why the overly descriptive lecture style comment?
180
- * 1. SIGINT and SIGQUIT are among the signals with this behavior
181
- * 2. a number of applications gank the above for their own use
182
- * 3. ruby's insanely useful "guard" is one of these applications
183
- * 4. despite having some level of understanding of POSIX signals and a few
184
- * of the scenarios that might cause problems, i learned this one only
185
- * after reading ruby 1.9's process.c
186
- * 5. if left completely undocumented, even slightly obscure bugfixes
187
- * may be removed as cruft by a future maintainer
188
- *
189
- * hindsight is 20/20 addition: if you're single-threaded and blocking on IO
190
- * with a subprocess, then handlers for deferrable signals might not get run
191
- * when you expect them to. In the case of Ruby 1.8, that means making use of
192
- * IO::select, which will preserve correct signal handling behavior.
193
- */
194
- if (setpgid(0,0) < 0) {
195
- fprintf(stderr, "Unable to set new process group.\n");
196
- return 1;
197
- }
198
-
199
- parse_cli_settings(argc, argv);
200
-
201
- FSEventStreamContext context = {0, NULL, NULL, NULL, NULL};
202
- FSEventStreamRef stream;
203
- stream = FSEventStreamCreate(kCFAllocatorDefault,
204
- (FSEventStreamCallback)&callback,
205
- &context,
206
- config.paths,
207
- config.sinceWhen,
208
- config.latency,
209
- config.flags);
210
-
211
- #ifdef DEBUG
212
- FSEventStreamShow(stream);
213
- fprintf(stderr, "\n");
214
- fflush(stderr);
215
- #endif
216
-
217
- FSEventStreamScheduleWithRunLoop(stream,
218
- CFRunLoopGetCurrent(),
219
- kCFRunLoopDefaultMode);
220
- FSEventStreamStart(stream);
221
- CFRunLoopRun();
222
- FSEventStreamFlushSync(stream);
223
- FSEventStreamStop(stream);
224
-
225
- return 0;
226
- }