Пример #1
0
        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);
        }