From 41cfce878ae7d3579360fe3445d0a33f13ca09c7 Mon Sep 17 00:00:00 2001 From: Patrick Martin Date: Thu, 19 Jul 2012 22:59:03 +0100 Subject: [PATCH] adding initial revision of Tutorial sample code --- projects/CPPBuilder5/.gitignore | 5 + projects/CPPBuilder5/Tutorial1.bpf | 5 + projects/CPPBuilder5/Tutorial1.bpr | 116 ++++++++++++++++++ projects/CPPBuilder5/Tutorial1.cpp | 15 +++ projects/CPPBuilder5/Tutorial1.mak | 187 +++++++++++++++++++++++++++++ projects/CPPBuilder5/bcbenv.bat | 3 + projects/CPPBuilder5/makefile | 50 ++++++++ 7 files changed, 381 insertions(+) create mode 100644 projects/CPPBuilder5/.gitignore create mode 100644 projects/CPPBuilder5/Tutorial1.bpf create mode 100644 projects/CPPBuilder5/Tutorial1.bpr create mode 100644 projects/CPPBuilder5/Tutorial1.cpp create mode 100644 projects/CPPBuilder5/Tutorial1.mak create mode 100644 projects/CPPBuilder5/bcbenv.bat create mode 100644 projects/CPPBuilder5/makefile diff --git a/projects/CPPBuilder5/.gitignore b/projects/CPPBuilder5/.gitignore new file mode 100644 index 00000000..09e4f1fb --- /dev/null +++ b/projects/CPPBuilder5/.gitignore @@ -0,0 +1,5 @@ +/Tutorial1.exe +/Tutorial1.obj +/Tutorial1.tds +/Tutorial1.~bpf +/Tutorial1.~bpr diff --git a/projects/CPPBuilder5/Tutorial1.bpf b/projects/CPPBuilder5/Tutorial1.bpf new file mode 100644 index 00000000..7022c6ce --- /dev/null +++ b/projects/CPPBuilder5/Tutorial1.bpf @@ -0,0 +1,5 @@ +USEUNIT("Tutorial1.cpp"); +//--------------------------------------------------------------------------- +This file is used by the project manager only and should be treated like the project file + + main \ No newline at end of file diff --git a/projects/CPPBuilder5/Tutorial1.bpr b/projects/CPPBuilder5/Tutorial1.bpr new file mode 100644 index 00000000..425e1dd5 --- /dev/null +++ b/projects/CPPBuilder5/Tutorial1.bpr @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=0 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=2057 +CodePage=1252 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[Excluded Packages] +$(BCB)\Projects\Bpl\ThemeManagerC5D.bpl=Soft Gems Theme Manager + +[HistoryLists\hlIncludePath] +Count=3 +Item0=$(BCB)\include;$(BCB)\include\vcl;..\..\single_include +Item1=..\..\..\..\CatchSimpleTest;$(BCB)\include;$(BCB)\include\vcl +Item2=$(BCB)\include;$(BCB)\include\vcl + +[HistoryLists\hlLibraryPath] +Count=2 +Item0=$(BCB)\lib\obj;$(BCB)\lib +Item1=..\..\..\..\CatchSimpleTest;$(BCB)\lib\obj;$(BCB)\lib + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[HistoryLists\hlConditionals] +Count=2 +Item0=_DEBUG;CATCH_PLATFORM_WINDOWS +Item1=_DEBUG + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +HostApplication= +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 +LinkCGLIB=0 + +[Language] +ActiveLang= +ProjectLang= +RootDir= + + \ No newline at end of file diff --git a/projects/CPPBuilder5/Tutorial1.cpp b/projects/CPPBuilder5/Tutorial1.cpp new file mode 100644 index 00000000..d08f35d5 --- /dev/null +++ b/projects/CPPBuilder5/Tutorial1.cpp @@ -0,0 +1,15 @@ + #define CATCH_CONFIG_MAIN // This tell CATCH to provide a main() - only do this in one cpp file + #include "catch.hpp" + + unsigned int Factorial( unsigned int number ) { + return number <= 1 ? number : Factorial(number-1)*number; + } + + TEST_CASE( "example/factorial", "The Factorial function returns the factorial of the number passed in" ) { + REQUIRE( Factorial(0) == (unsigned) 1 ); + REQUIRE( Factorial(1) == (unsigned) 1 ); + REQUIRE( Factorial(2) == (unsigned) 2 ); + REQUIRE( Factorial(3) == (unsigned) 6 ); + REQUIRE( Factorial(10) == (unsigned) 3628800 ); + + } diff --git a/projects/CPPBuilder5/Tutorial1.mak b/projects/CPPBuilder5/Tutorial1.mak new file mode 100644 index 00000000..2250517e --- /dev/null +++ b/projects/CPPBuilder5/Tutorial1.mak @@ -0,0 +1,187 @@ +# --------------------------------------------------------------------------- +!if !$d(BCB) +BCB = $(MAKEDIR)\.. +!endif + +# --------------------------------------------------------------------------- +# IDE SECTION +# --------------------------------------------------------------------------- +# The following section of the project makefile is managed by the BCB IDE. +# It is recommended to use the IDE to change any of the values in this +# section. +# --------------------------------------------------------------------------- + +VERSION = BCB.05.03 +# --------------------------------------------------------------------------- +PROJECT = Tutorial1.exe +OBJFILES = Tutorial1.obj +RESFILES = +MAINSOURCE = Tutorial1.bpf +RESDEPEN = $(RESFILES) +LIBFILES = +IDLFILES = +IDLGENFILES = +LIBRARIES = +PACKAGES = Vcl50.bpi Vclx50.bpi bcbsmp50.bpi Qrpt50.bpi Vcldb50.bpi Vclbde50.bpi \ + ibsmp50.bpi vcldbx50.bpi TeeUI50.bpi TeeDB50.bpi Tee50.bpi TeeQR50.bpi \ + VCLIB50.bpi bcbie50.bpi vclie50.bpi Inetdb50.bpi Inet50.bpi NMFast50.bpi \ + dclocx50.bpi bcb2kaxserver50.bpi +SPARELIBS = +DEFFILE = +# --------------------------------------------------------------------------- +PATHCPP = .; +PATHASM = .; +PATHPAS = .; +PATHRC = .; +DEBUGLIBPATH = $(BCB)\lib\debug +RELEASELIBPATH = $(BCB)\lib\release +USERDEFINES = _DEBUG;CATCH_PLATFORM_WINDOWS +SYSDEFINES = NO_STRICT;_NO_VCL;_RTLDLL;USEPACKAGES +INCLUDEPATH = $(BCB)\include;$(BCB)\include\vcl;..\..\single_include +LIBPATH = $(BCB)\lib\obj;$(BCB)\lib +WARNINGS= -w-par +# --------------------------------------------------------------------------- +CFLAG1 = -Od -H=$(BCB)\lib\vcl50.csm -Hc -Vx -Ve -X- -r- -a8 -b- -k -y -v -vi- -tWC \ + -tWM- -c +IDLCFLAGS = +PFLAGS = -$YD -$W -$O- -v -JPHNE -M +RFLAGS = +AFLAGS = /mx /w2 /zd +LFLAGS = -D"" -ap -Tpe -x -Gn -v +# --------------------------------------------------------------------------- +ALLOBJ = c0x32.obj $(PACKAGES) $(OBJFILES) +ALLRES = $(RESFILES) +ALLLIB = $(LIBFILES) $(LIBRARIES) import32.lib cw32i.lib +# --------------------------------------------------------------------------- +!ifdef IDEOPTIONS + +[Version Info] +IncludeVerInfo=0 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +!endif + + + + + +# --------------------------------------------------------------------------- +# MAKE SECTION +# --------------------------------------------------------------------------- +# This section of the project file is not used by the BCB IDE. It is for +# the benefit of building from the command-line using the MAKE utility. +# --------------------------------------------------------------------------- + +.autodepend +# --------------------------------------------------------------------------- +!if "$(USERDEFINES)" != "" +AUSERDEFINES = -d$(USERDEFINES:;= -d) +!else +AUSERDEFINES = +!endif + +!if !$d(BCC32) +BCC32 = bcc32 +!endif + +!if !$d(CPP32) +CPP32 = cpp32 +!endif + +!if !$d(DCC32) +DCC32 = dcc32 +!endif + +!if !$d(TASM32) +TASM32 = tasm32 +!endif + +!if !$d(LINKER) +LINKER = ilink32 +!endif + +!if !$d(BRCC32) +BRCC32 = brcc32 +!endif + + +# --------------------------------------------------------------------------- +!if $d(PATHCPP) +.PATH.CPP = $(PATHCPP) +.PATH.C = $(PATHCPP) +!endif + +!if $d(PATHPAS) +.PATH.PAS = $(PATHPAS) +!endif + +!if $d(PATHASM) +.PATH.ASM = $(PATHASM) +!endif + +!if $d(PATHRC) +.PATH.RC = $(PATHRC) +!endif +# --------------------------------------------------------------------------- +$(PROJECT): $(IDLGENFILES) $(OBJFILES) $(RESDEPEN) $(DEFFILE) + $(BCB)\BIN\$(LINKER) @&&! + $(LFLAGS) -L$(LIBPATH) + + $(ALLOBJ), + + $(PROJECT),, + + $(ALLLIB), + + $(DEFFILE), + + $(ALLRES) +! +# --------------------------------------------------------------------------- +.pas.hpp: + $(BCB)\BIN\$(DCC32) $(PFLAGS) -U$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -O$(INCLUDEPATH) --BCB {$< } + +.pas.obj: + $(BCB)\BIN\$(DCC32) $(PFLAGS) -U$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -O$(INCLUDEPATH) --BCB {$< } + +.cpp.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n$(@D) {$< } + +.c.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n$(@D) {$< } + +.c.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n. {$< } + +.cpp.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n. {$< } + +.asm.obj: + $(BCB)\BIN\$(TASM32) $(AFLAGS) -i$(INCLUDEPATH:;= -i) $(AUSERDEFINES) -d$(SYSDEFINES:;= -d) $<, $@ + +.rc.res: + $(BCB)\BIN\$(BRCC32) $(RFLAGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -fo$@ $< +# --------------------------------------------------------------------------- + + + + diff --git a/projects/CPPBuilder5/bcbenv.bat b/projects/CPPBuilder5/bcbenv.bat new file mode 100644 index 00000000..eb81a05c --- /dev/null +++ b/projects/CPPBuilder5/bcbenv.bat @@ -0,0 +1,3 @@ +@echo off +IF "%ProgramFiles(x86)%"=="" SET PATH="C:\PROGRA~1\Borland\CBUILD~1\bin";"C:\Program Files\Git\cmd";"c:\Program Files\doxygen\bin";C:\Windows\System32 & exit /b +SET PATH=C:\CBuilder5\bin;"C:\Program Files (x86)\Git\cmd";"c:\Program Files\doxygen\bin";C:\Windows\System32 diff --git a/projects/CPPBuilder5/makefile b/projects/CPPBuilder5/makefile new file mode 100644 index 00000000..641c129b --- /dev/null +++ b/projects/CPPBuilder5/makefile @@ -0,0 +1,50 @@ +ROOT = $(MAKEDIR)\.. +BRCC = $(ROOT)\bin\brcc32.exe + +.silent +default: clean all + +clean: + echo ========== cleaning object files ====== + -@DEL /F /Q /S *.obj *.tds *.exe 1>nul + + +# this override of the default implicit rule is a hack for not getting a ".bpr.exe" rule working correctly +# to override the default .cpp.exe rule +# currently relying upon BCB convention of a main cpp file named for the project listing project files +.cpp.exe: + echo ========== build for $@ ====== + bpr2mak -q $&.bpr + make -a -f $&.mak + +Tutorial1.exe: + +TARGETS= Tutorial1.exe + +all: $(TARGETS) + +help: + @echo targets built by this makefile: $(TARGETS) + @echo. + @echo help - shows this output + @echo all - builds all targets + @echo clean - cleans all targets + @echo tests - performs some tests on targets + @echo default - clean all + + +pre-tests: + echo ========== running tests ====== + +post-tests: + echo ========== completed tests ====== + +tests: Tutorial1.exe pre-tests unit-tests post-tests + + +unit-tests: Tutorial1.exe + -Tutorial1.exe + + + + \ No newline at end of file