Skip to content

Commit

Permalink
Change location of include files
Browse files Browse the repository at this point in the history
  • Loading branch information
Warrick FitzGerald committed Oct 18, 2018
1 parent 89ffedf commit d9d4748
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 5 deletions.
27 changes: 24 additions & 3 deletions EOSCPPManagerLib/EOSCPPManagerCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;

namespace EOSCPPManagerLib
{
Expand Down Expand Up @@ -76,7 +77,16 @@ public void createNewSmartContract(string folder, string contractName, bool over
foreach (var srcPath in Directory.GetFiles(Path.Combine(baseDir, "templateFiles\\.vscode")))
{
FileInfo fileInfo = new FileInfo(srcPath);
File.Copy(srcPath, Path.Combine(vscodeFolder,fileInfo.Name), true);
String destFilePath = Path.Combine(vscodeFolder, fileInfo.Name);
File.Copy(srcPath, destFilePath, true);

if(destFilePath.Contains("c_cpp_properties.json"))
{
string updatedPropertiesText = File.ReadAllText(destFilePath);
updatedPropertiesText = updatedPropertiesText.Replace("C:/eosincludes", Util.AppDataFolder().Replace(@"\","/"));
File.WriteAllText(destFilePath, updatedPropertiesText);

}
}

logger.Info("Template creation completed");
Expand Down Expand Up @@ -114,13 +124,22 @@ public void initializeWindowEnv()
public void initializeInclude()
{
logger.Info("Begin include init");
var includeFolder = config["includeFolder"];
logger.Info("Include Folder = {0}. To change this edit appsettings.json", includeFolder);
//var includeFolder = config["includeFolder"];
var includeFolder = Util.AppDataFolder();
logger.Info("Include Folder = {0}.", includeFolder);

if(Directory.Exists(includeFolder))
{
logger.Info("Deleting existsing folder");
Directory.Delete(includeFolder, true);
}

if(!Directory.Exists(includeFolder))
{
logger.Info("Create folder {0}", includeFolder);
Directory.CreateDirectory(includeFolder);
logger.Info("Pause for 2 seconds before starting the copy.");
Thread.Sleep(2000);
}


Expand Down Expand Up @@ -155,6 +174,8 @@ public void initializeInclude()
".Replace("\r","");
var asyncResult = DockerHelper.RunCommandAsync(cmd, Util.getContainerName(includeFolder)).Result;

logger.Info("Include File written to {0}. This include path will be referened in any new projects created.", includeFolder);

}

private void printPath(string path)
Expand Down
17 changes: 17 additions & 0 deletions EOSCPPManagerLib/Util.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;

namespace EOSCPPManagerLib
Expand Down Expand Up @@ -34,5 +37,19 @@ public static void copyLibs(string destinationPath)
{

}

public static string AppDataFolder()
{
var userPath = Environment.GetEnvironmentVariable(
RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ?
"LOCALAPPDATA" : "Home");

var assy = System.Reflection.Assembly.GetEntryAssembly();
var productName = assy.GetCustomAttributes<AssemblyProductAttribute>()
.FirstOrDefault();
var path = System.IO.Path.Combine(userPath, productName.Product);

return path;
}
}
}
2 changes: 2 additions & 0 deletions EOSEasyContract/EOSEasyContract.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<Company>EOSNewYork</Company>
<Authors>Warrick FitzGerald</Authors>
</PropertyGroup>

<ItemGroup>
Expand Down
3 changes: 3 additions & 0 deletions EOSEasyContract/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ public static int Main(string[] args)
var eosiocppDockerImage = config["eosiocppDockerImage"];

logger.Info("Check connection to local docker instance and confirm that image \"{0}\" exists", eosiocppDockerImage);
logger.Info("If this step hange/freezes for an extended period of time please confirm the following:");
logger.Info("\t 1. That your docker settings have \"expose daemon\" enabled. On windows this is tcp://localhost:2375 by default.");
logger.Info("\t 2. That your Antivirus is not blocking access to tcp://localhost:2375");

var exists = DockerHelper.CheckImageExistsAsync(eosiocppDockerImage).Result;
if (!exists)
Expand Down
3 changes: 1 addition & 2 deletions EOSEasyContract/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"eosiocppDockerImage": "binaryfocus/eosio_wasm_1.3.2",
"includeFolder": "c:\\eosincludes"
"eosiocppDockerImage": "binaryfocus/eosio_wasm_1.3.2"
}

0 comments on commit d9d4748

Please sign in to comment.