Browse Source

improve the amalgamation procedure; fix a compile issue on msvc

Julius Pfrommer 8 years ago
parent
commit
cffdd4cc60
1 changed files with 9 additions and 9 deletions
  1. 9 9
      tools/amalgamate.py

+ 9 - 9
tools/amalgamate.py

@@ -19,7 +19,6 @@ if pos > 0:
     outname = outname[:pos]
 include_re = re.compile("^#include (\".*\").*$")
 guard_re = re.compile("^#(?:(?:ifndef|define) [A-Z_]+_H_|endif /\* [A-Z_]+_H_ \*/|endif // [A-Z_]+_H_)")
-includes = []
 
 print ("Starting amalgamating file "+ args.outfile)
 
@@ -30,7 +29,7 @@ file.write(u"""/* THIS IS A SINGLE-FILE DISTRIBUTION CONCATENATED FROM THE OPEN6
  */
 
 /*
- * Copyright (C) 2015 the contributors as stated in the AUTHORS file
+ * Copyright (C) 2014-2016 the contributors as stated in the AUTHORS file
  *
  * This file is part of open62541. open62541 is free software: you can
  * redistribute it and/or modify it under the terms of the GNU Lesser General
@@ -44,7 +43,14 @@ file.write(u"""/* THIS IS A SINGLE-FILE DISTRIBUTION CONCATENATED FROM THE OPEN6
  * details.
  */\n\n""" % args.version)
 
-if not is_c:
+if is_c:
+    file.write(u'''#ifndef UA_DYNAMIC_LINKING
+# define UA_DYNAMIC_LINKING
+#endif
+
+#include "%s.h"
+''' % outname)
+else:
     file.write(u'''#ifndef %s
 #define %s
 
@@ -52,12 +58,6 @@ if not is_c:
 extern "C" {
 #endif\n''' % (outname.upper() + u"_H_", outname.upper() + u"_H_") )
 
-if not is_c:
-    for inc in includes:
-        file.write(u"#include " + inc + "\n")
-else:
-    file.write(u"#include \"" + outname + ".h\"\n")
-
 for fname in args.inputs:
     with io.open(fname, encoding="utf8") as infile:
         file.write(u"\n/*********************************** amalgamated original file \"" + fname + u"\" ***********************************/\n\n")