diff --git a/joj3_config_generator/models/const.py b/joj3_config_generator/models/const.py index e969399..981ef7c 100644 --- a/joj3_config_generator/models/const.py +++ b/joj3_config_generator/models/const.py @@ -8,6 +8,7 @@ DEFAULT_FILE_LIMIT = Memory("32m") DEFAULT_CASE_SCORE = 5 DEFAULT_CLOCK_LIMIT_MULTIPLIER = 2 DEFAULT_PROC_LIMIT = 50 +DEFAULT_PATH_ENV = "PATH=/usr/bin:/bin:/usr/local/bin" JOJ3_CONFIG_ROOT = PurePosixPath("/home/tt/.config/joj") TEAPOT_CONFIG_ROOT = PurePosixPath("/home/tt/.config/teapot") diff --git a/joj3_config_generator/models/result.py b/joj3_config_generator/models/result.py index eb5dfc9..8975215 100644 --- a/joj3_config_generator/models/result.py +++ b/joj3_config_generator/models/result.py @@ -7,6 +7,7 @@ from joj3_config_generator.models.const import ( DEFAULT_CPU_LIMIT, DEFAULT_FILE_LIMIT, DEFAULT_MEMORY_LIMIT, + DEFAULT_PATH_ENV, DEFAULT_PROC_LIMIT, ) @@ -46,7 +47,7 @@ InputFile = Union[LocalFile, MemoryFile, PreparedFile, Symlink] class Cmd(BaseModel): args: List[str] = [] - env: List[str] = ["PATH=/usr/bin:/bin:/usr/local/bin"] + env: List[str] = [DEFAULT_PATH_ENV] stdin: Union[InputFile, StreamIn] = MemoryFile(content="") stdout: Union[Collector, StreamOut] = Collector(name="stdout") stderr: Union[Collector, StreamOut] = Collector(name="stderr") diff --git a/joj3_config_generator/transformers/task.py b/joj3_config_generator/transformers/task.py index e976dfa..d3b3825 100644 --- a/joj3_config_generator/transformers/task.py +++ b/joj3_config_generator/transformers/task.py @@ -8,6 +8,7 @@ from joj3_config_generator.models import result, task from joj3_config_generator.models.common import Memory, Time from joj3_config_generator.models.const import ( DEFAULT_CLOCK_LIMIT_MULTIPLIER, + DEFAULT_PATH_ENV, JOJ3_CONFIG_ROOT, ) from joj3_config_generator.models.task import Parser as ParserEnum @@ -86,6 +87,7 @@ def get_executor_with( 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 diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index a500ed6..78b0cb6 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -111,7 +111,9 @@ "./tools/compile" ], "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" + "PATH=/usr/bin:/bin:/usr/local/bin", + "CC=clang", + "CXX=clang++" ], "stdin": { "content": "" diff --git a/tests/convert/basic/task.toml b/tests/convert/basic/task.toml index 4cb9d0f..7660b10 100644 --- a/tests/convert/basic/task.toml +++ b/tests/convert/basic/task.toml @@ -6,6 +6,7 @@ release.begin_time = 2024-12-29 23:59:59+08:00 [[stages]] name = "Compilation" +env = [ "CC=clang", "CXX=clang++" ] command = "./tools/compile" # eg. script running cmake commands files.import = [ "tools/compile" ] files.export = [ "h7/build/ex2", "h7/build/ex2-asan", "h7/build/ex2-ubsan", "h7/build/ex2-msan", "h7/build/compile_commands.json" ]