commit 9c5afa41eae9fbf02b57819da38168f1438f656b Author: Yilin Sun Date: Fri Mar 3 09:55:25 2023 +0800 Initial commit. Signed-off-by: Yilin Sun diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..66cfef8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/config/*.lock +/build +/cmake-build-* diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..e411e81 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "mruby"] + path = mruby + url = https://github.com/mruby/mruby.git diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..6c45373 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,28 @@ +cmake_minimum_required(VERSION 3.10) + +project(mruby_mcux) + +if(NOT DEFINED MRUBY_MCUX_TARGET) + message(WARNING "MRUBY_MCUX_TARGET not defined, using default.") + set(MRUBY_MCUX_TARGET imxrt10xx) +endif() + +add_custom_command(OUTPUT libmruby.a + COMMAND "${CMAKE_COMMAND}" "-E" "env" + "MRUBY_CONFIG=${CMAKE_CURRENT_SOURCE_DIR}/configs/${MRUBY_MCUX_TARGET}.rb" + "MRUBY_BUILD_DIR=${CMAKE_CURRENT_BINARY_DIR}/mruby" + "./minirake" + + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/mruby" +) + +add_custom_target(mruby + DEPENDS "libmruby.a" +) + +set_target_properties(mruby PROPERTIES + ADDITIONAL_CLEAN_FILES "${CMAKE_CURRENT_BINARY_DIR}/mruby" +) + +add_library(${PROJECT_NAME} INTERFACE) +target_link_libraries(${PROJECT_NAME} INTERFACE mruby) diff --git a/configs/imxrt1xxx.rb b/configs/imxrt1xxx.rb new file mode 100644 index 0000000..6d872e1 --- /dev/null +++ b/configs/imxrt1xxx.rb @@ -0,0 +1,56 @@ +# Cross Compiling configuration for i.MXRT 1xxx (Cortex-M7) + +MRuby::CrossBuild.new("imxrt1xxx") do |conf| + toolchain :gcc + + conf.cc do |cc| + cc.command = "arm-none-eabi-gcc" + cc.flags = "-mcpu=cortex-m7 -mthumb -mfloat-abi=hard -mfpu=fpv5-d16 -Wall -g -O2" + cc.compile_options = %Q[%{flags} -o "%{outfile}" -c "%{infile}"] + + #configuration for low memory environment + cc.defines << %w(MRB_HEAP_PAGE_SIZE=64) + cc.defines << %w(KHASH_DEFAULT_SIZE=8) + cc.defines << %w(MRB_GC_STRESS) + end + + conf.cxx do |cxx| + cxx.command = conf.cc.command.dup + cxx.include_paths = conf.cc.include_paths.dup + cxx.flags = conf.cc.flags.dup + cxx.defines = conf.cc.defines.dup + cxx.compile_options = conf.cc.compile_options.dup + end + + conf.linker do |linker| + linker.command="arm-none-eabi-ld" + end + + conf.archiver do |archiver| + archiver.command = "arm-none-eabi-ar" + archiver.archive_options = 'rcs "%{outfile}" %{objs}' + end + + #no executables + conf.bins = [] + + #do not build executable test + conf.build_mrbtest_lib_only + + #disable C++ exception + conf.disable_cxx_exception + + #gems from core + conf.gem :core => "mruby-sprintf" + conf.gem :core => "mruby-print" + conf.gem :core => "mruby-math" + conf.gem :core => "mruby-enum-ext" + conf.gem :core => "mruby-numeric-ext" + + #light-weight regular expression + #conf.gem :github => "masamitsu-murase/mruby-hs-regexp", :branch => "master" + + #Arduino API + #conf.gem :github =>"kyab/mruby-arduino", :branch => "master" + +end diff --git a/configs/lpc5500.rb b/configs/lpc5500.rb new file mode 100644 index 0000000..68193bd --- /dev/null +++ b/configs/lpc5500.rb @@ -0,0 +1,59 @@ +# Cross Compiling configuration for RX630 +# http://gadget.renesas.com/ +# +# Requires gnurx_v14.03 +MRuby::CrossBuild.new("lpc5500") do |conf| + toolchain :gcc + + conf.cc do |cc| + cc.command = "arm-none-eabi-gcc" + cc.flags = "-mcpu=cortex-m33 -mthumb -mfloat-abi=hard -mfpu=fpv5-sp-d16 -Wall -g -O2" + cc.compile_options = %Q[%{flags} -o "%{outfile}" -c "%{infile}"] + + #configuration for low memory environment + cc.defines << %w(MRB_USE_FLOAT32) + cc.defines << %w(MRB_HEAP_PAGE_SIZE=64) + cc.defines << %w(KHASH_DEFAULT_SIZE=8) + cc.defines << %w(MRB_GC_STRESS) + end + + conf.cxx do |cxx| + cxx.command = conf.cc.command.dup + cxx.include_paths = conf.cc.include_paths.dup + cxx.flags = conf.cc.flags.dup + cxx.defines = conf.cc.defines.dup + cxx.compile_options = conf.cc.compile_options.dup + end + + conf.linker do |linker| + linker.command="arm-none-eabi-ld" + end + + conf.archiver do |archiver| + archiver.command = "arm-none-eabi-ar" + archiver.archive_options = 'rcs "%{outfile}" %{objs}' + end + + #no executables + conf.bins = [] + + #do not build executable test + conf.build_mrbtest_lib_only + + #disable C++ exception + conf.disable_cxx_exception + + #gems from core + conf.gem :core => "mruby-sprintf" + conf.gem :core => "mruby-print" + conf.gem :core => "mruby-math" + conf.gem :core => "mruby-enum-ext" + conf.gem :core => "mruby-numeric-ext" + + #light-weight regular expression + #conf.gem :github => "masamitsu-murase/mruby-hs-regexp", :branch => "master" + + #Arduino API + #conf.gem :github =>"kyab/mruby-arduino", :branch => "master" + +end diff --git a/mruby b/mruby new file mode 160000 index 0000000..d7f4af0 --- /dev/null +++ b/mruby @@ -0,0 +1 @@ +Subproject commit d7f4af04ca2c5d7caf377623b9a0c2f86e10e9e8