aboutsummaryrefslogtreecommitdiffstats
path: root/build/plugins/swig.py
diff options
context:
space:
mode:
authorkakabba <kakabba@yandex-team.ru>2022-02-10 16:46:04 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:04 +0300
commit9c914f41ba5e9f9365f404e892197553ac23809e (patch)
tree1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /build/plugins/swig.py
parentc8e3995898c443e78266f7420aac5fb3da15d413 (diff)
downloadydb-9c914f41ba5e9f9365f404e892197553ac23809e.tar.gz
Restoring authorship annotation for <kakabba@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'build/plugins/swig.py')
-rw-r--r--build/plugins/swig.py98
1 files changed, 49 insertions, 49 deletions
diff --git a/build/plugins/swig.py b/build/plugins/swig.py
index 7b7e3e549d..32a37204a6 100644
--- a/build/plugins/swig.py
+++ b/build/plugins/swig.py
@@ -1,31 +1,31 @@
-import os
+import os
import posixpath
import re
-
-import _import_wrapper as iw
-import _common as common
-
-
+
+import _import_wrapper as iw
+import _common as common
+
+
def init():
iw.addrule('swg', Swig)
-class Swig(iw.CustomCommand):
- def __init__(self, path, unit):
+class Swig(iw.CustomCommand):
+ def __init__(self, path, unit):
self._tool = unit.get('SWIG_TOOL')
self._library_dir = unit.get('SWIG_LIBRARY') or 'contrib/tools/swig/Lib'
self._local_swig = unit.get('USE_LOCAL_SWIG') == "yes"
- self._path = path
+ self._path = path
self._flags = ['-cpperraswarn']
-
- self._bindir = common.tobuilddir(unit.path())
- self._input_name = common.stripext(os.path.basename(self._path))
-
- relpath = os.path.relpath(os.path.dirname(self._path), unit.path())
-
+
+ self._bindir = common.tobuilddir(unit.path())
+ self._input_name = common.stripext(os.path.basename(self._path))
+
+ relpath = os.path.relpath(os.path.dirname(self._path), unit.path())
+
self._swig_lang = unit.get('SWIG_LANG')
-
+
if self._swig_lang != 'jni_java':
self._main_out = os.path.join(
self._bindir,
@@ -50,57 +50,57 @@ class Swig(iw.CustomCommand):
]
self._incl_dirs = ['$S', '$B'] + [posixpath.join('$S', d) for d in incl_dirs]
- modname = unit.get('REALPRJNAME')
- self._flags.extend(['-module', modname])
-
+ modname = unit.get('REALPRJNAME')
+ self._flags.extend(['-module', modname])
+
if not self._local_swig:
unit.onaddincl(incl_dirs)
-
+
if self._swig_lang == 'python':
- self._out_name = modname + '.py'
- self._flags.extend(['-interface', unit.get('MODULE_PREFIX') + modname])
-
+ self._out_name = modname + '.py'
+ self._flags.extend(['-interface', unit.get('MODULE_PREFIX') + modname])
+
if self._swig_lang == 'perl':
- self._out_name = modname + '.pm'
- self._flags.append('-shadow')
+ self._out_name = modname + '.pm'
+ self._flags.append('-shadow')
unit.onpeerdir(['build/platform/perl'])
-
+
if self._swig_lang in ['jni_cpp', 'java']:
self._out_header = os.path.splitext(self._main_out)[0] + '.h'
if (not unit.get('USE_SYSTEM_JDK')) and (unit.get('OS_ANDROID') != "yes"):
unit.onpeerdir(['contrib/libs/jdk'])
-
+
self._package = 'ru.yandex.' + os.path.dirname(self._path).replace('$S/', '').replace('$B/', '').replace('/', '.').replace('-', '_')
if self._swig_lang in ['jni_java', 'java']:
self._out_name = os.path.splitext(os.path.basename(self._path))[0] + '.jsrc'
elif self._swig_lang != 'jni_cpp':
self._flags.append('-' + self._swig_lang)
-
- def descr(self):
- return 'SW', self._path, 'yellow'
-
- def flags(self):
- return self._flags
-
- def tools(self):
+
+ def descr(self):
+ return 'SW', self._path, 'yellow'
+
+ def flags(self):
+ return self._flags
+
+ def tools(self):
return ['contrib/tools/swig'] if not self._tool else []
-
- def input(self):
- return [
- (self._path, [])
- ]
-
- def output(self):
+
+ def input(self):
+ return [
+ (self._path, [])
+ ]
+
+ def output(self):
if self._swig_lang == 'jni_java':
return [(common.join_intl_paths(self._bindir, self._out_name), [])]
elif self._swig_lang == 'jni_cpp':
return [(self._main_out, []), (self._out_header, [])]
- return [
- (self._main_out, []),
+ 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 [])
-
+
def output_includes(self):
return [(self._out_header, [])] if self._swig_lang in ['java', 'jni_cpp'] else []
@@ -108,19 +108,19 @@ class Swig(iw.CustomCommand):
if self._local_swig:
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 do_run(self, binary, path):
+ 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)])
-
+
def do_run_java(self, binary, path):
import tarfile
-
+
outdir = self.resolve_path(self._bindir)
if self._swig_lang != 'jni_cpp':
java_srcs_dir = os.path.join(outdir, self._package.replace('.', '/'))