Skip to content

Commit

Permalink
Update dotnet script (#4337)
Browse files Browse the repository at this point in the history
* Uses new way to invoke compilers
* adds new
  • Loading branch information
hez2010 committed Nov 25, 2022
1 parent f1a4f16 commit 201f848
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 79 deletions.
26 changes: 15 additions & 11 deletions etc/config/csharp.amazon.properties
Expand Up @@ -2,16 +2,20 @@ compilers=&csharp
supportsBinary=false
needsMulti=false
compilerType=csharp
defaultCompiler=dotnet601csharp
defaultCompiler=dotnet700csharp

group.csharp.compilers=dotnet601csharp
group.csharp.compilers=dotnet6011csharp:dotnet700csharp

compiler.dotnet601csharp.exe=/opt/compiler-explorer/dotnet-v6.0.1/bin/coreclr/Linux.x64.Checked/.dotnet/dotnet
compiler.dotnet601csharp.name=.NET 6.0.101
compiler.dotnet601csharp.clrDir=/opt/compiler-explorer/dotnet-v6.0.1/bin/coreclr/Linux.x64.Checked
compiler.dotnet601csharp.runtimeId=linux-x64
compiler.dotnet601csharp.targetFramework=net6.0
compiler.dotnet601csharp.buildConfig=Release
compiler.dotnet601csharp.additionalSources=
compiler.dotnet601csharp.langVersion=latest
compiler.dotnet601csharp.nugetPackages=/opt/compiler-explorer/dotnet_nuget-v6.0.0/packages
compiler.dotnet6011csharp.exe=/opt/compiler-explorer/dotnet-v6.0.11/Core_Root/.dotnet/dotnet
compiler.dotnet6011csharp.name=.NET 6.0.403
compiler.dotnet6011csharp.clrDir=/opt/compiler-explorer/dotnet-v6.0.11/Core_Root
compiler.dotnet6011csharp.targetFramework=net6.0
compiler.dotnet6011csharp.buildConfig=Release
compiler.dotnet6011csharp.langVersion=latest

compiler.dotnet700csharp.exe=/opt/compiler-explorer/dotnet-v7.0.0/Core_Root/.dotnet/dotnet
compiler.dotnet700csharp.name=.NET 7.0.100
compiler.dotnet700csharp.clrDir=/opt/compiler-explorer/dotnet-v7.0.0/Core_Root
compiler.dotnet700csharp.targetFramework=net7.0
compiler.dotnet700csharp.buildConfig=Release
compiler.dotnet700csharp.langVersion=latest
19 changes: 12 additions & 7 deletions etc/config/csharp.defaults.properties
@@ -1,14 +1,19 @@
compilers=dotnet6csharp
compilers=dotnet6csharp:dotnet7csharp
supportsBinary=false
needsMulti=false
compilerType=csharp
defaultCompiler=dotnet6csharp
defaultCompiler=dotnet7csharp

compiler.dotnet6csharp.exe=/opt/compiler-explorer/dotnet-v6.0.1/bin/coreclr/Linux.x64.Checked/.dotnet/dotnet
compiler.dotnet6csharp.name=.NET 6.0.101
compiler.dotnet6csharp.clrDir=/opt/compiler-explorer/dotnet-v6.0.1/bin/coreclr/Linux.x64.Checked
compiler.dotnet6csharp.runtimeId=linux-x64
compiler.dotnet6csharp.exe=/opt/compiler-explorer/dotnet-v6.0.11/Core_Root/.dotnet/dotnet
compiler.dotnet6csharp.name=.NET 6.0.403
compiler.dotnet6csharp.clrDir=/opt/compiler-explorer/dotnet-v6.0.11/Core_Root
compiler.dotnet6csharp.targetFramework=net6.0
compiler.dotnet6csharp.buildConfig=Release
compiler.dotnet6csharp.additionalSources=
compiler.dotnet6csharp.langVersion=latest

compiler.dotnet7csharp.exe=/opt/compiler-explorer/dotnet-v7.0.0/Core_Root/.dotnet/dotnet
compiler.dotnet7csharp.name=.NET 7.0.100
compiler.dotnet7csharp.clrDir=/opt/compiler-explorer/dotnet-v7.0.0/Core_Root
compiler.dotnet7csharp.targetFramework=net7.0
compiler.dotnet7csharp.buildConfig=Release
compiler.dotnet7csharp.langVersion=latest
26 changes: 15 additions & 11 deletions etc/config/fsharp.amazon.properties
Expand Up @@ -2,16 +2,20 @@ compilers=&fsharp
supportsBinary=false
needsMulti=false
compilerType=fsharp
defaultCompiler=dotnet601fsharp
defaultCompiler=dotnet700fsharp

group.fsharp.compilers=dotnet601fsharp
group.fsharp.compilers=dotnet6011fsharp:dotnet700fsharp

compiler.dotnet601fsharp.exe=/opt/compiler-explorer/dotnet-v6.0.1/bin/coreclr/Linux.x64.Checked/.dotnet/dotnet
compiler.dotnet601fsharp.name=.NET 6.0.101
compiler.dotnet601fsharp.clrDir=/opt/compiler-explorer/dotnet-v6.0.1/bin/coreclr/Linux.x64.Checked
compiler.dotnet601fsharp.runtimeId=linux-x64
compiler.dotnet601fsharp.targetFramework=net6.0
compiler.dotnet601fsharp.buildConfig=Release
compiler.dotnet601fsharp.additionalSources=
compiler.dotnet601fsharp.langVersion=latest
compiler.dotnet601fsharp.nugetPackages=/opt/compiler-explorer/dotnet_nuget-v6.0.0/packages
compiler.dotnet6011fsharp.exe=/opt/compiler-explorer/dotnet-v6.0.11/Core_Root/.dotnet/dotnet
compiler.dotnet6011fsharp.name=.NET 6.0.403
compiler.dotnet6011fsharp.clrDir=/opt/compiler-explorer/dotnet-v6.0.11/Core_Root
compiler.dotnet6011fsharp.targetFramework=net6.0
compiler.dotnet6011fsharp.buildConfig=Release
compiler.dotnet6011fsharp.langVersion=latest

compiler.dotnet700fsharp.exe=/opt/compiler-explorer/dotnet-v7.0.0/Core_Root/.dotnet/dotnet
compiler.dotnet700fsharp.name=.NET 7.0.100
compiler.dotnet700fsharp.clrDir=/opt/compiler-explorer/dotnet-v7.0.0/Core_Root
compiler.dotnet700fsharp.targetFramework=net7.0
compiler.dotnet700fsharp.buildConfig=Release
compiler.dotnet700fsharp.langVersion=latest
19 changes: 12 additions & 7 deletions etc/config/fsharp.defaults.properties
@@ -1,14 +1,19 @@
compilers=dotnet6fsharp
compilers=dotnet6fsharp:dotnet7fsharp
supportsBinary=false
needsMulti=false
compilerType=fsharp
defaultCompiler=dotnet6fsharp
defaultCompiler=dotnet7fsharp

compiler.dotnet6fsharp.exe=/opt/compiler-explorer/dotnet-v6.0.1/bin/coreclr/Linux.x64.Checked/.dotnet/dotnet
compiler.dotnet6fsharp.name=.NET 6.0.101
compiler.dotnet6fsharp.clrDir=/opt/compiler-explorer/dotnet-v6.0.1/bin/coreclr/Linux.x64.Checked
compiler.dotnet6fsharp.runtimeId=linux-x64
compiler.dotnet6fsharp.exe=/opt/compiler-explorer/dotnet-v6.0.11/Core_Root/.dotnet/dotnet
compiler.dotnet6fsharp.name=.NET 6.0.403
compiler.dotnet6fsharp.clrDir=/opt/compiler-explorer/dotnet-v6.0.11/Core_Root
compiler.dotnet6fsharp.targetFramework=net6.0
compiler.dotnet6fsharp.buildConfig=Release
compiler.dotnet6fsharp.additionalSources=
compiler.dotnet6fsharp.langVersion=latest

compiler.dotnet7fsharp.exe=/opt/compiler-explorer/dotnet-v7.0.0/Core_Root/.dotnet/dotnet
compiler.dotnet7fsharp.name=.NET 7.0.100
compiler.dotnet7fsharp.clrDir=/opt/compiler-explorer/dotnet-v7.0.0/Core_Root
compiler.dotnet7fsharp.targetFramework=net7.0
compiler.dotnet7fsharp.buildConfig=Release
compiler.dotnet7fsharp.langVersion=latest
26 changes: 15 additions & 11 deletions etc/config/vb.amazon.properties
Expand Up @@ -2,16 +2,20 @@ compilers=&vb
supportsBinary=false
needsMulti=false
compilerType=vb
defaultCompiler=dotnet601vb
defaultCompiler=dotnet700vb

group.vb.compilers=dotnet601vb
group.vb.compilers=dotnet6011vb:dotnet700vb

compiler.dotnet601vb.exe=/opt/compiler-explorer/dotnet-v6.0.1/bin/coreclr/Linux.x64.Checked/.dotnet/dotnet
compiler.dotnet601vb.name=.NET 6.0.101
compiler.dotnet601vb.clrDir=/opt/compiler-explorer/dotnet-v6.0.1/bin/coreclr/Linux.x64.Checked
compiler.dotnet601vb.runtimeId=linux-x64
compiler.dotnet601vb.targetFramework=net6.0
compiler.dotnet601vb.buildConfig=Release
compiler.dotnet601vb.additionalSources=
compiler.dotnet601vb.langVersion=latest
compiler.dotnet601vb.nugetPackages=/opt/compiler-explorer/dotnet_nuget-v6.0.0/packages
compiler.dotnet6011vb.exe=/opt/compiler-explorer/dotnet-v6.0.11/Core_Root/.dotnet/dotnet
compiler.dotnet6011vb.name=.NET 6.0.403
compiler.dotnet6011vb.clrDir=/opt/compiler-explorer/dotnet-v6.0.11/Core_Root
compiler.dotnet6011vb.targetFramework=net6.0
compiler.dotnet6011vb.buildConfig=Release
compiler.dotnet6011vb.langVersion=latest

compiler.dotnet700vb.exe=/opt/compiler-explorer/dotnet-v7.0.0/Core_Root/.dotnet/dotnet
compiler.dotnet700vb.name=.NET 7.0.100
compiler.dotnet700vb.clrDir=/opt/compiler-explorer/dotnet-v7.0.0/Core_Root
compiler.dotnet700vb.targetFramework=net7.0
compiler.dotnet700vb.buildConfig=Release
compiler.dotnet700vb.langVersion=latest
19 changes: 12 additions & 7 deletions etc/config/vb.defaults.properties
@@ -1,14 +1,19 @@
compilers=dotnet6vb
compilers=dotnet6vb:dotnet7vb
supportsBinary=false
needsMulti=false
compilerType=vb
defaultCompiler=dotnet6vb
defaultCompiler=dotnet7vb

compiler.dotnet6vb.exe=/opt/compiler-explorer/dotnet-v6.0.1/bin/coreclr/Linux.x64.Checked/.dotnet/dotnet
compiler.dotnet6vb.name=.NET 6.0.101
compiler.dotnet6vb.clrDir=/opt/compiler-explorer/dotnet-v6.0.1/bin/coreclr/Linux.x64.Checked
compiler.dotnet6vb.runtimeId=linux-x64
compiler.dotnet6vb.exe=/opt/compiler-explorer/dotnet-v6.0.11/Core_Root/.dotnet/dotnet
compiler.dotnet6vb.name=.NET 6.0.403
compiler.dotnet6vb.clrDir=/opt/compiler-explorer/dotnet-v6.0.11/Core_Root
compiler.dotnet6vb.targetFramework=net6.0
compiler.dotnet6vb.buildConfig=Release
compiler.dotnet6vb.additionalSources=
compiler.dotnet6vb.langVersion=latest

compiler.dotnet7vb.exe=/opt/compiler-explorer/dotnet-v7.0.0/Core_Root/.dotnet/dotnet
compiler.dotnet7vb.name=.NET 7.0.100
compiler.dotnet7vb.clrDir=/opt/compiler-explorer/dotnet-v7.0.0/Core_Root
compiler.dotnet7vb.targetFramework=net7.0
compiler.dotnet7vb.buildConfig=Release
compiler.dotnet7vb.langVersion=latest
46 changes: 21 additions & 25 deletions lib/compilers/dotnet.ts
Expand Up @@ -31,29 +31,23 @@ import {BaseCompiler} from '../base-compiler';
import {DotNetAsmParser} from '../parsers/asm-parser-dotnet';

class DotNetCompiler extends BaseCompiler {
private rID: string;
private targetFramework: string;
private buildConfig: string;
private nugetPackagesPath: string;
private clrBuildDir: string;
private additionalSources: string;
private langVersion: string;

constructor(compilerInfo, env) {
super(compilerInfo, env);

this.rID = this.compilerProps(`compiler.${this.compiler.id}.runtimeId`);
this.targetFramework = this.compilerProps(`compiler.${this.compiler.id}.targetFramework`);
this.buildConfig = this.compilerProps(`compiler.${this.compiler.id}.buildConfig`);
this.nugetPackagesPath = this.compilerProps(`compiler.${this.compiler.id}.nugetPackages`);
this.clrBuildDir = this.compilerProps(`compiler.${this.compiler.id}.clrDir`);
this.additionalSources = this.compilerProps(`compiler.${this.compiler.id}.additionalSources`);
this.langVersion = this.compilerProps(`compiler.${this.compiler.id}.langVersion`);
this.asm = new DotNetAsmParser();
}

get compilerOptions() {
return ['publish', '-c', this.buildConfig, '--self-contained', '--runtime', this.rID, '-v', 'q', '--nologo'];
return ['build', '-c', this.buildConfig, '-v', 'q', '--nologo', '--no-restore'];
}

get configurableOptions() {
Expand Down Expand Up @@ -98,42 +92,39 @@ class DotNetCompiler extends BaseCompiler {

const projectFilePath = path.join(programDir, `CompilerExplorer${this.lang.extensions[0]}proj`);
const crossgen2Path = path.join(this.clrBuildDir, 'crossgen2', 'crossgen2.dll');
const nugetConfigPath = path.join(programDir, 'nuget.config');

const programPublishPath = path.join(
programDir,
'bin',
this.buildConfig,
this.targetFramework,
this.rID,
'publish',
);

const programDllPath = path.join(programPublishPath, 'CompilerExplorer.dll');
const programOutputPath = path.join(programDir, 'bin', this.buildConfig, this.targetFramework);
const programDllPath = path.join(programOutputPath, 'CompilerExplorer.dll');
const projectFileContent = `<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>${this.targetFramework}</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AssemblyName>CompilerExplorer</AssemblyName>
<LangVersion>${this.langVersion}</LangVersion>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<EnablePreviewFeatures>${this.langVersion === 'preview' ? 'true' : 'false'}</EnablePreviewFeatures>
<RestoreAdditionalProjectSources>
https://api.nuget.org/v3/index.json;${this.additionalSources ? this.additionalSources : ''}
</RestoreAdditionalProjectSources>
</PropertyGroup>
<ItemGroup>
<Compile Include="${sourceFile}" />
</ItemGroup>
</Project>
`;
const nugetConfigFileContent = `<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
</packageSources>
</configuration>
`;

execOptions.env.DOTNET_CLI_TELEMETRY_OPTOUT = 'true';
execOptions.env.DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 'true';
execOptions.env.NUGET_PACKAGES = this.nugetPackagesPath;
execOptions.env.NUGET_PACKAGES = path.join(programDir, '.nuget');
execOptions.env.DOTNET_NOLOGO = 'true';

execOptions.customCwd = programDir;
await fs.writeFile(projectFilePath, projectFileContent);
await fs.writeFile(nugetConfigPath, nugetConfigFileContent);

const crossgen2Options: string[] = [];
const configurableOptions = this.configurableOptions;
Expand All @@ -155,6 +146,9 @@ class DotNetCompiler extends BaseCompiler {
crossgen2Options.push(options[switchIndex]);
}

const restoreOptions = ['restore', '--configfile', nugetConfigPath, '-v', 'q', '--nologo'];
const restoreResult = await this.exec(compiler, restoreOptions, execOptions);

const compilerResult = await super.runCompiler(compiler, this.compilerOptions, inputFilename, execOptions);

if (compilerResult.code !== 0) {
Expand All @@ -165,7 +159,7 @@ class DotNetCompiler extends BaseCompiler {
compiler,
execOptions,
crossgen2Path,
programPublishPath,
this.clrBuildDir,
programDllPath,
crossgen2Options,
this.getOutputFilename(programDir, this.outputFilebase),
Expand All @@ -182,17 +176,19 @@ class DotNetCompiler extends BaseCompiler {
return this.compilerOptions;
}

async runCrossgen2(compiler, execOptions, crossgen2Path, publishPath, dllPath, options, outputPath) {
async runCrossgen2(compiler, execOptions, crossgen2Path, bclPath, dllPath, options, outputPath) {
const crossgen2Options = [
crossgen2Path,
'-r',
path.join(publishPath, '*'),
path.join(bclPath, '*'),
dllPath,
'-o',
'CompilerExplorer.r2r.dll',
'--codegenopt',
'NgenDisasm=*',
'--codegenopt',
'JitDisasm=*',
'--codegenopt',
'JitDiffableDasm=1',
'--parallelism',
'1',
Expand Down

0 comments on commit 201f848

Please sign in to comment.