-
-
Notifications
You must be signed in to change notification settings - Fork 546
Ruby scripting support #1006
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
Ruby scripting support #1006
Conversation
Awesome, I'll review it soon... |
Built and ran successfully on Ubuntu 16.04. The following is the log from building it... Looks like it's using
|
Well, IIRC once upon a time there was a debate on which build system mruby should use. Some people advocated for CMake, but eventually they settled down on Modern Linuxes and Macs usually come with Ruby distribution preinstalled. It's also straightforward to install Ruby on Windows OS though, with just a single 10 Meg download. 10 Meg is actually 1/12 of up-to-date TIC-80's GIT repo deep clone (120 Meg) and a small fraction of the total size of Windows SDK sans VS (810 Meg). I really see only two possible options now:
Also, my version of CMakeLists was supposed to yield an error when Ruby is not present on the system - have you reran |
Hmm, still doesn't fallback with a clean build... rm -rf *
git reset --hard HEAD
git submodule update --init --recursive
cd build
cmake ..
make
# ...
Scanning dependencies of target mruby
[ 26%] Creating directories for 'mruby'
[ 26%] No download step for 'mruby'
[ 27%] No patch step for 'mruby'
[ 27%] No update step for 'mruby'
[ 27%] No configure step for 'mruby'
[ 27%] Performing build step for 'mruby'
/bin/sh: 1: rake: not found
CMakeFiles/mruby.dir/build.make:110: recipe for target 'mruby-prefix/src/mruby-stamp/mruby-build' failed
make[2]: *** [mruby-prefix/src/mruby-stamp/mruby-build] Error 127
CMakeFiles/Makefile2:480: recipe for target 'CMakeFiles/mruby.dir/all' failed
make[1]: *** [CMakeFiles/mruby.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2 In the mean time, sent up this PR to clean up the built files remi6397#1 |
I've forgotten to mark new dependencies as required 😜 remi6397@6d07b4d |
That worked...
Would another good idea be to use
... or something? Possibly like this... remi6397#2 |
Fixed conflicts over at remi6397#3 |
Another at remi6397#4 😉 |
Let's return to this on the next version (0.90) |
Update jessie-backports repo location
Fix import command.
Enable CRT shader in wasm/WebGL build
Thanks for making TIC-80. It has been really fun to contribute :)
Update credits.
… some carts Revert "nesbox#1193: added music tempo/speed parameters to the RAM" This reverts commit 8c1e0ae.
Hi, thanks for adding mruby to TIC-80. I modified CMakeLists.txt and it worked on Windows and VisualStudio2019. Line 246 of CMakeLists.txt:
I also modified tic_mruby_build_config.rb and CMakeLists.txt to reduce the build size. tic_mruby_build_config.rb : MRuby::Build.new do |conf|
# load specific toolchain settings
conf.toolchain
# include the GEM box
conf.gembox 'default'
# C compiler settings
conf.cc do |cc|
cc.flags = [ENV['CFLAGS'] || %w()]
end
end Line 252 of CMakeLists.txt:
EDIT* Sorry for the wrong comment. |
Created a gembox containing only useful gems
This reverts commit 1a8bf83. It turns out that wrapping CMake's poor cross build support was not a good idea after all.
CMake's env helper is broken on Windows OS :/
@nesbox, the binary is 2.7M as of the latest commit (compiled with FreeBSD clang version 11.0.1 using config " Also, my branch builds perfectly on my freshly created Windows VM (Windows 10 19044.1288, latest Visual Studio 2022…). |
@nesbox, if I may ask, how much of a difference is that compared to the current mainline? |
set(VERSION_MAJOR 1) | ||
set(VERSION_MINOR 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Version switch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nah, it's just that GitHub is broken since I merged master.
It's not just GitHub doing that, I have seen that very behavior on GitLab @work too. Maybe I'm doing something wrong? 😕
* Genericize cross compilation * Clean mruby build artifacts with make/ninja clean
if(NOT RAKE) | ||
message(FATAL_ERROR "Program `rake' not found! Ruby and `rake' are required to build mruby support.") | ||
endif() | ||
if(NOT YACC) | ||
message(FATAL_ERROR "Program `yacc' not found! Either `yacc' or GNU Bison is required to build mruby support.") | ||
endif() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could these not result in a FATAL_ERROR? Since I don't have rake
or yacc
on my machine, I'm no longer able to build TIC-80.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't language support modules built unconditionally anyway?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the case of the other scripting languages, the dependencies are packed in. rake or yacc won't be available on a few different build systems. Curious if we could get it to build having needing them in there 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rake or yacc won't be available on a few different build systems
yacc
is a part of most modern C toolchains. rake
is a build system written in Ruby and usually distributed as a part of a standard Ruby installation. On Windows, all you ever need is the awesome Ruby Installer.
Of course, neither of those programs need to be present at runtime.
* Genericize cross compilation * Clean mruby build artifacts with make/ninja clean
conf.enable_test | ||
end | ||
|
||
MRuby::CrossBuild.new('target') do |conf| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could the mruby
config files live in src/api/mruby
or somewhere other than the root? Having it in the root seem unorganized. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has nothing to do with source; it's a build script, much like CMakeLists
[submodule "vendor/curl"] | ||
path = vendor/curl | ||
url = https://github.com/curl/curl.git | ||
shallow = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a lot of changes are showing up in this diff that have already been applied. Did something happen in the rebase that resulted in a lot of conflicts? Wouldn't want to lose any code changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nah, it's just that GitHub is broken since I merged master.
It's not just GitHub doing that, I have seen that very behavior on GitLab @work too. Maybe I'm doing something wrong? 😕
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can see the relevant changes here: https://github.com/nesbox/TIC-80/compare/master...remi6397:feature/ruby/mruby.patch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, could have likely been from the rebase. It's pretty easy to run into those rebase issues, I tend to avoid rebase because of it 😉 ... We can get that cleaned up 👍
Nothing wrong with rebase if it's done slowly and carefully. :-) |
I shall just open a new PR. It can't get any worse than that, no. |
#1726 that is. Sorry for inconvenience caused, but let's not emphasize style over substance. |
This PR adds support for the Ruby programming language, or to be precise a slimmed down variant of Ruby called MRuby.
Resources
pre-0.90 Description
This PR adds basic support for [Ruby](https://www.ruby-lang.org) scripting via [MRuby](https://mruby.org/).I thought it'd be nice to have Ruby as an option for scripting, because it's widely used in WebDev (Rails, Sinatra, etc.), DevOps (Puppet, Chef, Vagrant), ITSec (Logstash, Metasploit) and probably in many more applications beyond my field of expertise (SketchUp being the first one to come to my mind).
If you decided to merge, Ruby would make the second most popular language of those available in TIC (right after JavaScript).
I've already tested this on Windows (10, x64) and Linux (openSUSE Tumbleweed) and it compiles without any problems. There are still
macOS, Emscripten and Android left to test, but:1) I'd have to install XCode my Mac;2) I don't know how to x-compile for Emscripten; 3) I don't own any Android device.Apart from that, everything seems to work flawlessly. 😉
EDIT: Ran build on my Mac, it works there too.