From 9342c27ad7f9c5cc0a31635aed25365418555591 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Tue, 6 Aug 2002 22:10:59 +0000 Subject: [PATCH] Moved common code out of the *Test* rules and put it into separate rules (R5Objects, TestObjects). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@617 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- Jamrules | 155 +++++++++++++++++++++++++++---------------------------- 1 file changed, 75 insertions(+), 80 deletions(-) diff --git a/Jamrules b/Jamrules index d8bc030e15..75b90580e0 100644 --- a/Jamrules +++ b/Jamrules @@ -194,6 +194,7 @@ rule StdBinCommands { # StdBinCommands : ; local libs = $(2) ; + local source ; for source in $(1) { local target = $(source:S=) ; @@ -264,30 +265,17 @@ rule TestLib local dest = $(3) ; local libraries = $(4) ; local headerDirs = $(5) ; + local objects = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; - # Turn optimization off. - local optim = $(OPTIM) ; - OPTIM = ; + # Our Main replacement. + MainFromObjects $(target) : $(objects) ; + TestObjects $(sources) : $(headerDirs) ; -# SetupIncludes ; - SetupObjectsDir ; - MakeLocateObjects $(sources) ; - Main $(target) : $(sources) ; MakeLocate $(target) : $(dest) ; Depends $(target) : libcppunit.so ; Depends obostests : $(target) ; LinkSharedOSLibs $(target) : libcppunit.so $(libraries) ; - UseCppUnitObjectHeaders $(sources) ; - UsePublicObjectHeaders $(sources) : $(headerDirs) ; - ObjectDefines $(sources) : TEST_OBOS ; LINKFLAGS on $(target) = $(LINKFLAGS) -nostart -Xlinker -soname=\"$(target)\" ; - - # Turn debugging on. That is usually desired for test code. - ObjectCcFlags $(sources) : "-g" ; - ObjectC++Flags $(sources) : "-g" ; - - # Turn optimization on again. - OPTIM = $(optim) ; } rule R5TestLib @@ -306,37 +294,15 @@ rule R5TestLib local libraries = $(4) ; local objects = [ R5ObjectNames $(sources) ] ; - # Turn optimization off. - local optim = $(OPTIM) ; - OPTIM = ; - - SetupObjectsDir ; - MakeLocateObjects $(objects) ; - # Our Main replacement. MainFromObjects $(target) : $(objects) ; - local source ; - for source in [ FGristFiles $(sources) ] - { - local object = [ R5ObjectNames $(source) ] ; - Object $(object) : $(source) ; - LocalDepends obj : $(object) ; - } + TestObjects $(sources) : : true ; MakeLocate $(target) : $(dest) ; Depends $(target) : libcppunit.so ; Depends r5tests : $(target) ; LinkSharedOSLibs $(target) : libcppunit.so $(libraries) ; - UseCppUnitObjectHeaders $(objects) ; - ObjectDefines $(objects) : TEST_R5 ; LINKFLAGS on $(target) = $(LINKFLAGS) -nostart -Xlinker -soname=\"$(target)\" ; - - # Turn debugging on. That is usually desired for test code. - ObjectCcFlags $(objects) : "-g" ; - ObjectC++Flags $(objects) : "-g" ; - - # Turn optimization on again. - OPTIM = $(optim) ; } rule CommonUnitTest @@ -374,29 +340,16 @@ rule UnitTest local dest = $(3) ; local libraries = $(4) ; local headerDirs = $(5) ; + local objects = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; - # Turn optimization off. - local optim = $(OPTIM) ; - OPTIM = ; + # Our Main replacement. + MainFromObjects $(target) : $(objects) ; + TestObjects $(sources) : $(headerDirs) ; -# SetupIncludes ; - SetupObjectsDir ; - MakeLocateObjects $(sources) ; - Main $(target) : $(sources) ; MakeLocate $(target) : [ FDirName $(OBOS_TEST_DIR) $(dest) ] ; Depends $(target) : libcppunit.so ; Depends obostests : $(target) ; LinkSharedOSLibs $(target) : libcppunit.so $(libraries) ; - UseCppUnitObjectHeaders $(sources) ; - UsePublicObjectHeaders $(sources) : $(headerDirs) ; - ObjectDefines $(sources) : TEST_OBOS ; - - # Turn debugging on. That is usually desired for test code. - ObjectCcFlags $(sources) : "-g" ; - ObjectC++Flags $(sources) : "-g" ; - - # Turn optimization on again. - OPTIM = $(optim) ; } rule R5UnitTest @@ -415,36 +368,14 @@ rule R5UnitTest local libraries = $(4) ; local objects = [ R5ObjectNames $(sources) ] ; - # Turn optimization off. - local optim = $(OPTIM) ; - OPTIM = ; - - SetupObjectsDir ; - MakeLocateObjects $(objects) ; - # Our Main replacement. MainFromObjects $(target) : $(objects) ; - local source ; - for source in [ FGristFiles $(sources) ] - { - local object = [ R5ObjectNames $(source) ] ; - Object $(object) : $(source) ; - LocalDepends obj : $(object) ; - } + TestObjects $(sources) : : true ; MakeLocate $(target) : [ FDirName $(OBOS_TEST_DIR) $(dest) ] ; Depends $(target) : libcppunit.so ; Depends r5tests : $(target) ; LinkSharedOSLibs $(target) : libcppunit.so $(libraries) ; - UseCppUnitObjectHeaders $(objects) ; - ObjectDefines $(objects) : TEST_R5 ; - - # Turn debugging on. That is usually desired for test code. - ObjectCcFlags $(objects) : "-g" ; - ObjectC++Flags $(objects) : "-g" ; - - # Turn optimization on again. - OPTIM = $(optim) ; } rule R5ObjectNames @@ -456,6 +387,70 @@ rule R5ObjectNames return [ FGristFiles $(objects:S=$(SUFOBJ)) ] ; } +rule R5Objects +{ + # R5Objects + # Similar to Objects, but appends "_r5" to the object file names. + # The source files. + + local sources = $(1) ; + local source ; + for source in [ FGristFiles $(sources) ] + { + local object = [ R5ObjectNames $(source) ] ; + Object $(object) : $(source) ; + LocalDepends obj : $(object) ; + } +} + +rule TestObjects +{ + # TestLib : : + # Compiles objects for tests. + # The list of sources. + # A list of public header dirs (as passed to + # UsePublicHeaders). + # If set, "_r5" is appended to the object file names and + # is ignored. Furthermore the pre-processor macro + # TEST_R5 is defined, TEST_OBOS otherwise. + + local sources = $(1) ; + local headerDirs = $(2) ; + local r5 = $(3) ; + local objects ; + + # Turn optimization off. + local optim = $(OPTIM) ; + OPTIM = ; + + SetupObjectsDir ; + + # compile + if $(r5) { + objects = [ R5ObjectNames $(sources) ] ; + R5Objects $(sources) ; + } else { + objects = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; + Objects $(sources) ; + } + + # set headers/defines + UseCppUnitObjectHeaders $(objects) ; + if $(r5) { + ObjectDefines $(objects) : TEST_R5 ; + } else { + UsePublicObjectHeaders $(objects) : $(headerDirs) ; + ObjectDefines $(objects) : TEST_OBOS ; + } + + # Turn debugging on. That is usually desired for test code. + ObjectCcFlags $(objects) : "-g" ; + ObjectC++Flags $(objects) : "-g" ; + + # Turn optimization on again. + OPTIM = $(optim) ; +} + rule R5SharedLibraryNames { # R5SharedLibraryNames ;