OSDN Git Service

\90V\8bK\82É\8dì\90¬\82µ\82½TermLexer\82ð\97\98\97p\82µ\82Ä\93à\95\94\82ð\8fC\90³\82µ\82½\81B
[simplecms/utakata.git] / Rakefile
1 # -*- coding: utf-8 -*-
2 require "rake/clean"
3 require "rake/loaders/makefile"
4
5 CC = "g++"
6 cflags = "-g -O2 -fno-default-inline -Wall -g"
7
8 TOPDIR = "."
9
10 ldflags = "-DHAVE_CONFIG_H "
11 ldflags += "-L./test/gtest/gtest-all"
12
13 includes = " "
14 includes += "-I. -I."
15
16 # lists of compile dependency objects
17 SRCS = FileList["./src/**/*.cpp", "./lib/**/*.cpp"]
18 OBJS = SRCS.ext("o")
19 DEPS = SRCS.ext("po")
20 TEST_SRCS = FileList["./test/*.cpp"]
21 TEST_OBJECTS = TEST_SRCS.ext("o")
22 TEST_OBJECTS.include(OBJS)
23 TEST_DEPS = TEST_SRCS.ext("po")
24 TEST_PROGRAMS = TEST_SRCS.ext("")
25
26 EXEEXT = ""
27
28 # lists of clean objects
29 CLEAN.include(OBJS, TEST_OBJECTS)
30 CLOBBER.include(TEST_PROGRAMS)
31
32 task "default" => ["compile"]
33 task "test" => ["compile", "test_execute"]
34
35 desc "Compile all sources "
36 task "compile" => OBJS do |t|
37 end
38
39 rule "_test#{EXEEXT}" => TEST_OBJECTS do |t|
40   base = File.split(t.name);
41   base[1] = File.basename(base[1], EXEEXT) + ".o"
42   sh "#{CC} -o #{t.name} #{ldflags} #{cflags} #{includes} #{OBJS.join(' ')} ./test/gtest/gtest-all.o #{File.join(base)} "
43 end
44
45 rule '.o' => '.cpp' do |t|
46   depname = File.split(t.source)
47   depname[1] = File.basename(depname[1], ".cpp") + ".po"
48   sh "#{CC} -MD -MF #{File.join(depname[0], depname[1])} #{ldflags} #{cflags} #{includes} -c #{t.source} -o #{t.name}"
49 end
50
51 rule '.h' => '.cpp' do |t|
52 end
53
54 loader = Rake::MakefileLoader.new
55 DEPS.each do |f|
56   loader.load(f) if File.exists? f
57 end
58
59 TEST_DEPS.each do |f|
60   loader.load(f) if File.exists? f
61 end
62
63 desc "run all test program in `TEST_PROGRAMS`"
64 task :test_execute => TEST_PROGRAMS do |t|
65   t.prerequisites.each { |f|
66     sh "#{f} --gtest_color=yes"
67   }
68 end