feat: files.import-map
All checks were successful
build / build (push) Successful in 1m36s
build / trigger-build-image (push) Successful in 7s

This commit is contained in:
张泊明518370910136 2025-06-22 05:55:09 -04:00
parent d785216396
commit 53395359cd
GPG Key ID: D47306D7062CDA9D
4 changed files with 21 additions and 10 deletions

View File

@ -135,6 +135,9 @@ class ParserDiff(BaseModel):
class StageFiles(BaseModel):
import_: List[str] = Field([], validation_alias="import")
export: List[str] = []
import_map: Dict[str, str] = Field(
{}, validation_alias=AliasChoices("import-map", "import_map")
)
class Limit(BaseModel):

View File

@ -2,7 +2,7 @@ import re
import shlex
from functools import partial
from pathlib import Path, PurePosixPath
from typing import Any, Callable, Dict, List, Optional, Tuple
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
from joj3_config_generator.models import result, task
from joj3_config_generator.models.common import Memory, Time
@ -79,20 +79,25 @@ def get_parser_handler_map(
def get_executor_with(
task_stage: task.Stage, cached: Dict[str, None]
) -> result.ExecutorWith:
file_import = task_stage.files.import_
copy_in_files = (file for file in file_import if file not in cached)
copy_in: dict[
str,
Union[result.LocalFile, result.MemoryFile, result.PreparedFile, result.Symlink],
] = {
file: result.LocalFile(src=str(JOJ3_CONFIG_ROOT / file))
for file in task_stage.files.import_
if file not in cached
}
for src, dst in task_stage.files.import_map.items():
if dst in cached:
continue
copy_in[dst] = result.LocalFile(src=str(JOJ3_CONFIG_ROOT / src))
file_export = task_stage.files.export
copy_out_files = ["stdout", "stderr"]
executor_with_config = result.ExecutorWith(
default=result.Cmd(
args=shlex.split(task_stage.command),
env=[DEFAULT_PATH_ENV, *task_stage.env],
copy_in={
file: result.LocalFile(src=str(JOJ3_CONFIG_ROOT / file))
# all copyin files store in this tools folder
# TODO: are there any corner cases?
for file in copy_in_files
},
copy_in=copy_in,
copy_in_dir="." if task_stage.copy_in_cwd else "",
copy_out=copy_out_files,
copy_in_cached={file: file for file in cached},

View File

@ -143,6 +143,9 @@
"copyIn": {
"tools/compile": {
"src": "/home/tt/.config/joj/tools/compile"
},
"h7/Makefile": {
"src": "/home/tt/.config/joj/tools/Makefile"
}
},
"copyInCached": {},

View File

@ -20,8 +20,8 @@ name = "Compilation"
env = [ "CC=clang", "CXX=clang++" ]
command = "./tools/compile" # eg. script running cmake commands
files.import = [ "tools/compile" ]
files.import-map = { "tools/Makefile" = "h7/Makefile" }
files.export = [ "h7/build/ex2", "h7/build/ex2-asan", "h7/build/ex2-ubsan", "h7/build/ex2-msan", "h7/build/compile_commands.json" ]
score = 1
# compile parsers
parsers = [ "result-detail", "result-status" ]