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 c625eb6f0a72034a202601469478f92bc1d24101..f9ea8c653224f56900b25fb1faa2b0fbe961d918 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 c80e637a4cb384cde87c046f591294f93ab2aab1..819d454d281e0d63694e66a3da0e6e8e9afc5d53 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 0000000000000000000000000000000000000000..31408b4792b1251765eb86a5419aa2ba4fafceb3 --- /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 0000000000000000000000000000000000000000..31408b4792b1251765eb86a5419aa2ba4fafceb3 --- /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 0000000000000000000000000000000000000000..de1848541e57bf1728b0984d1d934a2101f0b179 --- /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 d8d804debcfbe01930a28857e479ca56ec689f47..b547857ec2d3d729d83ebd6c17ce83b6a846a63a 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 eea70a06dc60e2ba737201897fabf94740154d44..61590b77a948eb8274a5f19abb810d569d958c0f 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 f9b3568a4c2b869a5ee01df411c63ee059757ef8..a3eaf87c73cd7135b972f993a70dbed030d30e6e 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()