X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=commands%2Fgenerate.py;h=f0d1175fb666385b64c0ac93eaa8a874a55a387b;hb=b371676debccaa2abf20bb4b0a4fdce34647987b;hp=a08a4b39d8aadff0e107e043a0ce013c213b3792;hpb=f436e8b659469c16ac2805595ec8a5113b8309a6;p=tools%2Fsat.git diff --git a/commands/generate.py b/commands/generate.py index a08a4b3..f0d1175 100644 --- a/commands/generate.py +++ b/commands/generate.py @@ -23,12 +23,13 @@ import imp import subprocess import src +import src.debug as DBG parser = src.options.Options() parser.add_option('p', 'products', 'list2', 'products', - _("the list of products to generate")) + _("Optional: the list of products to generate")) parser.add_option('', 'yacsgen', 'string', 'yacsgen', - _("path to YACSGEN's module_generator package")) + _("Optional: path to YACSGEN's module_generator package")) def generate_component_list(config, product_info, context, logger): res = "?" @@ -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) @@ -59,33 +67,34 @@ def generate_component(config, compo, product_info, context, header, logger): src.printcolors.print_value(logger, "cpp_path", cpp_path, 4) # create a product_info at runtime - pp = src.pyconf.Mapping(config) - pp.name = compo - pp.nb_proc = 1 + compo_info = src.pyconf.Mapping(config) + compo_info.name = compo + compo_info.nb_proc = 1 generate_dir = os.path.join(config.APPLICATION.workdir, "GENERATED") install_dir = os.path.join(config.APPLICATION.workdir, "INSTALL") build_dir = os.path.join(config.APPLICATION.workdir, "BUILD") - pp.source_dir = os.path.join(generate_dir, compo + "_SRC") - pp.install_dir = os.path.join(install_dir, compo) - pp.build_dir = os.path.join(build_dir, compo) - pp.depend = product_info.depend - pp.depend.append(product_info.name, "") # add cpp module - pp.opt_depend = product_info.opt_depend + compo_info.source_dir = os.path.join(generate_dir, compo + "_SRC") + compo_info.install_dir = os.path.join(install_dir, compo) + compo_info.build_dir = os.path.join(build_dir, compo) + compo_info.depend = product_info.depend + compo_info.depend.append(product_info.name, "") # add cpp module + compo_info.opt_depend = product_info.opt_depend - config.PRODUCTS[compo].default = pp + config.PRODUCTS.addMapping(compo, src.pyconf.Mapping(config), "") + config.PRODUCTS[compo].default = compo_info - builder = src.compilation.Builder(config, logger, pp, check_src=False) + builder = src.compilation.Builder(config, logger, compo_info, check_src=False) builder.header = header # generate the component - # create GENERETE dir if necessary + # create GENERATE dir if necessary if not os.path.exists(generate_dir): os.mkdir(generate_dir) # delete previous generated directory if it already exists - if os.path.exists(pp.source_dir): - logger.write(" delete %s\n" % pp.source_dir, 4) - shutil.rmtree(pp.source_dir) + if os.path.exists(compo_info.source_dir): + logger.write(" delete %s\n" % compo_info.source_dir, 4) + shutil.rmtree(compo_info.source_dir) # generate generates in the current directory => change for generate dir curdir = os.curdir @@ -108,14 +117,14 @@ def generate_component(config, compo, product_info, context, header, logger): VersionSalome = src.get_salome_version(config) if VersionSalome >= 750 : use_autotools=False - builder.log_step('USE CMAKE') + builder.log('USE CMAKE', 3) else: use_autotools=True - builder.log_step('USE AUTOTOOLS') + builder.log('USE AUTOTOOLS', 3) result = "GENERATE" - builder.log_step('GENERATE') - + builder.log('GENERATE', 3) + prevstdout = sys.stdout prevstderr = sys.stderr @@ -132,9 +141,12 @@ def generate_component(config, compo, product_info, context, header, logger): cpplib, cpp_path) - if product_info.has_gui == "yes": + 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 @@ -145,8 +157,8 @@ def generate_component(config, compo, product_info, context, header, logger): if use_autotools: result = "BUID_CONFIGURE" - builder.log_step('BUID_CONFIGURE (no bootstrap)') - g.bootstrap(pp.source_dir, logger.logTxtFile) + builder.log('BUID_CONFIGURE (no bootstrap)', 3) + g.bootstrap(compo_info.source_dir, logger.logTxtFile) result = src.OK_STATUS finally: @@ -157,35 +169,34 @@ def generate_component(config, compo, product_info, context, header, logger): os.chdir(curdir) # do the compilation using the builder object - if not builder.prepare(): return "Error in prepare" + if builder.prepare()!= 0: return "Error in prepare" if use_autotools: - if not builder.configure(): return "Error in configure" + if builder.configure()!= 0: return "Error in configure" else: - if not builder.cmake(): return "Error in cmake" + if builder.cmake()!= 0: return "Error in cmake" - if not builder.make(): return "Error in make" - if not builder.install(): return "Error in make install" + if builder.make(config.VARS.nb_proc, "")!=0: return "Error in make" + if builder.install()!=0: return "Error in make install" # copy specified logo in generated component install directory # rem : logo is not copied in source dir because this would require # to modify the generated makefile - if "logo" in product_info: - destlogo = os.path.join(pp.install_dir, "share", "salome", + logo_path = src.product.product_has_logo(product_info) + if logo_path: + destlogo = os.path.join(compo_info.install_dir, "share", "salome", "resources", compo.lower(), compo + ".png") - src.Path(product_info.logo).copyfile(destlogo) + src.Path(logo_path).copyfile(destlogo) return result def build_context(config, logger): - environ_info = {} products_list = [ 'KERNEL', 'GUI' ] - environ_info['products'] = config.APPLICATION.products ctxenv = src.environment.SalomeEnviron(config, src.environment.Environ(dict( os.environ)), True) ctxenv.silent = True - ctxenv.set_full_environ(logger, environ_info) + ctxenv.set_full_environ(logger, config.APPLICATION.products.keys()) dicdir = {} for p in products_list: @@ -226,7 +237,7 @@ def check_module_generator(directory=None): """ undo = False if directory is not None and directory not in sys.path: - sys.path.insert(0, dir) + sys.path.insert(0, directory) undo = True res = None @@ -236,7 +247,7 @@ def check_module_generator(directory=None): res = info[1] except ImportError: if undo: - sys.path.remove(dir) + sys.path.remove(directory) res = None return res @@ -255,14 +266,14 @@ def check_yacsgen(config, directory, logger): yacs_src = "?" if directory is not None: yacsgen_dir = directory - yacs_src = _("Using YACSGEN form command line") + yacs_src = _("Using YACSGEN from command line") elif 'YACSGEN' in config.APPLICATION.products: yacsgen_info = src.product.get_product_config(config, 'YACSGEN') yacsgen_dir = yacsgen_info.install_dir - yacs_src = _("Using YACSGEN form application") + yacs_src = _("Using YACSGEN from application") elif os.environ.has_key("YACSGEN_ROOT_DIR"): yacsgen_dir = os.getenv("YACSGEN_ROOT_DIR") - yacs_src = _("Using YACSGEN form environment") + yacs_src = _("Using YACSGEN from environment") if yacsgen_dir is None: return (False, _("The generate command requires YACSGEN.")) @@ -281,7 +292,8 @@ def check_yacsgen(config, directory, logger): pv = os.getenv("PYTHON_VERSION") if pv is None: - pv = '.'.join(config.PRODUCT.prerequis["Python"].split('.')[:2]) + python_info = src.product.get_product_config(config, "Python") + pv = '.'.join(python_info.version.split('.')[:2]) assert pv is not None, "$PYTHON_VERSION not defined" yacsgen_dir = os.path.join(yacsgen_dir, "lib", "python%s" % pv, "site-packages") @@ -290,7 +302,7 @@ def check_yacsgen(config, directory, logger): return c return (False, - _("The python module mosule_generator was not found in YACSGEN")) + _("The python module module_generator was not found in YACSGEN")) def description(): @@ -300,7 +312,8 @@ def description(): :rtype: str ''' return _("The generate command generates SALOME modules from 'pure cpp' " - "products.\nWARNING this command NEEDS YACSGEN to run!") + "products.\nWARNING this command NEEDS YACSGEN to run!\n\nexample:" + "\nsat generate SALOME-master --products FLICACPP") def run(args, runner, logger):