forked from KolibriOS/kolibrios
[WS] Inform about unexisting compilers and qemu
git-svn-id: svn://kolibrios.org@9411 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
efffea0644
commit
f3f7980662
@ -1,4 +1,21 @@
|
|||||||
|
import shutil
|
||||||
|
|
||||||
def log(s, end = "\n"):
|
def log(s, end = "\n"):
|
||||||
print(s, end = end, flush = True)
|
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)
|
||||||
|
|
||||||
|
@ -62,6 +62,20 @@ def parse_rule_output(src, ptr):
|
|||||||
# Now we can read the string
|
# Now we can read the string
|
||||||
return get_strnig(src, ptr)
|
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):
|
def parse_tupfile_outputs(file_name):
|
||||||
outputs = []
|
outputs = []
|
||||||
with open(file_name) as f:
|
with open(file_name) as f:
|
||||||
@ -72,3 +86,17 @@ def parse_tupfile_outputs(file_name):
|
|||||||
# Find the next tup.rule call
|
# Find the next tup.rule call
|
||||||
rule_begin_index = tupfile.find("tup.rule(", rule_begin_index + len("tup.rule("))
|
rule_begin_index = tupfile.find("tup.rule(", rule_begin_index + len("tup.rule("))
|
||||||
return outputs
|
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
|
||||||
|
|
||||||
|
@ -5,7 +5,8 @@ path_to_tools_workspace = os.path.dirname(os.path.abspath(__file__))
|
|||||||
path_to_tools = os.path.dirname(path_to_tools_workspace)
|
path_to_tools = os.path.dirname(path_to_tools_workspace)
|
||||||
sys.path.append(path_to_tools)
|
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):
|
def get_executable_file(output_file_list):
|
||||||
for name in output_file_list:
|
for name in output_file_list:
|
||||||
@ -14,6 +15,8 @@ def get_executable_file(output_file_list):
|
|||||||
return name
|
return name
|
||||||
|
|
||||||
def build():
|
def build():
|
||||||
|
required_compilers = parse_required_compilers("Tupfile.lua")
|
||||||
|
require_tools(required_compilers)
|
||||||
os.system("tup")
|
os.system("tup")
|
||||||
output_file_list = parse_tupfile_outputs("Tupfile.lua")
|
output_file_list = parse_tupfile_outputs("Tupfile.lua")
|
||||||
return get_executable_file(output_file_list)
|
return get_executable_file(output_file_list)
|
||||||
|
@ -14,11 +14,13 @@ from workspace.build import build
|
|||||||
from lib.builds import builds_get, builds_get_contents
|
from lib.builds import builds_get, builds_get_contents
|
||||||
from lib.makeflop import Floppy
|
from lib.makeflop import Floppy
|
||||||
from lib.platform import is_win32, path
|
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
|
from lib.constants import tools_cache_kolibri_img
|
||||||
|
|
||||||
# TODO: Move into _tools/lib
|
# TODO: Move into _tools/lib
|
||||||
def run_qemu(start_dir = "workspace"):
|
def run_qemu(start_dir = "workspace"):
|
||||||
|
require_tools(("qemu-system-i386",))
|
||||||
|
|
||||||
qemu_command = f"qemu-system-i386"
|
qemu_command = f"qemu-system-i386"
|
||||||
flags = ""
|
flags = ""
|
||||||
flags += "-L . " # IDK why it does not work without this
|
flags += "-L . " # IDK why it does not work without this
|
||||||
|
Loading…
Reference in New Issue
Block a user