diff options
author | dvshkurko <dvshkurko@yandex-team.ru> | 2022-02-10 16:45:51 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:51 +0300 |
commit | 321ee9bce31ec6e238be26dbcbe539cffa2c3309 (patch) | |
tree | 14407a2757cbf29eb97e266b7f07e851f971000c /build/scripts | |
parent | 2f6ca198245aeffd5e2d82b65927c2465b68b4f5 (diff) | |
download | ydb-321ee9bce31ec6e238be26dbcbe539cffa2c3309.tar.gz |
Restoring authorship annotation for <dvshkurko@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'build/scripts')
-rw-r--r-- | build/scripts/c_templates/svn_interface.c | 314 | ||||
-rw-r--r-- | build/scripts/c_templates/svnversion.h | 78 | ||||
-rw-r--r-- | build/scripts/c_templates/ya.make | 10 | ||||
-rw-r--r-- | build/scripts/compile_java.py | 18 | ||||
-rwxr-xr-x | build/scripts/fetch_from.py | 62 | ||||
-rw-r--r-- | build/scripts/fetch_from_external.py | 2 | ||||
-rw-r--r-- | build/scripts/fetch_from_mds.py | 2 | ||||
-rwxr-xr-x | build/scripts/fetch_from_sandbox.py | 158 | ||||
-rw-r--r-- | build/scripts/go_tool.py | 12 | ||||
-rw-r--r-- | build/scripts/link_exe.py | 36 | ||||
-rw-r--r-- | build/scripts/run_msvc_wine.py | 6 | ||||
-rw-r--r-- | build/scripts/vcs_info.py | 500 | ||||
-rw-r--r-- | build/scripts/ya.make | 4 |
13 files changed, 601 insertions, 601 deletions
diff --git a/build/scripts/c_templates/svn_interface.c b/build/scripts/c_templates/svn_interface.c index d8bdd1a70d..45cb2b09b5 100644 --- a/build/scripts/c_templates/svn_interface.c +++ b/build/scripts/c_templates/svn_interface.c @@ -1,79 +1,79 @@ -// Used indirectly. See build/scripts/vcs_info.py -// ya-bin dump vcs-info > vcs.json +// Used indirectly. See build/scripts/vcs_info.py +// ya-bin dump vcs-info > vcs.json // python build/scripts/vcs_info.py vcs.json out.c build/scripts/c_templates/svn_interface.c <any_prefix>library/cpp/svnversion<any_suffix> - - -#include "build/scripts/c_templates/svnversion.h" - -#define STR1(x) #x -#define STR2(x) STR1(x) - -const char* GetProgramSvnVersion() { -#if defined(REVISION) -// for package systems generating from svn export but providing REVISION macro -#define STRREVISION STR2(REVISION) -#define REVISIONINFO "r" STRREVISION -#if defined(PROGRAM_VERSION) - return PROGRAM_VERSION "\n\n" REVISIONINFO; -#else - return REVISIONINFO " "__DATE__ - " "__TIME__; -#endif -#elif defined(PROGRAM_VERSION) - return PROGRAM_VERSION; -#else - return "No program version found"; -#endif -} - -const char* GetArcadiaSourcePath() { -#if defined(ARCADIA_SOURCE_PATH) - return ARCADIA_SOURCE_PATH; -#else - return ""; -#endif -} - -const char* GetArcadiaSourceUrl() { -#if defined(ARCADIA_SOURCE_URL) - return ARCADIA_SOURCE_URL; -#else - return ""; -#endif -} - -int GetArcadiaLastChangeNum() { -#if defined(ARCADIA_SOURCE_LAST_CHANGE) - return ARCADIA_SOURCE_LAST_CHANGE; -#else - return 0; -#endif -} - -const char* GetArcadiaLastChange() { -#if defined(ARCADIA_SOURCE_LAST_CHANGE) - return STR2(ARCADIA_SOURCE_LAST_CHANGE); -#else - return ""; -#endif -} - -const char* GetArcadiaLastAuthor() { -#if defined(ARCADIA_SOURCE_LAST_AUTHOR) - return ARCADIA_SOURCE_LAST_AUTHOR; -#else - return ""; -#endif -} - -int GetProgramSvnRevision() { -#if defined(ARCADIA_SOURCE_REVISION) - return ARCADIA_SOURCE_REVISION; -#else - return 0; -#endif -} - + + +#include "build/scripts/c_templates/svnversion.h" + +#define STR1(x) #x +#define STR2(x) STR1(x) + +const char* GetProgramSvnVersion() { +#if defined(REVISION) +// for package systems generating from svn export but providing REVISION macro +#define STRREVISION STR2(REVISION) +#define REVISIONINFO "r" STRREVISION +#if defined(PROGRAM_VERSION) + return PROGRAM_VERSION "\n\n" REVISIONINFO; +#else + return REVISIONINFO " "__DATE__ + " "__TIME__; +#endif +#elif defined(PROGRAM_VERSION) + return PROGRAM_VERSION; +#else + return "No program version found"; +#endif +} + +const char* GetArcadiaSourcePath() { +#if defined(ARCADIA_SOURCE_PATH) + return ARCADIA_SOURCE_PATH; +#else + return ""; +#endif +} + +const char* GetArcadiaSourceUrl() { +#if defined(ARCADIA_SOURCE_URL) + return ARCADIA_SOURCE_URL; +#else + return ""; +#endif +} + +int GetArcadiaLastChangeNum() { +#if defined(ARCADIA_SOURCE_LAST_CHANGE) + return ARCADIA_SOURCE_LAST_CHANGE; +#else + return 0; +#endif +} + +const char* GetArcadiaLastChange() { +#if defined(ARCADIA_SOURCE_LAST_CHANGE) + return STR2(ARCADIA_SOURCE_LAST_CHANGE); +#else + return ""; +#endif +} + +const char* GetArcadiaLastAuthor() { +#if defined(ARCADIA_SOURCE_LAST_AUTHOR) + return ARCADIA_SOURCE_LAST_AUTHOR; +#else + return ""; +#endif +} + +int GetProgramSvnRevision() { +#if defined(ARCADIA_SOURCE_REVISION) + return ARCADIA_SOURCE_REVISION; +#else + return 0; +#endif +} + const char* GetVCSDirty() { #if defined(DIRTY) @@ -83,33 +83,33 @@ const char* GetVCSDirty() #endif } -const char* GetProgramHash() { -#if defined(ARCADIA_SOURCE_HG_HASH) - return ARCADIA_SOURCE_HG_HASH; -#else - return ""; -#endif -} - -const char* GetProgramCommitId() { -#if defined(ARCADIA_SOURCE_REVISION) - if (ARCADIA_SOURCE_REVISION <= 0) { - return GetProgramHash(); - } - return STR2(ARCADIA_SOURCE_REVISION); -#else - return GetProgramHash(); -#endif -} - -const char* GetProgramScmData() { -#if defined(SCM_DATA) - return SCM_DATA; -#else - return ""; -#endif -} - +const char* GetProgramHash() { +#if defined(ARCADIA_SOURCE_HG_HASH) + return ARCADIA_SOURCE_HG_HASH; +#else + return ""; +#endif +} + +const char* GetProgramCommitId() { +#if defined(ARCADIA_SOURCE_REVISION) + if (ARCADIA_SOURCE_REVISION <= 0) { + return GetProgramHash(); + } + return STR2(ARCADIA_SOURCE_REVISION); +#else + return GetProgramHash(); +#endif +} + +const char* GetProgramScmData() { +#if defined(SCM_DATA) + return SCM_DATA; +#else + return ""; +#endif +} + const char* GetProgramShortVersionData() { #if defined(SVN_REVISION) && defined(SVN_TIME) return STR2(SVN_REVISION) " (" SVN_TIME ")"; @@ -118,30 +118,30 @@ const char* GetProgramShortVersionData() { #endif } -const char* GetProgramBuildUser() { -#if defined(BUILD_USER) - return BUILD_USER; -#else - return ""; -#endif -} - -const char* GetProgramBuildHost() { -#if defined(BUILD_HOST) - return BUILD_HOST; -#else - return ""; -#endif -} - -const char* GetProgramBuildDate() { -#if defined(BUILD_DATE) - return BUILD_DATE; -#else - return ""; -#endif -} - +const char* GetProgramBuildUser() { +#if defined(BUILD_USER) + return BUILD_USER; +#else + return ""; +#endif +} + +const char* GetProgramBuildHost() { +#if defined(BUILD_HOST) + return BUILD_HOST; +#else + return ""; +#endif +} + +const char* GetProgramBuildDate() { +#if defined(BUILD_DATE) + return BUILD_DATE; +#else + return ""; +#endif +} + int GetProgramBuildTimestamp() { #if defined(BUILD_TIMESTAMP) return BUILD_TIMESTAMP; @@ -151,34 +151,34 @@ int GetProgramBuildTimestamp() { } -const char* GetVCS() { -#if defined(VCS) - return VCS; -#else - return ""; -#endif -} - -const char* GetBranch() { -#if defined(BRANCH) - return BRANCH; -#else - return ""; -#endif -} - -int GetArcadiaPatchNumber() { -#if defined(ARCADIA_PATCH_NUMBER) - return ARCADIA_PATCH_NUMBER; -#else - return 42; -#endif -} - -const char* GetTag() { -#if defined(ARCADIA_TAG) - return ARCADIA_TAG; -#else - return ""; -#endif -} +const char* GetVCS() { +#if defined(VCS) + return VCS; +#else + return ""; +#endif +} + +const char* GetBranch() { +#if defined(BRANCH) + return BRANCH; +#else + return ""; +#endif +} + +int GetArcadiaPatchNumber() { +#if defined(ARCADIA_PATCH_NUMBER) + return ARCADIA_PATCH_NUMBER; +#else + return 42; +#endif +} + +const char* GetTag() { +#if defined(ARCADIA_TAG) + return ARCADIA_TAG; +#else + return ""; +#endif +} diff --git a/build/scripts/c_templates/svnversion.h b/build/scripts/c_templates/svnversion.h index 7aece931aa..3cc1adab35 100644 --- a/build/scripts/c_templates/svnversion.h +++ b/build/scripts/c_templates/svnversion.h @@ -1,42 +1,42 @@ -#pragma once - -// Permit compilation with NO_UTIL(): -// util/system/compiler.h -#if !defined(Y_HIDDEN) -#if defined(__GNUC__) -#define Y_HIDDEN __attribute__((visibility("hidden"))) -#else -#define Y_HIDDEN -#endif -#endif - -#if defined(__cplusplus) -extern "C" { -#endif -const char* GetProgramSvnVersion() Y_HIDDEN; // verbose multiline message -void PrintProgramSvnVersion() Y_HIDDEN; -const char* GetArcadiaSourcePath() Y_HIDDEN; // "/home/myltsev/arcadia" -const char* GetArcadiaSourceUrl() Y_HIDDEN; // "svn+ssh://arcadia.yandex.ru/arc/trunk/arcadia" -const char* GetArcadiaLastChange() Y_HIDDEN; // "2902074" -int GetArcadiaLastChangeNum() Y_HIDDEN; // 2902074 -const char* GetArcadiaLastAuthor() Y_HIDDEN; // "dieash" -int GetProgramSvnRevision() Y_HIDDEN; // 2902074 +#pragma once + +// Permit compilation with NO_UTIL(): +// util/system/compiler.h +#if !defined(Y_HIDDEN) +#if defined(__GNUC__) +#define Y_HIDDEN __attribute__((visibility("hidden"))) +#else +#define Y_HIDDEN +#endif +#endif + +#if defined(__cplusplus) +extern "C" { +#endif +const char* GetProgramSvnVersion() Y_HIDDEN; // verbose multiline message +void PrintProgramSvnVersion() Y_HIDDEN; +const char* GetArcadiaSourcePath() Y_HIDDEN; // "/home/myltsev/arcadia" +const char* GetArcadiaSourceUrl() Y_HIDDEN; // "svn+ssh://arcadia.yandex.ru/arc/trunk/arcadia" +const char* GetArcadiaLastChange() Y_HIDDEN; // "2902074" +int GetArcadiaLastChangeNum() Y_HIDDEN; // 2902074 +const char* GetArcadiaLastAuthor() Y_HIDDEN; // "dieash" +int GetProgramSvnRevision() Y_HIDDEN; // 2902074 const char* GetVCSDirty() Y_HIDDEN; -const char* GetProgramHash() Y_HIDDEN; -const char* GetProgramCommitId() Y_HIDDEN; -void PrintSvnVersionAndExit(int argc, char* argv[]) Y_HIDDEN; -void PrintSvnVersionAndExitEx(int argc, char* argv[], const char* opts) Y_HIDDEN; -void PrintSvnVersionAndExit0() Y_HIDDEN; -const char* GetProgramScmData() Y_HIDDEN; // verbose multiline message +const char* GetProgramHash() Y_HIDDEN; +const char* GetProgramCommitId() Y_HIDDEN; +void PrintSvnVersionAndExit(int argc, char* argv[]) Y_HIDDEN; +void PrintSvnVersionAndExitEx(int argc, char* argv[], const char* opts) Y_HIDDEN; +void PrintSvnVersionAndExit0() Y_HIDDEN; +const char* GetProgramScmData() Y_HIDDEN; // verbose multiline message const char* GetProgramShortVersionData() Y_HIDDEN; -const char* GetProgramBuildUser() Y_HIDDEN; -const char* GetProgramBuildHost() Y_HIDDEN; -const char* GetProgramBuildDate() Y_HIDDEN; +const char* GetProgramBuildUser() Y_HIDDEN; +const char* GetProgramBuildHost() Y_HIDDEN; +const char* GetProgramBuildDate() Y_HIDDEN; int GetProgramBuildTimestamp() Y_HIDDEN; -const char* GetVCS() Y_HIDDEN; -const char* GetBranch() Y_HIDDEN; -const char* GetTag() Y_HIDDEN; -int GetArcadiaPatchNumber() Y_HIDDEN; -#if defined(__cplusplus) -} -#endif +const char* GetVCS() Y_HIDDEN; +const char* GetBranch() Y_HIDDEN; +const char* GetTag() Y_HIDDEN; +int GetArcadiaPatchNumber() Y_HIDDEN; +#if defined(__cplusplus) +} +#endif diff --git a/build/scripts/c_templates/ya.make b/build/scripts/c_templates/ya.make index b395e11021..306077cc96 100644 --- a/build/scripts/c_templates/ya.make +++ b/build/scripts/c_templates/ya.make @@ -1,7 +1,7 @@ OWNER(g:ymake) -LIBRARY(dummy-vcs) -NO_PLATFORM() - -SRCS(svn_interface.c) -END() +LIBRARY(dummy-vcs) +NO_PLATFORM() + +SRCS(svn_interface.c) +END() diff --git a/build/scripts/compile_java.py b/build/scripts/compile_java.py index e95869e853..ad3164355d 100644 --- a/build/scripts/compile_java.py +++ b/build/scripts/compile_java.py @@ -12,7 +12,7 @@ def parse_args(args): parser = optparse.OptionParser() parser.add_option('--javac-bin') parser.add_option('--jar-bin') - parser.add_option('--vcs-mf') + parser.add_option('--vcs-mf') parser.add_option('--package-prefix') parser.add_option('--jar-output') parser.add_option('--srcs-jar-output') @@ -76,10 +76,10 @@ def main(): with zipfile.ZipFile(s) as zf: zf.extractall(classes_dir) - if opts.vcs_mf: - sp.check_call([opts.jar_bin, 'cfm', opts.jar_output, opts.vcs_mf, os.curdir], cwd=classes_dir) - else: - sp.check_call([opts.jar_bin, 'cfM', opts.jar_output, os.curdir], cwd=classes_dir) + if opts.vcs_mf: + sp.check_call([opts.jar_bin, 'cfm', opts.jar_output, opts.vcs_mf, os.curdir], cwd=classes_dir) + else: + sp.check_call([opts.jar_bin, 'cfM', opts.jar_output, os.curdir], cwd=classes_dir) if opts.srcs_jar_output: for s in jsrcs: @@ -92,10 +92,10 @@ def main(): shutil.copyfile(s, d) - if opts.vcs_mf: - sp.check_call([opts.jar_bin, 'cfm', opts.srcs_jar_output, opts.vcs_mf, os.curdir], cwd=sources_dir) - else: - sp.check_call([opts.jar_bin, 'cfM', opts.srcs_jar_output, os.curdir], cwd=sources_dir) + if opts.vcs_mf: + sp.check_call([opts.jar_bin, 'cfm', opts.srcs_jar_output, opts.vcs_mf, os.curdir], cwd=sources_dir) + else: + sp.check_call([opts.jar_bin, 'cfM', opts.srcs_jar_output, os.curdir], cwd=sources_dir) if __name__ == '__main__': diff --git a/build/scripts/fetch_from.py b/build/scripts/fetch_from.py index db4fea50bf..96f3acd589 100755 --- a/build/scripts/fetch_from.py +++ b/build/scripts/fetch_from.py @@ -4,7 +4,7 @@ import hashlib import json import logging import os -import platform +import platform import random import shutil import socket @@ -27,7 +27,7 @@ def add_common_arguments(parser): parser.add_argument('--untar-to') parser.add_argument('--rename', action='append', default=[], metavar='FILE', help='rename FILE to the corresponding output') parser.add_argument('--executable', action='store_true', help='make outputs executable') - parser.add_argument('--log-path') + parser.add_argument('--log-path') parser.add_argument('-v', '--verbose', action='store_true', default=os.environ.get('YA_VERBOSE_FETCHER'), help='increase stderr verbosity') parser.add_argument('outputs', nargs='*', default=[]) @@ -90,36 +90,36 @@ class OutputNotExistError(Exception): pass -def setup_logging(args, base_name): - def makedirs(path): - try: - os.makedirs(path) - except OSError: - pass - - if args.log_path: - log_file_name = args.log_path - else: - log_file_name = base_name + ".log" - - args.abs_log_path = os.path.abspath(log_file_name) - makedirs(os.path.dirname(args.abs_log_path)) - logging.basicConfig(filename=args.abs_log_path, level=logging.DEBUG) +def setup_logging(args, base_name): + def makedirs(path): + try: + os.makedirs(path) + except OSError: + pass + + if args.log_path: + log_file_name = args.log_path + else: + log_file_name = base_name + ".log" + + args.abs_log_path = os.path.abspath(log_file_name) + makedirs(os.path.dirname(args.abs_log_path)) + logging.basicConfig(filename=args.abs_log_path, level=logging.DEBUG) if args.verbose: logging.getLogger().addHandler(logging.StreamHandler(sys.stderr)) - - + + def is_temporary(e): - def is_broken(e): - return isinstance(e, urllib2.HTTPError) and e.code in (410, 404) + def is_broken(e): + return isinstance(e, urllib2.HTTPError) and e.code in (410, 404) if is_broken(e): return False - + if isinstance(e, (BadChecksumFetchError, IncompleteFetchError, urllib2.URLError, socket.error)): return True - + import error return error.is_temporary_error(e) @@ -293,16 +293,16 @@ def fetch_url(url, unpack, resource_file_name, expected_md5=None, expected_sha1= def chmod(filename, mode): - if platform.system().lower() == 'windows': - # https://docs.microsoft.com/en-us/windows/win32/fileio/hard-links-and-junctions: - # hard to reset read-only attribute for removal if there are multiple hardlinks - return + if platform.system().lower() == 'windows': + # https://docs.microsoft.com/en-us/windows/win32/fileio/hard-links-and-junctions: + # hard to reset read-only attribute for removal if there are multiple hardlinks + return stat = os.stat(filename) if stat.st_mode & 0o777 != mode: try: os.chmod(filename, mode) except OSError: - import pwd + import pwd sys.stderr.write("{} st_mode: {} pwuid: {}\n".format(filename, stat.st_mode, pwd.getpwuid(os.stat(filename).st_uid))) raise @@ -356,9 +356,9 @@ def process(fetched_file, file_name, args, remove=True): logging.info('Renaming %s to %s', src, dst) if os.path.exists(dst): raise ResourceUnpackingError("Target file already exists ({} -> {})".format(src, dst)) - if remove: - rename_or_copy_and_remove(src, dst) - else: + if remove: + rename_or_copy_and_remove(src, dst) + else: hardlink_or_copy(src, dst) for path in args.outputs: diff --git a/build/scripts/fetch_from_external.py b/build/scripts/fetch_from_external.py index d4ed6f4221..c7202d2ed2 100644 --- a/build/scripts/fetch_from_external.py +++ b/build/scripts/fetch_from_external.py @@ -18,7 +18,7 @@ def parse_args(): def main(args): external_file = args.external_file.rstrip('.external') if os.path.isfile(args.resource_file): - fetch_from.process(args.resource_file, os.path.basename(args.resource_file), args, False) + fetch_from.process(args.resource_file, os.path.basename(args.resource_file), args, False) return error = None diff --git a/build/scripts/fetch_from_mds.py b/build/scripts/fetch_from_mds.py index 5e4e656394..7ab993fc31 100644 --- a/build/scripts/fetch_from_mds.py +++ b/build/scripts/fetch_from_mds.py @@ -37,7 +37,7 @@ def main(args): if __name__ == '__main__': args = parse_args() - fetch_from.setup_logging(args, os.path.basename(__file__)) + fetch_from.setup_logging(args, os.path.basename(__file__)) try: main(args) diff --git a/build/scripts/fetch_from_sandbox.py b/build/scripts/fetch_from_sandbox.py index a99542e174..5408ca05af 100755 --- a/build/scripts/fetch_from_sandbox.py +++ b/build/scripts/fetch_from_sandbox.py @@ -15,7 +15,7 @@ import fetch_from ORIGIN_SUFFIX = '?origin=fetch-from-sandbox' MDS_PREFIX = 'http://storage-int.mds.yandex.net/get-sandbox/' -TEMPORARY_ERROR_CODES = (429, 500, 503, 504) +TEMPORARY_ERROR_CODES = (429, 500, 503, 504) def parse_args(): @@ -23,7 +23,7 @@ def parse_args(): fetch_from.add_common_arguments(parser) parser.add_argument('--resource-id', type=int, required=True) parser.add_argument('--custom-fetcher') - parser.add_argument('--resource-file') + parser.add_argument('--resource-file') return parser.parse_args() @@ -35,33 +35,33 @@ class UnsupportedProtocolException(Exception): pass -def _sky_path(): - return "/usr/local/bin/sky" +def _sky_path(): + return "/usr/local/bin/sky" -def _is_skynet_avaliable(): - if not os.path.exists(_sky_path()): - return False - try: - subprocess.check_output([_sky_path(), "--version"]) - return True - except subprocess.CalledProcessError: - return False - except OSError: - return False - - -def download_by_skynet(resource_info, file_name): +def _is_skynet_avaliable(): + if not os.path.exists(_sky_path()): + return False + try: + subprocess.check_output([_sky_path(), "--version"]) + return True + except subprocess.CalledProcessError: + return False + except OSError: + return False + + +def download_by_skynet(resource_info, file_name): def sky_get(skynet_id, target_dir, timeout=None): cmd_args = [_sky_path(), 'get', "-N", "Backbone", "--user", "--wait", "--dir", target_dir, skynet_id] if timeout is not None: cmd_args += ["--timeout", str(timeout)] - logging.info('Call skynet with args: %s', cmd_args) + logging.info('Call skynet with args: %s', cmd_args) stdout = subprocess.check_output(cmd_args).strip() logging.debug('Skynet call with args %s is finished, result is %s', cmd_args, stdout) return stdout - if not _is_skynet_avaliable(): + if not _is_skynet_avaliable(): raise UnsupportedProtocolException("Skynet is not available") skynet_id = resource_info.get("skynet_id") @@ -94,7 +94,7 @@ def _urlopen(url, data=None, headers=None): logging.warning('failed to fetch URL %s with HTTP code %d: %s', url, e.code, e) retry_after = int(e.headers.get('Retry-After', str(retry_after))) - if e.code not in TEMPORARY_ERROR_CODES: + if e.code not in TEMPORARY_ERROR_CODES: raise except Exception as e: @@ -141,9 +141,9 @@ def fetch(resource_id, custom_fetcher): ) raise - if resource_info.get('state', 'DELETED') != 'READY': - raise ResourceInfoError("Resource {} is not READY".format(resource_id)) - + if resource_info.get('state', 'DELETED') != 'READY': + raise ResourceInfoError("Resource {} is not READY".format(resource_id)) + logging.info('Resource %s info %s', str(resource_id), json.dumps(resource_info)) resource_file_name = os.path.basename(resource_info["file_name"]) @@ -159,15 +159,15 @@ def fetch(resource_id, custom_fetcher): random.shuffle(storage_links) return storage_links - skynet = _is_skynet_avaliable() - - if not skynet: - logging.info("Skynet is not available, will try other protocols") - + skynet = _is_skynet_avaliable() + + if not skynet: + logging.info("Skynet is not available, will try other protocols") + def iter_tries(): - if skynet: - yield lambda: download_by_skynet(resource_info, resource_file_name) - + if skynet: + yield lambda: download_by_skynet(resource_info, resource_file_name) + if custom_fetcher: yield lambda: fetch_via_script(custom_fetcher, resource_id) @@ -191,78 +191,78 @@ def fetch(resource_id, custom_fetcher): try: fetched_file = action() break - except UnsupportedProtocolException: - pass - except subprocess.CalledProcessError as e: + except UnsupportedProtocolException: + pass + except subprocess.CalledProcessError as e: logging.warning('failed to fetch resource %s with subprocess: %s', resource_id, e) - time.sleep(i) - except urllib2.HTTPError as e: + time.sleep(i) + except urllib2.HTTPError as e: logging.warning('failed to fetch resource %s with HTTP code %d: %s', resource_id, e.code, e) - if e.code not in TEMPORARY_ERROR_CODES: - exc_info = exc_info or sys.exc_info() - time.sleep(i) + if e.code not in TEMPORARY_ERROR_CODES: + exc_info = exc_info or sys.exc_info() + time.sleep(i) except Exception as e: logging.exception(e) exc_info = exc_info or sys.exc_info() time.sleep(i) else: - if exc_info: - raise exc_info[0], exc_info[1], exc_info[2] - else: - raise Exception("No available protocol and/or server to fetch resource") + if exc_info: + raise exc_info[0], exc_info[1], exc_info[2] + else: + raise Exception("No available protocol and/or server to fetch resource") return fetched_file, resource_info['file_name'] -def _get_resource_info_from_file(resource_file): - if resource_file is None or not os.path.exists(resource_file): - return None - - RESOURCE_INFO_JSON = "resource_info.json" - RESOURCE_CONTENT_FILE_NAME = "resource" - - resource_dir, resource_file = os.path.split(resource_file) - if resource_file != RESOURCE_CONTENT_FILE_NAME: - return None - - resource_json = os.path.join(resource_dir, RESOURCE_INFO_JSON) - if not os.path.isfile(resource_json): - return None - - try: - with open(resource_json, 'r') as j: - resource_info = json.load(j) - resource_info['file_name'] # check consistency - return resource_info - except: - logging.debug('Invalid %s in %s', RESOURCE_INFO_JSON, resource_dir) - - return None - - +def _get_resource_info_from_file(resource_file): + if resource_file is None or not os.path.exists(resource_file): + return None + + RESOURCE_INFO_JSON = "resource_info.json" + RESOURCE_CONTENT_FILE_NAME = "resource" + + resource_dir, resource_file = os.path.split(resource_file) + if resource_file != RESOURCE_CONTENT_FILE_NAME: + return None + + resource_json = os.path.join(resource_dir, RESOURCE_INFO_JSON) + if not os.path.isfile(resource_json): + return None + + try: + with open(resource_json, 'r') as j: + resource_info = json.load(j) + resource_info['file_name'] # check consistency + return resource_info + except: + logging.debug('Invalid %s in %s', RESOURCE_INFO_JSON, resource_dir) + + return None + + def main(args): custom_fetcher = os.environ.get('YA_CUSTOM_FETCHER') - resource_info = _get_resource_info_from_file(args.resource_file) - if resource_info: - fetched_file = args.resource_file - file_name = resource_info['file_name'] - else: - # This code should be merged to ya and removed. - fetched_file, file_name = fetch(args.resource_id, custom_fetcher) + resource_info = _get_resource_info_from_file(args.resource_file) + if resource_info: + fetched_file = args.resource_file + file_name = resource_info['file_name'] + else: + # This code should be merged to ya and removed. + fetched_file, file_name = fetch(args.resource_id, custom_fetcher) - fetch_from.process(fetched_file, file_name, args, remove=not custom_fetcher and not resource_info) + fetch_from.process(fetched_file, file_name, args, remove=not custom_fetcher and not resource_info) if __name__ == '__main__': args = parse_args() - fetch_from.setup_logging(args, os.path.basename(__file__)) + fetch_from.setup_logging(args, os.path.basename(__file__)) try: main(args) except Exception as e: logging.exception(e) - print >>sys.stderr, open(args.abs_log_path).read() + print >>sys.stderr, open(args.abs_log_path).read() sys.stderr.flush() import error diff --git a/build/scripts/go_tool.py b/build/scripts/go_tool.py index c1e98b20c0..a25a871a94 100644 --- a/build/scripts/go_tool.py +++ b/build/scripts/go_tool.py @@ -474,12 +474,12 @@ def do_link_exe(args): compile_args.output = os.path.join(args.output_root, 'main.a') compile_args.real_import_path = compile_args.import_path compile_args.import_path = 'main' - - if args.vcs and os.path.isfile(compile_args.vcs): - build_info = os.path.join('library', 'go', 'core', 'buildinfo') + + if args.vcs and os.path.isfile(compile_args.vcs): + build_info = os.path.join('library', 'go', 'core', 'buildinfo') if any([x.startswith(build_info) for x in compile_args.peers]): - compile_args.go_srcs.append(compile_args.vcs) - + compile_args.go_srcs.append(compile_args.vcs) + do_link_lib(compile_args) cmd = [args.go_link, '-o', args.output] import_config_name = create_import_config(args.peers + args.non_local_peers, False, args.import_map, args.module_map) @@ -814,7 +814,7 @@ if __name__ == '__main__': parser.add_argument('++asm-flags', nargs='*') parser.add_argument('++compile-flags', nargs='*') parser.add_argument('++link-flags', nargs='*') - parser.add_argument('++vcs', nargs='?', default=None) + parser.add_argument('++vcs', nargs='?', default=None) parser.add_argument('++vet', nargs='?', const=True, default=False) parser.add_argument('++vet-flags', nargs='*', default=None) parser.add_argument('++vet-info-ext', default=vet_info_ext) diff --git a/build/scripts/link_exe.py b/build/scripts/link_exe.py index f469e3b442..d89528b6fa 100644 --- a/build/scripts/link_exe.py +++ b/build/scripts/link_exe.py @@ -1,6 +1,6 @@ import sys import subprocess -import optparse +import optparse from process_whole_archive_option import ProcessWholeArchiveOption @@ -15,19 +15,19 @@ def get_leaks_suppressions(cmd): return supp, newcmd -musl_libs = '-lc', '-lcrypt', '-ldl', '-lm', '-lpthread', '-lrt', '-lutil' - - -def fix_cmd(musl, c): +musl_libs = '-lc', '-lcrypt', '-ldl', '-lm', '-lpthread', '-lrt', '-lutil' + + +def fix_cmd(musl, c): return [i for i in c if (not musl or i not in musl_libs) and not i.endswith('.ios.interface') and not i.endswith('.pkg.fake')] - - + + def gen_default_suppressions(inputs, output, source_root): import collections import os supp_map = collections.defaultdict(set) - for filename in inputs: + for filename in inputs: sanitizer = os.path.basename(filename).split('.', 1)[0] with open(os.path.join(source_root, filename)) as src: for line in src: @@ -36,17 +36,17 @@ def gen_default_suppressions(inputs, output, source_root): continue supp_map[sanitizer].add(line) - with open(output, "wb") as dst: + with open(output, "wb") as dst: for supp_type, supps in supp_map.items(): dst.write('extern "C" const char *__%s_default_suppressions() {\n' % supp_type) dst.write(' return "{}";\n'.format('\\n'.join(sorted(supps)))) dst.write('}\n') -def parse_args(): - parser = optparse.OptionParser() - parser.disable_interspersed_args() - parser.add_option('--musl', action='store_true') +def parse_args(): + parser = optparse.OptionParser() + parser.disable_interspersed_args() + parser.add_option('--musl', action='store_true') parser.add_option('--custom-step') parser.add_option('--python') parser.add_option('--source-root') @@ -54,13 +54,13 @@ def parse_args(): parser.add_option('--linker-output') parser.add_option('--whole-archive-peers', action='append') parser.add_option('--whole-archive-libs', action='append') - return parser.parse_args() - - + return parser.parse_args() + + if __name__ == '__main__': - opts, args = parse_args() + opts, args = parse_args() - cmd = fix_cmd(opts.musl, args) + cmd = fix_cmd(opts.musl, args) cmd = ProcessWholeArchiveOption(opts.arch, opts.whole_archive_peers, opts.whole_archive_libs).construct_cmd(cmd) if opts.custom_step: diff --git a/build/scripts/run_msvc_wine.py b/build/scripts/run_msvc_wine.py index 439d1f8831..ed2660f3b8 100644 --- a/build/scripts/run_msvc_wine.py +++ b/build/scripts/run_msvc_wine.py @@ -407,7 +407,7 @@ def process_free_args(args, wine, bld_root, mode): else: result.append(process_arg(arg)) return pwa.ProcessWholeArchiveOption('WINDOWS', wa_peers, wa_libs).construct_cmd(result) - + def run_main(): parser = argparse.ArgumentParser() parser.add_argument('wine', action='store') @@ -507,8 +507,8 @@ def run_main(): # non-zero return code - bad, return it immediately if rc: - print >>sys.stderr, '##win_cmd##' + ' '.join(cmd) - print >>sys.stderr, '##args##' + ' '.join(free_args) + print >>sys.stderr, '##win_cmd##' + ' '.join(cmd) + print >>sys.stderr, '##args##' + ' '.join(free_args) return rc # check for output existence(if we expect it!) and real length diff --git a/build/scripts/vcs_info.py b/build/scripts/vcs_info.py index 319d1b4631..fa7376e739 100644 --- a/build/scripts/vcs_info.py +++ b/build/scripts/vcs_info.py @@ -1,16 +1,16 @@ -import base64 -import json -import os -import re -import sys -import shutil -import tempfile -import textwrap -import zipfile - - -class _Formatting(object): - @staticmethod +import base64 +import json +import os +import re +import sys +import shutil +import tempfile +import textwrap +import zipfile + + +class _Formatting(object): + @staticmethod def is_str(strval): if sys.version_info >= (3, 0, 0): return isinstance(strval, (bytes,str)) @@ -25,266 +25,266 @@ class _Formatting(object): return isinstance(strval, unicode) @staticmethod - def escape_special_symbols(strval): + def escape_special_symbols(strval): encoding_needed = _Formatting.encoding_needed(strval) c_str = strval.encode('utf-8') if encoding_needed else strval retval = b"" - for c in c_str: + for c in c_str: if sys.version_info >= (3, 0, 0): c = bytes([c]) - if c in ("\\", "\""): - retval += "\\" + c - elif ord(c) < ord(' '): + if c in ("\\", "\""): + retval += "\\" + c + elif ord(c) < ord(' '): retval += c.decode('latin-1').encode('unicode_escape') - else: - retval += c + else: + retval += c return retval.decode('utf-8') if encoding_needed else retval - - @staticmethod - def escape_line_feed(strval, indent=' '): - return strval.replace(r'\n', '\\n"\\\n' + indent + '"') - - @staticmethod + + @staticmethod + def escape_line_feed(strval, indent=' '): + return strval.replace(r'\n', '\\n"\\\n' + indent + '"') + + @staticmethod def escape_trigraphs(strval): return strval.replace(r'?', '\\?') @staticmethod - def escaped_define(strkey, val): - name = "#define " + strkey + " " + def escaped_define(strkey, val): + name = "#define " + strkey + " " if _Formatting.is_str(val): - define = "\"" + _Formatting.escape_line_feed( + define = "\"" + _Formatting.escape_line_feed( _Formatting.escape_trigraphs(_Formatting.escape_special_symbols(val))) + "\"" - else: - define = str(val) - return name + define - - @staticmethod - def escaped_go_map_key(strkey, strval): + else: + define = str(val) + return name + define + + @staticmethod + def escaped_go_map_key(strkey, strval): if _Formatting.is_str(strval): - return ' ' + '"' + strkey + '": "' + _Formatting.escape_special_symbols(strval) + '",' - else: - return ' ' + '"' + strkey + '": "' + str(strval) + '",' - - -def get_default_json(): - return json.loads('''{ + return ' ' + '"' + strkey + '": "' + _Formatting.escape_special_symbols(strval) + '",' + else: + return ' ' + '"' + strkey + '": "' + str(strval) + '",' + + +def get_default_json(): + return json.loads('''{ "ARCADIA_SOURCE_HG_HASH": "0000000000000000000000000000000000000000", "ARCADIA_SOURCE_LAST_AUTHOR": "<UNKNOWN>", - "ARCADIA_SOURCE_LAST_CHANGE": -1, - "ARCADIA_SOURCE_PATH": "/", - "ARCADIA_SOURCE_REVISION": -1, - "ARCADIA_SOURCE_URL": "", - "BRANCH": "unknown-vcs-branch", - "BUILD_DATE": "", + "ARCADIA_SOURCE_LAST_CHANGE": -1, + "ARCADIA_SOURCE_PATH": "/", + "ARCADIA_SOURCE_REVISION": -1, + "ARCADIA_SOURCE_URL": "", + "BRANCH": "unknown-vcs-branch", + "BUILD_DATE": "", "BUILD_TIMESTAMP": 0, - "BUILD_HOST": "localhost", - "BUILD_USER": "nobody", + "BUILD_HOST": "localhost", + "BUILD_USER": "nobody", "PROGRAM_VERSION": "Arc info:\\n Branch: unknown-vcs-branch\\n Commit: 0000000000000000000000000000000000000000\\n Author: <UNKNOWN>\\n Summary: No VCS\\n\\n", "SCM_DATA": "Arc info:\\n Branch: unknown-vcs-branch\\n Commit: 0000000000000000000000000000000000000000\\n Author: <UNKNOWN>\\n Summary: No VCS\\n", - "VCS": "arc", - "ARCADIA_PATCH_NUMBER": 0, - "ARCADIA_TAG": "" -}''') - - -def get_json(file_name): - try: - with open(file_name, 'r') as f: - out = json.load(f) - - # TODO: check 'tar+svn' parsing - for i in ['ARCADIA_SOURCE_REVISION', 'ARCADIA_SOURCE_LAST_CHANGE', 'SVN_REVISION']: + "VCS": "arc", + "ARCADIA_PATCH_NUMBER": 0, + "ARCADIA_TAG": "" +}''') + + +def get_json(file_name): + try: + with open(file_name, 'r') as f: + out = json.load(f) + + # TODO: check 'tar+svn' parsing + for i in ['ARCADIA_SOURCE_REVISION', 'ARCADIA_SOURCE_LAST_CHANGE', 'SVN_REVISION']: if i in out and _Formatting.is_str(out[i]): - try: - out[i] = int(out[i]) - except: - out[i] = -1 - return out - except: - return get_default_json() - - -def print_c(json_file, output_file, argv): - """ params: - json file - output file - $(SOURCE_ROOT)/build/scripts/c_templates/svn_interface.c""" - def gen_header(info): - lines = [] - for k, v in info.items(): - lines.append(_Formatting.escaped_define(k, v)) - return lines - - interface = argv[0] - - with open(interface) as c: - c_file = c.read() - with open(output_file, 'w') as f: + try: + out[i] = int(out[i]) + except: + out[i] = -1 + return out + except: + return get_default_json() + + +def print_c(json_file, output_file, argv): + """ params: + json file + output file + $(SOURCE_ROOT)/build/scripts/c_templates/svn_interface.c""" + def gen_header(info): + lines = [] + for k, v in info.items(): + lines.append(_Formatting.escaped_define(k, v)) + return lines + + interface = argv[0] + + with open(interface) as c: + c_file = c.read() + with open(output_file, 'w') as f: header = '\n'.join(gen_header(json_file)) if sys.version_info < (3, 0, 0): header = header.encode('utf-8') f.write(header + '\n' + c_file) - - -def merge_java_content(old_content, json_file): - new_content, names = print_java_mf(json_file) - - def split_to_sections(content): - sections = [] - cur_section = [] - for l in content: - if l.rstrip(): - cur_section.append(l) - else: - sections.append(cur_section) - cur_section = [] - - if cur_section: # should not be needed according to format specification - sections.append(cur_section) - - return sections - - def drop_duplicate_entries(main_section, names): - header = re.compile('^([A-Za-z0-9][A-Za-z0-9_-]*): .*$') - new_main_section = [] - for l in main_section: - match = header.match(l) - # duplicate entry - if match: - skip = match.group(1) in names - - if not skip: - new_main_section.append(l) - return new_main_section - - if old_content: - sections = split_to_sections(old_content) - sections[0] = drop_duplicate_entries(sections[0], names) - else: - sections = [['Manifest-Version: 1.0\n']] - - sections[0].extend(map(lambda x: x + '\n', new_content)) - - return ''.join(map(lambda x: ''.join(x), sections)) + '\n' - - -def merge_java_mf_jar(json_file, out_manifest, jar_file): - try: - temp_dir = tempfile.mkdtemp() - try: - with zipfile.ZipFile(jar_file, 'r') as jar: - jar.extract(os.path.join('META-INF', 'MANIFEST.MF'), path=temp_dir) - except KeyError: - pass - - merge_java_mf_dir(json_file, out_manifest, temp_dir) - finally: - shutil.rmtree(temp_dir) - - -def merge_java_mf_dir(json_file, out_manifest, input_dir): - manifest = os.path.join(input_dir, 'META-INF', 'MANIFEST.MF') - - old_lines = [] - if os.path.isfile(manifest): - with open(manifest, 'r') as f: - old_lines = f.readlines() - - with open(out_manifest, 'w') as f: - f.write(merge_java_content(old_lines, json_file)) - - -def merge_java_mf(json_file, out_manifest, input): - if zipfile.is_zipfile(input): - merge_java_mf_jar(json_file, out_manifest, input) - elif os.path.isdir(input): - merge_java_mf_dir(json_file, out_manifest, input) - - -def print_java_mf(info): - wrapper = textwrap.TextWrapper(subsequent_indent=' ', - break_long_words=True, - replace_whitespace=False, - drop_whitespace=False) - names = set() - - def wrap(key, val): - names.add(key[:-2]) - if not val: - return [] - return wrapper.wrap(key + val) - - lines = wrap('Program-Version-String: ', base64.b64encode(info['PROGRAM_VERSION'].encode('utf-8'))) - lines += wrap('SCM-String: ', base64.b64encode(info['SCM_DATA'].encode('utf-8'))) - lines += wrap('Arcadia-Source-Path: ', info['ARCADIA_SOURCE_PATH']) - lines += wrap('Arcadia-Source-URL: ', info['ARCADIA_SOURCE_URL']) - lines += wrap('Arcadia-Source-Revision: ', str(info['ARCADIA_SOURCE_REVISION'])) - lines += wrap('Arcadia-Source-Hash: ', info['ARCADIA_SOURCE_HG_HASH'].rstrip()) - lines += wrap('Arcadia-Source-Last-Change: ', str(info['ARCADIA_SOURCE_LAST_CHANGE'])) - lines += wrap('Arcadia-Source-Last-Author: ', info['ARCADIA_SOURCE_LAST_AUTHOR']) - lines += wrap('Build-User: ', info['BUILD_USER']) - lines += wrap('Build-Host: ', info['BUILD_HOST']) - lines += wrap('Version-Control-System: ', info['VCS']) - lines += wrap('Branch: ', info['BRANCH']) - lines += wrap('Arcadia-Tag: ', info.get('ARCADIA_TAG', '')) - lines += wrap('Arcadia-Patch-Number: ', str(info.get('ARCADIA_PATCH_NUMBER', 42))) - if 'SVN_REVISION' in info: - lines += wrap('SVN-Revision: ', str(info['SVN_REVISION'])) - lines += wrap('SVN-Arcroot: ', info['SVN_ARCROOT']) - lines += wrap('SVN-Time: ', info['SVN_TIME']) - lines += wrap('Build-Date: ', info['BUILD_DATE']) + + +def merge_java_content(old_content, json_file): + new_content, names = print_java_mf(json_file) + + def split_to_sections(content): + sections = [] + cur_section = [] + for l in content: + if l.rstrip(): + cur_section.append(l) + else: + sections.append(cur_section) + cur_section = [] + + if cur_section: # should not be needed according to format specification + sections.append(cur_section) + + return sections + + def drop_duplicate_entries(main_section, names): + header = re.compile('^([A-Za-z0-9][A-Za-z0-9_-]*): .*$') + new_main_section = [] + for l in main_section: + match = header.match(l) + # duplicate entry + if match: + skip = match.group(1) in names + + if not skip: + new_main_section.append(l) + return new_main_section + + if old_content: + sections = split_to_sections(old_content) + sections[0] = drop_duplicate_entries(sections[0], names) + else: + sections = [['Manifest-Version: 1.0\n']] + + sections[0].extend(map(lambda x: x + '\n', new_content)) + + return ''.join(map(lambda x: ''.join(x), sections)) + '\n' + + +def merge_java_mf_jar(json_file, out_manifest, jar_file): + try: + temp_dir = tempfile.mkdtemp() + try: + with zipfile.ZipFile(jar_file, 'r') as jar: + jar.extract(os.path.join('META-INF', 'MANIFEST.MF'), path=temp_dir) + except KeyError: + pass + + merge_java_mf_dir(json_file, out_manifest, temp_dir) + finally: + shutil.rmtree(temp_dir) + + +def merge_java_mf_dir(json_file, out_manifest, input_dir): + manifest = os.path.join(input_dir, 'META-INF', 'MANIFEST.MF') + + old_lines = [] + if os.path.isfile(manifest): + with open(manifest, 'r') as f: + old_lines = f.readlines() + + with open(out_manifest, 'w') as f: + f.write(merge_java_content(old_lines, json_file)) + + +def merge_java_mf(json_file, out_manifest, input): + if zipfile.is_zipfile(input): + merge_java_mf_jar(json_file, out_manifest, input) + elif os.path.isdir(input): + merge_java_mf_dir(json_file, out_manifest, input) + + +def print_java_mf(info): + wrapper = textwrap.TextWrapper(subsequent_indent=' ', + break_long_words=True, + replace_whitespace=False, + drop_whitespace=False) + names = set() + + def wrap(key, val): + names.add(key[:-2]) + if not val: + return [] + return wrapper.wrap(key + val) + + lines = wrap('Program-Version-String: ', base64.b64encode(info['PROGRAM_VERSION'].encode('utf-8'))) + lines += wrap('SCM-String: ', base64.b64encode(info['SCM_DATA'].encode('utf-8'))) + lines += wrap('Arcadia-Source-Path: ', info['ARCADIA_SOURCE_PATH']) + lines += wrap('Arcadia-Source-URL: ', info['ARCADIA_SOURCE_URL']) + lines += wrap('Arcadia-Source-Revision: ', str(info['ARCADIA_SOURCE_REVISION'])) + lines += wrap('Arcadia-Source-Hash: ', info['ARCADIA_SOURCE_HG_HASH'].rstrip()) + lines += wrap('Arcadia-Source-Last-Change: ', str(info['ARCADIA_SOURCE_LAST_CHANGE'])) + lines += wrap('Arcadia-Source-Last-Author: ', info['ARCADIA_SOURCE_LAST_AUTHOR']) + lines += wrap('Build-User: ', info['BUILD_USER']) + lines += wrap('Build-Host: ', info['BUILD_HOST']) + lines += wrap('Version-Control-System: ', info['VCS']) + lines += wrap('Branch: ', info['BRANCH']) + lines += wrap('Arcadia-Tag: ', info.get('ARCADIA_TAG', '')) + lines += wrap('Arcadia-Patch-Number: ', str(info.get('ARCADIA_PATCH_NUMBER', 42))) + if 'SVN_REVISION' in info: + lines += wrap('SVN-Revision: ', str(info['SVN_REVISION'])) + lines += wrap('SVN-Arcroot: ', info['SVN_ARCROOT']) + lines += wrap('SVN-Time: ', info['SVN_TIME']) + lines += wrap('Build-Date: ', info['BUILD_DATE']) if 'BUILD_TIMESTAMP' in info: lines += wrap('Build-Timestamp: ', str(info['BUILD_TIMESTAMP'])) - return lines, names - - -def print_java(json_file, output_file, argv): - """ params: - json file - output file - file""" - input = argv[0] if argv else os.curdir - merge_java_mf(json_file, output_file, input) - - -def print_go(json_file, output_file): - def gen_map(info): - lines = [] - for k, v in info.items(): - lines.append(_Formatting.escaped_go_map_key(k, v)) - return lines - - with open(output_file, 'w') as f: - f.write('\n'.join([ - 'package main', - 'import ("a.yandex-team.ru/library/go/core/buildinfo")', - 'var buildinfomap = map[string]string {'] + gen_map(json_file) + ['}'] + - ['func init() {', - ' buildinfo.InitBuildInfo(buildinfomap)', - '}'] - ).encode('utf-8') + '\n') - - -if __name__ == '__main__': - if 'output-go' in sys.argv: - lang = 'Go' - sys.argv.remove('output-go') - elif 'output-java' in sys.argv: - lang = 'Java' - sys.argv.remove('output-java') - else: - lang = 'C' - - if 'no-vcs' in sys.argv: - sys.argv.remove('no-vcs') - json_file = get_default_json() - else: - json_name = sys.argv[1] - json_file = get_json(json_name) - - if lang == 'Go': - print_go(json_file, sys.argv[2]) - elif lang == 'Java': - print_java(json_file, sys.argv[2], sys.argv[3:]) - else: - print_c(json_file, sys.argv[2], sys.argv[3:]) + return lines, names + + +def print_java(json_file, output_file, argv): + """ params: + json file + output file + file""" + input = argv[0] if argv else os.curdir + merge_java_mf(json_file, output_file, input) + + +def print_go(json_file, output_file): + def gen_map(info): + lines = [] + for k, v in info.items(): + lines.append(_Formatting.escaped_go_map_key(k, v)) + return lines + + with open(output_file, 'w') as f: + f.write('\n'.join([ + 'package main', + 'import ("a.yandex-team.ru/library/go/core/buildinfo")', + 'var buildinfomap = map[string]string {'] + gen_map(json_file) + ['}'] + + ['func init() {', + ' buildinfo.InitBuildInfo(buildinfomap)', + '}'] + ).encode('utf-8') + '\n') + + +if __name__ == '__main__': + if 'output-go' in sys.argv: + lang = 'Go' + sys.argv.remove('output-go') + elif 'output-java' in sys.argv: + lang = 'Java' + sys.argv.remove('output-java') + else: + lang = 'C' + + if 'no-vcs' in sys.argv: + sys.argv.remove('no-vcs') + json_file = get_default_json() + else: + json_name = sys.argv[1] + json_file = get_json(json_name) + + if lang == 'Go': + print_go(json_file, sys.argv[2]) + elif lang == 'Java': + print_java(json_file, sys.argv[2], sys.argv[3:]) + else: + print_c(json_file, sys.argv[2], sys.argv[3:]) diff --git a/build/scripts/ya.make b/build/scripts/ya.make index 710165e40d..a4830bec08 100644 --- a/build/scripts/ya.make +++ b/build/scripts/ya.make @@ -54,7 +54,7 @@ TEST_SRCS( java_pack_to_file.py link_asrc.py link_dyn_lib.py - link_exe.py + link_exe.py link_fat_obj.py link_lib.py llvm_opt_wrapper.py @@ -83,7 +83,7 @@ TEST_SRCS( tared_protoc.py touch.py unpacking_jtest_runner.py - vcs_info.py + vcs_info.py with_coverage.py with_crash_on_timeout.py with_pathsep_resolve.py |