Skip to content

Commit ebb8051

Browse files
committed
Add Filesys::Notify::Simple dependency
Adds configure switch to add native file watcher dependency for optimal file watching performance. Emits a warning in case the dependency is missing.
1 parent 70b2701 commit ebb8051

File tree

1 file changed

+41
-4
lines changed

1 file changed

+41
-4
lines changed

Makefile.PL

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ my $debug_mode = 0;
3939
my $install_sassc = 0;
4040
my $install_plugins = 1;
4141
my $install_library = 0;
42+
my $native_watcher = 0;
4243
my $compiler = undef;
4344
my $profiling = 0;
4445
my $skip_manifest = 0;
@@ -62,6 +63,7 @@ sub help
6263
print " --sassc Install optional sassc cli utility\n";
6364
print " --plugins Install optional libsass plugins (default)\n";
6465
print " --library Install libsass library (auto-enabled)\n";
66+
print " --native-watcher Depend on optimized file watcher module\n";
6567
print " --help This help screen\n";
6668
print "\n The following options are for developers only:\n\n";
6769
print " --debug Build libsass in debug mode\n";
@@ -153,6 +155,7 @@ GetOptions(
153155
'--skip-git!' => \$skip_git,
154156
'--skip-version!' => \$skip_version,
155157
'--skip-manifest!' => \$skip_manifest,
158+
'--native-watcher!' => \$native_watcher,
156159
# options for git submodules
157160
'--update-deps!' => \$update_deps,
158161
'--checkout-deps!' => \$checkout_deps,
@@ -416,14 +419,41 @@ if ($EMMV > 7.10 && $EMMV < 7.20) {
416419
}
417420
}
418421

422+
################################################################################
423+
# Emit a message to inform user of suboptimal watch behavior
424+
# Filesys::Notify::KQueue will use inefficient polling scans
425+
################################################################################
426+
427+
# stores choosen matcher
428+
my $watchdeps = undef;
429+
430+
# list watchers per OS
431+
my %watchers = (
432+
'linux' => [ 'Linux::Inotify2', 0.01 ],
433+
'darwin' => [ 'Mac::FSEvents', 0.01 ],
434+
'freebsd' => [ 'Filesys::Notify::KQueue', 0.01 ],
435+
'MSWin32' => [ 'Win32::ChangeNotify', 0.01 ],
436+
'cygwin' => [ 'Win32::ChangeNotify', 0.01 ]
437+
);
438+
439+
# check if dependency is wanted and/or available
440+
if (exists $watchers{$^O} && ! $ENV{PERL_FNS_NO_OPT}) {
441+
if ($native_watcher) { $watchdeps = $watchers{$^O}; }
442+
elsif (!eval { require $watchers{$^O}->[0]; return 1; }) {
443+
warn "Consider installing $watchers{$^O}->[0]\n";
444+
warn "Or configure with `--native-watcher` option\n";
445+
}
446+
}
447+
419448
################################################################################
420449
# See lib/ExtUtils/MakeMaker.pm for details of how to
421450
# influence content of the Makefile that is written.
422451
################################################################################
423452

424453
my %WriteMakefile = (
425454
NAME => 'CSS::Sass',
426-
VERSION_FROM => 'lib/CSS/Sass.pm', # finds $VERSION, requires EU::MM from perl >= 5.5
455+
# finds $VERSION, requires EU::MM from perl >= 5.5
456+
VERSION_FROM => 'lib/CSS/Sass.pm',
427457
# runtime dependencies
428458
PREREQ_PM => {
429459
# 'perl' => 5.008000,
@@ -432,13 +462,20 @@ my %WriteMakefile = (
432462
'warnings' => 0, # core as of 5.008
433463
'strict' => 0, # core as of 5.008,
434464
# dependencies for psass cli tool
465+
# 'Benchmark' => 0.01,
435466
'Getopt::Long' => 0.01,
436467
'Encode::Locale' => 0.01,
437468
# dependencies for file watcher
438-
'List::Util' => 1.45,
469+
# uniq only available since 1.45
470+
'List::Util' => 1.45, # core as of 5.008
439471
# this is an optional dependency
440-
# not sure if we want to force it
441-
# 'Filesys::Notify::Simple' => 0.01,
472+
# only needed for psass filewatcher
473+
'Filesys::Notify::Simple' => 0.01,
474+
# it doesn't have any dependencies
475+
# but you may want to install one of
476+
# Linux::Inotify2, Win32::ChangeNotify
477+
# Mac::FSEvents, Filesys::Notify::KQueue
478+
$watchdeps ? @{$watchdeps} : (),
442479
},
443480
# test dependencies
444481
TEST_REQUIRES => {

0 commit comments

Comments
 (0)