diff options
| author | Yuichiro MASUI <[email protected]> | 2012-12-29 05:37:55 +0900 |
|---|---|---|
| committer | Yuichiro MASUI <[email protected]> | 2013-01-03 02:24:15 +0900 |
| commit | 7c469c0b9dadd1de09fed18c3e5cc551012c38c1 (patch) | |
| tree | b79aa703ef7c528896c4f1be8280d0691314008b /mrblib | |
| parent | a48fc0d7952ad1f10ae777637269fe6a3f9ad0a2 (diff) | |
| download | mruby-7c469c0b9dadd1de09fed18c3e5cc551012c38c1.tar.gz mruby-7c469c0b9dadd1de09fed18c3e5cc551012c38c1.zip | |
Rebuild CRuby based building script without Makefile
Tested CRuby 1.8.6 and 1.9.3
You can see building configuration in build_config.rb
Diffstat (limited to 'mrblib')
| -rw-r--r-- | mrblib/CMakeLists.txt | 60 | ||||
| -rw-r--r-- | mrblib/Makefile | 79 | ||||
| -rw-r--r-- | mrblib/mrblib.rake | 15 |
3 files changed, 15 insertions, 139 deletions
diff --git a/mrblib/CMakeLists.txt b/mrblib/CMakeLists.txt deleted file mode 100644 index a0386f0fe..000000000 --- a/mrblib/CMakeLists.txt +++ /dev/null @@ -1,60 +0,0 @@ -# transform mruby's standard lib into a C library - -file(GLOB MRBLIB_SRC_RB "*.rb") - -if(CMAKE_CROSSCOMPILING) - # create native tools and `mrblib.ctmp` required to build `mrblib.c` - include(ExternalProject) - ExternalProject_Add(mruby-native - DOWNLOAD_COMMAND "" - SOURCE_DIR "${CMAKE_SOURCE_DIR}" - CONFIGURE_COMMAND "${CMAKE_COMMAND}" "${CMAKE_SOURCE_DIR}" - INSTALL_COMMAND "" - BINARY_DIR "${CMAKE_BINARY_DIR}/native" - ) - - # aggregate mruby's standard library as a single C file - add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/mrblib.c" - DEPENDS mruby-native init_mrblib.c "${CMAKE_BINARY_DIR}/native/mrblib/mrblib.ctmp" - COMMAND "${CMAKE_BINARY_DIR}/native/tools/xpcat/xpcat" - -o "${CMAKE_CURRENT_BINARY_DIR}/mrblib.c" - "${CMAKE_CURRENT_SOURCE_DIR}/init_mrblib.c" - "${CMAKE_BINARY_DIR}/native/mrblib/mrblib.ctmp" - ) -else() - # generate a single rb file from all existing ones - add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/mrblib.rbtmp" - DEPENDS xpcat - COMMAND xpcat -o "${CMAKE_CURRENT_BINARY_DIR}/mrblib.rbtmp" ${MRBLIB_SRC_RB} - ) - - # mruby compile and generate C byte array representation - add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/mrblib.ctmp" - DEPENDS mrbc "${CMAKE_CURRENT_BINARY_DIR}/mrblib.rbtmp" - COMMAND mrbc -Bmrblib_irep -o"${CMAKE_CURRENT_BINARY_DIR}/mrblib.ctmp" - "${CMAKE_CURRENT_BINARY_DIR}/mrblib.rbtmp" - ) - - # aggregate mruby's standard library as a single C file - add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/mrblib.c" - DEPENDS xpcat init_mrblib.c "${CMAKE_CURRENT_BINARY_DIR}/mrblib.ctmp" - COMMAND xpcat -o "${CMAKE_CURRENT_BINARY_DIR}/mrblib.c" - "${CMAKE_CURRENT_SOURCE_DIR}/init_mrblib.c" - "${CMAKE_CURRENT_BINARY_DIR}/mrblib.ctmp" - ) -endif() - - -# generate final static libmruby archive library -add_library(libmruby_static STATIC - mrblib.c - $<TARGET_OBJECTS:mruby_object> - ) -set_target_properties(libmruby_static PROPERTIES OUTPUT_NAME mruby) - -install(TARGETS libmruby_static - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - ) - -# vim: ts=2 sts=2 sw=2 et diff --git a/mrblib/Makefile b/mrblib/Makefile deleted file mode 100644 index 57ce1387b..000000000 --- a/mrblib/Makefile +++ /dev/null @@ -1,79 +0,0 @@ -# Makefile description. -# basic build file for mruby library (Ruby part) - -# project-specific macros -# extension of the executable-file is modifiable(.exe .out ...) -BASEDIR = . -TARGET := mrblib -MLIB := $(TARGET).o -CLIB := $(TARGET).c -DLIB := $(TARGET).ctmp -RLIB := $(TARGET).rbtmp -DEPLIB := $(TARGET).d -MRB1 := $(BASEDIR)/*.rb -MRBS := $(MRB1) -LIBR0 := ../lib/libmruby_core.a -LIBR := ../lib/libmruby.a - -# libraries, includes -INCLUDES = -I../src -I../include - -ifeq ($(strip $(COMPILE_MODE)),) - # default compile option - COMPILE_MODE = debug -endif - -ifeq ($(COMPILE_MODE),debug) - CFLAGS = -g -O3 -else ifeq ($(COMPILE_MODE),release) - CFLAGS = -O3 -else ifeq ($(COMPILE_MODE),small) - CFLAGS = -Os -endif - -ALL_CFLAGS = -Wall -Werror-implicit-function-declaration $(CFLAGS) -ifeq ($(OS),Windows_NT) - MAKE_FLAGS = CC=$(CC) LL=$(LL) ALL_CFLAGS='$(ALL_CFLAGS)' LDFLAGS='$(LDFLAGS)' -else - MAKE_FLAGS = CC='$(CC)' LL='$(LL)' ALL_CFLAGS='$(ALL_CFLAGS)' LDFLAGS='$(LDFLAGS)' -endif - -# mruby compiler -ifeq ($(OS),Windows_NT) -MRBC = ../bin/mrbc.exe -else -MRBC = ../bin/mrbc -endif - - -############################## -# generic build targets, rules - -.PHONY : all -all : $(LIBR) - -# update libmruby.a -$(LIBR) : $(MLIB) $(LIBR0) - $(CP) $(LIBR0) $(LIBR) - $(AR) r $(LIBR) $(MLIB) - -# Compile mrblib source -$(MLIB) : $(CLIB) - $(CC) $(ALL_CFLAGS) -MMD $(INCLUDES) -c $(CLIB) -o $(MLIB) - -# Compile C source from merged mruby source -$(CLIB) : $(RLIB) $(MRBC) - $(MRBC) -Bmrblib_irep -o$(DLIB) $(RLIB); $(CAT) init_$(TARGET).c $(DLIB) > $@ - -$(MRBC) : $(LIBR0) - $(MAKE) -C ../tools/mrbc $(MAKE_FLAGS) - -# merge mruby sources -$(RLIB) : $(MRBS) - $(CAT) $(MRBS) > $@ - -# clean up -.PHONY : clean -clean : - @echo "make: removing targets, objects and depend files of `pwd`" - -$(RM_F) $(MRBC) $(MLIB) $(CLIB) $(RLIB) $(DLIB) $(DEPLIB) $(LIBR) diff --git a/mrblib/mrblib.rake b/mrblib/mrblib.rake new file mode 100644 index 000000000..5dab4cee9 --- /dev/null +++ b/mrblib/mrblib.rake @@ -0,0 +1,15 @@ +dir = File.dirname(__FILE__).sub(%r|^\./|, '') + +MRuby.each_target do + self.libmruby << "#{build_dir}/#{dir}/mrblib.o" + + file "#{build_dir}/#{dir}/mrblib.o" => "#{build_dir}/#{dir}/mrblib.c" + file "#{build_dir}/#{dir}/mrblib.c" => [mrbcfile] + Dir.glob("#{dir}/*.rb") do |t| + mrbc, *rbfiles = t.prerequisites + FileUtils.mkdir_p File.dirname(t.name) + open(t.name, 'w') do |f| + f.puts File.read("#{dir}/init_mrblib.c") + compile_mruby f, rbfiles, 'mrblib_irep' + end + end +end |
