Do not override module name if it is specified in swg file
@@ -2,6 +2,7 @@ import argparse
import os
import subprocess
import tarfile
+import re
def just_do_it():
@@ -16,8 +17,27 @@ def just_do_it():
java_srcs_dir = os.path.join(os.path.dirname(args.jsrc_out), args.package.replace('.', '/'))
if not os.path.exists(java_srcs_dir):
os.makedirs(java_srcs_dir)
+
+ modrx = re.compile('^%module\\b')
+ haveModule = False
+ with open(args.src, 'r') as f:
+ for line in f:
+ if modrx.match(line):
+ haveModule = True
+ break
+
+ moduleArgs = []
+ if haveModule:
+ try:
+ modArgIdx = args.index('-module')
+ del args[modArgIdx:modArgsIdx + 2]
+ except:
+ pass
+ else:
+ moduleArgs = [ '-module', os.path.splitext(os.path.basename(args.src))[0]]
+
subprocess.check_call([args.tool, '-c++'] + args.flag +
- ['-o', args.cpp_out, '-java', '-module', os.path.splitext(os.path.basename(args.src))[0], '-package', args.package, '-outdir', java_srcs_dir, args.src])
+ ['-o', args.cpp_out, '-java'] + moduleArgs + ['-package', args.package, '-outdir', java_srcs_dir, args.src])
with tarfile.open(args.jsrc_out, 'a') as tf:
tf.add(java_srcs_dir, arcname=args.package.replace('.', '/'))
header = os.path.splitext(args.cpp_out)[0]+'.h'
