Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable parallel build and test #57

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ YACC = bison
# -d: generate header with default name
YFLAGS = --verbose --debug -d

# number of jobs to run
NPROCS := 1
OS := $(shell uname -s)
# Find available processor numbers based on different OS.
ifeq ($(OS),Linux)
NPROCS := $(shell grep -c ^processor /proc/cpuinfo)
else ifeq ($(OS),Darwin)
NPROCS := $(shell sysctl -n hw.ncpu)
endif # $(OS)
# Specify the number of jobs to run simultaneously.
MAKEFLAGS += -j$(NPROCS)

# Note that lex.yy.cpp is excluded deliberately, as "lex.yy.cpp" is considered a
# header file (it's included by "y.tab.cpp").
OBJS := $(shell find . -name "*.cpp" ! -name "y.tab.cpp" ! -name "lex.yy.cpp" ) y.tab.o
Expand All @@ -20,7 +32,7 @@ DEPS = $(OBJS:.o=.d)
all: $(TARGET)

test: $(TARGET)
make -C test/
cd test/ && $(MAKE) MAKEFLAGS=

$(TARGET): $(OBJS)
$(CXX) $(CXXFLAGS) $(OBJS) -o $@
Expand All @@ -42,6 +54,6 @@ main.o: %.o: %.cpp y.tab.hpp

clean:
rm -rf *.s *.o lex.yy.* y.tab.* *.output *.ssa $(TARGET) $(OBJS) $(DEPS)
make -C test/ clean
cd test/ && $(MAKE) clean MAKEFLAGS=

-include $(DEPS)
2 changes: 1 addition & 1 deletion test/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.PHONY: test clean

test:
turnt **/*.c --diff
turnt **/*.c --diff -j

clean:
rm -f *.s **/*.s *.o **/*.o *.ssa **/*.ssa
2 changes: 1 addition & 1 deletion test/codegen/turnt.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
command = "../../vitaminc -o test.ssa < {filename} && qbe -o out.s test.ssa && cc out.s -o a.o && ./a.o; echo $?"
command = "../../vitaminc -o {filename}.ssa < {filename} && qbe -o {filename}.s {filename}.ssa && cc {filename}.s -o {filename}.o && ./{filename}.o; echo $?"
output.exp = "-"