Slide 1

Slide 1 text

Independence of mruby Can we build mruby without Cruby? Takeshi Watanabe (Fusic Co., Ltd.)

Slide 2

Slide 2 text

About me. • GitHub: @take-cheeze • Seems like a mruby contributor(weakest of big four). • Just a mruby pull requester. • Moved to Fukuoka this July.

Slide 3

Slide 3 text

Things to say before • Thank my new company for taking me to RubyKaigi. • I want mruby jobs!

Slide 4

Slide 4 text

What I’ll talk • Why does mruby build depend on CRuby? • There was a guy who love rake. • mruby was using CMake when I first saw. • We don’t want to add the dependency in some cases. • Can GNU make replace it? • I’m using GNU make(don’t know nmake). • Don’t use file names with whitespaces in GNU make.

Slide 5

Slide 5 text

Things to know • What is minirake? • Subset of rake for building mruby • Can do what rake can do with single script. • How to build without CRuby 1. Build mruby only with Makefile. 2. Run mruby build with built mruby(and minirake).

Slide 6

Slide 6 text

Things I did. • Build minirake as a single binary. • Run build and test with built minirake and mruby. • Make Makefile very fat. ※ There was a precedent to make minirake single binary: • https://github.com/gromnitsky/minirake

Slide 7

Slide 7 text

Making minirake a single binary 1. Build minirake single binary as usual. 2. Build mruby with built minirake. 3. Fix things that didn’t work well. • Add missing things: tsort, pathname, fileutils, … • Make mrbgem compatible with CRuby. • Reusing idea before mruby-cli: https://github.com/mruby/mruby/pull/1676

Slide 8

Slide 8 text

Remove CRuby dependency 1. Port minirake scripts to Makefile. 2. Do porting until you finish. • GNU make reference and stackoverflow was my friend. 3. Makefile more than 300 line is created. • I can do complex text generating with Makefile.

Slide 9

Slide 9 text

Part of artifacts:

Slide 10

Slide 10 text

Time taken to build • My machine: • ThinkPad X1 Carbon 5th / Windows 10 • RAM 16GB/Intel(R) Core(TM) i7-7500U CPU @2.70GHz 2.90GHz • Command used to run: time make test • About 10 minutes on Windows Subsystem for Linux • About 4 minutes on CentOS7 on VirtualBox

Slide 11

Slide 11 text

Thoughts after finishing • Makefile is a great build tool. • Too many ways for process in Ruby (`,open3,spawn,system) • Need environment variables support to system method for cross build. • Thank all the developers of mrbgems I used. • Mainly port of Dir.glob (and the great idea): https://github.com/gromnitsky/mruby-dir-glob • IIJ for many stable mrbgems. • I want keyword arguments(because of FileUtils) • Actually I implemented it: https://github.com/mruby/mruby/pull/3629

Slide 12

Slide 12 text

When can we use this? • No plan making Pull-Request. • It’s too big to make a review. • How do we do with mrbgems minirake uses? • Is it really useful? • Does mruby really need to be independent from CRuby? • There is many CRuby rake code to build mruby.

Slide 13

Slide 13 text

Thanks for listening! • Any mruby jobs is welcomed!