diff options
author | orivej <orivej@yandex-team.ru> | 2022-02-10 16:45:01 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:01 +0300 |
commit | 2d37894b1b037cf24231090eda8589bbb44fb6fc (patch) | |
tree | be835aa92c6248212e705f25388ebafcf84bc7a1 /build/plugins/swig.py | |
parent | 718c552901d703c502ccbefdfc3c9028d608b947 (diff) | |
download | ydb-2d37894b1b037cf24231090eda8589bbb44fb6fc.tar.gz |
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'build/plugins/swig.py')
-rw-r--r-- | build/plugins/swig.py | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/build/plugins/swig.py b/build/plugins/swig.py index 24a0bf4cb3..32a37204a6 100644 --- a/build/plugins/swig.py +++ b/build/plugins/swig.py @@ -1,15 +1,15 @@ import os import posixpath -import re +import re import _import_wrapper as iw import _common as common -def init(): - iw.addrule('swg', Swig) - - +def init(): + iw.addrule('swg', Swig) + + class Swig(iw.CustomCommand): def __init__(self, path, unit): self._tool = unit.get('SWIG_TOOL') @@ -17,7 +17,7 @@ class Swig(iw.CustomCommand): self._local_swig = unit.get('USE_LOCAL_SWIG') == "yes" self._path = path - self._flags = ['-cpperraswarn'] + self._flags = ['-cpperraswarn'] self._bindir = common.tobuilddir(unit.path()) self._input_name = common.stripext(os.path.basename(self._path)) @@ -42,12 +42,12 @@ class Swig(iw.CustomCommand): lang_specific_incl_dir = 'perl5' elif self._swig_lang in ['jni_cpp', 'jni_java']: lang_specific_incl_dir = 'java' - incl_dirs = [ + incl_dirs = [ "FOR", "swig", posixpath.join(self._library_dir, lang_specific_incl_dir), "FOR", "swig", self._library_dir - ] + ] self._incl_dirs = ['$S', '$B'] + [posixpath.join('$S', d) for d in incl_dirs] modname = unit.get('REALPRJNAME') @@ -99,7 +99,7 @@ class Swig(iw.CustomCommand): return [ (self._main_out, []), (common.join_intl_paths(self._bindir, self._out_name), (['noauto', 'add_to_outs'] if self._swig_lang != 'java' else [])), - ] + ([(self._out_header, [])] if self._swig_lang == 'java' else []) + ] + ([(self._out_header, [])] if self._swig_lang == 'java' else []) def output_includes(self): return [(self._out_header, [])] if self._swig_lang in ['java', 'jni_cpp'] else [] @@ -109,30 +109,30 @@ class Swig(iw.CustomCommand): binary = self._tool return self.do_run_java(binary, self._path) if self._swig_lang in ['java', 'jni_cpp', 'jni_java'] else self.do_run(binary, self._path) - def _incl_flags(self): - return ['-I' + self.resolve_path(x) for x in self._incl_dirs] - + def _incl_flags(self): + return ['-I' + self.resolve_path(x) for x in self._incl_dirs] + def do_run(self, binary, path): - self.call([binary] + self._flags + [ - '-o', self.resolve_path(common.get(self.output, 0)), - '-outdir', self.resolve_path(self._bindir) - ] + self._incl_flags() + [self.resolve_path(path)]) + self.call([binary] + self._flags + [ + '-o', self.resolve_path(common.get(self.output, 0)), + '-outdir', self.resolve_path(self._bindir) + ] + self._incl_flags() + [self.resolve_path(path)]) def do_run_java(self, binary, path): - import tarfile + import tarfile - outdir = self.resolve_path(self._bindir) + outdir = self.resolve_path(self._bindir) if self._swig_lang != 'jni_cpp': java_srcs_dir = os.path.join(outdir, self._package.replace('.', '/')) if not os.path.exists(java_srcs_dir): os.makedirs(java_srcs_dir) - flags = self._incl_flags() - src = self.resolve_path(path) - with open(src, 'r') as f: - if not re.search(r'(?m)^%module\b', f.read()): - flags += ['-module', os.path.splitext(os.path.basename(src))[0]] - + flags = self._incl_flags() + src = self.resolve_path(path) + with open(src, 'r') as f: + if not re.search(r'(?m)^%module\b', f.read()): + flags += ['-module', os.path.splitext(os.path.basename(src))[0]] + if self._swig_lang == 'jni_cpp': self.call([binary, '-c++', '-o', self._main_out, '-java', '-package', self._package] + flags + [src]) elif self._swig_lang == 'jni_java': @@ -142,11 +142,11 @@ class Swig(iw.CustomCommand): binary, '-c++', '-o', self._main_out, '-outdir', java_srcs_dir, '-java', '-package', self._package, ] + flags + [src]) - + if self._swig_lang in ['jni_java', 'java']: with tarfile.open(os.path.join(outdir, self._out_name), 'a') as tf: tf.add(java_srcs_dir, arcname=self._package.replace('.', '/')) - + if self._swig_lang in ['jni_cpp', 'java']: header = os.path.splitext(self.resolve_path(self._main_out))[0] + '.h' if not os.path.exists(header): |