public CppInclusionContextResult CreateInclusionContextResult(CppGlobalSymbolCache cache,
                                                                      CppFileLocation rootFile,
                                                                      FileProcessingOptions options, long cacheVersion, Lifetime lifetime)
        {
            var locationTracker = cache.Solution.GetComponent <InjectedHlslFileLocationTracker>();

            if (!locationTracker.IsValid(rootFile))
            {
                return(CppInclusionContextResult.Fail(CppInclusionContextResult.Status.UNSUITABLE_PROJECT_FILE));
            }


            var properties = new CppCompilationProperties()
            {
                LanguageKind = CppLanguageKind.HLSL, ClrSupport = VCXCompileAsManagedOptions.ManagedNotSet,
            };

            var cgIncludeFolder =
                CgIncludeDirectoryTracker.GetCgIncludeFolderPath(cache.Solution.GetComponent <UnityVersion>());

            if (!cgIncludeFolder.IsEmpty)
            {
                properties.IncludePaths.Add(cgIncludeFolder);
            }
            properties.IncludePaths.Add(cache.Solution.SolutionDirectory);

            return(CreateInclusionContextResult(cache, rootFile, options, properties, null, cacheVersion, lifetime));
        }
Exemplo n.º 2
0
        public CppInclusionContextResult CreateInclusionContextResult(CppGlobalSymbolCache cache,
                                                                      CppFileLocation rootFile,
                                                                      FileProcessingOptions options, long cacheVersion, Lifetime lifetime)
        {
            var locationTracker = cache.Solution.GetComponent <ShaderLabCppFileLocationTracker>();

            if (!locationTracker.IsValid(rootFile))
            {
                return(CppInclusionContextResult.Fail(CppInclusionContextResult.Status.UNSUITABLE_PROJECT_FILE));
            }


            var properties = new CppCompilationProperties()
            {
                LanguageKind = CppLanguageKind.HLSL, ClrSupport = VCXCompileAsManagedOptions.ManagedNotSet,
            };

            var cgIncludeFolder =
                CgIncludeDirectoryTracker.GetCgIncludeFolderPath(cache.Solution.GetComponent <UnityVersion>());

            if (!cgIncludeFolder.IsEmpty)
            {
                properties.IncludePaths.Add(cgIncludeFolder);
            }

            var shaderCache = cache.Solution.GetComponent <ShaderLabCppFileLocationTracker>();

            // TODO 1) is cache ready? what will happen under document transaction? check for bad moment?
            // TODO 2) what will happen under psi transaction? include in cache could be out-of date. Try use include quickfix when cginclude is after cgprogram where QF is used
            var includeLocation = shaderCache.GetIncludes(rootFile);

            return(InjectInclusionContextProviderUtil.CreateInclusionContextResult(cache, rootFile,
                                                                                   includeLocation, options, properties, null, cacheVersion, lifetime));
        }