Skip to content

Commit

Permalink
use Devel::CheckCompiler
Browse files Browse the repository at this point in the history
  • Loading branch information
skaji committed Jul 13, 2023
1 parent 39d3dc2 commit b9c243e
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: perl -V
run: ${{ matrix.perl }} -V
- name: Install Dependencies
run: curl -fsSL --compressed https://raw.githubusercontent.com/skaji/cpm/main/cpm | ${{ matrix.perl }} - install -g ${{ matrix.cpm-option }} --with-develop --with-recommends --show-build-log-on-failure
run: curl -fsSL --compressed https://raw.githubusercontent.com/skaji/cpm/main/cpm | ${{ matrix.perl }} - install -g ${{ matrix.cpm-option }} --with-configure --with-develop --with-recommends --show-build-log-on-failure
- name: Build
run: ${{ matrix.perl }} Makefile.PL && make
- name: Run Tests
Expand Down
1 change: 1 addition & 0 deletions META.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"prereqs" : {
"configure" : {
"requires" : {
"Devel::CheckCompiler" : "0.07",
"ExtUtils::MakeMaker" : "0"
}
},
Expand Down
31 changes: 25 additions & 6 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,35 @@ use warnings;

use ExtUtils::Constant ();
use Config ();
use Devel::CheckCompiler ();

if ($^O ne 'darwin') {
die "OS unsupported\n";
}

my $check = <<'EOF';
#include <stdio.h>
#include <CoreFoundation/CoreFoundation.h>
#include <CoreServices/CoreServices.h>
int main() {
FSEventStreamEventId id = FSEventsGetCurrentEventId();
return (int)id;
}
EOF

my $lddlflags = join " ", (
$Config::Config{lddlflags} ? $Config::Config{lddlflags} : (),
"-framework CoreServices",
"-framework CoreFoundation",
);

my $ok = Devel::CheckCompiler::check_compile($check, executable => 1, extra_linker_flags => $lddlflags);
if (!$ok) {
print "This OS does not have FSEventsGetCurrentEventId() function. exit";
exit 0;
}

my @c_name = qw(
kFSEventStreamCreateFlagNone
kFSEventStreamCreateFlagWatchRoot
Expand All @@ -43,12 +67,6 @@ ExtUtils::Constant::WriteConstants(
NAMES => \@name,
);

my $lddlflags = join " ", grep { length $_ } (
$Config::Config{lddlflags},
"-framework CoreServices",
"-framework CoreFoundation",
);

my %args = (
LDDLFLAGS => $lddlflags,
);
Expand All @@ -57,6 +75,7 @@ my %WriteMakefileArgs = (
"ABSTRACT" => "Monitor a directory structure for changes",
"AUTHOR" => "Andy Grundman <andy\@hybridized.org>, Rob Hoelz <rob\@hoelz.ro>",
"CONFIGURE_REQUIRES" => {
"Devel::CheckCompiler" => "0.07",
"ExtUtils::MakeMaker" => 0
},
"DISTNAME" => "Mac-FSEvents",
Expand Down
3 changes: 3 additions & 0 deletions cpm.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
prereqs:
configure:
requires:
Devel::CheckCompiler: { version: '0.07' }
runtime:
requires:
perl: { version: '5.008008' }
Expand Down
30 changes: 24 additions & 6 deletions maint/Makefile_header.PL
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,35 @@ use warnings;

use ExtUtils::Constant ();
use Config ();
use Devel::CheckCompiler ();

if ($^O ne 'darwin') {
die "OS unsupported\n";
}

my $check = <<'EOF';
#include <stdio.h>
#include <CoreFoundation/CoreFoundation.h>
#include <CoreServices/CoreServices.h>
int main() {
FSEventStreamEventId id = FSEventsGetCurrentEventId();
return (int)id;
}
EOF

my $lddlflags = join " ", (
$Config::Config{lddlflags} ? $Config::Config{lddlflags} : (),
"-framework CoreServices",
"-framework CoreFoundation",
);

my $ok = Devel::CheckCompiler::check_compile($check, executable => 1, extra_linker_flags => $lddlflags);
if (!$ok) {
print "This OS does not have FSEventsGetCurrentEventId() function. exit";
exit 0;
}

my @c_name = qw(
kFSEventStreamCreateFlagNone
kFSEventStreamCreateFlagWatchRoot
Expand All @@ -33,12 +57,6 @@ ExtUtils::Constant::WriteConstants(
NAMES => \@name,
);

my $lddlflags = join " ", grep { length $_ } (
$Config::Config{lddlflags},
"-framework CoreServices",
"-framework CoreFoundation",
);

my %args = (
LDDLFLAGS => $lddlflags,
);

0 comments on commit b9c243e

Please sign in to comment.