Salome HOME
nouvelle option sat package -e pour inclure dans l'archive un lanceur basé sur un...
authorcrouzet <nicolas.crouzet@cea.fr>
Tue, 2 Mar 2021 16:14:06 +0000 (17:14 +0100)
committercrouzet <nicolas.crouzet@cea.fr>
Tue, 2 Mar 2021 16:14:06 +0000 (17:14 +0100)
commands/package.py
complete_sat.sh

index da5fe6f01b2b0bf70e05b88424311db79d81f31c..1e275cf99d7bdb38b84b416e91f1eaacacf976b5 100644 (file)
@@ -104,6 +104,8 @@ parser.add_option('', 'ftp', 'boolean', 'ftp',
     _('Optional: Do not embed archives for products in archive mode.' 
     'Sat prepare will use ftp instead to retrieve them'),
     False)
+parser.add_option('e', 'exe', 'string', 'exe',
+    _('Optional: Produce an extra launcher based upon the exe given as argument.'), "")
 parser.add_option('p', 'project', 'string', 'project',
     _('Optional: Produce an archive that contains a project.'), "")
 parser.add_option('t', 'salometools', 'boolean', 'sat',
@@ -367,7 +369,8 @@ def hack_for_distene_licence(filepath, licence_file):
 def produce_relative_env_files(config,
                               logger,
                               file_dir,
-                              binaries_dir_name):
+                              binaries_dir_name,
+                              exe_name=None):
     '''Create some specific environment files for the binary package. These 
        files use relative paths.
     
@@ -376,6 +379,7 @@ def produce_relative_env_files(config,
     :param file_dir str: the directory where to put the files
     :param binaries_dir_name str: the name of the repository where the binaries
                                   are, in the archive.
+    :param exe_name str: if given generate a launcher executing exe_name
     :return: the list of path of the produced environment files
     :rtype: List
     '''  
@@ -392,6 +396,9 @@ def produce_relative_env_files(config,
       shell = "bash"
       filename  = "env_launch.sh"
 
+    if exe_name:
+        filename=os.path.basename(exe_name)
+
     # Write
     filepath = writer.write_env_file(filename,
                           False, # for launch
@@ -407,6 +414,14 @@ def produce_relative_env_files(config,
       src.replace_in_file(filepath, '"out_dir_Path', '"${out_dir_Path}' )
       src.replace_in_file(filepath, ':out_dir_Path', ':${out_dir_Path}' )
 
+    if exe_name:
+        if src.architecture.is_windows():
+            cmd="\n\nrem Launch exe with user arguments\n%s " % exe_name + "%*"
+        else:
+            cmd='\n\n# Launch exe with user arguments\n%s "$*"' % exe_name
+        with open(filepath, "a") as exe_launcher:
+            exe_launcher.write(cmd)
+
     # change the rights in order to make the file executable for everybody
     os.chmod(filepath,
              stat.S_IRUSR |
@@ -757,6 +772,22 @@ WARNING: existing binaries directory from previous detar installation:
     else:
       filename  = "env_launch.sh"
     d_products["environment file"] = (env_file, filename)      
+
+    # If option exe, produce an extra launcher based on specified exe
+    if options.exe:
+        exe_file = produce_relative_env_files(config,
+                                              logger,
+                                              tmp_working_dir,
+                                              binaries_dir_name,
+                                              options.exe)
+            
+        if src.architecture.is_windows():
+          filename  = os.path.basename(options.exe) + ".bat"
+        else:
+          filename  = os.path.basename(options.exe) + ".sh"
+        d_products["exe file"] = (exe_file, filename)      
+    
+
     return d_products
 
 def source_package(sat, config, logger, options, tmp_working_dir):
index 53dbdb4271ff9cf3f1cbc1a2a358e61a1b2e0570..7470b1bbc7763b398767fea08c134409dd4a3b7f 100755 (executable)
@@ -237,7 +237,7 @@ _salomeTools_complete()
             return 0
             ;;
         package)
-            opts="--name --binaries --sources --project --salometools --force_creation --add_files --with_vcs --ftp --without_property"
+            opts="--name --binaries --sources --exe --project --salometools --force_creation --add_files --with_vcs --ftp --without_property"
             COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
             return 0
             ;;