feat: files.import-map
This commit is contained in:
parent
d785216396
commit
53395359cd
|
@ -135,6 +135,9 @@ class ParserDiff(BaseModel):
|
||||||
class StageFiles(BaseModel):
|
class StageFiles(BaseModel):
|
||||||
import_: List[str] = Field([], validation_alias="import")
|
import_: List[str] = Field([], validation_alias="import")
|
||||||
export: List[str] = []
|
export: List[str] = []
|
||||||
|
import_map: Dict[str, str] = Field(
|
||||||
|
{}, validation_alias=AliasChoices("import-map", "import_map")
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class Limit(BaseModel):
|
class Limit(BaseModel):
|
||||||
|
|
|
@ -2,7 +2,7 @@ import re
|
||||||
import shlex
|
import shlex
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from pathlib import Path, PurePosixPath
|
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 import result, task
|
||||||
from joj3_config_generator.models.common import Memory, Time
|
from joj3_config_generator.models.common import Memory, Time
|
||||||
|
@ -79,20 +79,25 @@ def get_parser_handler_map(
|
||||||
def get_executor_with(
|
def get_executor_with(
|
||||||
task_stage: task.Stage, cached: Dict[str, None]
|
task_stage: task.Stage, cached: Dict[str, None]
|
||||||
) -> result.ExecutorWith:
|
) -> result.ExecutorWith:
|
||||||
file_import = task_stage.files.import_
|
copy_in: dict[
|
||||||
copy_in_files = (file for file in file_import if file not in cached)
|
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
|
file_export = task_stage.files.export
|
||||||
copy_out_files = ["stdout", "stderr"]
|
copy_out_files = ["stdout", "stderr"]
|
||||||
executor_with_config = result.ExecutorWith(
|
executor_with_config = result.ExecutorWith(
|
||||||
default=result.Cmd(
|
default=result.Cmd(
|
||||||
args=shlex.split(task_stage.command),
|
args=shlex.split(task_stage.command),
|
||||||
env=[DEFAULT_PATH_ENV, *task_stage.env],
|
env=[DEFAULT_PATH_ENV, *task_stage.env],
|
||||||
copy_in={
|
copy_in=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_dir="." if task_stage.copy_in_cwd else "",
|
copy_in_dir="." if task_stage.copy_in_cwd else "",
|
||||||
copy_out=copy_out_files,
|
copy_out=copy_out_files,
|
||||||
copy_in_cached={file: file for file in cached},
|
copy_in_cached={file: file for file in cached},
|
||||||
|
|
|
@ -143,6 +143,9 @@
|
||||||
"copyIn": {
|
"copyIn": {
|
||||||
"tools/compile": {
|
"tools/compile": {
|
||||||
"src": "/home/tt/.config/joj/tools/compile"
|
"src": "/home/tt/.config/joj/tools/compile"
|
||||||
|
},
|
||||||
|
"h7/Makefile": {
|
||||||
|
"src": "/home/tt/.config/joj/tools/Makefile"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"copyInCached": {},
|
"copyInCached": {},
|
||||||
|
|
|
@ -20,8 +20,8 @@ name = "Compilation"
|
||||||
env = [ "CC=clang", "CXX=clang++" ]
|
env = [ "CC=clang", "CXX=clang++" ]
|
||||||
command = "./tools/compile" # eg. script running cmake commands
|
command = "./tools/compile" # eg. script running cmake commands
|
||||||
files.import = [ "tools/compile" ]
|
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" ]
|
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
|
# compile parsers
|
||||||
parsers = [ "result-detail", "result-status" ]
|
parsers = [ "result-detail", "result-status" ]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user