Ejemplo n.º 1
0
        private CodebaseGenerator(CommandArgs appArgs, bool returnFullSources, LoggerDelegate logger)
        {
            _logger            = logger;
            _assemblyVersion   = typeof(Program).Assembly.GetName().Version.ToString();
            _returnFullSources = returnFullSources;
            _genResults        = new SolCodeGenResults();

            // Normalize source directory
            _solSourceDirectory = Path.GetFullPath(appArgs.SolSourceDirectory);

            // If we were passed a single sol file rather than a source directory
            if (_solSourceDirectory.EndsWith(".sol", StringComparison.OrdinalIgnoreCase) && File.Exists(_solSourceDirectory))
            {
                _solSourceSingleFile = _solSourceDirectory;
                _solSourceDirectory  = Path.GetDirectoryName(_solSourceDirectory);
            }

            // Match the solc file path output format which replaces Windows path separator characters with unix style.
            if (Path.DirectorySeparatorChar == '\\')
            {
                _solSourceDirectory = _solSourceDirectory.Replace('\\', '/');
            }

            if (string.IsNullOrWhiteSpace(appArgs.OutputDirectory))
            {
                string sourceFilesParentDir = Directory.GetParent(_solSourceDirectory).FullName;
                _generatedContractsDirectory = Path.Combine(sourceFilesParentDir, GeneratedContractsDefaultDirectory);
            }
            else
            {
                _generatedContractsDirectory = Path.GetFullPath(appArgs.OutputDirectory);
            }

            if (string.IsNullOrWhiteSpace(appArgs.AssemblyOutputDirectory))
            {
                string sourceFilesParentDir = Directory.GetParent(_solSourceDirectory).FullName;
                _generatedAssemblyDirectory = Path.Combine(sourceFilesParentDir, GeneratedAssemblyDefaultDirectory);
            }
            else
            {
                _generatedAssemblyDirectory = Path.GetFullPath(appArgs.AssemblyOutputDirectory);
            }

            if (_solSourceSingleFile != null)
            {
                _solSourceDirectory = string.Empty;
            }

            if (!string.IsNullOrEmpty(appArgs.LegacySolcPath))
            {
                _legacySolcPath = Path.GetFullPath(appArgs.LegacySolcPath);
            }

            _namespace               = appArgs.Namespace;
            _solcVersion             = appArgs.SolcVersion;
            _solcOptimzer            = appArgs.SolcOptimizer;
            _solcLib                 = SetupSolcLib();
            _solidityCompilerVersion = _solcLib.Version.ToString(3);
        }
Ejemplo n.º 2
0
        public Compilation(SolCodeGenResults codeGenResults, string @namespace, string outputDirectory)
        {
            _codeGenResults  = codeGenResults;
            _outputDirectory = outputDirectory;
            _namespace       = @namespace;

            _generatedAssemblyFile = Path.Combine(_outputDirectory, _namespace + ".dll");
            _generatedPdbFile      = Path.Combine(_outputDirectory, _namespace + ".pdb");
            _generatedXmlDocFile   = Path.Combine(_outputDirectory, _namespace + ".xml");
        }
Ejemplo n.º 3
0
        private CodebaseGenerator(CommandArgs appArgs, bool returnFullSources)
        {
            _assemblyVersion   = typeof(Program).Assembly.GetName().Version.ToString();
            _returnFullSources = returnFullSources;
            _genResults        = new SolCodeGenResults();

            // Normalize source directory
            _solSourceDirectory = Path.GetFullPath(appArgs.SolSourceDirectory);

            // Match the solc file path output format which replaces Windows path separator characters with unix style.
            if (Path.DirectorySeparatorChar == '\\')
            {
                _solSourceDirectory = _solSourceDirectory.Replace('\\', '/');
            }

            if (string.IsNullOrWhiteSpace(appArgs.OutputDirectory))
            {
                string sourceFilesParentDir = Directory.GetParent(_solSourceDirectory).FullName;
                _generatedContractsDirectory = Path.Combine(sourceFilesParentDir, GeneratedContractsDefaultDirectory);
            }
            else
            {
                _generatedContractsDirectory = Path.GetFullPath(appArgs.OutputDirectory);
            }

            if (string.IsNullOrWhiteSpace(appArgs.AssemblyOutputDirectory))
            {
                string sourceFilesParentDir = Directory.GetParent(_solSourceDirectory).FullName;
                _generatedAssemblyDirectory = Path.Combine(sourceFilesParentDir, GeneratedAssemblyDefaultDirectory);
            }
            else
            {
                _generatedAssemblyDirectory = Path.GetFullPath(appArgs.AssemblyOutputDirectory);
            }

            if (!string.IsNullOrEmpty(appArgs.LegacySolcPath))
            {
                _legacySolcPath = Path.GetFullPath(appArgs.LegacySolcPath);
            }

            _namespace               = appArgs.Namespace;
            _solcVersion             = appArgs.SolcVersion;
            _solcOptimzer            = appArgs.SolcOptimizer;
            _solcLib                 = SetupSolcLib();
            _solidityCompilerVersion = _solcLib.Version.ToString(3);
        }