1ec33767ab
every system component now has its own self-contained build system, and a seed file describing the component and its build system and dependencies. a new tool, meadow, collects and uses these seed files to build the components into a full system. meadow also manages the target system root and a host prefix where toolchain tools are installed to. the build system has also been updated to use a new $ARCH-rosetta-gcc compiler, and the patches files necessary to build it have been added to toolchain/cross-compiler.
120 lines
3.1 KiB
Python
120 lines
3.1 KiB
Python
import os
|
|
import json
|
|
import shutil
|
|
import subprocess
|
|
from build import *
|
|
from pathlib import Path as SysPath
|
|
from cache import Cache
|
|
from env import Environment
|
|
from platform import Platform
|
|
from target import Target
|
|
from path import Path
|
|
|
|
class SourceOnlyBuildSystem(BuildSystem):
|
|
def __init__(self, **kwargs):
|
|
self.__data = kwargs.get('data', None)
|
|
super().__init__(**kwargs)
|
|
|
|
|
|
def __get_watched_files(self):
|
|
result = []
|
|
ns = self.get_path_namespaces()
|
|
|
|
if 'watch_files' in self.__data:
|
|
watch_list = self.__data['watch_files']
|
|
for p in watch_list:
|
|
path = Path(p)
|
|
|
|
real_paths = path.expand_path(relative_to=ns)
|
|
for p2 in real_paths:
|
|
result.append(p2)
|
|
|
|
manifest_path = os.path.join(self.binary_dir(), 'compile_commands.json')
|
|
manifest_file = None
|
|
manifest = None
|
|
try:
|
|
manifest_file = open(manifest_path, mode='r')
|
|
except:
|
|
return result
|
|
|
|
try:
|
|
manifest = json.load(manifest_file)
|
|
except:
|
|
return result
|
|
|
|
for v in manifest:
|
|
if 'file' not in v:
|
|
continue
|
|
|
|
path = v['file']
|
|
result.append(path)
|
|
|
|
return result
|
|
|
|
|
|
def __get_mtime(self):
|
|
files = self.__get_watched_files()
|
|
result = 0
|
|
|
|
for path in files:
|
|
mtime = os.path.getmtime(path)
|
|
|
|
if mtime > result:
|
|
result = mtime
|
|
|
|
return result
|
|
|
|
|
|
def _is_configuration_out_of_date(self):
|
|
parent = self.parent()
|
|
seed_path = parent.seed_path()
|
|
seed_mtime = os.path.getmtime(seed_path)
|
|
target_mtime = Cache.get(f'component.{self.name()}.configure-mtime')
|
|
if target_mtime is None:
|
|
return True
|
|
|
|
return seed_mtime > target_mtime
|
|
|
|
|
|
def _is_build_out_of_date(self):
|
|
current_mtime = self.__get_mtime()
|
|
target_mtime = Cache.get(f'component.{self.name()}.build-mtime')
|
|
if target_mtime is None:
|
|
return True
|
|
|
|
if current_mtime > target_mtime:
|
|
return True
|
|
|
|
for d in self.parent().collect_dependencies():
|
|
build_system = d.build_system()
|
|
if build_system is None:
|
|
continue
|
|
|
|
if build_system.is_build_out_of_date() or build_system.is_configuration_out_of_date():
|
|
return True
|
|
|
|
return False
|
|
|
|
|
|
def configure(self, **kwargs):
|
|
parent = self.parent()
|
|
seed_path = parent.seed_path()
|
|
seed_mtime = os.path.getmtime(seed_path)
|
|
Cache.set(f'component.{self.name()}.configure-mtime', seed_mtime)
|
|
|
|
|
|
def build(self, **kwargs):
|
|
pass
|
|
|
|
|
|
def install(self, **kwargs):
|
|
self.install_from_seed()
|
|
|
|
previous_mtime = Cache.get(f'component.{self.name()}.build-mtime')
|
|
if previous_mtime is None:
|
|
previous_mtime = 0
|
|
|
|
new_mtime = self.__get_mtime()
|
|
if new_mtime > previous_mtime:
|
|
Cache.set(f'component.{self.name()}.build-mtime', new_mtime)
|