мпаиуцагцкмпцкмпгшк
All checks were successful
Build and Push Docker Images / build (src/LiquidCode.Tester.Gateway/Dockerfile, git.nullptr.top/liquidcode/liquidcode-tester-gateway-roman, gateway) (push) Successful in 52s
Build and Push Docker Images / build (src/LiquidCode.Tester.Worker/Dockerfile, git.nullptr.top/liquidcode/liquidcode-tester-worker-roman, worker) (push) Successful in 1m5s
All checks were successful
Build and Push Docker Images / build (src/LiquidCode.Tester.Gateway/Dockerfile, git.nullptr.top/liquidcode/liquidcode-tester-gateway-roman, gateway) (push) Successful in 52s
Build and Push Docker Images / build (src/LiquidCode.Tester.Worker/Dockerfile, git.nullptr.top/liquidcode/liquidcode-tester-worker-roman, worker) (push) Successful in 1m5s
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using LiquidCode.Tester.Worker.Services.Isolate;
|
using LiquidCode.Tester.Worker.Services.Isolate;
|
||||||
using LiquidCode.Tester.Worker.Models;
|
using LiquidCode.Tester.Worker.Models;
|
||||||
@@ -85,19 +87,66 @@ public class CppCompilationServiceIsolate : ICompilationService
|
|||||||
|
|
||||||
File.Copy(sourceFilePath, boxSourcePath, overwrite: true);
|
File.Copy(sourceFilePath, boxSourcePath, overwrite: true);
|
||||||
|
|
||||||
|
// Copy common headers from the source directory (e.g., testlib.h)
|
||||||
|
var sourceDirectory = Path.GetDirectoryName(sourceFilePath);
|
||||||
|
if (!string.IsNullOrEmpty(sourceDirectory) && Directory.Exists(sourceDirectory))
|
||||||
|
{
|
||||||
|
foreach (var header in Directory.EnumerateFiles(sourceDirectory))
|
||||||
|
{
|
||||||
|
if (string.Equals(header, sourceFilePath, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var extension = Path.GetExtension(header);
|
||||||
|
if (extension is ".h" or ".hpp" or ".hh" or ".hxx" or ".h++" or ".inl" or ".tcc" )
|
||||||
|
{
|
||||||
|
var destination = Path.Combine(boxDir, Path.GetFileName(header));
|
||||||
|
File.Copy(header, destination, overwrite: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Resolve compiler and flags
|
// Resolve compiler and flags
|
||||||
var (compiler, compilerFlags) = ResolveVersion(version);
|
var (compiler, compilerFlags) = ResolveVersion(version);
|
||||||
_logger.LogDebug("Using compiler: {Compiler} with flags: {Flags}", compiler, string.Join(' ', compilerFlags));
|
_logger.LogDebug("Using compiler: {Compiler} with flags: {Flags}", compiler, string.Join(' ', compilerFlags));
|
||||||
|
|
||||||
// Build compiler arguments
|
// Build compiler arguments
|
||||||
var arguments = new List<string>(compilerFlags);
|
var arguments = new List<string>(compilerFlags);
|
||||||
|
var directoryBindings = new List<DirectoryBinding>
|
||||||
|
{
|
||||||
|
new DirectoryBinding { HostPath = "/usr/include", SandboxPath = "/usr/include", ReadOnly = true },
|
||||||
|
new DirectoryBinding { HostPath = "/usr/lib", SandboxPath = "/usr/lib", ReadOnly = true },
|
||||||
|
new DirectoryBinding { HostPath = "/lib", SandboxPath = "/lib", ReadOnly = true }
|
||||||
|
};
|
||||||
|
|
||||||
// Add include directories
|
// Add include directories
|
||||||
if (includeDirectories != null)
|
if (includeDirectories != null)
|
||||||
{
|
{
|
||||||
foreach (var includeDir in includeDirectories.Where(d => !string.IsNullOrWhiteSpace(d)))
|
foreach (var includeDir in includeDirectories.Where(d => !string.IsNullOrWhiteSpace(d)))
|
||||||
{
|
{
|
||||||
arguments.Add($"-I{includeDir}");
|
var resolvedIncludeDir = includeDir;
|
||||||
|
|
||||||
|
if (!Path.IsPathRooted(resolvedIncludeDir))
|
||||||
|
{
|
||||||
|
var baseDir = sourceDirectory ?? Directory.GetCurrentDirectory();
|
||||||
|
resolvedIncludeDir = Path.GetFullPath(Path.Combine(baseDir, includeDir));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Directory.Exists(resolvedIncludeDir))
|
||||||
|
{
|
||||||
|
arguments.Add($"-I{resolvedIncludeDir}");
|
||||||
|
directoryBindings.Add(new DirectoryBinding
|
||||||
|
{
|
||||||
|
HostPath = resolvedIncludeDir,
|
||||||
|
SandboxPath = resolvedIncludeDir,
|
||||||
|
ReadOnly = true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
arguments.Add($"-I{includeDir}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,12 +182,7 @@ public class CppCompilationServiceIsolate : ICompilationService
|
|||||||
EnableNetwork = false,
|
EnableNetwork = false,
|
||||||
StderrFile = stderrFilePath,
|
StderrFile = stderrFilePath,
|
||||||
WorkingDirectory = "/box",
|
WorkingDirectory = "/box",
|
||||||
DirectoryBindings = new List<DirectoryBinding>
|
DirectoryBindings = directoryBindings
|
||||||
{
|
|
||||||
new DirectoryBinding { HostPath = "/usr/include", SandboxPath = "/usr/include", ReadOnly = true },
|
|
||||||
new DirectoryBinding { HostPath = "/usr/lib", SandboxPath = "/usr/lib", ReadOnly = true },
|
|
||||||
new DirectoryBinding { HostPath = "/lib", SandboxPath = "/lib", ReadOnly = true }
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Read compiler output
|
// Read compiler output
|
||||||
|
|||||||
Reference in New Issue
Block a user