Compare commits
4 Commits
3610233a64
...
858a853767
Author | SHA1 | Date |
---|---|---|
|
858a853767 | |
|
1d55a41a2d | |
|
6ef0cdf7b4 | |
|
2a9de4d7b2 |
|
@ -156,7 +156,11 @@ class Job {
|
|||
'-s',
|
||||
'-c',
|
||||
'/box/submission',
|
||||
'-e',
|
||||
'-E',
|
||||
'HOME=/tmp',
|
||||
...this.runtime.env_vars.flat_map(v => ['-E', v]),
|
||||
'-E',
|
||||
`PISTON_LANGUAGE=${this.runtime.language}`,
|
||||
`--dir=${this.runtime.pkgdir}`,
|
||||
`--dir=/etc:noexec`,
|
||||
`--processes=${this.runtime.max_process_count}`,
|
||||
|
@ -175,10 +179,6 @@ class Job {
|
|||
...args,
|
||||
],
|
||||
{
|
||||
env: {
|
||||
...this.runtime.env_vars,
|
||||
PISTON_LANGUAGE: this.runtime.language,
|
||||
},
|
||||
stdio: 'pipe',
|
||||
}
|
||||
);
|
||||
|
|
|
@ -178,15 +178,7 @@ class Runtime {
|
|||
const env_file = path.join(this.pkgdir, '.env');
|
||||
const env_content = fss.read_file_sync(env_file).toString();
|
||||
|
||||
this._env_vars = {};
|
||||
|
||||
env_content
|
||||
.trim()
|
||||
.split('\n')
|
||||
.map(line => line.split('=', 2))
|
||||
.forEach(([key, val]) => {
|
||||
this._env_vars[key.trim()] = val.trim();
|
||||
});
|
||||
this._env_vars = env_content.trim().split('\n');
|
||||
}
|
||||
|
||||
return this._env_vars;
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Check if exactly one argument is provided
|
||||
if [ $# -eq 1 ]; then
|
||||
mv $1 $1.java
|
||||
filename=$1.java
|
||||
shift
|
||||
java $filename "$@"
|
||||
else
|
||||
# Initialize an empty array to hold the filenames
|
||||
declare -a javaFiles
|
||||
|
||||
# Loop through each argument
|
||||
for file in "$@"; do
|
||||
# Check if the file already ends with .java
|
||||
if [[ "$file" == *.java ]]; then
|
||||
# If it does, add it directly to the array
|
||||
javaFiles+=("$file")
|
||||
else
|
||||
# If it doesn't, add .java extension then add to the array
|
||||
javaFiles+=("${file}.java")
|
||||
fi
|
||||
done
|
||||
|
||||
# Compile all Java files at once
|
||||
javac "${javaFiles[@]}"
|
||||
|
||||
# Run the compiled Java classes
|
||||
# Assuming the first argument is the main class file to run
|
||||
# Remove .java extension from the main class name if present
|
||||
mainClass="${1%.java}"
|
||||
# Execute the main class
|
||||
java "$mainClass"
|
||||
fi
|
Loading…
Reference in New Issue