5

What the best strategy to release a Raku binding for C library using NativeCall for both windows and Linux?

Does the developer need to compile both the .dll and .so files and upload them with the raku code to github? Or there are an option on raku like perl to bundle the C source files with Raku code and C compiler will run as part of make and make install?

ugexe
  • 5,297
  • 1
  • 28
  • 49
smith
  • 3,232
  • 26
  • 55

1 Answers1

6

The libraries do not need to be compiled first (although they could be). To accomplish this first you'll need a Build.rakumod file in the root of your distribution:

class Builder {
    method build($dist-path) {
        # do build stuff to your module
        # which is located at $dist-path
    }

    # Only needed for panda compatability
    method isa($what) {
        return True if $what.^name eq 'Panda::Builder';
        callsame;
    }
}

Then you'll want to use a module like LibraryMake. Here we use it's make routine in the build method:

use LibraryMake;

class Builder {
    method build($dist-path) {
        make($dist-path, "$dist-path/resources");

        # or you could do the appropriate `shell` calls
        # yourself and have no extra dependencies
    }

    ...

This method is supported by the package managers zef and panda, and also allows it to be manually ran via raku -I. -MBuild -e 'Builder.new.build($*CWD)'

Here is a working example

ugexe
  • 5,297
  • 1
  • 28
  • 49