提交 c22740f1 编写于 作者: G greg-williams

* Updated rakefile to work on Unix-based systems

git-svn-id: http://unity.svn.sourceforge.net/svnroot/unity/trunk@8 e7d17a6e-8845-0410-bbbc-c8efb4fdad7e
上级 6e2de5e5
...@@ -2,19 +2,30 @@ ...@@ -2,19 +2,30 @@
module RakefileConstants module RakefileConstants
C_EXTENSION = '.c' C_EXTENSION = '.c'
OBJ_EXTENSION = '.obj'
BIN_EXTENSION = '.exe' def Kernel.is_windows?
processor, platform, *rest = RUBY_PLATFORM.split("-")
platform == 'mswin32'
end
if Kernel.is_windows?
OBJ_EXTENSION = '.obj'
BIN_EXTENSION = '.exe'
else
OBJ_EXTENSION = '.o'
BIN_EXTENSION = '.out'
end
UNIT_TEST_PATH = 'test' UNIT_TEST_PATH = 'test'
UNITY_PATH = '../src' UNITY_PATH = '../src'
SOURCE_PATH = 'src' SOURCE_PATH = 'src'
BUILD_PATH = 'build' BUILD_PATH = 'build'
UNITY_SRC = UNITY_PATH + '\unity.c' UNITY_SRC = UNITY_PATH + '/unity.c'
UNITY_HDR = UNITY_PATH + '\unity.h' UNITY_HDR = UNITY_PATH + '/unity.h'
COMPILER = 'gcc.exe' COMPILER = 'gcc'
LINKER = 'gcc.exe' LINKER = 'gcc'
end end
...@@ -32,11 +43,11 @@ module RakefileHelpers ...@@ -32,11 +43,11 @@ module RakefileHelpers
end end
def compile src, obj def compile src, obj
execute "#{COMPILER} -c -I#{SOURCE_PATH} -I#{UNITY_PATH} -DTEST #{src} -o#{obj}" execute "#{COMPILER} -c -I#{SOURCE_PATH} -I#{UNITY_PATH} -DTEST #{src} -o #{obj}"
end end
def link prerequisites, executable def link prerequisites, executable
execute "#{LINKER} -DTEST #{prerequisites.join(' ')} -o#{executable}" execute "#{LINKER} -DTEST #{prerequisites.join(' ')} -o #{executable}"
end end
def run_test executable def run_test executable
......
...@@ -2,27 +2,38 @@ ...@@ -2,27 +2,38 @@
module RakefileConstants module RakefileConstants
C_EXTENSION = '.c' C_EXTENSION = '.c'
OBJ_EXTENSION = '.obj'
BIN_EXTENSION = '.exe' def Kernel.is_windows?
processor, platform, *rest = RUBY_PLATFORM.split("-")
platform == 'mswin32'
end
if Kernel.is_windows?
OBJ_EXTENSION = '.obj'
BIN_EXTENSION = '.exe'
else
OBJ_EXTENSION = '.o'
BIN_EXTENSION = '.out'
end
UNIT_TEST_PATH = 'test' UNIT_TEST_PATH = 'test'
UNITY_PATH = 'src' UNITY_PATH = 'src'
SOURCE_PATH = 'src' SOURCE_PATH = 'src'
BUILD_PATH = 'build' BUILD_PATH = 'build'
UNITY_SRC = UNITY_PATH + '\unity.c' UNITY_SRC = UNITY_PATH + '/unity.c'
UNITY_HDR = UNITY_PATH + '\unity.h' UNITY_HDR = UNITY_PATH + '/unity.h'
BIN_PATH = 'build' BIN_PATH = 'build'
UNITY_TEST_SRC = UNIT_TEST_PATH + '\testunity.c' UNITY_TEST_SRC = UNIT_TEST_PATH + '/testunity.c'
UNITY_TEST_RUNNER_SRC = UNIT_TEST_PATH + '\testunity_Runner.c' UNITY_TEST_RUNNER_SRC = UNIT_TEST_PATH + '/testunity_Runner.c'
UNITY_OBJ = BIN_PATH + '\unity' + OBJ_EXTENSION UNITY_OBJ = BIN_PATH + '/unity' + OBJ_EXTENSION
UNITY_TEST_OBJ = BIN_PATH + '\testunity' + OBJ_EXTENSION UNITY_TEST_OBJ = BIN_PATH + '/testunity' + OBJ_EXTENSION
UNITY_TEST_RUNNER_OBJ = BIN_PATH + '\testunity_Runner' + OBJ_EXTENSION UNITY_TEST_RUNNER_OBJ = BIN_PATH + '/testunity_Runner' + OBJ_EXTENSION
UNITY_TEST_EXEC = UNITY_TEST_OBJ.ext BIN_EXTENSION UNITY_TEST_EXEC = UNITY_TEST_OBJ.ext BIN_EXTENSION
TEST_RESULTS = UNITY_TEST_OBJ.ext '.testpass' TEST_RESULTS = UNITY_TEST_OBJ.ext '.testpass'
COMPILER = 'gcc.exe' COMPILER = 'gcc'
LINKER = 'gcc.exe' LINKER = 'gcc'
end end
...@@ -40,11 +51,11 @@ module RakefileHelpers ...@@ -40,11 +51,11 @@ module RakefileHelpers
end end
def compile src, obj def compile src, obj
execute "#{COMPILER} -c -I#{SOURCE_PATH} -I#{UNITY_PATH} -DTEST #{src} -o#{obj}" execute "#{COMPILER} -c -I#{SOURCE_PATH} -I#{UNITY_PATH} -DTEST #{src} -o #{obj}"
end end
def link prerequisites, executable def link prerequisites, executable
execute "#{LINKER} -DTEST #{prerequisites.join(' ')} -o#{executable}" execute "#{LINKER} -DTEST #{prerequisites.join(' ')} -o #{executable}"
end end
def run_test executable def run_test executable
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册