Skip to content

Commit 95924ee

Browse files
committed
Import from internal tree
1 parent 2f09c53 commit 95924ee

20 files changed

+4409
-0
lines changed

.clang-format

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
BasedOnStyle: Chromium
2+
Language: Cpp
3+
MaxEmptyLinesToKeep: 3
4+
IndentCaseLabels: false
5+
AllowShortIfStatementsOnASingleLine: false
6+
AllowShortCaseLabelsOnASingleLine: false
7+
AllowShortLoopsOnASingleLine: false
8+
DerivePointerAlignment: false
9+
PointerAlignment: Right
10+
SpaceAfterCStyleCast: true
11+
TabWidth: 4
12+
UseTab: Never
13+
IndentWidth: 4
14+
BreakBeforeBraces: Linux
15+
AccessModifierOffset: -4
16+
ForEachMacros:
17+
- foreach
18+
- list_for_each
19+
- list_for_each_safe
20+
- list_for_each_entry
21+
- list_for_each_entry_safe

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
out
2+
a.out
3+
*.o
4+
*.elf
5+
*.log
6+
*.lst

Makefile

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
CC ?= gcc
2+
CFLAGS := -O -g \
3+
-ansi -pedantic \
4+
-Wall -Wextra
5+
6+
include mk/common.mk
7+
include mk/arm.mk
8+
9+
STAGE0 := shecc
10+
STAGE1 := shecc-stage1.elf
11+
STAGE2 := shecc-stage2.elf
12+
13+
OUT ?= out
14+
SRCDIR := $(shell find src -type d)
15+
LIBDIR := $(shell find lib -type d)
16+
17+
SRCS := $(wildcard $(patsubst %,%/main.c, $(SRCDIR)))
18+
OBJS := $(SRCS:%.c=$(OUT)/%.o)
19+
deps := $(OBJS:%.o=%.o.d)
20+
TESTS := $(wildcard tests/*.c)
21+
TESTBINS := $(TESTS:%.c=$(OUT)/%.elf)
22+
23+
all: bootstrap
24+
25+
$(OUT)/tests/%.elf: tests/%.c $(OUT)/$(STAGE0)
26+
$(VECHO) " SHECC\t$@\n"
27+
$(Q)$(OUT)/$(STAGE0) --dump-ir -o $@ $< > $(basename $@).log ; \
28+
chmod +x $@ ; $(PRINTF) "Running $@ ...\n"
29+
$(Q)$(ARM_EXEC) $@ && $(call pass)
30+
# $(CROSS_COMPILE)objdump -d $@ > $(basename $@).lst
31+
32+
check: $(TESTBINS) tests/driver.sh
33+
tests/driver.sh
34+
35+
$(OUT)/%.o: %.c
36+
$(VECHO) " CC\t$@\n"
37+
$(Q)$(CC) -o $@ $(CFLAGS) -c -MMD -MF $@.d $<
38+
39+
SHELL_HACK := $(shell mkdir -p $(OUT) $(OUT)/$(SRCDIR) $(OUT)/tests)
40+
$(OUT)/libc.inc: $(OUT)/inliner $(LIBDIR)/c.c
41+
$(VECHO) " GEN\t$@\n"
42+
$(Q)$(OUT)/inliner $(LIBDIR)/c.c $@
43+
44+
$(OUT)/inliner: tools/inliner.c
45+
$(VECHO) " CC+LD\t$@\n"
46+
$(Q)$(CC) $(CFLAGS) -o $@ $^
47+
48+
$(OUT)/$(STAGE0): $(OUT)/libc.inc $(OBJS)
49+
$(VECHO) " LD\t$@\n"
50+
$(Q)$(CC) $(CFLAGS) $(OBJS) -o $@
51+
52+
$(OUT)/$(STAGE1): $(OUT)/$(STAGE0)
53+
$(VECHO) " SHECC\t$@\n"
54+
$(Q)$(OUT)/$(STAGE0) --dump-ir -o $@ $(SRCDIR)/main.c > $(OUT)/shecc-stage1.log
55+
$(Q)chmod a+x $@
56+
57+
$(OUT)/$(STAGE2): $(OUT)/$(STAGE1)
58+
$(VECHO) " SHECC\t$@\n"
59+
$(Q)$(ARM_EXEC) $(OUT)/$(STAGE1) -o $@ $(SRCDIR)/main.c
60+
61+
bootstrap: $(OUT)/$(STAGE2)
62+
$(Q)if ! diff -q $(OUT)/$(STAGE1) $(OUT)/$(STAGE2); then \
63+
echo "Unable to bootstrap. Aborting"; false; \
64+
fi
65+
66+
.PHONY: clean
67+
clean:
68+
-$(RM) $(OUT)/$(STAGE0) $(OUT)/$(STAGE1) $(OUT)/$(STAGE2)
69+
-$(RM) $(OBJS) $(deps)
70+
-$(RM) $(TESTBINS) $(OUT)/tests/*.log $(OUT)/tests/*.lst
71+
-$(RM) $(OUT)/shecc*.log
72+
-$(RM) $(OUT)/inliner $(OUT)/libc.inc
73+
74+
-include $(deps)

0 commit comments

Comments
 (0)