From 6a75011328154d53090f69f05352bea015d2938d Mon Sep 17 00:00:00 2001 From: Alexander Schwinn <al.schwinn@gsi.de> Date: Mon, 17 Jul 2017 11:20:30 +0200 Subject: [PATCH] Bug 1445 - move generated code for fesa-class into "generated" folder --- .../src/xml/migration/2_0_xto2_1_x.py | 5 ++++- .../migration2_0_Xto2_1_X/migrators.py | 19 +++++++++++++++---- .../myProject/Makefile.specific | 15 +++++++++++++++ .../myProject/Makefile.specific.correct | 15 +++++++++++++++ .../myProject/Makefile.specific.original | 13 +++++++++++++ .../migration2_0_Xto2_1_X/testMigration.py | 19 +++++++++++++++---- .../src/xml/migration/migrationBase.py | 2 ++ silecs-codegen/src/xml/migration/runTests.py | 2 ++ 8 files changed, 81 insertions(+), 9 deletions(-) create mode 100644 silecs-codegen/src/xml/migration/migration2_0_Xto2_1_X/myProject/Makefile.specific create mode 100644 silecs-codegen/src/xml/migration/migration2_0_Xto2_1_X/myProject/Makefile.specific.correct create mode 100644 silecs-codegen/src/xml/migration/migration2_0_Xto2_1_X/myProject/Makefile.specific.original diff --git a/silecs-codegen/src/xml/migration/2_0_xto2_1_x.py b/silecs-codegen/src/xml/migration/2_0_xto2_1_x.py index c625eb6..f9ea8c6 100644 --- a/silecs-codegen/src/xml/migration/2_0_xto2_1_x.py +++ b/silecs-codegen/src/xml/migration/2_0_xto2_1_x.py @@ -32,15 +32,18 @@ class Migration(MigrationBase): def migrateClass(self, context, projectDir ): modified = fesaClassIncludeHeaderMigrator(context,self.silecsDocument) removeSilecsDesignGenCode(context, self.silecsDocument) + modified |= fesaClassMakeSpecificMigrator(self.silecsDocument) + self.updateFESAMakeSpecific() return modified def migrateDeployUnit(self, context, projectDir ): modified = False removeSilecsDeployGenCode(context, projectDir) + self.updateFESAMakeSpecific() return modified if __name__ == "__main__": migration = Migration(sys.argv) migration.migrate() - migration.updateFESAMakeSpecific() + diff --git a/silecs-codegen/src/xml/migration/migration2_0_Xto2_1_X/migrators.py b/silecs-codegen/src/xml/migration/migration2_0_Xto2_1_X/migrators.py index c80e637..819d454 100644 --- a/silecs-codegen/src/xml/migration/migration2_0_Xto2_1_X/migrators.py +++ b/silecs-codegen/src/xml/migration/migration2_0_Xto2_1_X/migrators.py @@ -15,12 +15,12 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import libxml2 -import FileUtils +from migration import FileUtils import os import shutil def fesaClassIncludeHeaderMigrator(context,silecsDocument): - print("Info: The include calls in all FESA source files will be updated to use the new 'generated-silecs' folder") + print("Migration-Info: The include calls in all FESA source files will be updated to use the new 'generated-silecs' folder") modified = False silecsClassNodes = context.xpathEval("//SILECS-Class") if not silecsClassNodes: @@ -37,8 +37,19 @@ def fesaClassIncludeHeaderMigrator(context,silecsDocument): modified = True return modified +def fesaClassMakeSpecificMigrator(silecsDocument): + print("Migration-Info: Compiler flags for new codegen-folder will be added into the Makefile.specific of your FESA class") + modified = False + projectDir = FileUtils.getProjectDir(silecsDocument) + makeSpecific = os.path.join(projectDir,"myProject","Makefile.specific") + if os.path.isfile(makeSpecific): + with open(makeSpecific, "a") as myfile: + myfile.write("\nCOMPILER_FLAGS += -I./generated-silecs/cpp") + modified = True + return modified + def removeSilecsDesignGenCode(context, silecsDocument): - print("Info: The silecs generated C++ code which was located in 'Common' moved to 'generated-silecs' in the root directory. The old code will be removed") + print("Migration-Info: The silecs generated C++ code which was located in 'Common' moved to 'generated-silecs' in the root directory. The old code will be removed") silecsClassNodes = context.xpathEval("//SILECS-Class") if not silecsClassNodes: raise Exception('Node "SILECS-Class" not found') @@ -54,7 +65,7 @@ def removeSilecsDesignGenCode(context, silecsDocument): os.remove(hppFile) def removeSilecsDeployGenCode(context, projectDir): - print("Info: the silecsdeploy folder 'generated' will be named 'generated-silecs' to be consistant with silecsdesign. The old folder will be removed.") + print("Migration-Info: the silecsdeploy folder 'generated' will be named 'generated-silecs' to be consistant with silecsdesign. The old folder will be removed.") clientFolder = os.path.join(projectDir,"generated","client") controllerFolder = os.path.join(projectDir,"generated","controller") wrapperFolder = os.path.join(projectDir,"generated","wrapper") diff --git a/silecs-codegen/src/xml/migration/migration2_0_Xto2_1_X/myProject/Makefile.specific b/silecs-codegen/src/xml/migration/migration2_0_Xto2_1_X/myProject/Makefile.specific new file mode 100644 index 0000000..31408b4 --- /dev/null +++ b/silecs-codegen/src/xml/migration/migration2_0_Xto2_1_X/myProject/Makefile.specific @@ -0,0 +1,15 @@ +# Include SILECS library path +SILECS_PATH ?= /home/schwinn/git/silecs-base/silecs-communication-cpp/build + +# Additional compiler warning flags +override WARNFLAGS += + +# Additional compiler flags +COMPILER_FLAGS += -I$(SILECS_PATH)/include -I$(SILECS_PATH)/include/silecs-communication/interface/core +COMPILER_FLAGS += +LINKER_FLAGS += + +# Additional headers (Custom.h Specific.h ...) which need to be installed +EXTRA_HEADERS += + +COMPILER_FLAGS += -I./generated-silecs/cpp \ No newline at end of file diff --git a/silecs-codegen/src/xml/migration/migration2_0_Xto2_1_X/myProject/Makefile.specific.correct b/silecs-codegen/src/xml/migration/migration2_0_Xto2_1_X/myProject/Makefile.specific.correct new file mode 100644 index 0000000..31408b4 --- /dev/null +++ b/silecs-codegen/src/xml/migration/migration2_0_Xto2_1_X/myProject/Makefile.specific.correct @@ -0,0 +1,15 @@ +# Include SILECS library path +SILECS_PATH ?= /home/schwinn/git/silecs-base/silecs-communication-cpp/build + +# Additional compiler warning flags +override WARNFLAGS += + +# Additional compiler flags +COMPILER_FLAGS += -I$(SILECS_PATH)/include -I$(SILECS_PATH)/include/silecs-communication/interface/core +COMPILER_FLAGS += +LINKER_FLAGS += + +# Additional headers (Custom.h Specific.h ...) which need to be installed +EXTRA_HEADERS += + +COMPILER_FLAGS += -I./generated-silecs/cpp \ No newline at end of file diff --git a/silecs-codegen/src/xml/migration/migration2_0_Xto2_1_X/myProject/Makefile.specific.original b/silecs-codegen/src/xml/migration/migration2_0_Xto2_1_X/myProject/Makefile.specific.original new file mode 100644 index 0000000..de18485 --- /dev/null +++ b/silecs-codegen/src/xml/migration/migration2_0_Xto2_1_X/myProject/Makefile.specific.original @@ -0,0 +1,13 @@ +# Include SILECS library path +SILECS_PATH ?= /home/schwinn/git/silecs-base/silecs-communication-cpp/build + +# Additional compiler warning flags +override WARNFLAGS += + +# Additional compiler flags +COMPILER_FLAGS += -I$(SILECS_PATH)/include -I$(SILECS_PATH)/include/silecs-communication/interface/core +COMPILER_FLAGS += +LINKER_FLAGS += + +# Additional headers (Custom.h Specific.h ...) which need to be installed +EXTRA_HEADERS += diff --git a/silecs-codegen/src/xml/migration/migration2_0_Xto2_1_X/testMigration.py b/silecs-codegen/src/xml/migration/migration2_0_Xto2_1_X/testMigration.py index d8d804d..b547857 100644 --- a/silecs-codegen/src/xml/migration/migration2_0_Xto2_1_X/testMigration.py +++ b/silecs-codegen/src/xml/migration/migration2_0_Xto2_1_X/testMigration.py @@ -18,10 +18,21 @@ from test.testBase import * import libxml2 from migration.migration2_0_Xto2_1_X.migrators import * -import inspect #get caller name +import inspect # get caller name +from shutil import copyfile +import os +def testFesaClassMakeSpecificMigrator(): + currentDirectory = os.path.dirname(os.path.abspath(__file__)) + makefileSpecific = os.path.join(currentDirectory, "myProject", "Makefile.specific") + makefileSpecificOriginal = os.path.join(currentDirectory, "myProject", "Makefile.specific.original") + makefileSpecificCorrect = os.path.join(currentDirectory, "myProject", "Makefile.specific.correct") + if os.path.isfile(makefileSpecific): + os.remove(makefileSpecific) + copyfile(makefileSpecificOriginal, makefileSpecific) + fesaClassMakeSpecificMigrator(makefileSpecific) + assertFileEqual(makefileSpecific,makefileSpecificCorrect) + def runTests(): - print("nothing so far") - #testdesignValueTypeMigrator() - #testdesignBlockRegisterMigrator() + testFesaClassMakeSpecificMigrator() # print deployDoc # for debugging diff --git a/silecs-codegen/src/xml/migration/migrationBase.py b/silecs-codegen/src/xml/migration/migrationBase.py index eea70a0..61590b7 100644 --- a/silecs-codegen/src/xml/migration/migrationBase.py +++ b/silecs-codegen/src/xml/migration/migrationBase.py @@ -54,6 +54,7 @@ class MigrationBase(object): def updateFESAMakeSpecific(self): projectDir = FileUtils.getProjectDir(self.silecsDocument) makeSpecific = os.path.join(projectDir,"Makefile.specific") + print("Migration-Info: Old Version-Strings in '" + makeSpecific + "' will be replaced\n") if os.path.isfile(makeSpecific): oldComm = "silecs-communication-cpp/" + self.versionOld newComm = "silecs-communication-cpp/" + self.versionNew @@ -64,6 +65,7 @@ class MigrationBase(object): def removeGenCode(self): projectDir = FileUtils.getProjectDir(self.silecsDocument) + print("Migration-Info: Generated-code folder of '" + projectDir + "' will be removed\n") clientFolder = projectDir + "/generated/client" controllerFolder = projectDir + "/generated/controller" wrapperFolder = projectDir + "/generated/wrapper" diff --git a/silecs-codegen/src/xml/migration/runTests.py b/silecs-codegen/src/xml/migration/runTests.py index f9b3568..a3eaf87 100644 --- a/silecs-codegen/src/xml/migration/runTests.py +++ b/silecs-codegen/src/xml/migration/runTests.py @@ -18,6 +18,7 @@ from test.testBase import * import migration.migration_0_9_0to0_10_0.testMigration import migration.migration0_10_0to1_0_0.testMigration import migration.migration1_0_Xto2_0_0.testMigration +import migration.migration2_0_Xto2_1_X.testMigration SilecsDeployOld = '''<?xml version="1.0" encoding="UTF-8"?> <SILECS-Deploy silecs-version="oldVersion" created="03/04/16" updated="03/04/16" @@ -48,4 +49,5 @@ def runAllTests(): migration.migration_0_9_0to0_10_0.testMigration.runTests() migration.migration0_10_0to1_0_0.testMigration.runTests() migration.migration1_0_Xto2_0_0.testMigration.runTests() + migration.migration2_0_Xto2_1_X.testMigration.runTests() allTestsOk() -- GitLab