Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RbSys::ExtensionTask #144

Merged
merged 10 commits into from
Feb 5, 2023
Merged

Add RbSys::ExtensionTask #144

merged 10 commits into from
Feb 5, 2023

Conversation

ianks
Copy link
Collaborator

@ianks ianks commented Feb 4, 2023

This PR is a first cut for a rake-compiler-dock compatible extension task. For now, it just wraps the existing RCD extension task with saner defaults. Here is are the changes I made to wasmtime-rb to make integrate it:

diff --git i/rakelib/compile.rake w/rakelib/compile.rake
index 6df4c80..7695062 100644
--- i/rakelib/compile.rake
+++ w/rakelib/compile.rake
@@ -1,21 +1,7 @@
-require "rake/extensiontask"
+require "rb_sys/extensiontask"
 
-CROSS_PLATFORMS = [ENV["RUBY_TARGET"]].compact
-SOURCE_PATTERN = "**/src/**/*.{rs,toml,lock}"
-
-Rake::ExtensionTask.new("wasmtime_rb", GEMSPEC) do |ext|
+RbSys::ExtensionTask.new("wasmtime-rb", GEMSPEC) do |ext|
   ext.lib_dir = "lib/wasmtime"
-  ext.ext_dir = "ext"
-  ext.cross_compile = !CROSS_PLATFORMS.empty?
-  ext.cross_platform = CROSS_PLATFORMS
-
-  ext.cross_compiling do |gem_spec|
-    # No need for rb_sys to compile
-    gem_spec.dependencies.reject! { |d| d.name == "rb_sys" }
-
-    # Remove unnecessary files
-    gem_spec.files -= Dir[SOURCE_PATTERN, "**/Cargo.*", "**/extconf.rb"]
-  end
 end
 
 namespace :compile do

Much simpler. Users should begin adopting this interface, and in the future I have some other planned improvements for making cross-compilation much easier.

The other big other nice change is the root ./target directory will be used, will reduce duplicative compilation of crates.

@ianks
Copy link
Collaborator Author

ianks commented Feb 5, 2023

@ianks
Copy link
Collaborator Author

ianks commented Feb 5, 2023

Confirmed working for commonmarker as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant