Salome HOME
scs #13189: report des modifications pour que SAT fonctionne sous windows
authorNabil Ghodbane <nabil.ghodbane@cea.fr>
Mon, 15 Jul 2019 12:12:43 +0000 (14:12 +0200)
committerNabil Ghodbane <nabil.ghodbane@cea.fr>
Mon, 15 Jul 2019 12:12:43 +0000 (14:12 +0200)
commands/config.py
commands/package.py
src/architecture.py
src/compilation.py
src/environment.py
src/fileEnviron.py
src/product.py
src/system.py

index 50ad5f7bbc0e6768edbcdbb3b01a7a061e7c5ac9..3d44311fe9fd7de6ae697765cd34d0f411cdd393 100644 (file)
@@ -135,6 +135,10 @@ class ConfigManager:
         var['srcDir'] =  osJoin(var['salometoolsway'], 'src')
         var['internal_dir'] =  osJoin(var['srcDir'], 'internal_config')
         var['sep']= os.path.sep
+        if src.architecture.is_windows():
+          var['scriptExtension'] = '.bat'
+        else:
+          var['scriptExtension'] = '.sh'
         
         # datadir has a default location
         var['datadir'] =  osJoin(var['salometoolsway'], 'data')
index ec2a16cafc30c46b72b7cfda785fb7ffdb336ffd..267a29370a68afb0c83f76753130985b005dc691 100644 (file)
@@ -342,10 +342,17 @@ def produce_relative_env_files(config,
                                            file_dir,
                                            src_root=None)
     
+    if src.architecture.is_windows():
+      shell = "bat"
+      filename  = "env_launch.bat"
+    else:
+      shell = "bash"
+      filename  = "env_launch.sh"
+
     # Write
-    filepath = writer.write_env_file("env_launch.sh",
+    filepath = writer.write_env_file(filename,
                           False, # for launch
-                          "bash",
+                          shell,
                           for_package = binaries_dir_name)
 
     # Little hack to put out_dir_Path as environment variable
@@ -674,8 +681,12 @@ WARNING: existing binaries directory from previous detar installation:
                                            tmp_working_dir,
                                            binaries_dir_name)
 
-    d_products["environment file"] = (env_file, "env_launch.sh")
-      
+    if src.architecture.is_windows():
+      filename  = "env_launch.bat"
+    else:
+      filename  = "env_launch.sh"
+    d_products["environment file"] = (env_file, filename)      
+
     return d_products
 
 def source_package(sat, config, logger, options, tmp_working_dir):
index 5b8711b4a05d3e87e2a519da7fa767a3d00e8a66..d5404828c67ba2ea48fe63c8754b619e11a672cb 100644 (file)
@@ -54,7 +54,7 @@ def get_distribution(codes):
     :rtype: str
     '''
     if is_windows():
-        return "Win"
+        return "W" # in order to fulfill the 8196 length constraint!
 
     # else get linux distribution description from platform, and encode it with code
     lin_distrib = platform.dist()[0].lower()
index 4951c554ac6d9be7dea5b86327eecc05a99fe0d8..48a56209745d4df43da0b2fd9e41ebf068776720 100644 (file)
@@ -454,6 +454,7 @@ CC=\\"hack_libtool\\"%g" libtool'''
         assert self.build_environ is not None
         # pass additional variables to environment 
         # (may be used by the build script)
+        self.build_environ.set("APPLICATION_NAME", self.config.APPLICATION.name)
         self.build_environ.set("SOURCE_DIR", str(self.source_dir))
         self.build_environ.set("INSTALL_DIR", str(self.install_dir))
         self.build_environ.set("PRODUCT_INSTALL", str(self.install_dir))
index f4816e7e239f18dcef76c7523e2dff72c84f1fae..ae27354a8767b79918c540adab38f0f4abaf6b9c 100644 (file)
@@ -73,8 +73,17 @@ class Environ:
         :param value str: the value to append to key
         :param sep str: the separator string
         """
-        for c in [";", ":"]: # windows or linux path separators
-          if c in value:
+        if src.architecture.is_windows():
+          separators = [';']
+        else:
+          separators = [':']
+        for c in separators: # windows or linux path separators
+          isOK = True
+          if c in value and not src.architecture.is_windows():
+            isOK = False
+          elif c in value and src.architecture.is_windows() and value.count(':') > 1:
+            isOK = False
+          if not isOK:
             raise Exception("Environ append key '%s' value '%s' contains forbidden character '%s'" % (key, value, c))
         # check if the key is already in the environment
         if key in self.environ:
@@ -111,8 +120,17 @@ class Environ:
         :param value str: the value to prepend to key
         :param sep str: the separator string
         """
-        for c in [";", ":"]: # windows or linux path separators
-          if c in value:
+        if src.architecture.is_windows():
+          separators = [';']
+        else:
+          separators = [':']
+        for c in separators: # windows or linux path separators
+          isOK = True
+          if c in value and not src.architecture.is_windows():
+            isOK = False
+          elif c in value and src.architecture.is_windows() and value.count(':') > 1:
+            isOK = False
+          if not isOK:
             raise Exception("Environ prepend key '%s' value '%s' contains forbidden character '%s'" % (key, value, c))
         # check if the key is already in the environment
         if key in self.environ:
@@ -499,11 +517,11 @@ class SalomeEnviron:
                     self.prepend('LD_LIBRARY_PATH', lib_path)
 
             l = [ bin_path, lib_path ]
-            if self.has_python:
-                l.append(pylib1_path)
-                l.append(pylib2_path)
-
-            self.prepend('PYTHONPATH', l)
+            if not src.product.product_is_wheel(pi):
+                if self.has_python:
+                    l.append(pylib1_path)
+                    l.append(pylib2_path)
+                self.prepend('PYTHONPATH', l)
 
     def set_cpp_env(self, product_info):
         """\
index ab79916b5a030c22e9223a32d0d453fd44410260..468b0e83a4e85c8f0ffa7937570cb9f2edb3f2e1 100644 (file)
@@ -19,6 +19,7 @@
 import os
 import pprint as PP
 import src.debug as DBG
+import src.architecture
 
 bat_header="""\
 @echo off
@@ -180,8 +181,18 @@ class FileEnviron(object):
         :param value str: the value to append to key
         :param sep str: the separator string
         """
-        for c in [";", ":"]: # windows or linux path separators
-          if c in value:
+        separators = []
+        if src.architecture.is_windows(): 
+          separators = [':']
+        else:
+          separators = [';']
+        for c in separators: # windows or linux path separators
+          isOK = True
+          if c in value and not src.architecture.is_windows():
+            isOK = False
+          elif c in value and src.architecture.is_windows() and value.count(':') > 1:
+            isOK = False
+          if not isOK:
             raise Exception("FileEnviron append key '%s' value '%s' contains forbidden character '%s'" % (key, value, c))
         self.set(key, self.get(key) + sep + value)
         if (key, sep) not in self.toclean:
@@ -210,8 +221,18 @@ class FileEnviron(object):
         :param value str: the value to prepend to key
         :param sep str: the separator string
         """
-        for c in [";", ":"]: # windows or linux path separators
-          if c in value:
+        separators = []
+        if src.architecture.is_windows(): 
+          separators = [':']
+        else:
+          separators = [';']
+        for c in separators: # windows or linux path separators
+          isOK = True
+          if c in value and not src.architecture.is_windows():
+            isOK = False
+          elif c in value and src.architecture.is_windows() and value.count(':') > 1:
+            isOK = False
+          if not isOK:
             raise Exception("FileEnviron prepend key '%s' value '%s' contains forbidden character '%s'" % (key, value, c))
         self.set(key, value + sep + self.get(key))
         if (key, sep) not in self.toclean:
@@ -555,8 +576,18 @@ class LauncherFileEnviron:
         :param value str: the value to append to key
         :param sep str: the separator string
         """
-        for c in [";", ":"]: # windows or linux path separators
-          if c in value:
+        separators = []
+        if src.architecture.is_windows(): 
+          separators = [':']
+        else:
+          separators = [';']
+        for c in separators: # windows or linux path separators
+          isOK = True
+          if c in value and not src.architecture.is_windows():
+            isOK = False
+          elif c in value and src.architecture.is_windows() and value.count(':') > 1:
+            isOK = False
+          if not isOK:
             raise Exception("LauncherFileEnviron append key '%s' value '%s' contains forbidden character '%s'" % (key, value, c))
         if self.is_defined(key) :
             self.add(key, value)
index 44d20e9faf8bf4b2670f4c1d95d4dfb101ff27dc..f6c8cc214b4c52fdcfa4cfb3a8de5843ff4813fb 100644 (file)
@@ -1089,3 +1089,15 @@ def get_product_components(product_info):
             compo_list = [ compo_list ]
 
     return compo_list
+def product_is_wheel(product_info):
+    """ tells whether a product is a wheel
+    
+    :param product_info Config: The configuration specific to 
+                               the product
+    :return: True if the product has a wheel, else False
+    :rtype: Boolean
+    """
+    return ("properties" in product_info and
+            "is_wheel" in product_info.properties and
+            product_info.properties.is_wheel == "yes")
+
index 6b793397f12e8280bece2dd60d28b37caaadbe4c..73f9c18385b495dabdfc59f5fa1ee03bf5f515b6 100644 (file)
@@ -28,6 +28,7 @@ import tarfile
 
 import debug as DBG
 import utilsSat as UTS
+import src
 
 from . import printcolors
 
@@ -85,7 +86,10 @@ def git_extract(from_what, tag, where, logger, environment=None):
   if not where.exists():
     where.make()
   if tag == "master" or tag == "HEAD":
-    cmd = r"""
+    if src.architecture.is_windows():
+      cmd = "git clone %(remote)s %(where)s"
+    else:
+      cmd = r"""
 set -x
 git clone %(remote)s %(where)s
 """
@@ -94,8 +98,10 @@ git clone %(remote)s %(where)s
     # NOTICE: this command only works with recent version of git
     #         because --work-tree does not work with an absolute path
     where_git = os.path.join(str(where), ".git")
-
-    cmd = r"""
+    if src.architecture.is_windows():
+      cmd = "rmdir %(where)s && git clone %(remote)s %(where)s && git --git-dir=%(where_git)s --work-tree=%(where)s checkout %(tag)s"
+    else:
+      cmd = r"""
 set -x
 rmdir %(where)s
 git clone %(remote)s %(where)s && \
@@ -159,8 +165,8 @@ def git_extract_sub_dir(from_what, tag, where, sub_dir, logger, environment=None
            'tmpWhere': tmpWhere,
            }
   DBG.write("git_extract_sub_dir", aDict)
-
-  cmd = r"""
+  if not src.architecture.is_windows():
+    cmd = r"""
 set -x
 export tmpDir=%(tmpWhere)s && \
 rm -rf $tmpDir
@@ -171,6 +177,19 @@ mv %(sub_dir)s %(where)s && \
 git log -1 > %(where)s/README_git_log.txt && \
 rm -rf $tmpDir
 """ % aDict
+  else:
+    cmd = r"""
+
+set tmpDir=%(tmpWhere)s && \
+rm -rf $tmpDir
+git clone %(remote)s $tmpDir && \
+cd $tmpDir && \
+git checkout %(tag)s && \
+mv %(sub_dir)s %(where)s && \
+git log -1 > %(where)s/README_git_log.txt && \
+rm -rf $tmpDir
+""" % aDict
+
   DBG.write("cmd", cmd)
 
   for nbtry in range(0,3): # retries case of network problem