Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 9410 → Rev 9411

/_tools/lib/logging.py
1,4 → 1,21
import shutil
 
def log(s, end = "\n"):
print(s, end = end, flush = True)
 
def require_tools(names):
assert(type(names) == list or type(names) == tuple)
for name in names:
assert(type(name) == str)
 
not_found = []
for name in names:
if shutil.which(name) is None:
not_found.append(name)
 
if len(not_found) != 0:
log("Sorry, I can't find some tools:")
for name in not_found:
print(f"- {name}")
exit(1)
 
/_tools/lib/tupfile_parser.py
62,6 → 62,20
# Now we can read the string
return get_strnig(src, ptr)
 
def parse_required_compiler(src, ptr):
# Get straignt to the first argument
ptr += len("tup.getconfig")
# Get to parenthese
ptr = get_to(src, ptr, "(")
# Get to start of the requirement string
ptr = get_to(src, ptr, "\"")
# Read the requirement string (like NO_FASM)
requirement_string = get_strnig(src, ptr)
if requirement_string.startswith("NO_"):
return requirement_string[len("NO_"):].lower().replace("_", "-")
else:
return None
 
def parse_tupfile_outputs(file_name):
outputs = []
with open(file_name) as f:
72,3 → 86,17
# Find the next tup.rule call
rule_begin_index = tupfile.find("tup.rule(", rule_begin_index + len("tup.rule("))
return outputs
 
def parse_required_compilers(file_name):
compilers = []
with open(file_name) as f:
tupfile = f.read()
rule_begin_index = tupfile.find("tup.getconfig(")
while (rule_begin_index != -1):
required_compiler = parse_required_compiler(tupfile, rule_begin_index)
if required_compiler is not None:
compilers.append(required_compiler)
# Find the next tup.getconfig call
rule_begin_index = tupfile.find("tup.getconfig(", rule_begin_index + len("tup.getconfig"))
return compilers
/_tools/workspace/build.py
5,7 → 5,8
path_to_tools = os.path.dirname(path_to_tools_workspace)
sys.path.append(path_to_tools)
 
from lib.tupfile_parser import parse_tupfile_outputs
from lib.tupfile_parser import parse_required_compilers, parse_tupfile_outputs
from lib.logging import require_tools
 
def get_executable_file(output_file_list):
for name in output_file_list:
14,6 → 15,8
return name
 
def build():
required_compilers = parse_required_compilers("Tupfile.lua")
require_tools(required_compilers)
os.system("tup")
output_file_list = parse_tupfile_outputs("Tupfile.lua")
return get_executable_file(output_file_list)
/_tools/workspace/run.py
14,11 → 14,13
from lib.builds import builds_get, builds_get_contents
from lib.makeflop import Floppy
from lib.platform import is_win32, path
from lib.logging import log
from lib.logging import log, require_tools
from lib.constants import tools_cache_kolibri_img
 
# TODO: Move into _tools/lib
def run_qemu(start_dir = "workspace"):
require_tools(("qemu-system-i386",))
 
qemu_command = f"qemu-system-i386"
flags = ""
flags += "-L . " # IDK why it does not work without this