in reply to Re^3: Better way to force Inline to use compiled binary instead of C source?
in thread Better way to force Inline to use compiled binary instead of C source?
And instead of providing the OBJECT config option as OBJECT => '$(O_FILES)', we now have to do something like:--- C.pm_orig 2021-12-20 22:11:48 +1100 +++ C.pm 2022-06-28 22:08:10 +1000 @@ -177,6 +177,20 @@ $o->{ILSM}{XS}{PREFIX} = $value; next; } + if($key eq 'OBJECT') { + $o->mkpath($o->{API}{build_dir}) unless -d $o->{API}{buil +d_dir}; + require File::Copy; + $o->add_string($o->{ILSM}{MAKEFILE}, 'OBJECT', '$(O_FILES +)'); + die "'OBJECT' must specify an array reference" + unless ref($value) eq 'ARRAY'; + for my $fn(@$value) { + File::Copy::copy("${fn}.h", $o->{API}{build_dir} . "/${ +fn}.h") + if -e "${fn}.h"; + File::Copy::copy("${fn}.c", $o->{API}{build_dir} . "/${ +fn}.c") + if -e "${fn}.c"; + } + next; + } if ($key eq 'FILTERS') { next if $value eq '1' or $value eq '0'; # ignore ENABLE, +DISABLE $value = [$value] unless ref($value) eq 'ARRAY'; @@ -374,7 +388,7 @@ open $lockfh, '>', $file or die "lockfile $file: $!"; flock($lockfh, LOCK_EX) or die "flock: $!\n" if $^O !~ /^VMS| +riscos|VOS$/; } - $o->mkpath($o->{API}{build_dir}); + $o->mkpath($o->{API}{build_dir}) unless -d $o->{API}{build_dir}; $o->call('preprocess', 'Build Preprocess'); $o->call('parse', 'Build Parse'); $o->call('write_XS', 'Build Glue 1');
That's assuming that the '.h' and '.c' files are in the cwd.OBJECT => ['./bar', './baz'],
And that works fine straight away.use warnings; use Inline C => Config => BUILD_NOISY => 1, OBJECT => ['./bar', './baz'], ; use Inline C =><<'EOC'; #include "bar.h" #include "baz.h" void foo(int i) { printf("bar: %d\n", bar(i)); printf("baz: %d\n", baz(i)); } EOC foo(42);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Better way to force Inline to use compiled binary instead of C source?
by bliako (Abbot) on Jun 28, 2022 at 13:48 UTC | |
by syphilis (Archbishop) on Jun 29, 2022 at 04:02 UTC |