private static void build() { //If we're already building then exit if (building) { return; } building = true; try { logger.Info("Building ... "); Stopwatch sw = new Stopwatch(); sw.Start(); logger.Info("Check if container {0} exists", Util.getContainerName(sourceCodePath)); Dictionary <String, String> mounts = new Dictionary <string, string>(); mounts.Add(sourceCodePath, "/data"); var containerExists = DockerHelper.CheckContainerExistsAsync(Util.getContainerName(sourceCodePath), mounts).Result; if (!containerExists) { logger.Info("No existing container found"); var n = DockerHelper.StartDockerAsync(dockerImage, Util.getContainerName(sourceCodePath), false, mounts).Result; } else { logger.Info("Existing container found"); } //string cmd = "ls /"; string cmd = "./build.sh"; var asyncResult = DockerHelper.RunCommandAsync(cmd, Util.getContainerName(sourceCodePath)).Result; sw.Stop(); logger.Info("Done Building. Build Duration = " + sw.Elapsed); } catch (Exception ex) { logger.Error(ex.Message); } finally { building = false; } }
public void initializeInclude() { logger.Info("Begin include init"); //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); } Dictionary <String, String> mounts = new Dictionary <string, string>(); mounts.Add(includeFolder, "/host_eosinclude"); logger.Info("Check if container {0} exists", Util.getContainerName(includeFolder)); var containerExists = DockerHelper.CheckContainerExistsAsync(Util.getContainerName(includeFolder), mounts).Result; if (!containerExists) { var eosiocppDockerImage = config["eosiocppDockerImage"]; //logger.Info("Container {0} not found. Please run \"EOSEasyContract init docker\"", eosiocppDockerImage); //return; //var eosiocppDockerImage = config["eosiocppDockerImage"]; logger.Info("Container did not exist. Creating new Container to copy include files from: {0}", Util.getContainerName(includeFolder)); var n = DockerHelper.StartDockerAsync(eosiocppDockerImage, Util.getContainerName(includeFolder), false, mounts).Result; var containerExistsTake2 = DockerHelper.CheckContainerExistsAsync(Util.getContainerName(includeFolder), mounts).Result; logger.Info("Check if container {0} exists", Util.getContainerName(includeFolder)); if (!containerExistsTake2) { logger.Error("Container not found. We tried creating the container but something went wrong and we still can't access the container."); logger.Error("Container {0} not found. Please run \"EOSEasyContract init docker\" and then try again.", eosiocppDockerImage); return; } } else { logger.Info("Existing container found"); } //string cmd = "cp -R /usr/local/eosio/include /host_eosinclude"; string cmd = @"mkdir -p /host_eosinclude/usr/local/eosio; \ cp -v -R /usr/local/eosio /host_eosinclude/usr/local; \ mkdir -p /host_eosinclude/usr/local/eosio.cdt/include; \ cp -v -R /usr/local/eosio.cdt/include /host_eosinclude/usr/local/eosio.cdt/; \ mkdir -p /host_eosinclude/usr/local/include; \ cp -v -R /usr/local/eosio/include /host_eosinclude/usr/local; \ mkdir -p /host_eosinclude/usr/global/include; \ cp -v -R /usr/include /host_eosinclude/usr/global; ".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); }