Exemplo n.º 1
0
        public ITargetChecker NewTargetFactoryForFamily(TargetPlatforms family)
        {
            switch (family)
            {
            case TargetPlatforms.windows:
                return(new WindowsTargetChecker());

            case TargetPlatforms.unix:
                return(new UnixTargetChecker());

            case TargetPlatforms.ios:
                return(new CiscoIosChecker());

            case TargetPlatforms.undefined:
                return(new UndefinedTargetChecker());

            case TargetPlatforms.catos:
            case TargetPlatforms.macos:
            case TargetPlatforms.pixos:
            case TargetPlatforms.vmware_infrastructure:
                break;
            }

            throw new NotSupportedException(String.Format("{0} platform is not supported currently.", family.ToString()));
        }
        static void InitializePrototypes()
        {
            // #TODO_BLAM: if we use a 'null' engine entry, add it here, before the prototypes are read
            using (var s = OpenRegistryTagElementStream())
            {
                SerializePrototypes(s);
                SerializeTargets(s);
            }

            KSoft.Debug.ValueCheck.IsLessThanEqualTo("EngineRegistry: Too many registered engines",
                                                     BlamEngine.kMaxCount, Engines.Count);
            KSoft.Debug.ValueCheck.IsLessThanEqualTo("EngineRegistry: Too many registered target platforms",
                                                     EngineTargetPlatform.kMaxCount, TargetPlatforms.Count);
            KSoft.Debug.ValueCheck.IsLessThanEqualTo("EngineRegistry: Too many registered resource models",
                                                     kMaxResourceModels, ResourceModels.Count);

            KSoft.Debug.ValueCheck.IsDistinct("EngineRegistry: Duplicate engines registered",
                                              "name", Engines.Select(e => e.Name));
            KSoft.Debug.ValueCheck.IsDistinct("EngineRegistry: Duplicate target platforms registered",
                                              "name", TargetPlatforms.Select(e => e.Name));
            KSoft.Debug.ValueCheck.IsDistinct("EngineRegistry: Duplicate resource models registered",
                                              "name", ResourceModels);

            gEngines.TrimExcess();
            gTargetPlatforms.TrimExcess();
            gResourceModels.TrimExcess();

            BlamEngine.InitializeEngineBuildHandles();
            kNullValidTargetPlatforms = new Collections.BitSet(TargetPlatforms.Count);
            InitializeTargetPlatformIndicies();
        }
Exemplo n.º 3
0
        public static void TranslateAll(
            TextWriter logw,
            string outputPath,
            bool readSymbols,
            bool enableCpp,
            bool enableBundler,
            TargetPlatforms targetPlatform,
            DebugInformationOptions debugInformationOptions,
            IEnumerable <string> assemblyPaths)
        {
            var storage = new CodeTextStorage(
                logw,
                outputPath,
                enableCpp,
                "    ");

            foreach (var aseemblyPath in assemblyPaths)
            {
                Translate(
                    logw,
                    storage,
                    readSymbols,
                    enableBundler,
                    targetPlatform,
                    debugInformationOptions,
                    aseemblyPath);
            }
        }
Exemplo n.º 4
0
        public static void Translate(
            CodeTextStorage storage,
            bool readSymbols,
            bool enableBundler,
            TargetPlatforms targetPlatform,
            DebugInformationOptions debugInformationOptions,
            string assemblyPath)
        {
            System.Console.WriteLine("IL2C: Preparing assembly: \"{0}\" ...", Path.GetFullPath(assemblyPath));

            var translateContext = new TranslateContext(assemblyPath, readSymbols);

            System.Console.WriteLine(" done.");
            using (var _ = storage.EnterScope("meta"))
            {
                MetadataSerializer metaSerializer = new MetadataSerializer(translateContext);
                metaSerializer.WriteResult(storage);
            }

            using (var _ = storage.EnterScope("include"))
            {
            }

            using (var _ = storage.EnterScope("src"))
            {
            }
        }
Exemplo n.º 5
0
        public static void Translate(
            TextWriter logw,
            CodeTextStorage storage,
            bool readSymbols,
            bool enableBundler,
            TargetPlatforms targetPlatform,
            DebugInformationOptions debugInformationOptions,
            string assemblyPath)
        {
            logw.Write("IL2C: Preparing assembly: \"{0}\" ...", Path.GetFullPath(assemblyPath));

            var translateContext  = new TranslateContext(assemblyPath, readSymbols, targetPlatform);
            var preparedFunctions = AssemblyPreparer.Prepare(translateContext);

            logw.WriteLine(" done.");

            using (var _ = storage.EnterScope("include"))
            {
                AssemblyWriter.WriteHeader(
                    storage,
                    translateContext,
                    preparedFunctions);
            }

            using (var _ = storage.EnterScope("src"))
            {
                AssemblyWriter.WriteSourceCode(
                    storage,
                    translateContext,
                    preparedFunctions,
                    enableBundler,
                    debugInformationOptions);
            }
        }
Exemplo n.º 6
0
        public virtual TargetCheckingResult CheckTargetAvailability(TargetPlatforms targetPlatform, string address, string encryptedCredentials, string sshPort)
        {
            var token = LogonModSic();

            try
            {
                return(ModSicProxyService.CheckTargetAvailability(targetPlatform, address, encryptedCredentials, sshPort, token));
            }
            finally
            {
                ModSicProxyService.Logout(token);
            }
        }
Exemplo n.º 7
0
 public static void TranslateAll(
     CodeTextStorage storage,
     bool readSymbols,
     bool enableBundler,
     TargetPlatforms targetPlatform,
     DebugInformationOptions debugInformationOptions,
     params string[] assemblyPaths)
 {
     TranslateAll(
         storage,
         readSymbols,
         enableBundler,
         targetPlatform,
         debugInformationOptions,
         (IEnumerable <string>)assemblyPaths);
 }
Exemplo n.º 8
0
 public static void TranslateAll(
     TextWriter logw,
     string outputPath,
     bool readSymbols,
     bool enableBundler,
     TargetPlatforms targetPlatform,
     DebugInformationOptions debugInformationOptions,
     params string[] assemblyPaths)
 {
     TranslateAll(
         logw,
         outputPath,
         readSymbols,
         enableBundler,
         targetPlatform,
         debugInformationOptions,
         (IEnumerable <string>)assemblyPaths);
 }
Exemplo n.º 9
0
 public static void TranslateAll(
     CodeTextStorage storage,
     bool readSymbols,
     bool enableBundler,
     TargetPlatforms targetPlatform,
     DebugInformationOptions debugInformationOptions,
     IEnumerable <string> assemblyPaths)
 {
     foreach (var aseemblyPath in assemblyPaths)
     {
         Translate(
             storage,
             readSymbols,
             enableBundler,
             targetPlatform,
             debugInformationOptions,
             aseemblyPath);
     }
 }
Exemplo n.º 10
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="platforms">Specifies the platforms where the tagged test should execute.</param>
        public PlatformFactAttribute(TargetPlatforms platforms)
            : base()
        {
            if (NeonHelper.IsWindows && (platforms & TargetPlatforms.Windows) != 0)
            {
                return;
            }

            if (NeonHelper.IsLinux && (platforms & TargetPlatforms.Linux) != 0)
            {
                return;
            }

            if (NeonHelper.IsOSX && (platforms & TargetPlatforms.Osx) != 0)
            {
                return;
            }

            Skip = $"Unit test is disabled for: {RuntimeInformation.OSDescription}";
        }
Exemplo n.º 11
0
        public TargetCheckingResult CheckTargetAvailability(TargetPlatforms targetPlatform, string address, string encryptedCredentials, string sshPort, string token)
        {
            try
            {
                var targetChecker      = new TargetChecker();
                var credentialsInBytes = Encoding.Default.GetBytes(encryptedCredentials);
                var targetInfo         = new TargetInfoExtractor().GetTargetInformation(credentialsInBytes, address, sshPort);

                return(targetChecker.Check(targetPlatform, targetInfo));
            }
            catch (Exception ex)
            {
                var logMessage = String.Format(EXECUTION_ERROR_MESSAGE, ex.Message, ex.StackTrace);
                Logger.Error(logMessage);
                return(new TargetCheckingResult()
                {
                    ErrorMessage = ex.Message, IsTargetAvailable = false
                });
            }
        }
Exemplo n.º 12
0
            public GMExtensionProxyFile CreateFromDisk(string path, TargetPlatforms targetPlatform)
            {
                if (path == null)
                {
                    throw new ArgumentNullException(nameof(path));
                }

                var proxyFile = new GMExtensionProxyFile(extensionFile)
                {
                    Project        = extensionFile.Project,
                    Id             = Guid.NewGuid(),
                    TargetPlatform = targetPlatform
                };

                proxyFile.SetFile(path);

                proxyFiles.Add(proxyFile);

                return(proxyFile);
            }
Exemplo n.º 13
0
        public ITargetChecker NewTargetFactoryForFamily(TargetPlatforms family)
        {
            switch (family)
            {
                case TargetPlatforms.windows:
                    return new WindowsTargetChecker();
                case TargetPlatforms.unix:
                    return new UnixTargetChecker();
                case TargetPlatforms.ios:
                    return new CiscoIosChecker();
                case TargetPlatforms.undefined:
                    return new UndefinedTargetChecker();
                case TargetPlatforms.catos:
                case TargetPlatforms.macos:
                case TargetPlatforms.pixos:
                case TargetPlatforms.vmware_infrastructure:
                    break;
            }

            throw new NotSupportedException(String.Format("{0} platform is not supported currently.", family.ToString()));
        }
Exemplo n.º 14
0
 public TargetCheckingResult Check(TargetPlatforms family, TargetInfo targetInfo)
 {
     var targetChecker = new TargetCheckerFactory().NewTargetFactoryForFamily(family);
     return targetChecker.Check(targetInfo);
 }
Exemplo n.º 15
0
 public virtual TargetCheckingResult CheckTargetAvailability(TargetPlatforms targetPlatform, string address, string encryptedCredentials, string sshPort, string token)
 {
     return this.ModSicChannel.CheckTargetAvailability(targetPlatform, address, encryptedCredentials, sshPort, token);
 }
Exemplo n.º 16
0
        public virtual TargetCheckingResult CheckTargetAvailability(TargetPlatforms targetPlatform, string address, string encryptedCredentials, string sshPort)
        {
            var token = LogonModSic();
            try
            {
                return ModSicProxyService.CheckTargetAvailability(targetPlatform, address, encryptedCredentials, sshPort, token);
            }
            finally
            {
                ModSicProxyService.Logout(token);
            }

        }
Exemplo n.º 17
0
        public TargetCheckingResult Check(TargetPlatforms family, TargetInfo targetInfo)
        {
            var targetChecker = new TargetCheckerFactory().NewTargetFactoryForFamily(family);

            return(targetChecker.Check(targetInfo));
        }
Exemplo n.º 18
0
        public TargetCheckingResult CheckTargetAvailability(TargetPlatforms targetPlatform, string address, string encryptedCredentials, string sshPort, string token)
        {
            try
            {
                var targetChecker = new TargetChecker();
                var credentialsInBytes = Encoding.Default.GetBytes(encryptedCredentials);
                var targetInfo = new TargetInfoExtractor().GetTargetInformation(credentialsInBytes, address, sshPort);

                return targetChecker.Check(targetPlatform, targetInfo);
            }
            catch (Exception ex)
            {
                var logMessage = String.Format(EXECUTION_ERROR_MESSAGE, ex.Message, ex.StackTrace);
                Logger.Error(logMessage);
                return new TargetCheckingResult() { ErrorMessage = ex.Message, IsTargetAvailable = false };
            }
        }
Exemplo n.º 19
0
 public virtual TargetCheckingResult CheckTargetAvailability(TargetPlatforms targetPlatform, string address, string encryptedCredentials, string sshPort, string token)
 {
     return(this.ModSicChannel.CheckTargetAvailability(targetPlatform, address, encryptedCredentials, sshPort, token));
 }