diff --git a/examples/rakefile_helper_GCC.rb b/examples/rakefile_helper_GCC.rb index 161f007e887d233f775f625a647e43bd4e4f7e5a..05e85b804ad230edaf58932691da690b5016908c 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 6df7bbffb59af560d42c3fbb0915c20fc5c4827d..99a9bf5ccc3d406cbb1def2d4ce8350f95559813 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