Skip to content

Commit e0d6430

Browse files
author
mimaki
committed
add mruby sources
1 parent 54ad561 commit e0d6430

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+87350
-4
lines changed

.gitignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# /
2+
*.bak
3+
*.dylib
4+
*.inc
5+
*.o
6+
*.orig
7+
*.rej
8+
*.sav
9+
*.swp
10+
*.d
11+
*~
12+
.DS_Store
13+
.ccmalloc
14+
.svn
15+
/.git
16+
cscope.out
17+
mruby.exe
18+
y.tab.c

Makefile

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# makefile discription.
2+
# basic build file for Rite-VM(mruby)
3+
# 11.Apr.2011 coded by Kenji Yoshimoto.
4+
# 17.Jan.2012 coded by Hiroshi Mimaki.
5+
6+
# project-specific macros
7+
# extension of the executable-file is modifiable(.exe .out ...)
8+
TARGET := bin/mrubysample
9+
RITEVM := lib/ritevm
10+
MRUBY := tools/mruby/mruby
11+
ifeq ($(OS),Windows_NT)
12+
EXE := $(TARGET).exe
13+
LIB := $(RITEVM).lib
14+
MRB := $(MRUBY).exe
15+
else
16+
EXE := $(TARGET)
17+
LIB := $(RITEVM).a
18+
MRB := $(MRUBY)
19+
endif
20+
MSRC := src/minimain.c
21+
YSRC := src/parse.y
22+
YC := src/y.tab.c
23+
EXCEPT1 := $(YC) $(MSRC)
24+
OBJM := $(patsubst %.c,%.o,$(MSRC))
25+
OBJY := $(patsubst %.c,%.o,$(YC))
26+
OBJ1 := $(patsubst %.c,%.o,$(filter-out $(EXCEPT1),$(wildcard src/*.c)))
27+
#OBJ2 := $(patsubst %.c,%.o,$(wildcard ext/regex/*.c))
28+
#OBJ3 := $(patsubst %.c,%.o,$(wildcard ext/enc/*.c))
29+
OBJS := $(OBJ1) $(OBJ2) $(OBJ3)
30+
# mruby libraries
31+
EXTC := mrblib/mrblib.c
32+
EXTRB := $(wildcard mrblib/*.rb)
33+
EXT0 := $(patsubst %.c,%.o,src/$(EXTC))
34+
# ext libraries
35+
EXTS := $(EXT0)
36+
37+
# libraries, includes
38+
LIBS = $(LIB) -lm
39+
INCLUDES = -I./src -I./include
40+
41+
# library for iOS
42+
IOSLIB := $(RITEVM)-ios.a
43+
IOSSIMLIB := $(RITEVM)-iossim.a
44+
IOSDEVLIB := $(RITEVM)-iosdev.a
45+
IOSSIMCC := xcrun -sdk iphoneos llvm-gcc-4.2 -arch i386 -isysroot "/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/"
46+
IOSDEVCC := xcrun -sdk iphoneos llvm-gcc-4.2 -arch armv7 -isysroot "/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/"
47+
48+
# compiler, linker (gcc)
49+
CC = gcc
50+
LL = gcc
51+
YACC = bison
52+
DEBUG_MODE = 1
53+
ifeq ($(DEBUG_MODE),1)
54+
CFLAGS = -g
55+
else
56+
CFLAGS = -O3
57+
endif
58+
ALL_CFLAGS = -Wall -Werror-implicit-function-declaration $(CFLAGS)
59+
MAKE_FLAGS = --no-print-directory CC="$(CC)" LL="$(LL)"
60+
61+
##############################
62+
# generic build targets, rules
63+
64+
.PHONY : all
65+
all : $(LIB) $(MRB) $(EXE)
66+
@echo "make: built targets of `pwd`"
67+
68+
##############################
69+
# make library for iOS
70+
.PHONY : ios
71+
ios : $(IOSLIB)
72+
73+
$(IOSLIB) : $(IOSSIMLIB) $(IOSDEVLIB)
74+
lipo -arch i386 $(IOSSIMLIB) -arch armv7 $(IOSDEVLIB) -create -output $(IOSLIB)
75+
76+
$(IOSSIMLIB) :
77+
$(MAKE) clean -C src $(MAKE_FLAGS)
78+
$(MAKE) -C src $(MAKE_FLAGS) CC="$(IOSSIMCC)" LL="$(IOSSIMCC)"
79+
cp $(LIB) $(IOSSIMLIB)
80+
81+
$(IOSDEVLIB) :
82+
$(MAKE) clean -C src $(MAKE_FLAGS)
83+
$(MAKE) -C src $(MAKE_FLAGS) CC="$(IOSDEVCC)" LL="$(IOSDEVCC)"
84+
cp $(LIB) $(IOSDEVLIB)
85+
86+
# executable constructed using linker from object files
87+
$(EXE) : $(OBJM) $(LIB)
88+
$(LL) -o $@ $(OBJM) $(LIBS)
89+
90+
-include $(OBJS:.o=.d)
91+
92+
# src compile
93+
$(LIB) : $(EXTS) $(OBJS) $(OBJY)
94+
$(MAKE) -C src $(MAKE_FLAGS)
95+
96+
# mruby interpreter compile
97+
$(MRB) : $(EXTS) $(OBJS) $(OBJY)
98+
$(MAKE) -C tools/mruby $(MAKE_FLAGS)
99+
100+
# objects compiled from source
101+
$(OBJS) :
102+
$(MAKE) -C src $(MAKE_FLAGS) && $(MAKE) -C tools/mruby $(MAKE_FLAGS)
103+
104+
# extend libraries complile
105+
$(EXTS) : $(EXTRB)
106+
$(MAKE) -C mrblib $(MAKE_FLAGS)
107+
108+
# test module compile
109+
$(OBJM) : $(MSRC)
110+
$(CC) $(ALL_CFLAGS) -MMD $(INCLUDES) -c $(MSRC) -o $(OBJM)
111+
112+
# clean up
113+
.PHONY : clean
114+
clean :
115+
$(MAKE) clean -C src $(MAKE_FLAGS)
116+
$(MAKE) clean -C tools/mruby $(MAKE_FLAGS)
117+
-rm -f $(EXE) $(OBJM)
118+
-rm -f $(OBJM:.o=.d)
119+
-rm -f $(IOSLIB) $(IOSSIMLIB) $(IOSDEVLIB)
120+
@echo "make: removing targets, objects and depend files of `pwd`"

README.md

Lines changed: 0 additions & 4 deletions
This file was deleted.

Todo.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
やること(まだできてないこと) / not yet complete
2+
3+
* ヒアドキュメント / here document
4+
* 特殊変数 ($1,$2..) / special variables
5+
* super in aliased methods
6+
* BEGIN/END (対応しないんだっけ?)
7+
* const_missing
8+
* respond_to_missing
9+
10+
改善すること(できているが直すこと)
11+
12+
* Hash (サイズを減らす。khashを使うか、順序を保存するか)
13+
* stringEx (encoding削除、CODERANGE削除、UTF-8 or ASCII以外削除)
14+
* 気づいたら書き加える

bin/.gitkeep

Whitespace-only changes.

doc/.gitkeep

Whitespace-only changes.

ext/.gitkeep

Whitespace-only changes.

include/mrbconf.h

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#ifndef MRUBYCONF_H
2+
#define MRUBYCONF_H
3+
4+
#include <stdint.h>
5+
typedef double mrb_float;
6+
typedef int32_t mrb_int;
7+
typedef intptr_t mrb_sym;
8+
9+
#define readint(p,base) strtol((p),NULL,(base))
10+
#define readfloat(p) strtod((p),NULL)
11+
12+
#undef INCLUDE_ENCODING /* not use encoding classes (ascii only) */
13+
#define INCLUDE_ENCODING /* use UTF-8 encoding classes */
14+
15+
#undef INCLUDE_REGEXP /* not use regular expression classes */
16+
#define INCLUDE_REGEXP /* use regular expression classes */
17+
18+
#ifdef INCLUDE_REGEXP
19+
# define INCLUDE_ENCODING /* Regexp depends Encoding */
20+
#endif
21+
22+
#undef HAVE_UNISTD_H /* WINDOWS */
23+
#define HAVE_UNISTD_H /* LINUX */
24+
25+
#define SIZEOF_INT 4
26+
#define SIZEOF_SHORT 2
27+
#define SIZEOF_LONG 4
28+
#define SIZEOF_LONG_LONG 8
29+
#define SIZEOF___INT64 0
30+
#define SIZEOF_VOIDP 4
31+
#define SIZEOF_FLOAT 4
32+
#define SIZEOF_DOUBLE 8
33+
34+
#ifndef FALSE
35+
# define FALSE 0
36+
#endif
37+
38+
#ifndef TRUE
39+
# define TRUE 1
40+
#endif
41+
42+
#endif /* MRUBYCONF_H */

0 commit comments

Comments
 (0)