Salome HOME
#20601 : correctif pour le cas où le nom du pyconf diffère du nom du produit
[tools/sat.git] / commands / generate.py
index c60a22b1e825b4c9089a56d82f3499d5f97a56f7..e7e05b4123e65e2ccb881be604b6ab4b396b060c 100644 (file)
@@ -23,6 +23,7 @@ import imp
 import subprocess
 
 import src
+import src.debug as DBG
 
 parser = src.options.Options()
 parser.add_option('p', 'products', 'list2', 'products',
@@ -49,8 +50,15 @@ def generate_component_list(config, product_info, context, logger):
     return res
 
 def generate_component(config, compo, product_info, context, header, logger):
-    hxxfile = compo + ".hxx"
-    cpplib = "lib" + compo + "CXX.so"
+#   get from config include file name and librairy name, or take default value
+    if "hxxfile" in product_info:
+        hxxfile = product_info.hxxfile
+    else:
+        hxxfile = compo + ".hxx"
+    if "cpplib" in product_info:
+        cpplib = product_info.cpplib
+    else:
+        cpplib = "lib" + compo + "CXX.so"
     cpp_path = product_info.install_dir
 
     logger.write("%s\n" % header, 4, False)
@@ -75,7 +83,7 @@ def generate_component(config, compo, product_info, context, header, logger):
     config.PRODUCTS.addMapping(compo, src.pyconf.Mapping(config), "")
     config.PRODUCTS[compo].default = compo_info
 
-    builder = src.compilation.Builder(config, logger, compo_info, check_src=False)
+    builder = src.compilation.Builder(config, logger, compo, compo_info, check_src=False)
     builder.header = header
 
     # generate the component
@@ -135,7 +143,10 @@ def generate_component(config, compo, product_info, context, header, logger):
 
         if src.product.product_has_salome_gui(product_info):
             # get files to build a template GUI
-            gui_files = salome_compo.getGUIfilesTemplate()
+            try: # try new yacsgen api
+                gui_files = salome_compo.getGUIfilesTemplate(compo)
+            except:  # use old yacsgen api
+                gui_files = salome_compo.getGUIfilesTemplate()
         else:
             gui_files = None
 
@@ -260,7 +271,7 @@ def check_yacsgen(config, directory, logger):
         yacsgen_info = src.product.get_product_config(config, 'YACSGEN')
         yacsgen_dir = yacsgen_info.install_dir
         yacs_src = _("Using YACSGEN from application")
-    elif os.environ.has_key("YACSGEN_ROOT_DIR"):
+    elif "YACSGEN_ROOT_DIR" in os.environ:
         yacsgen_dir = os.getenv("YACSGEN_ROOT_DIR")
         yacs_src = _("Using YACSGEN from environment")
 
@@ -358,6 +369,15 @@ def run(args, runner, logger):
             logger.write(_("not a generated product\n"), 3, False)
             continue
 
+        logger.write(_("\nCleaning generated directories\n"), 3, False)
+        # clean source, build and install directories of the generated product
+        # no verbosity to avoid warning at the first generation, for which dirs don't exist
+        runner.clean(runner.cfg.VARS.application + 
+                  " --products " + pi.name + 
+                  " --generated",
+                  batch=True,
+                  verbose=0,
+                  logger_add_link = logger)
         nbgen += 1
         try:
             result = generate_component_list(runner.cfg,