fix missing buildinfo on Windows

This commit is contained in:
Damien Elmes 2020-11-05 11:21:27 +10:00
parent 29ae7480f2
commit 3f47ff9abd
2 changed files with 9 additions and 5 deletions

View file

@ -5,8 +5,8 @@ use lazy_static::lazy_static;
use std::env; use std::env;
fn buildinfo(key: &str) -> &'static str { fn buildinfo(key: &str) -> &'static str {
let volatile = include_str!(concat!(env!("OUT_DIR"), "/../../buildinfo.txt")); let buildinfo = include_str!(concat!(env!("OUT_DIR"), "/../../buildinfo.txt"));
for line in volatile.split('\n') { for line in buildinfo.split('\n') {
let mut it = line.split(' '); let mut it = line.split(' ');
if it.next().unwrap() == key { if it.next().unwrap() == key {
return it.next().unwrap(); return it.next().unwrap();

View file

@ -9,15 +9,19 @@ release_mode = sys.argv[3] == "release"
version_re = re.compile('anki_version = "(.*)"') version_re = re.compile('anki_version = "(.*)"')
def output(text: str) -> None:
"Add text with a '\n' to stdout; avoiding a '\r' on Windows"
sys.stdout.buffer.write(text.encode("utf8") + b"\n")
# extract version number from defs.bzl # extract version number from defs.bzl
for line in open(defs_file).readlines(): for line in open(defs_file).readlines():
if ver := version_re.match(line): if ver := version_re.match(line):
print(f"STABLE_VERSION {ver.group(1)}") output(f"STABLE_VERSION {ver.group(1)}")
for line in open(stamp_file).readlines(): for line in open(stamp_file).readlines():
if line.startswith("STABLE_BUILDHASH"): if line.startswith("STABLE_BUILDHASH"):
if release_mode: if release_mode:
print(line.strip()) output(line.strip())
else: else:
# if not in release mode, map buildhash to a consistent value # if not in release mode, map buildhash to a consistent value
print("STABLE_BUILDHASH dev") output("STABLE_BUILDHASH dev")