Skip to content

Commit

Permalink
Re-structure the file
Browse files Browse the repository at this point in the history
  • Loading branch information
yuuu committed Jan 11, 2025
1 parent cda2dba commit 3f40283
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 97 deletions.
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
build/
sdkconfig
sdkconfig.old
.vscode
components/picoruby-esp32/mrb
mrb
.env

4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "components/picoruby-esp32/picoruby"]
path = components/picoruby-esp32/picoruby
[submodule "picoruby"]
path = picoruby
url = https://github.com/picoruby/picoruby.git
72 changes: 67 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,68 @@
# The following lines of boilerplate have to be in your project's
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.16)
idf_component_register(
SRCS
${COMPONENT_DIR}/picoruby-esp32.c
${COMPONENT_DIR}/picoruby/mrbgems/picoruby-machine/ports/esp32/machine.c
${COMPONENT_DIR}/picoruby/mrbgems/picoruby-io-console/ports/esp32/io-console.c
${COMPONENT_DIR}/picoruby/mrbgems/picoruby-filesystem-fat/ports/esp32/flash_disk.c
${COMPONENT_DIR}/picoruby/mrbgems/picoruby-env/ports/esp32/env.c
INCLUDE_DIRS
${COMPONENT_DIR}
${COMPONENT_DIR}/picoruby/mrbgems/picoruby-mrubyc/lib/mrubyc/src
${COMPONENT_DIR}/picoruby/mrbgems/picoruby-machine/include
${COMPONENT_DIR}/picoruby/mrbgems/picoruby-filesystem-fat/ports/esp32
REQUIRES esp_driver_uart
)

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(picoruby-esp32)
add_definitions(
-DMRBC_TICK_UNIT=10
-DMRBC_TIMESLICE_TICK_COUNT=1
-DMRBC_USE_FLOAT=2
-DMRC_CUSTOM_ALLOC
-DMRBC_CONVERT_CRLF=1
-DNDEBUG
)

set(PICORUBY_DIR ${COMPONENT_DIR}/picoruby)
set(LIBMRUBY_FILE ${PICORUBY_DIR}/build/esp32/lib/libmruby.a)

# Build PicoRuby
add_custom_command(
OUTPUT ${LIBMRUBY_FILE}
COMMAND ${CMAKE_COMMAND} -E echo "MRUBY_CONFIG=${IDF_TARGET_ARCH}-esp rake"
COMMAND ${CMAKE_COMMAND} -E env MRUBY_CONFIG=${IDF_TARGET_ARCH}-esp rake
WORKING_DIRECTORY ${PICORUBY_DIR}
COMMENT "PicoRuby build"
VERBATIM
)

add_prebuilt_library(
libmruby ${LIBMRUBY_FILE}
REQUIRES ${COMPONENT_NAME}
)
target_link_libraries(${COMPONENT_LIB} PRIVATE libmruby)

add_custom_target(
picoruby DEPENDS ${LIBMRUBY_FILE}
DEPENDS ${LIBMRUBY_FILE}
)
add_dependencies(${COMPONENT_LIB} picoruby)

# Compile Ruby files
add_custom_target(
mrbdir ALL
COMMAND ${CMAKE_COMMAND} -E make_directory ${COMPONENT_DIR}/mrb
)
add_dependencies(${COMPONENT_LIB} mrbdir)

set(RUBY_FILES main_task)
set(PICORBC ${COMPONENT_DIR}/picoruby/bin/picorbc)

foreach(rb ${RUBY_FILES})
add_custom_target(${rb}
COMMAND ${PICORBC} -B${rb} -o${COMPONENT_DIR}/mrb/${rb}.c ${COMPONENT_DIR}/mrblib/${rb}.rb
DEPENDS mrbdir
)
endforeach(rb)

add_custom_target(generate_files ALL DEPENDS mrbdir ${RUBY_FILES})
add_dependencies(${COMPONENT_LIB} generate_files)
File renamed without changes.
68 changes: 0 additions & 68 deletions components/picoruby-esp32/CMakeLists.txt

This file was deleted.

File renamed without changes.
6 changes: 0 additions & 6 deletions main/CMakeLists.txt

This file was deleted.

12 changes: 0 additions & 12 deletions main/main.c

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file removed sdkconfig.ci
Empty file.

0 comments on commit 3f40283

Please sign in to comment.