Permalink
Browse files

rewrote Makefile

  • Loading branch information...
1 parent 38a9d86 commit 6bae45b689f7e7182d7895d37f578a357f68c36d @peryaudo committed with peryaudo Sep 13, 2013
View
@@ -1,14 +1,10 @@
all:
- cd src; make
- cd test; make
- cd runtime; make
+ cd build/unix; make all
-clean:
- cd src; make clean
- cd test; make clean
- cd runtime; make clean
+test:
+ cd build/unix; make test
-test: all
- cd test; make test
+clean:
+ cd build/unix; make clean
.PHONY: all test clean
View
@@ -1,25 +0,0 @@
-CXX = g++
-
-ifeq ($(OS),Windows_NT)
- EXEEXT = .exe
- LIBS = `llvm-config --libs` -static-libgcc -static-libstdc++ -static
-else
- EXEEXT =
- LIBS = `llvm-config --libs`
-endif
-
-CXXFLAGS = -Wall -O3
-CPPFLAGS =
-LDFLAGS = `llvm-config --ldflags`
-
-all : $(TARGET)$(EXEEXT)
-
-%.o: %.cc
- $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $<
-
-$(TARGET)$(EXEEXT): $(OBJS)
- $(CXX) -o $(TARGET)$(EXEEXT) $(OBJS) $(LIBS) $(LDFLAGS) $(CXXFLAGS) $(CPPFLAGS)
-
-clean:
- $(RM) $(TARGET) $(OBJS)
-
View
@@ -0,0 +1,98 @@
+CTEST_XX = clang++
+
+ifeq ($(OS),Windows_NT)
+ EXEEXT = .exe
+ LIBS = `llvm-config --libs` -static-libgcc -static-libstdc++ -static
+else
+ EXEEXT =
+ LIBS = `llvm-config --libs`
+endif
+
+CXXFLAGS = -Wall -O3
+CPPFLAGS =
+LDFLAGS = `llvm-config --ldflags`
+
+OBJDIR = obj
+TEST_OBJDIR = test/obj
+DEPDIR = dep
+BINDIR = bin
+TEST_BINDIR = test/bin
+
+TARGETS = $(PERYAN_TARGET) $(BINDIR)/peryandefs $(BINDIR)/unixcl.o $(PERYAN_UNIT_TEST_TARGET) $(PERYAN_INTEGRATION_TEST_TARGET)
+
+PERYAN_TARGET = $(BINDIR)/peryan$(EXEEXT)
+PERYAN_SRCDIR = ../../src
+PERYAN_SRCS = Main.cc WarningPrinter.cc Token.cc FileSourceReader.cc Lexer.cc Parser.cc \
+ SymbolRegister.cc SymbolResolver.cc TypeResolver.cc LLVMCodeGen.cc
+PERYAN_OBJS = $(addprefix $(OBJDIR)/, $(patsubst %.cc, %.o, $(PERYAN_SRCS)))
+
+PERYAN_UNIT_TEST_TARGET = $(TEST_BINDIR)/peryan_unit_test$(EXEEXT)
+PERYAN_UNIT_TEST_SRCDIR = ../../test/unit
+PERYAN_UNIT_TEST_SRCS = ASTPrinterTest.cc LexerTest.cc ParserTest.cc SemanticsTest.cc
+PERYAN_UNIT_TEST_OBJS = $(addprefix $(TEST_OBJDIR)/, $(patsubst %.cc, %.o, $(PERYAN_UNIT_TEST_SRCS)) gtest-all.o gtest_main.o) \
+ $(addprefix $(OBJDIR)/, $(patsubst %.cc, %.o, $(filter-out LLVMCodeGen.cc Main.cc, $(PERYAN_SRCS))))
+
+PERYAN_INTEGRATION_TEST_TARGET = $(TEST_BINDIR)/peryan_integration_test$(EXEEXT)
+PERYAN_INTEGRATION_TEST_SRCDIR = ../../test/integration
+
+PERYAN_RUNTIME_SRCDIR = ../../runtime
+
+all: $(TARGETS)
+
+test: $(PERYAN_UNIT_TEST_TARGET) $(PERYAN_INTEGRATION_TEST_TARGET)
+ $(PERYAN_UNIT_TEST_TARGET)
+ cd $(TEST_BINDIR); rm -rf actual; rm -rf compiled; mkdir actual; mkdir compiled; ./peryan_integration_test$(EXEEXT);
+
+DEPS = $(addprefix $(DEPDIR)/, $(patsubst %.cc, %.d, $(PERYAN_SRCS))) \
+ $(addprefix $(DEPDIR)/, $(patsubst %.cc, %.d, $(PERYAN_UNIT_TEST_SRCS)))
+
+clean:
+ $(RM) -rf bin dep obj test
+
+-include $(DEPS)
+
+$(PERYAN_TARGET): $(PERYAN_OBJS)
+ mkdir -p $(BINDIR)
+ $(CXX) -o $@ $(PERYAN_OBJS) $(LIBS) $(LDFLAGS) $(CXXFLAGS) $(CPPFLAGS)
+
+$(PERYAN_UNIT_TEST_TARGET): $(PERYAN_UNIT_TEST_OBJS)
+ mkdir -p $(TEST_BINDIR)
+ $(CXX) -o $@ $(PERYAN_UNIT_TEST_OBJS) $(LIBS) $(LDFLAGS) $(CXXFLAGS) $(CPPFLAGS)
+
+$(BINDIR)/unixcl.o: $(addprefix $(PERYAN_RUNTIME_SRCDIR)/, unixcl.c common.h)
+ mkdir -p $(BINDIR)
+ gcc -O3 -Wall -c $< -o $@
+
+$(TEST_OBJDIR)/%.o: $(PERYAN_UNIT_TEST_SRCDIR)/%.cc
+ mkdir -p $(TEST_OBJDIR)
+ mkdir -p $(DEPDIR)
+ $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $< -MMD -MF $(DEPDIR)/$(*F).d
+
+$(OBJDIR)/%.o: $(PERYAN_SRCDIR)/%.cc
+ mkdir -p $(OBJDIR)
+ mkdir -p $(DEPDIR)
+ $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $< -MMD -MF $(DEPDIR)/$(*F).d
+
+$(OBJDIR)/LLVMCodeGen.o:
+ mkdir -p $(OBJDIR)
+ mkdir -p $(DEPDIR)
+ $(CXX) $(CXXFLAGS) `llvm-config --cxxflags` $(CPPFLAGS) -c -o $@ $(PERYAN_SRCDIR)/LLVMCodeGen.cc
+
+$(TEST_OBJDIR)/gtest-all.o : $(addprefix $(PERYAN_UNIT_TEST_SRCDIR)/, gtest/gtest-all.cc gtest/gtest.h)
+ mkdir -p $(TEST_OBJDIR)
+ $(CXX) $(CXXFLAGS) -I$(PERYAN_UNIT_TEST_SRCDIR) -c $< -o $@
+
+$(TEST_OBJDIR)/gtest_main.o : $(addprefix $(PERYAN_UNIT_TEST_SRCDIR)/, gtest/gtest_main.cc gtest/gtest.h)
+ mkdir -p $(TEST_OBJDIR)
+ $(CXX) $(CXXFLAGS) -I$(PERYAN_UNIT_TEST_SRCDIR) -c $< -o $@
+
+$(BINDIR)/peryandefs: $(PERYAN_RUNTIME_SRCDIR)/peryandefs
+ mkdir -p $(BINDIR)
+ cp $< $@
+
+$(PERYAN_INTEGRATION_TEST_TARGET): $(PERYAN_INTEGRATION_TEST_SRCDIR)/tester.pr \
+ $(PERYAN_TARGET) $(BINDIR)/unixcl.o $(BINDIR)/peryandefs
+ mkdir -p $(TEST_BINDIR)
+ $(PERYAN_TARGET) --runtime-path $(BINDIR) $< $@
+
+.PHONY: all test clean
View
@@ -1,18 +0,0 @@
-TARGETS = unixcl.o
-
-ifeq ($(OS),Windows_NT)
- TARGETS += win32.o
-else
- TARGETS +=
-endif
-
-all: $(TARGETS)
-
-unixcl.o: unixcl.c common.h
- gcc -O3 -Wall -c unixcl.c -o unixcl.o
-
-win32.o: win32.c common.h
- gcc -O3 -Wall -c win32.c -o win32.o
-
-clean:
- rm -rf unixcl.o win32.o
View
@@ -1,25 +0,0 @@
-TARGET = peryan
-OBJS = Token.o Lexer.o Parser.o Main.o FileSourceReader.o SymbolRegister.o SymbolResolver.o TypeResolver.o LLVMCodeGen.o WarningPrinter.o
-
-include ../Makefile.in
-
-Token.o: Token.cc Token.h Tokens.def
-
-Lexer.o: Lexer.cc Token.h Tokens.def SourceReader.h WarningPrinter.h Lexer.h
-
-Parser.o: Parser.cc Token.h Tokens.def Lexer.h AST.h SymbolTable.h Options.h WarningPrinter.h Parser.h SymbolRegister.h SymbolResolver.h TypeResolver.h
-
-Main.o: Main.cc Options.h WarningPrinter.h AST.h ASTPrinter.h SourceReader.h FileSourceReader.h Token.h Tokens.def Lexer.h SymbolTable.h Parser.h CodeGen.h LLVMCodeGen.h
-
-FileSourceReader.o: FileSourceReader.cc FileSourceReader.h Options.h SourceReader.h
-
-WarningPrinter.o: WarningPrinter.cc WarningPrinter.h Lexer.h Tokens.def Token.h
-
-SymbolRegister.o: SymbolRegister.cc SymbolRegister.h SymbolTable.h AST.h Token.h Tokens.def
-
-SymbolResolver.o: SymbolResolver.cc SymbolResolver.h SymbolTable.h AST.h Token.h Tokens.def
-
-TypeResolver.o: TypeResolver.cc TypeResolver.h SymbolTable.h AST.h Token.h Tokens.def
-
-LLVMCodeGen.o: LLVMCodeGen.cc SymbolTable.h AST.h LLVMCodeGen.h Parser.h CodeGen.h Token.h Tokens.def Lexer.h
- $(CXX) $(CXXFLAGS) `llvm-config --cxxflags` $(CPPFLAGS) -c -o $@ $<
View
@@ -1,14 +0,0 @@
-all:
- cd ../src/; make
- cd unit; make
- cd integration; make
-
-test:
- cd unit; make test
- cd integration; make test
-
-clean:
- cd unit; make clean
- cd integration; make clean
-
-.PHONY: all test clean
@@ -1,15 +0,0 @@
-all:
-
-clean:
- rm -rf compiled/*
- rm -rf actual/*
- rm -rf ./tester
-
-test:
- ../../src/peryan --runtime-path ../../runtime tester.pr ./tester
- ./tester
-
-# for emergency debugging
-# ruby run_tester.rb
-
-.PHONY: all test clean
Binary file not shown.
@@ -1,53 +0,0 @@
-#!/usr/bin/env ruby
-
-puts "Peran Integration Tester"
-puts "\e[32m[==========]\e[0m Running testcases under test/integration/cases/"
-
-total = 0
-Dir.glob('./cases/*') do |fileName|
- succeeded = true
- basename = File.basename(fileName, '.pr')
- puts "\e[32m[----------]\e[0m"
- puts "\e[32m[ RUN ]\e[0m #{basename}"
- pr = "#{fileName}"
- native = "./compiled/#{basename}"
- actual = "./actual/#{basename}.txt"
- expected = "./expected/#{basename}.txt"
-
- commands = ["PERYAN_RUNTIME_PATH=../../runtime ../../src/peryan #{pr} #{native}",
- "#{native} > #{actual}"]
- commands.each do |command|
- if not system(command)
- puts "\e[31m[ ]\e[0m Error while executing: #{command}"
- succeeded = false
- break
- end
- end
-
- if succeeded
- actual_text = File.open(actual).read
- expected_text = File.open(expected).read
-
- if actual_text != expected_text
- puts "Error: assertion failed:"
- puts "Actual: #{actual_text}"
- puts "Expected: #{expected_text}"
- succeeded = false
- end
- end
-
- if succeeded
- puts "\e[32m[ OK ]\e[0m #{File.basename(fileName, '.pr')}"
- puts "\e[32m[----------]\e[0m"
- else
- puts "\e[31m[ FAILED ]\e[0m #{File.basename(fileName, '.pr')}"
- puts "\e[31m[----------]\e[0m"
- total += 1
- end
-end
-
-if total == 0 then
- puts "\e[32m[==========]\e[0m All integration tests succeeded."
-else
- puts "\e[31m[==========]\e[0m #{total} integration test(s) failed"
-end
@@ -3,7 +3,7 @@ mes "\e[32m[==========]\e[0m Running testcases under test/integration/cases/"
var dirs :: String
-dirlist dirs, "cases/*.pr", 0
+dirlist dirs, "../../../../test/integration/cases/*.pr", 0
notesel dirs
var total = noteinfo(0)
@@ -13,7 +13,7 @@ repeat total
var fileName :: String
noteget fileName, cnt
- var baseName = strmid(fileName, strlen("cases/"), strlen(fileName) - 3 - strlen("cases/"))
+ var baseName = strmid(fileName, strlen("../../../../test/integration/cases/"), strlen(fileName) - 3 - strlen("../../../../test/integration/cases/"))
mes "\e[32m[----------]\e[0m"
@@ -25,7 +25,7 @@ repeat total
var cur = ""
- cur = "..\\..\\src\\peryan --runtime-path ../../runtime " + fileName + " compiled/" + baseName
+ cur = "..\\..\\bin\\peryan --runtime-path ../../bin " + fileName + " compiled/" + baseName
ret = exec(cur)
if ret != 0 {
mes "\e[31m[ ]\e[0m Error while executing: " + cur
@@ -48,7 +48,7 @@ repeat total
var expected :: String
notesel expected
- noteload "expected/" + baseName + ".txt"
+ noteload "../../../../test/integration/expected/" + baseName + ".txt"
if expected != actual {
mes "Error: assertion failed:"

0 comments on commit 6bae45b

Please sign in to comment.