Skip to content

Commit

Permalink
add mruby sources
Browse files Browse the repository at this point in the history
  • Loading branch information
mimaki committed Apr 20, 2012
1 parent 54ad561 commit e0d6430
Show file tree
Hide file tree
Showing 111 changed files with 87,350 additions and 4 deletions.
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# /
*.bak
*.dylib
*.inc
*.o
*.orig
*.rej
*.sav
*.swp
*.d
*~
.DS_Store
.ccmalloc
.svn
/.git
cscope.out
mruby.exe
y.tab.c
120 changes: 120 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# makefile discription.
# basic build file for Rite-VM(mruby)
# 11.Apr.2011 coded by Kenji Yoshimoto.
# 17.Jan.2012 coded by Hiroshi Mimaki.

# project-specific macros
# extension of the executable-file is modifiable(.exe .out ...)
TARGET := bin/mrubysample
RITEVM := lib/ritevm
MRUBY := tools/mruby/mruby
ifeq ($(OS),Windows_NT)
EXE := $(TARGET).exe
LIB := $(RITEVM).lib
MRB := $(MRUBY).exe
else
EXE := $(TARGET)
LIB := $(RITEVM).a
MRB := $(MRUBY)
endif
MSRC := src/minimain.c
YSRC := src/parse.y
YC := src/y.tab.c
EXCEPT1 := $(YC) $(MSRC)
OBJM := $(patsubst %.c,%.o,$(MSRC))
OBJY := $(patsubst %.c,%.o,$(YC))
OBJ1 := $(patsubst %.c,%.o,$(filter-out $(EXCEPT1),$(wildcard src/*.c)))
#OBJ2 := $(patsubst %.c,%.o,$(wildcard ext/regex/*.c))
#OBJ3 := $(patsubst %.c,%.o,$(wildcard ext/enc/*.c))
OBJS := $(OBJ1) $(OBJ2) $(OBJ3)
# mruby libraries
EXTC := mrblib/mrblib.c
EXTRB := $(wildcard mrblib/*.rb)
EXT0 := $(patsubst %.c,%.o,src/$(EXTC))
# ext libraries
EXTS := $(EXT0)

# libraries, includes
LIBS = $(LIB) -lm
INCLUDES = -I./src -I./include

# library for iOS
IOSLIB := $(RITEVM)-ios.a
IOSSIMLIB := $(RITEVM)-iossim.a
IOSDEVLIB := $(RITEVM)-iosdev.a
IOSSIMCC := xcrun -sdk iphoneos llvm-gcc-4.2 -arch i386 -isysroot "/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/"
IOSDEVCC := xcrun -sdk iphoneos llvm-gcc-4.2 -arch armv7 -isysroot "/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/"

# compiler, linker (gcc)
CC = gcc
LL = gcc
YACC = bison
DEBUG_MODE = 1
ifeq ($(DEBUG_MODE),1)
CFLAGS = -g
else
CFLAGS = -O3
endif
ALL_CFLAGS = -Wall -Werror-implicit-function-declaration $(CFLAGS)
MAKE_FLAGS = --no-print-directory CC="$(CC)" LL="$(LL)"

##############################
# generic build targets, rules

.PHONY : all
all : $(LIB) $(MRB) $(EXE)
@echo "make: built targets of `pwd`"

##############################
# make library for iOS
.PHONY : ios
ios : $(IOSLIB)

$(IOSLIB) : $(IOSSIMLIB) $(IOSDEVLIB)
lipo -arch i386 $(IOSSIMLIB) -arch armv7 $(IOSDEVLIB) -create -output $(IOSLIB)

$(IOSSIMLIB) :
$(MAKE) clean -C src $(MAKE_FLAGS)
$(MAKE) -C src $(MAKE_FLAGS) CC="$(IOSSIMCC)" LL="$(IOSSIMCC)"
cp $(LIB) $(IOSSIMLIB)

$(IOSDEVLIB) :
$(MAKE) clean -C src $(MAKE_FLAGS)
$(MAKE) -C src $(MAKE_FLAGS) CC="$(IOSDEVCC)" LL="$(IOSDEVCC)"
cp $(LIB) $(IOSDEVLIB)

# executable constructed using linker from object files
$(EXE) : $(OBJM) $(LIB)
$(LL) -o $@ $(OBJM) $(LIBS)

-include $(OBJS:.o=.d)

# src compile
$(LIB) : $(EXTS) $(OBJS) $(OBJY)
$(MAKE) -C src $(MAKE_FLAGS)

# mruby interpreter compile
$(MRB) : $(EXTS) $(OBJS) $(OBJY)
$(MAKE) -C tools/mruby $(MAKE_FLAGS)

# objects compiled from source
$(OBJS) :
$(MAKE) -C src $(MAKE_FLAGS) && $(MAKE) -C tools/mruby $(MAKE_FLAGS)

# extend libraries complile
$(EXTS) : $(EXTRB)
$(MAKE) -C mrblib $(MAKE_FLAGS)

# test module compile
$(OBJM) : $(MSRC)
$(CC) $(ALL_CFLAGS) -MMD $(INCLUDES) -c $(MSRC) -o $(OBJM)

# clean up
.PHONY : clean
clean :
$(MAKE) clean -C src $(MAKE_FLAGS)
$(MAKE) clean -C tools/mruby $(MAKE_FLAGS)
-rm -f $(EXE) $(OBJM)
-rm -f $(OBJM:.o=.d)
-rm -f $(IOSLIB) $(IOSSIMLIB) $(IOSDEVLIB)
@echo "make: removing targets, objects and depend files of `pwd`"
4 changes: 0 additions & 4 deletions README.md

This file was deleted.

14 changes: 14 additions & 0 deletions Todo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
やること(まだできてないこと) / not yet complete

* ヒアドキュメント / here document
* 特殊変数 ($1,$2..) / special variables
* super in aliased methods
* BEGIN/END (対応しないんだっけ?)
* const_missing
* respond_to_missing

改善すること(できているが直すこと)

* Hash (サイズを減らす。khashを使うか、順序を保存するか)
* stringEx (encoding削除、CODERANGE削除、UTF-8 or ASCII以外削除)
* 気づいたら書き加える
Empty file added bin/.gitkeep
Empty file.
Empty file added doc/.gitkeep
Empty file.
Empty file added ext/.gitkeep
Empty file.
42 changes: 42 additions & 0 deletions include/mrbconf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#ifndef MRUBYCONF_H
#define MRUBYCONF_H

#include <stdint.h>
typedef double mrb_float;
typedef int32_t mrb_int;
typedef intptr_t mrb_sym;

#define readint(p,base) strtol((p),NULL,(base))
#define readfloat(p) strtod((p),NULL)

#undef INCLUDE_ENCODING /* not use encoding classes (ascii only) */
#define INCLUDE_ENCODING /* use UTF-8 encoding classes */

#undef INCLUDE_REGEXP /* not use regular expression classes */
#define INCLUDE_REGEXP /* use regular expression classes */

#ifdef INCLUDE_REGEXP
# define INCLUDE_ENCODING /* Regexp depends Encoding */
#endif

#undef HAVE_UNISTD_H /* WINDOWS */
#define HAVE_UNISTD_H /* LINUX */

#define SIZEOF_INT 4
#define SIZEOF_SHORT 2
#define SIZEOF_LONG 4
#define SIZEOF_LONG_LONG 8
#define SIZEOF___INT64 0
#define SIZEOF_VOIDP 4
#define SIZEOF_FLOAT 4
#define SIZEOF_DOUBLE 8

#ifndef FALSE
# define FALSE 0
#endif

#ifndef TRUE
# define TRUE 1
#endif

#endif /* MRUBYCONF_H */
Loading

0 comments on commit e0d6430

Please sign in to comment.