Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Rick Hull
    @rickhull
    from the compile.md
    conf.gem "#{root}/mrbgems/mruby-bin-mruby"
    conf.gem "#{root}/mrbgems/mruby-bin-mirb"
    it's hard to know what root refers to, and i'm not sure why I would want my mruby executable inside mrbgems/ and why it would be named mruby-bin-mruby
    and I can't imagine how conf.gem accepts a string and knows from looking at the string whether and how to build mruby vs mirb
    Rick Hull
    @rickhull
    that said, with conf.gem "#{root}/mrbgems/mruby-bin-mruby" I now have mruby_src/bin/mruby
    quite a magical string value, eh?
    i was imagining the string was specifying an output, but I guess it specifies a well-known input
    vagrant@contrib-jessie:~/mruby/sleep_world$ mruby_src/bin/mruby hello_world.rb
    trace:
            [0] hello_world.rb:12
    hello_world.rb:12:undefined method 'puts' for main (NoMethodError)
    LOL
    I guess I need conf.gembox 'default' ?
    Rick Hull
    @rickhull
    yup, GOT IT! \o/
    I am sure there are misconceptions that need correcting
    I also noted the lack of require in limitations.md
    Rick Hull
    @rickhull
    for my next trick, I would like to start with several .rb files and compile an executable
    this seems to be less than straightforward
    http://mruby.org/docs/articles/executing-ruby-code-with-mruby.html mrb_load_string(mrb, "puts 'hello world'");
    is it a bad idea to slurp .rb files in such a C program?
    Rick Hull
    @rickhull
    I would think mrb_load_file() is sensible
    aha! there appears to be an mrb_load_file()
    Rick Hull
    @rickhull
    I've come up with this, which works as expected:
    #include <stdlib.h>
    #include <mruby.h>
    #include <mruby/compile.h>
    
    int
    main(void)
    {
      mrb_state *mrb = mrb_open();
      if (!mrb) {
        printf("mrb problem");
        exit(1);
      }
      FILE *fp = fopen("hello_world.rb", "r");
      mrb_load_file(mrb, fp);
      /* mrb_load_string(mrb, "puts 'hello world'"); */
      mrb_close(mrb);
      return 0;
    }
    is there a way to incorporate mgems with this approach?
    I am planning on making a ruby utility which will accept multiple .rb filenames from ARGV, inject them into the .c code above, and perform the compilation
    it doesn't quite feel like the right approach
    Rick Hull
    @rickhull
    it looks like exceptions are not displayed
    Rick Hull
    @rickhull
    ha, I see -- myprog is loading the ruby files when it executes
    Rick Hull
    @rickhull
    now I've injected the contents of 3 .rb files into a C string, and it works
    quelle horreur
    Rick Hull
    @rickhull
    exceptions from ruby are not "handled" in that no error message is displayed and the program exits 0
    Rick Hull
    @rickhull
    added exception handling; no backtrace with mrb_load_string()
    Rick Hull
    @rickhull
    Rick Hull
    @rickhull
    added bytecode feature, equivalent to the last (fastest) execution methodology here: http://mruby.org/docs/articles/executing-ruby-code-with-mruby.html
    # to demo
    git clone --recursive https://github.com/rickhull/mruby_tools
    cd mruby_tools
    rake bytecode hello_world
    rake verbose bytecode hello_world for more stuff to look at
    ruby -Ilib bin/mrbt -b examples/hello_world.rb to execute directly
    any number of .rb files are supported, at least in theory; not sure what the practical limit is
    Yannick Koechlin
    @yannick
    @ober to implement some mruby features for the h2o webserver
    Yannick Koechlin
    @yannick
    @rickhull mruby_tools looks pretty cool but it seems to not auto link dlls (at least on macos)
    @mattn did you ever see shotantan/mruby-json@23a313a , is this something that should be fixed?
    Yannick Koechlin
    @yannick
    i don't completely understand, how i can e.g. define a class or module through loading ritevm bytecode. mrb_load_irep_cxt(mrb, code, mrb->root_c); seems not to be enough
    Ghost
    @ghost~55825bd315522ed4b3e214bb
    Hello. I'm working on GStreamer plugins to use from Ruby. I have some problem with shared libraries. I use RVM, Ruby is build to use RVM libdir as RUNPATH. However it does not use GStreamer library from RUNPATH but from system when it loads extension library which depends on GStreamer.
    mattn
    @mattn
    @yannick sorry, long delay. recently, I added JSON.pretty_generate.
    Steven! Ragnarök
    @nuclearsandwich

    I am trying to build mruby for the Atmel SAMD21-based Circuit Playground Express board. I'm compiling libmruby.a with this build_config.rb https://gist.github.com/nuclearsandwich/d18375a375acd703bf1687d97fe57d92 and trying to link it from an external project for now. So none of the include paths in the build_config are being used. When I try to link libmruby.a I get the error below:

    "arm-none-eabi-gcc" -o MRUBY_CPX.elf "hal/src/hal_io.o" "samd21a/gcc/gcc/startup_samd21.o" "hal/utils/src/utils_syscalls.o" "hal/src/hal_delay.o" "hpl/pm/hpl_pm.o" "hpl/core/hpl_init.o" "samd21a/gcc/system_samd21.o" "hpl/core/hpl_core_m0plus_base.o" "hal/utils/src/utils_assert.o" "hpl/dmac/hpl_dmac.o" "hpl/sysctrl/hpl_sysctrl.o" "hpl/gclk/hpl_gclk.o" "hal/src/hal_init.o" "main.o" "hal/utils/src/utils_list.o" "examples/driver_examples.o" "driver_init.o" "hal/src/hal_gpio.o" "hal/utils/src/utils_event.o" "hal/src/hal_sleep.o" "atmel_start.o" "hal/src/hal_atomic.o" ../../build/arm-none-eabi-cpx/lib/libmruby.a  -Wl,--start-group -lgcc -lc -lm  -Wl,--end-group -mthumb \
    -Wl,-Map="MRUBY_CPX.map" --specs=nano.specs -Wl,--gc-sections -mcpu=cortex-m0plus \
     \
    -T"../samd21a/gcc/gcc/samd21g18a_flash.ld" \
    -L"../samd21a/gcc/gcc"
    /usr/lib/gcc/arm-none-eabi/8.1.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libc_nano.a(lib_a-writer.o): In function `_write_r':                                                                                                                                            
    writer.c:(.text._write_r+0x10): undefined reference to `_write'                                                                                                                                                                                                                
    /usr/lib/gcc/arm-none-eabi/8.1.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libc_nano.a(lib_a-readr.o): In function `_read_r':                                                                                                                                              
    readr.c:(.text._read_r+0x10): undefined reference to `_read'                                                                                                                                                                                                                   
    collect2: error: ld returned 1 exit status                                                                                                                                                                                                                                     
    make: *** [Makefile:167: MRUBY_CPX.elf] Error 1

    I'm pretty unfamiliar with embedded toolchains so I'm not sure if these missing references are due to failing to properly disable functionality in mruby I don't need yet or if I have to find these functions to for this platform.

    Steven! Ragnarök
    @nuclearsandwich
    Well. I was able to use an atmel package that provides stdio functionality via the serial interface. But when I tried to fit the mruby-compiler on the board I ran out of room in the flash storage (256K).
    Tom Black
    @blacktm

    Hi @nuclearsandwich, I recently got a Circuit Playground Express, and an Arduboy, and micro:bit. Trying to get MRuby running on all of them, but haven’t gotten as far as you yet. I did notice that the memory sizes (program and SRAM) on these little microcontrollers is pretty small (Arduboy has a tiny 32K/2.5K ATmega32U4). Might have to use MRuby/c for the smallest of these, which might also be too big for some (~40K interpreter size I think, compared to ~400K for MRuby). For the Circuit Playground, we should be able to squeeze programs into the 2MB of SPI Flash (separate memory from the ATSAMD21 chip) — they were able to get CircuitPython on there, which perhaps has a similar footprint to MRuby. Also, I think we can compile and execute Ruby over the serial interface, rather than having to re-flash the entire thing, and that would be awesome.

    Should we open an issue on the MRuby repo to talk generally about microcontroller support?

    Steven! Ragnarök
    @nuclearsandwich
    Hey that's awesome! Glad others are havingg the same idea. I am trying to finish the write up of how far in I got.
    Regarding interpreter footprint, MicroPython, the basis for CircuitPython is explicitly optimized for microcontroller devices whereas MRuby's core focus is, I believe, in being a full computer Ruby that's a bit lighter weight and easier to embed. So I don't think the interpreter sizes are likely to be that close in size. On top of that, the Ruby parser has many more moving parts than a python parser needs.
    I'm not sure how much of the SPI flash we can utilize for the MRuby firmware as I don't think we can execute from it directly. The 2M SPI is also where the user code and data needs to go so if we use too much of it we'll limit what end users can do with it.
    Steven! Ragnarök
    @nuclearsandwich
    Unless someone from mruby core requests it, I think I'd like to have a precise request before opening an issue. Something like "Make it possible to run mruby-compiler in XXX RAM / ROM?" Then we can explore the feasibility of that.