PLC build: prevent duplicated CFLAGS for PLC C files.
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Wed, 11 Dec 2024 09:30:07 +0100 (3 months ago)
changeset 4069 e4f648e0595a
parent 4068 4f47609a5f62
child 4070 fabc5d6c5a8c
child 4071 d0be57df5f8d
PLC build: prevent duplicated CFLAGS for PLC C files.
ProjectController.py
opc_ua/client.py
--- a/ProjectController.py	Tue Dec 10 12:44:38 2024 +0100
+++ b/ProjectController.py	Wed Dec 11 09:30:07 2024 +0100
@@ -279,6 +279,9 @@
         self.IECcodeDigest = None
         self.LastBuiltIECcodeDigest = None
 
+        # compute CFLAGS for PLC code
+        self.plcCFLAGS = '"-I%s" -Wno-unused-function' % os.path.abspath(self.iec2c_cfg.getLibCPath())
+
     def LoadLibraries(self):
         self.Libraries = OrderedDict()
         TypeStack = []
@@ -656,12 +659,10 @@
         if len(self.Libraries) == 0:
             return [], [], ()
         self.GetIECProgramsAndVariables()
-        LibIECCflags = '"-I%s" -Wno-unused-function' % os.path.abspath(
-            self.GetIECLibPath())
         LocatedCCodeAndFlags = []
         Extras = []
         for lib in self.Libraries.values():
-            res = lib.Generate_C(buildpath, self._VariablesList, LibIECCflags)
+            res = lib.Generate_C(buildpath, self._VariablesList, self.plcCFLAGS)
             LocatedCCodeAndFlags.append(res[:2])
             if len(res) > 2:
                 Extras.extend(res[2:])
@@ -938,8 +939,6 @@
         self.PLCGeneratedLocatedVars = self.GetLocations()
         # Keep track of generated C files for later use by self.CTNGenerate_C
         self.PLCGeneratedCFiles = C_files
-        # compute CFLAGS for plc
-        self.plcCFLAGS = '"-I%s" -Wno-unused-function' % self.iec2c_cfg.getLibCPath()
 
         self.LastBuiltIECcodeDigest = self.IECcodeDigest
 
@@ -1254,13 +1253,6 @@
             self.logger.write_error(traceback.format_exc())
             return False
 
-        # Extensions also need plcCFLAGS in case they include beremiz.h
-        CTNLocationCFilesAndCFLAGS = [
-            (loc, [
-                (code, self.plcCFLAGS+" "+cflags)
-                for code,cflags in code_and_cflags], do_calls)
-            for loc, code_and_cflags, do_calls in CTNLocationCFilesAndCFLAGS]
-
         self.LocationCFilesAndCFLAGS = LibCFilesAndCFLAGS + \
             CTNLocationCFilesAndCFLAGS
         self.LDFLAGS = CTNLDFLAGS + LibLDFLAGS
--- a/opc_ua/client.py	Tue Dec 10 12:44:38 2024 +0100
+++ b/opc_ua/client.py	Wed Dec 11 09:30:07 2024 +0100
@@ -148,7 +148,10 @@
         LDFLAGS = ['"' + os.path.join(Open62541LibraryPath, "libopen62541.a") + '"', '-lcrypto']
 
         CFLAGS = ' '.join(['-I"' + path + '"' for path in Open62541IncludePaths])
-
+        
+        # Add IEC library path to CFLAGS (needs beremiz.h)
+        CFLAGS += ' "-I%s"' % os.path.abspath(self.GetCTRoot().GetIECLibPath())
+        
         # Note: all user provided files are systematicaly copied, including cryptomaterial
 
         return [(c_path, CFLAGS)], LDFLAGS, True