Skip to content

Commit

Permalink
Fixed problem with tsc
Browse files Browse the repository at this point in the history
  • Loading branch information
BrentBlanckaert committed Nov 13, 2024
1 parent 3b70092 commit 3214aa5
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 14 deletions.
2 changes: 1 addition & 1 deletion tested/judge/compilation.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def run_compilation(
decide to fallback to individual mode if the compilation result is
not positive.
"""
command, files = bundle.language.compilation(dependencies)
command, files = bundle.language.compilation(dependencies, directory)
_logger.debug(
"Generating files with command %s in directory %s", command, directory
)
Expand Down
2 changes: 1 addition & 1 deletion tested/languages/bash/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def is_source_file(self, file: Path) -> bool:
def submission_file(self) -> str:
return submission_name(self)

def compilation(self, files: list[str]) -> CallbackResult:
def compilation(self, files: list[str], directory: Path) -> CallbackResult:
submission = submission_file(self)
main_file = list(filter(lambda x: x == submission, files))
if main_file:
Expand Down
2 changes: 1 addition & 1 deletion tested/languages/c/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def datatype_support(self) -> dict[AllTypes, TypeSupport]:
"double_extended": "supported",
}

def compilation(self, files: list[str]) -> CallbackResult:
def compilation(self, files: list[str], directory: Path) -> CallbackResult:
main_file = files[-1]
exec_file = Path(main_file).stem
result = executable_name(exec_file)
Expand Down
2 changes: 1 addition & 1 deletion tested/languages/csharp/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def datatype_support(self) -> dict[AllTypes, TypeSupport]:
"tuple": "supported",
}

def compilation(self, files: list[str]) -> CallbackResult:
def compilation(self, files: list[str], directory: Path) -> CallbackResult:
# In C#, all output files are located in a subdirectory, so we just
# want to copy over the subdirectory.
def file_filter(file: Path) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion tested/languages/haskell/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def supported_constructs(self) -> set[Construct]:
Construct.GLOBAL_VARIABLES,
}

def compilation(self, files: list[str]) -> CallbackResult:
def compilation(self, files: list[str], directory: Path) -> CallbackResult:
main_ = files[-1]
exec_ = main_.rstrip(".hs")
assert self.config
Expand Down
2 changes: 1 addition & 1 deletion tested/languages/java/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def collection_restrictions(self) -> dict[AllTypes, set[ExpressionTypes]]:
BasicSequenceTypes.SET: restrictions,
}

def compilation(self, files: list[str]) -> CallbackResult:
def compilation(self, files: list[str], directory: Path) -> CallbackResult:
def file_filter(file: Path) -> bool:
return file.suffix == ".class"

Expand Down
2 changes: 1 addition & 1 deletion tested/languages/javascript/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def datatype_support(self) -> dict[AllTypes, TypeSupport]:
def collection_restrictions(self) -> dict[AllTypes, set[ExpressionTypes]]:
return {AdvancedObjectTypes.OBJECT: {BasicStringTypes.TEXT}}

def compilation(self, files: list[str]) -> CallbackResult:
def compilation(self, files: list[str], directory: Path) -> CallbackResult:
submission = submission_file(self)
main_file = list(filter(lambda x: x == submission, files))
if main_file:
Expand Down
2 changes: 1 addition & 1 deletion tested/languages/kotlin/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def collection_restrictions(self) -> dict[AllTypes, set[ExpressionTypes]]:
BasicSequenceTypes.SET: restrictions, # type: ignore
}

def compilation(self, files: list[str]) -> CallbackResult:
def compilation(self, files: list[str], directory: Path) -> CallbackResult:
def file_filter(file: Path) -> bool:
return file.suffix == ".class"

Expand Down
4 changes: 3 additions & 1 deletion tested/languages/language.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def __init__(self, config: Optional["GlobalConfig"]):
"""
self.config = config

def compilation(self, files: list[str]) -> CallbackResult:
def compilation(self, files: list[str], directory: Path) -> CallbackResult:
"""
Callback for generating the compilation command.
Expand Down Expand Up @@ -139,6 +139,8 @@ def compilation(self, files: list[str]) -> CallbackResult:
be useful to compile. By convention, the last file in the list
is the file containing the "main" function.
:param directory: The directory in which these files can be found.
:return: The compilation command and either the resulting files or a filter
for the resulting files.
"""
Expand Down
2 changes: 1 addition & 1 deletion tested/languages/python/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def collection_restrictions(self) -> dict[AllTypes, set[ExpressionTypes]]:
BasicSequenceTypes.SET: restrictions, # type: ignore
}

def compilation(self, files: list[str]) -> CallbackResult:
def compilation(self, files: list[str], directory: Path) -> CallbackResult:
result = [x.replace(".py", ".pyc") for x in files]
return [
_executable(),
Expand Down
2 changes: 1 addition & 1 deletion tested/languages/runhaskell/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


class RunHaskell(Haskell):
def compilation(self, files: list[str]) -> CallbackResult:
def compilation(self, files: list[str], directory: Path) -> CallbackResult:
submission = submission_file(self)
main_file = list(filter(lambda x: x == submission, files))
if main_file:
Expand Down
18 changes: 15 additions & 3 deletions tested/languages/typescript/config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import logging
import os
import re
Expand Down Expand Up @@ -105,15 +106,26 @@ def datatype_support(self) -> dict[AllTypes, TypeSupport]:
def collection_restrictions(self) -> dict[AllTypes, set[ExpressionTypes]]:
return {AdvancedObjectTypes.OBJECT: {BasicStringTypes.TEXT}}

def compilation(self, files: list[str]) -> CallbackResult:
def compilation(self, files: list[str], directory: Path) -> CallbackResult:
submission = submission_file(self)
main_file = list(filter(lambda x: x == submission, files))

# Create a config file to just that extends tsconfig.
# This way it will only run tsc on the current file.
config_file = {
"extends": str(Path(__file__).parent / "tsconfig.json"),
"include": [f"{main_file[0]}"]
}
with open(str(directory / "tsconfig-sub.json"), "w") as file:
file.write(json.dumps(config_file, indent=4))


if main_file:
return (
[
"tsc",
"--noEmit",
main_file[0],
"--project",
"tsconfig-sub.json",
],
files,
)
Expand Down

0 comments on commit 3214aa5

Please sign in to comment.