diff options
author | snowball <snowball@yandex-team.ru> | 2022-02-10 16:46:32 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:32 +0300 |
commit | 83a8efcf3af051e3dd59c00d1d5dafc96412ec1e (patch) | |
tree | 1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /build/scripts | |
parent | 4d57126b1bae3cfd0f4f95c32d1a85ca684ee92c (diff) | |
download | ydb-83a8efcf3af051e3dd59c00d1d5dafc96412ec1e.tar.gz |
Restoring authorship annotation for <snowball@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'build/scripts')
-rw-r--r-- | build/scripts/_fake_src.cpp | 4 | ||||
-rwxr-xr-x | build/scripts/build_mn.py | 484 | ||||
-rwxr-xr-x | build/scripts/build_pln_header.py | 58 | ||||
-rwxr-xr-x | build/scripts/cat.py | 8 | ||||
-rwxr-xr-x | build/scripts/configure_file.py | 104 | ||||
-rw-r--r-- | build/scripts/error.py | 2 | ||||
-rw-r--r-- | build/scripts/fetch_resource.py | 2 | ||||
-rw-r--r-- | build/scripts/fs_tools.py | 4 | ||||
-rwxr-xr-x | build/scripts/mkdir.py | 22 | ||||
-rw-r--r-- | build/scripts/preprocess.py | 4 | ||||
-rw-r--r-- | build/scripts/run_msvc_wine.py | 32 | ||||
-rwxr-xr-x | build/scripts/symlink.py | 58 | ||||
-rwxr-xr-x | build/scripts/touch.py | 10 | ||||
-rw-r--r-- | build/scripts/writer.py | 2 |
14 files changed, 397 insertions, 397 deletions
diff --git a/build/scripts/_fake_src.cpp b/build/scripts/_fake_src.cpp index d99bfa2e4a..139597f9cb 100644 --- a/build/scripts/_fake_src.cpp +++ b/build/scripts/_fake_src.cpp @@ -1,2 +1,2 @@ - - + + diff --git a/build/scripts/build_mn.py b/build/scripts/build_mn.py index f09d935783..5bb03c247c 100755 --- a/build/scripts/build_mn.py +++ b/build/scripts/build_mn.py @@ -1,12 +1,12 @@ -#!/usr/bin/env python -# Ymake MatrixNet support - -import sys -import os -import shutil -import re +#!/usr/bin/env python +# Ymake MatrixNet support + +import sys +import os +import shutil +import re import subprocess - + def get_value(val): dct = val.split('=', 1) @@ -15,41 +15,41 @@ def get_value(val): return '' -class BuildMnBase(object): +class BuildMnBase(object): def Run(self, mninfo, mnname, mnrankingSuffix, mncppPath, check=False, ptr=False, multi=False): - self.mninfo = mninfo - self.mnname = mnname + self.mninfo = mninfo + self.mnname = mnname self.mnrankingSuffix = mnrankingSuffix - self.mncppPath = mncppPath - self.check = check - self.ptr = ptr - self.multi = multi + self.mncppPath = mncppPath + self.check = check + self.ptr = ptr + self.multi = multi dataprefix = "MN_External_" mninfoName = os.path.basename(self.mninfo) data = dataprefix + mnname datasize = data + "Size" - - if self.multi: - if self.ptr: - mntype = "const NMatrixnet::TMnMultiCategPtr" - mnload = "(new NMatrixnet::TMnMultiCateg( {1}, {2}, \"{0}\"))".format(mninfoName, data, datasize) - else: - mntype = "const NMatrixnet::TMnMultiCateg" - mnload = "({1}, {2}, \"{0}\")".format(mninfoName, data, datasize) - else: - if self.ptr: - mntype = "const NMatrixnet::TMnSsePtr" + + if self.multi: + if self.ptr: + mntype = "const NMatrixnet::TMnMultiCategPtr" + mnload = "(new NMatrixnet::TMnMultiCateg( {1}, {2}, \"{0}\"))".format(mninfoName, data, datasize) + else: + mntype = "const NMatrixnet::TMnMultiCateg" + mnload = "({1}, {2}, \"{0}\")".format(mninfoName, data, datasize) + else: + if self.ptr: + mntype = "const NMatrixnet::TMnSsePtr" mnload = "(new NMatrixnet::TMnSseInfo({1}, {2}, \"{0}\"))".format(mninfoName, data, datasize) - else: - mntype = "const NMatrixnet::TMnSseInfo" + else: + mntype = "const NMatrixnet::TMnSseInfo" mnload = "({1}, {2}, \"{0}\")".format(mninfoName, data, datasize) - - if self.check: - self.CheckMn() - - mncpptmpPath = self.mncppPath + ".tmp" - mncpptmp = open(mncpptmpPath, 'w') - + + if self.check: + self.CheckMn() + + mncpptmpPath = self.mncppPath + ".tmp" + mncpptmp = open(mncpptmpPath, 'w') + if self.multi: mncpptmp.write("#include <kernel/matrixnet/mn_multi_categ.h>\n") else: @@ -62,269 +62,269 @@ class BuildMnBase(object): mncpptmp.write(" extern const ui32 {1}{0}Size;\n".format(self.mnname, dataprefix)) mncpptmp.write(" }\n") mncpptmp.write("}\n") - archiverCall = subprocess.Popen([self.archiver, "-q", "-p", "-o", rodatapath, self.mninfo], stdout=None, stderr=subprocess.PIPE) + archiverCall = subprocess.Popen([self.archiver, "-q", "-p", "-o", rodatapath, self.mninfo], stdout=None, stderr=subprocess.PIPE) archiverCall.wait() - mncpptmp.write("extern {0} {1};\n".format(mntype, self.mnname)) - mncpptmp.write("{0} {1}{2};".format(mntype, self.mnname, mnload)) - mncpptmp.close() - shutil.move(mncpptmpPath, self.mncppPath) - - def CheckMn(self): - if not self.fml_unused_tool: - print >>sys.stderr, "fml_unused_tool undefined!" - failed_msg = "fml_unused_tool failed: {0} -A {1} -e -r {2}".format(self.fml_unused_tool, self.SrcRoot, self.mninfo) - assert not subprocess.call([self.fml_unused_tool, "-A", self.SrcRoot, "-e", "-r", self.mninfo]), failed_msg - - -class BuildMn(BuildMnBase): - def Run(self, argv): + mncpptmp.write("extern {0} {1};\n".format(mntype, self.mnname)) + mncpptmp.write("{0} {1}{2};".format(mntype, self.mnname, mnload)) + mncpptmp.close() + shutil.move(mncpptmpPath, self.mncppPath) + + def CheckMn(self): + if not self.fml_unused_tool: + print >>sys.stderr, "fml_unused_tool undefined!" + failed_msg = "fml_unused_tool failed: {0} -A {1} -e -r {2}".format(self.fml_unused_tool, self.SrcRoot, self.mninfo) + assert not subprocess.call([self.fml_unused_tool, "-A", self.SrcRoot, "-e", "-r", self.mninfo]), failed_msg + + +class BuildMn(BuildMnBase): + def Run(self, argv): if len(argv) < 6: print >>sys.stderr, "BuildMn.Run(<ARCADIA_ROOT> <archiver> <mninfo> <mnname> <mnrankingSuffix> <cppOutput> [params...])" - sys.exit(1) - - self.SrcRoot = argv[0] - self.archiver = argv[1] - + sys.exit(1) + + self.SrcRoot = argv[0] + self.archiver = argv[1] + mninfo = argv[2] mnname = argv[3] mnrankingSuffix = argv[4] mncppPath = argv[5] - check = False - ptr = False - multi = False + check = False + ptr = False + multi = False self.fml_unused_tool = '' for param in argv[6:]: - if param == "CHECK": - check = True - elif param == "PTR": - ptr = True - elif param == "MULTI": - multi = True + if param == "CHECK": + check = True + elif param == "PTR": + ptr = True + elif param == "MULTI": + multi = True elif param.startswith('fml_tool='): self.fml_unused_tool = get_value(param) - else: - print >>sys.stdout, "Unknown param: {0}".format(param) - super(BuildMn, self).Run(mninfo, mnname, mnrankingSuffix, mncppPath, check=check, ptr=ptr, multi=multi) - - -class BuildMns(BuildMnBase): + else: + print >>sys.stdout, "Unknown param: {0}".format(param) + super(BuildMn, self).Run(mninfo, mnname, mnrankingSuffix, mncppPath, check=check, ptr=ptr, multi=multi) + + +class BuildMns(BuildMnBase): def InitBase(self, listname, mnrankingSuffix): - self.autogen = '// DO NOT EDIT THIS FILE DIRECTLY, AUTOGENERATED!\n' + self.autogen = '// DO NOT EDIT THIS FILE DIRECTLY, AUTOGENERATED!\n' self.mnrankingSuffix = mnrankingSuffix self.mnlistname = listname + mnrankingSuffix - self.mnlistelem = "const NMatrixnet::TMnSsePtr*" + self.mnlistelem = "const NMatrixnet::TMnSsePtr*" mnlisttype = "TMap< TString, {0} >".format(self.mnlistelem) - self.mnlist = "const {0} {1}".format(mnlisttype, self.mnlistname) - + self.mnlist = "const {0} {1}".format(mnlisttype, self.mnlistname) + self.mnmultilistname = "{0}{1}Multi".format(listname, self.mnrankingSuffix) - self.mnmultilistelem = "const NMatrixnet::TMnMultiCategPtr*" + self.mnmultilistelem = "const NMatrixnet::TMnMultiCategPtr*" mnmultilisttype = "TMap< TString, {0} >".format(self.mnmultilistelem) - self.mnmultilist = "const {0} {1}".format(mnmultilisttype, self.mnmultilistname) - - def InitForAll(self, argv): + self.mnmultilist = "const {0} {1}".format(mnmultilisttype, self.mnmultilistname) + + def InitForAll(self, argv): if len(argv) < 8: print >>sys.stderr, "BuildMns.InitForAll(<ARCADIA_ROOT> <BINDIR> <archiver> <listname> <mnranking_suffix> <hdrfile> <srcfile> <mninfos> [fml_tool=<fml_unused_tool> CHECK])" - sys.exit(1) - - bmns_args = [] - self.check = False + sys.exit(1) + + bmns_args = [] + self.check = False self.fml_unused_tool = '' - for arg in argv: - if arg == "CHECK": - self.check = True + for arg in argv: + if arg == "CHECK": + self.check = True elif arg.startswith('fml_tool='): self.fml_unused_tool = get_value(arg) - else: - bmns_args.append(arg) - - self.SrcRoot = bmns_args[0] - self.BINDIR = bmns_args[1] - self.archiver = bmns_args[2] + else: + bmns_args.append(arg) + + self.SrcRoot = bmns_args[0] + self.BINDIR = bmns_args[1] + self.archiver = bmns_args[2] self.listname = bmns_args[3] self.mnrankingSuffix = get_value(bmns_args[4]) self.hdrfile = bmns_args[5] self.srcfile = bmns_args[6] self.mninfos = bmns_args[7:] - + self.InitBase(self.listname, self.mnrankingSuffix) - - def InitForHeader(self, argv): + + def InitForHeader(self, argv): if len(argv) < 4: print >>sys.stderr, "BuildMns.InitForHeader(<listname> <rankingSuffix> <hdrfile> <mninfos...>)" - sys.exit(1) - - self.listname = argv[0] + sys.exit(1) + + self.listname = argv[0] self.mnrankingSuffix = get_value(argv[1]) self.hdrfile = argv[2] self.mninfos = argv[3:] - + self.InitBase(self.listname, self.mnrankingSuffix) - - def InitForCpp(self, argv): + + def InitForCpp(self, argv): if len(argv) < 5: print >>sys.stderr, "BuildMns.InitForCpp(<listname> <rankingSuffix> <hdrfile> <srcfile> <mninfos...>)" - sys.exit(1) - - self.listname = argv[0] + sys.exit(1) + + self.listname = argv[0] self.mnrankingSuffix = get_value(argv[1]) self.hdrfile = argv[2] self.srcfile = argv[3] self.mninfos = argv[4:] - + self.InitBase(self.listname, self.mnrankingSuffix) - - def InitForFiles(self, argv): + + def InitForFiles(self, argv): if len(argv) < 7: print >>sys.stderr, "BuildMns.InitForFiles(<ARCADIA_ROOT> <BINDIR> <archiver> <fml_unused_tool> <listname> <rankingSuffix> <mninfos...> [CHECK])" - sys.exit(1) - - bmns_args = [] - self.check = False + sys.exit(1) + + bmns_args = [] + self.check = False self.fml_unused_tool = '' - for arg in argv: - if arg == "CHECK": - self.check = True + for arg in argv: + if arg == "CHECK": + self.check = True elif arg.startswith('fml_tool='): self.fml_unused_tool = get_value(arg) - else: - bmns_args.append(arg) - - self.SrcRoot = bmns_args[0] - self.BINDIR = bmns_args[1] - self.archiver = bmns_args[2] + else: + bmns_args.append(arg) + + self.SrcRoot = bmns_args[0] + self.BINDIR = bmns_args[1] + self.archiver = bmns_args[2] self.listname = bmns_args[3] self.mnrankingSuffix = get_value(bmns_args[4]) self.mninfos = bmns_args[5:] - - def BuildMnsHeader(self): - if self.mninfos: - self.mninfos = sorted(set(self.mninfos)) - - tmpHdrPath = self.hdrfile + ".tmp" - tmpHdrFile = open(tmpHdrPath, 'w') - - tmpHdrFile.write(self.autogen) - tmpHdrFile.write("#include <kernel/matrixnet/mn_sse.h>\n") - tmpHdrFile.write("#include <kernel/matrixnet/mn_multi_categ.h>\n\n") - tmpHdrFile.write("extern {0};\n".format(self.mnlist)) - tmpHdrFile.write("extern {0};\n".format(self.mnmultilist)) - - for item in self.mninfos: - mnfilename = os.path.basename(item) - mnfilename, ext = os.path.splitext(mnfilename) - - mnname = re.sub("[^-a-zA-Z0-9_]", "_", mnfilename) - - if ext == ".info": + + def BuildMnsHeader(self): + if self.mninfos: + self.mninfos = sorted(set(self.mninfos)) + + tmpHdrPath = self.hdrfile + ".tmp" + tmpHdrFile = open(tmpHdrPath, 'w') + + tmpHdrFile.write(self.autogen) + tmpHdrFile.write("#include <kernel/matrixnet/mn_sse.h>\n") + tmpHdrFile.write("#include <kernel/matrixnet/mn_multi_categ.h>\n\n") + tmpHdrFile.write("extern {0};\n".format(self.mnlist)) + tmpHdrFile.write("extern {0};\n".format(self.mnmultilist)) + + for item in self.mninfos: + mnfilename = os.path.basename(item) + mnfilename, ext = os.path.splitext(mnfilename) + + mnname = re.sub("[^-a-zA-Z0-9_]", "_", mnfilename) + + if ext == ".info": mnname = "staticMn{0}{1}Ptr".format(self.mnrankingSuffix, mnname) - tmpHdrFile.write("extern const NMatrixnet::TMnSsePtr {0};\n".format(mnname)) - elif ext == ".mnmc": + tmpHdrFile.write("extern const NMatrixnet::TMnSsePtr {0};\n".format(mnname)) + elif ext == ".mnmc": mnname = "staticMnMulti{0}{1}Ptr".format(self.mnrankingSuffix, mnname) - tmpHdrFile.write("extern const NMatrixnet::TMnMultiCategPtr {0};\n".format(mnname)) - - tmpHdrFile.close() - shutil.move(tmpHdrPath, self.hdrfile) - - def BuildMnFiles(self): - for item in self.mninfos: - mnfilename = os.path.basename(item) - mnfilename, ext = os.path.splitext(mnfilename) - - mnname = re.sub("[^-a-zA-Z0-9_]", "_", mnfilename) - - if ext == ".info": + tmpHdrFile.write("extern const NMatrixnet::TMnMultiCategPtr {0};\n".format(mnname)) + + tmpHdrFile.close() + shutil.move(tmpHdrPath, self.hdrfile) + + def BuildMnFiles(self): + for item in self.mninfos: + mnfilename = os.path.basename(item) + mnfilename, ext = os.path.splitext(mnfilename) + + mnname = re.sub("[^-a-zA-Z0-9_]", "_", mnfilename) + + if ext == ".info": mnname = "staticMn{0}{1}Ptr".format(self.mnrankingSuffix, mnname) - super(BuildMns, self).Run(item, mnname, self.mnrankingSuffix, self.BINDIR + "/mn.{0}.cpp".format(mnname), check=self.check, ptr=True, multi=False) - elif ext == ".mnmc": + super(BuildMns, self).Run(item, mnname, self.mnrankingSuffix, self.BINDIR + "/mn.{0}.cpp".format(mnname), check=self.check, ptr=True, multi=False) + elif ext == ".mnmc": mnname = "staticMnMulti{0}{1}Ptr".format(self.mnrankingSuffix, mnname) - # BUILD_MN_PTR_MULTI - super(BuildMns, self).Run(item, mnname, self.mnrankingSuffix, self.BINDIR + "/mnmulti.{0}.cpp".format(mnname), check=False, ptr=True, multi=True) - - def BuildMnsCpp(self): - if self.mninfos: - self.mninfos = sorted(set(self.mninfos)) - - tmpSrcPath = self.srcfile + ".tmp" - tmpSrcFile = open(tmpSrcPath, 'w') - hdrrel = os.path.basename(self.hdrfile) - - mnnames = [] - mnmultinames = [] - for item in self.mninfos: - mnfilename = os.path.basename(item) - mnfilename, ext = os.path.splitext(mnfilename) - - if ext == ".info": - mnnames.append(mnfilename) - elif ext == ".mnmc": + # BUILD_MN_PTR_MULTI + super(BuildMns, self).Run(item, mnname, self.mnrankingSuffix, self.BINDIR + "/mnmulti.{0}.cpp".format(mnname), check=False, ptr=True, multi=True) + + def BuildMnsCpp(self): + if self.mninfos: + self.mninfos = sorted(set(self.mninfos)) + + tmpSrcPath = self.srcfile + ".tmp" + tmpSrcFile = open(tmpSrcPath, 'w') + hdrrel = os.path.basename(self.hdrfile) + + mnnames = [] + mnmultinames = [] + for item in self.mninfos: + mnfilename = os.path.basename(item) + mnfilename, ext = os.path.splitext(mnfilename) + + if ext == ".info": + mnnames.append(mnfilename) + elif ext == ".mnmc": mnmultinames.append(mnfilename) - - tmpSrcFile.write(self.autogen) - tmpSrcFile.write("#include \"{0}\"\n\n".format(hdrrel)) - - if mnnames: - mndata = self.mnlistname + "_data" + + tmpSrcFile.write(self.autogen) + tmpSrcFile.write("#include \"{0}\"\n\n".format(hdrrel)) + + if mnnames: + mndata = self.mnlistname + "_data" tmpSrcFile.write("static const std::pair< TString, {0} > {1}[] = {{\n".format(self.mnlistelem, mndata)) - for item in mnnames: - mnname = re.sub("[^-a-zA-Z0-9_]", "_", item) + for item in mnnames: + mnname = re.sub("[^-a-zA-Z0-9_]", "_", item) tmpSrcFile.write(" std::make_pair(TString(\"{0}\"), &staticMn{1}{2}Ptr),\n".format(item, self.mnrankingSuffix, mnname)) - tmpSrcFile.write("};\n") - tmpSrcFile.write("{0}({1},{1} + sizeof({1}) / sizeof({1}[0]));\n\n".format(self.mnlist, mndata)) - else: - tmpSrcFile.write("{0};\n\n".format(self.mnlist)) - - if mnmultinames: - mnmultidata = self.mnmultilistname + "_data" + tmpSrcFile.write("};\n") + tmpSrcFile.write("{0}({1},{1} + sizeof({1}) / sizeof({1}[0]));\n\n".format(self.mnlist, mndata)) + else: + tmpSrcFile.write("{0};\n\n".format(self.mnlist)) + + if mnmultinames: + mnmultidata = self.mnmultilistname + "_data" tmpSrcFile.write("static const std::pair< TString, {0} > {1}[] = {{\n".format(self.mnmultilistelem, mnmultidata)) - for item in mnmultinames: - mnname = re.sub("[^-a-zA-Z0-9_]", "_", item) + for item in mnmultinames: + mnname = re.sub("[^-a-zA-Z0-9_]", "_", item) tmpSrcFile.write(" std::make_pair(TString(\"{0}\"), &staticMnMulti{1}{2}Ptr),\n".format(item, self.mnrankingSuffix, mnname)) - tmpSrcFile.write("};\n") - tmpSrcFile.write("{0}({1},{1} + sizeof({1}) / sizeof({1}[0]));\n".format(self.mnmultilist, mnmultidata)) - else: - tmpSrcFile.write("{0};\n".format(self.mnmultilist)) - - tmpSrcFile.close() - shutil.move(tmpSrcPath, self.srcfile) - - -def BuildMnsAllF(argv): - bldMns = BuildMns() - bldMns.InitForAll(argv) - bldMns.BuildMnsCpp() - bldMns.BuildMnsHeader() - bldMns.BuildMnFiles() - - -def BuildMnsCppF(argv): - bldMns = BuildMns() - bldMns.InitForCpp(argv) - bldMns.BuildMnsCpp() - - -def BuildMnsHeaderF(argv): - bldMns = BuildMns() - bldMns.InitForHeader(argv) - bldMns.BuildMnsHeader() - - -def BuildMnsFilesF(argv): - bldMns = BuildMns() - bldMns.InitForFiles(argv) - bldMns.BuildMnFiles() - - -def BuildMnF(argv): - bldMn = BuildMn() - bldMn.Run(argv) - - -if __name__ == '__main__': - if len(sys.argv) < 2: + tmpSrcFile.write("};\n") + tmpSrcFile.write("{0}({1},{1} + sizeof({1}) / sizeof({1}[0]));\n".format(self.mnmultilist, mnmultidata)) + else: + tmpSrcFile.write("{0};\n".format(self.mnmultilist)) + + tmpSrcFile.close() + shutil.move(tmpSrcPath, self.srcfile) + + +def BuildMnsAllF(argv): + bldMns = BuildMns() + bldMns.InitForAll(argv) + bldMns.BuildMnsCpp() + bldMns.BuildMnsHeader() + bldMns.BuildMnFiles() + + +def BuildMnsCppF(argv): + bldMns = BuildMns() + bldMns.InitForCpp(argv) + bldMns.BuildMnsCpp() + + +def BuildMnsHeaderF(argv): + bldMns = BuildMns() + bldMns.InitForHeader(argv) + bldMns.BuildMnsHeader() + + +def BuildMnsFilesF(argv): + bldMns = BuildMns() + bldMns.InitForFiles(argv) + bldMns.BuildMnFiles() + + +def BuildMnF(argv): + bldMn = BuildMn() + bldMn.Run(argv) + + +if __name__ == '__main__': + if len(sys.argv) < 2: print >>sys.stderr, "Usage: build_mn.py <funcName> <args...>" - sys.exit(1) - - if (sys.argv[2:]): - globals()[sys.argv[1]](sys.argv[2:]) - else: - globals()[sys.argv[1]]() + sys.exit(1) + + if (sys.argv[2:]): + globals()[sys.argv[1]](sys.argv[2:]) + else: + globals()[sys.argv[1]]() diff --git a/build/scripts/build_pln_header.py b/build/scripts/build_pln_header.py index 413286a11e..c73693f444 100755 --- a/build/scripts/build_pln_header.py +++ b/build/scripts/build_pln_header.py @@ -1,35 +1,35 @@ -#!/usr/bin/env python - -import sys -import os - - -def BuildPlnHeader(): - if len(sys.argv) < 2: +#!/usr/bin/env python + +import sys +import os + + +def BuildPlnHeader(): + if len(sys.argv) < 2: print >>sys.stderr, "Usage: build_pln_header.py <absolute/path/to/OutFile>" - sys.exit(1) - - print >>sys.stdout, "Build Pln Header..." - outPath = sys.argv[1] - tmpPath = outPath + '.tmp' - tmpFile = open(tmpPath, 'w') - + sys.exit(1) + + print >>sys.stdout, "Build Pln Header..." + outPath = sys.argv[1] + tmpPath = outPath + '.tmp' + tmpFile = open(tmpPath, 'w') + tmpFile.write('#include <library/cpp/sse/sse.h>\n') - tmpFile.write('#include <kernel/relevfml/relev_fml.h>\n') - for path in sys.argv[2:]: - name = os.path.basename(path).split(".")[0] # name without extensions - tmpFile.write('\nextern SRelevanceFormula fml{0};\n'.format(name)) - tmpFile.write('float {0}(const float* f);\n'.format(name)) - tmpFile.write('void {0}SSE(const float* const* factors, float* result);\n'.format(name)) - tmpFile.close() - try: + tmpFile.write('#include <kernel/relevfml/relev_fml.h>\n') + for path in sys.argv[2:]: + name = os.path.basename(path).split(".")[0] # name without extensions + tmpFile.write('\nextern SRelevanceFormula fml{0};\n'.format(name)) + tmpFile.write('float {0}(const float* f);\n'.format(name)) + tmpFile.write('void {0}SSE(const float* const* factors, float* result);\n'.format(name)) + tmpFile.close() + try: os.remove(outPath) except: pass try: - os.rename(tmpPath, outPath) - except: - print >>sys.stdout, 'Error: Failed to rename ' + tmpPath + ' to ' + outPath - -if __name__ == '__main__': - BuildPlnHeader() + os.rename(tmpPath, outPath) + except: + print >>sys.stdout, 'Error: Failed to rename ' + tmpPath + ' to ' + outPath + +if __name__ == '__main__': + BuildPlnHeader() diff --git a/build/scripts/cat.py b/build/scripts/cat.py index 7f87ca89be..0c3f73d96f 100755 --- a/build/scripts/cat.py +++ b/build/scripts/cat.py @@ -1,8 +1,8 @@ -#!/usr/bin/env python -import sys -from shutil import copyfileobj as copy +#!/usr/bin/env python +import sys +from shutil import copyfileobj as copy import os.path - + if __name__ == '__main__': for filename in sys.argv[1:] or ["-"]: if filename == "-": diff --git a/build/scripts/configure_file.py b/build/scripts/configure_file.py index 14eec7fa57..1873ed70eb 100755 --- a/build/scripts/configure_file.py +++ b/build/scripts/configure_file.py @@ -1,59 +1,59 @@ -#!/usr/bin/env python2.7 - -import sys -import os.path +#!/usr/bin/env python2.7 + +import sys +import os.path import re - -cmakeDef01 = "#cmakedefine01" -cmakeDef = "#cmakedefine" - - -def replaceLine(l, varDict, define): - words = l.split() - if words: - if words[0] == cmakeDef: - sPos = l.find(cmakeDef) - ePos = sPos + len(cmakeDef) - l = l[:sPos] + define + l[ePos:] + '\n' - if words[0] == cmakeDef01: - var = words[1] - cmakeValue = varDict.get(var) - if cmakeValue == 'yes': - val = '1' - else: - val = '0' - sPos = l.find(cmakeDef01) - ePos = l.find(var) + len(var) - l = l[:sPos] + define + ' ' + var + ' ' + val + l[ePos + 1:] + '\n' - + +cmakeDef01 = "#cmakedefine01" +cmakeDef = "#cmakedefine" + + +def replaceLine(l, varDict, define): + words = l.split() + if words: + if words[0] == cmakeDef: + sPos = l.find(cmakeDef) + ePos = sPos + len(cmakeDef) + l = l[:sPos] + define + l[ePos:] + '\n' + if words[0] == cmakeDef01: + var = words[1] + cmakeValue = varDict.get(var) + if cmakeValue == 'yes': + val = '1' + else: + val = '0' + sPos = l.find(cmakeDef01) + ePos = l.find(var) + len(var) + l = l[:sPos] + define + ' ' + var + ' ' + val + l[ePos + 1:] + '\n' + finder = re.compile(".*?(@[a-zA-Z0-9_]+@).*") - while True: + while True: re_result = finder.match(l) if not re_result: - return l + return l key = re_result.group(1)[1:-1] l = l[:re_result.start(1)] + varDict.get(key, '') + l[re_result.end(1):] - - -def main(inputPath, outputPath, varDict): - define = '#define' if os.path.splitext(outputPath)[1] != '.asm' else '%define' - with open(outputPath, 'w') as output: - with open(inputPath, 'r') as input: - for l in input: - output.write(replaceLine(l, varDict, define)) - - -def usage(): - print "usage: configure_file.py inputPath outputPath key1=value1 ..." - exit(1) - - -if __name__ == "__main__": - if len(sys.argv) < 3: - usage() - varDict = {} - for x in sys.argv[3:]: + + +def main(inputPath, outputPath, varDict): + define = '#define' if os.path.splitext(outputPath)[1] != '.asm' else '%define' + with open(outputPath, 'w') as output: + with open(inputPath, 'r') as input: + for l in input: + output.write(replaceLine(l, varDict, define)) + + +def usage(): + print "usage: configure_file.py inputPath outputPath key1=value1 ..." + exit(1) + + +if __name__ == "__main__": + if len(sys.argv) < 3: + usage() + varDict = {} + for x in sys.argv[3:]: key, value = str(x).split('=', 1) - varDict[key] = value - - main(sys.argv[1], sys.argv[2], varDict) + varDict[key] = value + + main(sys.argv[1], sys.argv[2], varDict) diff --git a/build/scripts/error.py b/build/scripts/error.py index b36d1d9cda..f7d8ecb2cc 100644 --- a/build/scripts/error.py +++ b/build/scripts/error.py @@ -22,7 +22,7 @@ class ExitCodes(object): TEST_FAILED = 10 COMPILATION_FAILED = 11 INFRASTRUCTURE_ERROR = 12 - NOT_RETRIABLE_ERROR = 13 + NOT_RETRIABLE_ERROR = 13 YT_STORE_FETCH_ERROR = 14 diff --git a/build/scripts/fetch_resource.py b/build/scripts/fetch_resource.py index 0808b68ca3..d5af311e5d 100644 --- a/build/scripts/fetch_resource.py +++ b/build/scripts/fetch_resource.py @@ -30,7 +30,7 @@ def fetch_resource(id_): try: return fetch(u) - except Exception: + except Exception: continue raise Exception('Cannot fetch resource {}'.format(id_)) diff --git a/build/scripts/fs_tools.py b/build/scripts/fs_tools.py index 3c286d0a46..dec4c349c8 100644 --- a/build/scripts/fs_tools.py +++ b/build/scripts/fs_tools.py @@ -28,7 +28,7 @@ if __name__ == '__main__': args = pcf.get_args(sys.argv[2:]) if mode == 'copy': - shutil.copy(args[0], args[1]) + shutil.copy(args[0], args[1]) elif mode == 'copy_tree_no_link': dst = args[1] shutil.copytree(args[0], dst, ignore=lambda dirname, names: [n for n in names if os.path.islink(os.path.join(dirname, n))]) @@ -45,7 +45,7 @@ if __name__ == '__main__': os.makedirs(os.path.dirname(d)) except OSError: pass - shutil.copy(s, d) + shutil.copy(s, d) elif mode == 'copy_all_files': src = args[0] dst = args[1] diff --git a/build/scripts/mkdir.py b/build/scripts/mkdir.py index aa26988bed..a326b29300 100755 --- a/build/scripts/mkdir.py +++ b/build/scripts/mkdir.py @@ -1,12 +1,12 @@ -#!/usr/bin/env python -import os -import sys - - +#!/usr/bin/env python +import os +import sys + + def mkdir_p(directory): - if not os.path.exists(directory): - os.makedirs(directory) - -if __name__ == "__main__": - for directory in sys.argv[1:]: - mkdir_p(directory) + if not os.path.exists(directory): + os.makedirs(directory) + +if __name__ == "__main__": + for directory in sys.argv[1:]: + mkdir_p(directory) diff --git a/build/scripts/preprocess.py b/build/scripts/preprocess.py index f720ff13d7..4657bef732 100644 --- a/build/scripts/preprocess.py +++ b/build/scripts/preprocess.py @@ -1,5 +1,5 @@ -import sys -import os +import sys +import os def load_file(p): diff --git a/build/scripts/run_msvc_wine.py b/build/scripts/run_msvc_wine.py index e68a381b01..439d1f8831 100644 --- a/build/scripts/run_msvc_wine.py +++ b/build/scripts/run_msvc_wine.py @@ -53,7 +53,7 @@ def subst_path(l): def call_wine_cmd_once(wine, cmd, env, mode): - p = run_subprocess(wine + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=env, close_fds=True, shell=False) + p = run_subprocess(wine + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=env, close_fds=True, shell=False) output = find_cmd_out(cmd) error = None @@ -71,20 +71,20 @@ def call_wine_cmd_once(wine, cmd, env, mode): # print >>sys.stderr, cmd, env, wine - stdout_and_stderr, _ = p.communicate() + stdout_and_stderr, _ = p.communicate() - return_code = p.returncode - if not stdout_and_stderr: - if return_code != 0: + return_code = p.returncode + if not stdout_and_stderr: + if return_code != 0: raise Exception('wine did something strange') - return return_code - elif ' : fatal error ' in stdout_and_stderr: - return_code = 1 - elif ' : error ' in stdout_and_stderr: - return_code = 2 + return return_code + elif ' : fatal error ' in stdout_and_stderr: + return_code = 1 + elif ' : error ' in stdout_and_stderr: + return_code = 2 - lines = [x.strip() for x in stdout_and_stderr.split('\n')] + lines = [x.strip() for x in stdout_and_stderr.split('\n')] prefixes = [ 'Microsoft (R)', @@ -135,12 +135,12 @@ def call_wine_cmd_once(wine, cmd, env, mode): if good_line(l): yield subst_path(l.strip()) - stdout_and_stderr = '\n'.join(filter_lines()).strip() + stdout_and_stderr = '\n'.join(filter_lines()).strip() - if stdout_and_stderr: - print >>sys.stderr, stdout_and_stderr + if stdout_and_stderr: + print >>sys.stderr, stdout_and_stderr - return return_code + return return_code def prepare_vc(fr, to): @@ -471,7 +471,7 @@ def run_main(): } slave_cmd = [sys.executable, sys.argv[0], wine, 'slave', json.dumps(args)] - p = run_subprocess(slave_cmd, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, shell=False) + p = run_subprocess(slave_cmd, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, shell=False) out, _ = p.communicate() return p.wait(), out diff --git a/build/scripts/symlink.py b/build/scripts/symlink.py index e8f90c366e..17bc8447f1 100755 --- a/build/scripts/symlink.py +++ b/build/scripts/symlink.py @@ -1,29 +1,29 @@ -#!/usr/bin/env python - -import sys -import os -import platform -from subprocess import call - - -def symlink(): - if len(sys.argv) < 3: - print >>sys.stderr, "Usage: symlink.py <source> <target>" - sys.exit(1) - - source = sys.argv[1] - target = sys.argv[2] - - print "Making a symbolic link from {0} to {1}".format(source, target) - - sysName = platform.system() - if sysName == "Windows": # and not os.path.exists(target) - if os.path.isdir(source): - call(["mklink", "/D", target, source], shell=True) - else: - call(["mklink", target, source], shell=True) - else: - call(["ln", "-f", "-s", "-n", source, target]) - -if __name__ == '__main__': - symlink() +#!/usr/bin/env python + +import sys +import os +import platform +from subprocess import call + + +def symlink(): + if len(sys.argv) < 3: + print >>sys.stderr, "Usage: symlink.py <source> <target>" + sys.exit(1) + + source = sys.argv[1] + target = sys.argv[2] + + print "Making a symbolic link from {0} to {1}".format(source, target) + + sysName = platform.system() + if sysName == "Windows": # and not os.path.exists(target) + if os.path.isdir(source): + call(["mklink", "/D", target, source], shell=True) + else: + call(["mklink", target, source], shell=True) + else: + call(["ln", "-f", "-s", "-n", source, target]) + +if __name__ == '__main__': + symlink() diff --git a/build/scripts/touch.py b/build/scripts/touch.py index 240047ae11..e01ba7f86b 100755 --- a/build/scripts/touch.py +++ b/build/scripts/touch.py @@ -5,14 +5,14 @@ import os import sys import time - + def main(argv): - parser = optparse.OptionParser(add_help_option=False) + parser = optparse.OptionParser(add_help_option=False) parser.disable_interspersed_args() - parser.add_option('-?', '--help', dest='help', - action='store_true', default=None, help='print help') - parser.add_option('-t', dest='t', action='store', default=None) + parser.add_option('-?', '--help', dest='help', + action='store_true', default=None, help='print help') + parser.add_option('-t', dest='t', action='store', default=None) opts, argv_rest = parser.parse_args(argv) if getattr(opts, 'help', False): diff --git a/build/scripts/writer.py b/build/scripts/writer.py index 6006e60f62..21bb3006e5 100644 --- a/build/scripts/writer.py +++ b/build/scripts/writer.py @@ -16,7 +16,7 @@ def parse_args(): parser.add_argument('-P', '--path-list', action='store_true', default=False) return parser.parse_args(args) - + def smart_shell_quote(v): if v is None: return None |