]> git.lyx.org Git - lyx.git/blobdiff - development/scons/scons_utils.py
Scons: msvc command line support.
[lyx.git] / development / scons / scons_utils.py
index f8aff3c889e8200dc65be8bd617815958ceefca8..164b8f30cfea80af1927237ccd74675346fce541 100644 (file)
@@ -56,8 +56,13 @@ def env_subst(target, source, env):
   contents = source_file.read()
   for k, v in env.items():
     try:
-      contents = re.sub('@'+k+'@', env.subst('$'+k).replace('\n',r'\\n\\\n'), contents)
-      contents = re.sub('%'+k+'%', env.subst('$'+k).replace('\n',r'\\n\\\n'), contents)
+      val = env.subst('$'+k)
+      # temporary fix for the \Resource backslash problem
+      val = val.replace('\\', '/')
+      # multi-line replacement
+      val = val.replace('\n',r'\\n\\\n')
+      contents = re.sub('@'+k+'@', val, contents)
+      contents = re.sub('%'+k+'%', val, contents)
     except:
       pass
   target_file.write(contents + "\n")
@@ -65,6 +70,16 @@ def env_subst(target, source, env):
   #st = os.stat(str(source[0]))
   #os.chmod(str(target[0]), stat.S_IMODE(st[stat.ST_MODE]) | stat.S_IWRITE)
 
+#
+# glob filenames
+#
+def globSource(dir, pattern, build_dir=None, exclude=[], include=[]):
+  ''' glob files, in dir and use build_dir as returned path name '''
+  files = filter(lambda x: x not in exclude, glob.glob1(dir, pattern)) + include
+  if build_dir is None:
+    return files
+  else:
+    return ['%s/%s' % (build_dir, x) for x in files]
 
 #
 # autoconf tests
@@ -86,7 +101,7 @@ def checkPackage(conf, pkg):
   return ret
 
 
-def startConfigH(top_src_dir):
+def startConfigH():
   ''' Write the first part of config.h '''
   global config_content
   config_content = '''/* src/config.h.  Generated by scon.  */
@@ -108,13 +123,13 @@ def startConfigH(top_src_dir):
 '''
 
 
-def addToConfig(lines, top_src_dir):
+def addToConfig(lines, newline=2):
   ''' utility function: shortcut for appending lines to outfile
     add newline at the end of lines.
   '''
   global config_content
   if lines.strip() != '':
-    config_content += lines + '\n\n'
+    config_content += lines + '\n'*newline
 
 
 def endConfigH(top_src_dir):
@@ -180,7 +195,8 @@ int main()
 """
   conf.Message('Checking for the number of args for mkdir... ')
   ret = conf.TryLink(check_mkdir_one_arg_source, '.c') or \
-    conf.TryLink('#include <unistd.h>' + check_mkdir_one_arg_source, '.c')
+    conf.TryLink('#include <unistd.h>' + check_mkdir_one_arg_source, '.c') or \
+    conf.TryLink('#include <direct.h>' + check_mkdir_one_arg_source, '.c')
   if ret:
     conf.Result('one')
   else:
@@ -188,6 +204,23 @@ int main()
   return ret
 
 
+# CXX_GLOBAL_CSTD
+def checkCXXGlobalCstd(conf):
+  ''' Check the use of std::tolower or tolower '''
+  check_global_cstd_source = '''
+#include <cctype>
+using std::tolower;
+int main()
+{
+  return 0;
+}
+'''
+  conf.Message('Check for the use of global cstd... ')
+  ret = conf.TryLink(check_global_cstd_source, '.c')
+  conf.Result(ret)
+  return ret
+
+
 # SELECT_TYPE_ARG1
 # SELECT_TYPE_ARG234
 # SELECT_TYPE_ARG5