From d0a0f64c135827304d0e8d6ab26b302a5bd7727c Mon Sep 17 00:00:00 2001 From: Bertrand Bellenot <bertrand.bellenot@cern.ch> Date: Fri, 30 May 2014 12:02:43 +0200 Subject: [PATCH] Add run_games.C macro, needed to prepare the environment before running the games.C macro --- tutorials/gui/games.C | 52 +++++++++++---------------------------- tutorials/gui/run_games.C | 44 +++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 37 deletions(-) create mode 100644 tutorials/gui/run_games.C diff --git a/tutorials/gui/games.C b/tutorials/gui/games.C index 896cfe47589..80b21e91f9f 100644 --- a/tutorials/gui/games.C +++ b/tutorials/gui/games.C @@ -1,3 +1,16 @@ +#ifndef __RUN_GAMES__ + +void games() +{ + Error("games", "Must be called from run_games.C..."); +} + +#else + +class Hello; +class Aclock; +class Tetris; + void games() { // This macro runs three "games" that each nicely illustrate the graphics capabilities of ROOT. @@ -6,43 +19,6 @@ void games() // It uses the small classes generated in $ROOTSYS/test/Hello, // Aclock, Tetris //Author: Valeriy Onuchin - - Bool_t UNIX = strcmp(gSystem->GetName(), "Unix") == 0; - Int_t st1 = gSystem->Load("$(ROOTSYS)/test/Aclock"); - if (st1 == -1) { - printf("===>The macro games will try to build the Aclock library\n"); - if (UNIX) - gSystem->Exec("(cd $ROOTSYS/test; make Aclock)"); - else - gSystem->Exec("(cd %ROOTSYS%\\test && nmake -f Makefile.win32 Aclock.dll)"); - - st1 = gSystem->Load("$(ROOTSYS)/test/Aclock"); - } - Int_t st2 = gSystem->Load("$(ROOTSYS)/test/Hello"); - if (st2 == -1) { - printf("===>The macro games will try to build the Hello library\n"); - if (UNIX) - gSystem->Exec("(cd $ROOTSYS/test; make Hello)"); - else - gSystem->Exec("(cd %ROOTSYS%\\test && nmake -f Makefile.win32 Hello.dll)"); - - st2 = gSystem->Load("$(ROOTSYS)/test/Hello"); - } - Int_t st3 = gSystem->Load("$(ROOTSYS)/test/Tetris"); - if (st3 == -1) { - if (UNIX) { - printf("===>The macro games will try to build the Tetris library\n"); - gSystem->Exec("(cd $ROOTSYS/test; make Tetris)"); - } else { - gSystem->Exec("(cd %ROOTSYS%\\test && nmake -f Makefile.win32 Tetris.dll)"); - } - st3 = gSystem->Load("$(ROOTSYS)/test/Tetris"); - } - - if (st1 || st2 || st3) { - printf("ERROR: one of the shared libs in $ROOTSYS/test didn't load properly\n"); - return; - } // run the dancing Hello World Hello *hello = new Hello(); @@ -53,3 +29,5 @@ void games() // run the Tetris game Tetris *tetris = new Tetris(); } + +#endif diff --git a/tutorials/gui/run_games.C b/tutorials/gui/run_games.C new file mode 100644 index 00000000000..ac5b8183b2d --- /dev/null +++ b/tutorials/gui/run_games.C @@ -0,0 +1,44 @@ +// Macro used to prepare the environment before running the games.C macro + +void run_games() +{ + gSystem->Load("libGui"); + Bool_t UNIX = strcmp(gSystem->GetName(), "Unix") == 0; + Int_t st1 = gSystem->Load("$(ROOTSYS)/test/Aclock"); + if (st1 == -1) { + printf("===>The macro games will try to build the Aclock library\n"); + if (UNIX) + gSystem->Exec("(cd $ROOTSYS/test; make Aclock)"); + else + gSystem->Exec("(cd %ROOTSYS%\\test && nmake -f Makefile.win32 Aclock.dll)"); + + st1 = gSystem->Load("$(ROOTSYS)/test/Aclock"); + } + Int_t st2 = gSystem->Load("$(ROOTSYS)/test/Hello"); + if (st2 == -1) { + printf("===>The macro games will try to build the Hello library\n"); + if (UNIX) + gSystem->Exec("(cd $ROOTSYS/test; make Hello)"); + else + gSystem->Exec("(cd %ROOTSYS%\\test && nmake -f Makefile.win32 Hello.dll)"); + + st2 = gSystem->Load("$(ROOTSYS)/test/Hello"); + } + Int_t st3 = gSystem->Load("$(ROOTSYS)/test/Tetris"); + if (st3 == -1) { + if (UNIX) { + printf("===>The macro games will try to build the Tetris library\n"); + gSystem->Exec("(cd $ROOTSYS/test; make Tetris)"); + } else { + gSystem->Exec("(cd %ROOTSYS%\\test && nmake -f Makefile.win32 Tetris.dll)"); + } + st3 = gSystem->Load("$(ROOTSYS)/test/Tetris"); + } + if (st1 || st2 || st3) { + printf("ERROR: one of the shared libs in $ROOTSYS/test didn't load properly\n"); + return; + } + gROOT->ProcessLine("#define __RUN_GAMES__ 1"); + gInterpreter->ExecuteMacro("games.C"); + gROOT->ProcessLine("#undef __RUN_GAMES__"); +} -- GitLab