From c22740f14afae3dec3d2412ae233db9045a08a06 Mon Sep 17 00:00:00 2001 From: greg-williams Date: Thu, 13 Nov 2008 16:22:10 +0000 Subject: [PATCH] * 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 --- examples/rakefile_helper_GCC.rb | 27 +++++++++++++++++------- rakefile_helper_GCC.rb | 37 +++++++++++++++++++++------------ 2 files changed, 43 insertions(+), 21 deletions(-) diff --git a/examples/rakefile_helper_GCC.rb b/examples/rakefile_helper_GCC.rb index 161f007..05e85b8 100644 --- a/examples/rakefile_helper_GCC.rb +++ b/examples/rakefile_helper_GCC.rb @@ -2,19 +2,30 @@ module RakefileConstants 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' UNITY_PATH = '../src' SOURCE_PATH = 'src' BUILD_PATH = 'build' - UNITY_SRC = UNITY_PATH + '\unity.c' - UNITY_HDR = UNITY_PATH + '\unity.h' + UNITY_SRC = UNITY_PATH + '/unity.c' + UNITY_HDR = UNITY_PATH + '/unity.h' - COMPILER = 'gcc.exe' - LINKER = 'gcc.exe' + COMPILER = 'gcc' + LINKER = 'gcc' end @@ -32,11 +43,11 @@ module RakefileHelpers end 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 def link prerequisites, executable - execute "#{LINKER} -DTEST #{prerequisites.join(' ')} -o#{executable}" + execute "#{LINKER} -DTEST #{prerequisites.join(' ')} -o #{executable}" end def run_test executable diff --git a/rakefile_helper_GCC.rb b/rakefile_helper_GCC.rb index 6df7bbf..99a9bf5 100644 --- a/rakefile_helper_GCC.rb +++ b/rakefile_helper_GCC.rb @@ -2,27 +2,38 @@ module RakefileConstants 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' UNITY_PATH = 'src' SOURCE_PATH = 'src' BUILD_PATH = 'build' - UNITY_SRC = UNITY_PATH + '\unity.c' - UNITY_HDR = UNITY_PATH + '\unity.h' + UNITY_SRC = UNITY_PATH + '/unity.c' + UNITY_HDR = UNITY_PATH + '/unity.h' BIN_PATH = 'build' - UNITY_TEST_SRC = UNIT_TEST_PATH + '\testunity.c' - UNITY_TEST_RUNNER_SRC = UNIT_TEST_PATH + '\testunity_Runner.c' - UNITY_OBJ = BIN_PATH + '\unity' + OBJ_EXTENSION - UNITY_TEST_OBJ = BIN_PATH + '\testunity' + OBJ_EXTENSION - UNITY_TEST_RUNNER_OBJ = BIN_PATH + '\testunity_Runner' + OBJ_EXTENSION + UNITY_TEST_SRC = UNIT_TEST_PATH + '/testunity.c' + UNITY_TEST_RUNNER_SRC = UNIT_TEST_PATH + '/testunity_Runner.c' + UNITY_OBJ = BIN_PATH + '/unity' + OBJ_EXTENSION + UNITY_TEST_OBJ = BIN_PATH + '/testunity' + OBJ_EXTENSION + UNITY_TEST_RUNNER_OBJ = BIN_PATH + '/testunity_Runner' + OBJ_EXTENSION UNITY_TEST_EXEC = UNITY_TEST_OBJ.ext BIN_EXTENSION TEST_RESULTS = UNITY_TEST_OBJ.ext '.testpass' - COMPILER = 'gcc.exe' - LINKER = 'gcc.exe' + COMPILER = 'gcc' + LINKER = 'gcc' end @@ -40,11 +51,11 @@ module RakefileHelpers end 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 def link prerequisites, executable - execute "#{LINKER} -DTEST #{prerequisites.join(' ')} -o#{executable}" + execute "#{LINKER} -DTEST #{prerequisites.join(' ')} -o #{executable}" end def run_test executable -- GitLab