Skip to content

Commit

Permalink
Changed MRI install directories and version
Browse files Browse the repository at this point in the history
  • Loading branch information
Hadeweka committed Sep 7, 2021
1 parent ad27287 commit 7cbb043
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 23 deletions.
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,7 @@ The term 'anyoli' means 'green' in the Maasai language, thus naming 'anyolite'.

#### Features

* [ ] Full MRI Ruby as alternative implementation (might be postponed to a later release)
* * [X] Basic functionality similar to mruby
* * [X] Calling of script lines
* * [ ] Bytecode compilation (might not be possible)
* * [ ] Even more tests
* * [ ] Copy source in build directory and call compile scripts there
* * [ ] Find solution for UTF-8 function names leading to crashes
* * [ ] Find solution for MRI crash at second script file loading
* [X] Full MRI Ruby as alternative implementation
* [X] AnyolitePointer helper class for accessing pointers
* [X] Infrastructure to convert script files into bytecode at runtime and compiletime
* [X] Support for setting and getting instance, class and global variables from Crystal
Expand All @@ -245,6 +238,7 @@ The term 'anyoli' means 'green' in the Maasai language, thus naming 'anyolite'.
* [X] Changed `RClass*` to `RClassPtr` to allow compatibility with MRI
* [X] Reorganized some macros
* [X] Changed directory structure
* [X] Several code changes for compatibility with MRI
* [X] Block variables for functions definitions have now an underscore in front of them

#### Usability
Expand Down
11 changes: 6 additions & 5 deletions Rakefile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,11 @@ def set_option(name, value)
raise "MSVC compilation of MRI is not supported yet."
# TODO
elsif ANYOLITE_COMPILER == :gcc
system "cd #{$config.rb_dir}/#{$config.implementation}; ./autogen.sh"
system "cd #{$config.rb_dir}/#{$config.implementation}; ./configure --prefix=\"#{temp_path}/#{$config.build_path}/#{$config.implementation}\""
system "cd #{$config.rb_dir}/#{$config.implementation}; make"
system "cd #{$config.rb_dir}/#{$config.implementation}; make install"
system "cp -r #{$config.rb_dir}/#{$config.implementation} #{temp_path}/#{$config.build_path}/src_#{$config.implementation}"
system "cd #{$config.build_path}/src_#{$config.implementation}; ./autogen.sh"
system "cd #{$config.build_path}/src_#{$config.implementation}; ./configure --prefix=\"#{temp_path}/#{$config.build_path}/#{$config.implementation}\""
system "cd #{$config.build_path}/src_#{$config.implementation}; make"
system "cd #{$config.build_path}/src_#{$config.implementation}; make install"
else
end
else
Expand Down Expand Up @@ -136,7 +137,7 @@ def set_option(name, value)
end
elsif ANYOLITE_COMPILER == :gcc
GLUE_FILES.each do |name|
system "cc -std=c99 -I#{$config.build_path}/#{$config.implementation}/include/ruby-3.1.0 -I#{$config.build_path}/#{$config.implementation}/include/ruby-3.1.0/x86_64-linux -I#{$config.build_path}/#{$config.implementation}/include/ruby-3.1.0/aarch64-linux -c #{$config.glue_dir}/#{name}.c -o #{$config.build_path}/glue/#{$config.implementation}/#{name}.o"
system "cc -std=c99 -I#{$config.build_path}/#{$config.implementation}/include/ruby-3.0.0 -I#{$config.build_path}/#{$config.implementation}/include/ruby-3.0.0/x86_64-linux -I#{$config.build_path}/#{$config.implementation}/include/ruby-3.0.0/aarch64-linux -c #{$config.glue_dir}/#{name}.c -o #{$config.build_path}/glue/#{$config.implementation}/#{name}.o"
end
else
GLUE_FILES.each do |name|
Expand Down
2 changes: 1 addition & 1 deletion config_files/anyolite_config_mri.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"implementation": "mri",
"build_path": "build",
"rb_fork": "https://github.com/ruby/ruby",
"rb_release": "master",
"rb_release": "v3_0_2",
"rb_dir": "third_party",
"rb_config": "",
"glue_dir": "glue/mri"
Expand Down
48 changes: 39 additions & 9 deletions glue/mri/script_helper.c
Original file line number Diff line number Diff line change
@@ -1,38 +1,66 @@
#include <ruby.h>

//! TODO: Is a complete cleanup maybe possible? For now, the state is kept.

extern void* open_interpreter(void) {

static int first_run = 1;

if(!first_run) {

printf("ERROR: Only one Ruby interpreter can be used at this point.\n");
return (void*) 0;

}

RUBY_INIT_STACK;
ruby_init();

first_run = 0;

return (void*) 0;

}

extern void close_interpreter(void* rb) {

static int first_run = 1;

if(!first_run) {

return;

}

first_run = 0;

ruby_cleanup(0);

}

extern void load_script_from_file(void* rb, const char* filename) {

static int first_script = 1;
static int first_run = 1;

if(first_script) {
char* args[2] = {"test", (char*) filename};

if(!first_run) {

ruby_script(filename);
first_script = 0;
printf("ERROR: Ruby scripts can only be run once at this point.\n");
return;

}

int error;
void* options = ruby_options(2, args);

char* args[2] = {"test", (char*) filename};
int ex_node_status;
int ex_node_return = ruby_executable_node(options, &ex_node_status);

void* options = ruby_options(2, args);
if(!ex_node_return) {

printf("Error: File %s could not be executed.\n", filename);
ruby_cleanup(ex_node_status);
return;

}

int return_value = ruby_exec_node(options);

Expand All @@ -45,6 +73,8 @@ extern void load_script_from_file(void* rb, const char* filename) {

}

first_run = 0;

//! TODO: Fix segfaults at second execution

}
Expand Down

0 comments on commit 7cbb043

Please sign in to comment.