diff --git a/src/Stratis.VS.SolidityProjectBuildTasks/CompileContracts.cs b/src/Stratis.VS.SolidityProjectBuildTasks/CompileContracts.cs index 490610c..18c019a 100644 --- a/src/Stratis.VS.SolidityProjectBuildTasks/CompileContracts.cs +++ b/src/Stratis.VS.SolidityProjectBuildTasks/CompileContracts.cs @@ -1,4 +1,6 @@ using System; +using System.Diagnostics; +using System.IO; using System.Linq; using Microsoft.Build.Framework; using Microsoft.Build.Utilities; @@ -18,8 +20,24 @@ public class CompileContracts : Task public override bool Execute() { - Log.LogMessage(MessageImportance.High, "{0}:{1}", ExtDir, Contracts.Select(c => c.ItemSpec).ToArray()); - return true; + var solcpath = Directory.Exists(Path.Combine(ProjectDir, "node_modules", "solc", "solc.js")) ? Path.Combine(ProjectDir, "node_modules", "solc", "solc.js") : + Path.Combine(ExtDir, "node_modules", "solc", "solc.js"); + Log.LogMessage(MessageImportance.High, "Compiling {0} files in directory:{1}", Contracts.Count(), ProjectDir); + + + var psi = new ProcessStartInfo("cmd.exe", "/c node" + solcpath + " --base-path=\"" + ProjectDir + "\"") + { + WorkingDirectory = ProjectDir, + CreateNoWindow = true, + RedirectStandardOutput = false, + RedirectStandardInput = false, + RedirectStandardError = false, + }; + var p = new Process() + { + StartInfo = psi + }; + return false; } } } diff --git a/src/Stratis.VS.SolidityProjectBuildTasks/SolidityCompilerIO.cs b/src/Stratis.VS.SolidityProjectBuildTasks/SolidityCompilerIO.cs new file mode 100644 index 0000000..8abb0e5 --- /dev/null +++ b/src/Stratis.VS.SolidityProjectBuildTasks/SolidityCompilerIO.cs @@ -0,0 +1,117 @@ +namespace Stratis.VS.StratisEVM.SolidityCompilerIO +{ + using System; + using System.Collections.Generic; + + using System.Globalization; + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + + public partial class SolidityCompilerInput + { + [JsonProperty("language")] + public string Language { get; set; } + + [JsonProperty("sources")] + public Sources Sources { get; set; } + + [JsonProperty("settings")] + public Settings Settings { get; set; } + } + + public partial class Settings + { + [JsonProperty("remappings")] + public string[] Remappings { get; set; } + + [JsonProperty("optimizer")] + public Optimizer Optimizer { get; set; } + + [JsonProperty("evmVersion")] + public string EvmVersion { get; set; } + + [JsonProperty("metadata")] + public Metadata Metadata { get; set; } + + [JsonProperty("libraries")] + public Libraries Libraries { get; set; } + + [JsonProperty("outputSelection")] + public OutputSelection OutputSelection { get; set; } + } + + public partial class Libraries + { + [JsonProperty("myFile.sol")] + public LibrariesMyFileSol MyFileSol { get; set; } + } + + public partial class LibrariesMyFileSol + { + [JsonProperty("MyLib")] + public string MyLib { get; set; } + } + + public partial class Metadata + { + [JsonProperty("useLiteralContent")] + public bool UseLiteralContent { get; set; } + } + + public partial class Optimizer + { + [JsonProperty("enabled")] + public bool Enabled { get; set; } + + [JsonProperty("runs")] + public long Runs { get; set; } + } + + public partial class OutputSelection + { + [JsonProperty("*")] + public Empty Empty { get; set; } + + [JsonProperty("def")] + public Def Def { get; set; } + } + + public partial class Def + { + [JsonProperty("MyContract")] + public string[] MyContract { get; set; } + } + + public partial class Empty + { + [JsonProperty("")] + public string[] Purple { get; set; } + } + + public partial class Sources + { + [JsonProperty("myFile.sol")] + public SourcesMyFileSol MyFileSol { get; set; } + + [JsonProperty("mortal")] + public Mortal Mortal { get; set; } + } + + public partial class Mortal + { + [JsonProperty("keccak256")] + public string Keccak256 { get; set; } + + [JsonProperty("content")] + public string Content { get; set; } + } + + public partial class SourcesMyFileSol + { + [JsonProperty("keccak256")] + public string Keccak256 { get; set; } + + [JsonProperty("urls")] + public string[] Urls { get; set; } + } +} diff --git a/src/Stratis.VS.SolidityProjectBuildTasks/Stratis.VS.SolidityProjectBuildTasks.csproj b/src/Stratis.VS.SolidityProjectBuildTasks/Stratis.VS.SolidityProjectBuildTasks.csproj index db6b927..237be4f 100644 --- a/src/Stratis.VS.SolidityProjectBuildTasks/Stratis.VS.SolidityProjectBuildTasks.csproj +++ b/src/Stratis.VS.SolidityProjectBuildTasks/Stratis.VS.SolidityProjectBuildTasks.csproj @@ -11,6 +11,7 @@ +