コード例 #1
0
        /// <summary>
        /// Enumerates list of libraries that should be linked with project build file.
        /// </summary>
        /// <param name="platform">One of the target platforms.</param>
        /// <param name="configuration">One of the target configurations.</param>
        public virtual IEnumerable <DependencyFile> EnumerateLinkedLibraries(TargetPlatform platform, TargetConfiguration configuration)
        {
            foreach (var libraryFile in Directory.EnumerateFiles(GetLocation()))
            {
                if (!MatchesPlatformConfiguration(libraryFile, platform, configuration))
                {
                    continue;
                }
                var libraryFileExtension = (Path.GetExtension(libraryFile) ?? "").ToLowerInvariant();
                if (TargetInfo.IsMicrosoftPlatform(platform))
                {
                    switch (libraryFileExtension)
                    {
                    case ".lib":
                        yield return(new DependencyFile(libraryFile, DependencyFileType.StaticLibrary));

                        break;
                    }
                }
                else if (TargetInfo.IsApplePlatform(platform))
                {
                    // TODO: '.framework' bundles on Apple platforms.
                    switch (libraryFileExtension)
                    {
                    case ".a":
                        yield return(new DependencyFile(libraryFile, DependencyFileType.StaticLibrary));

                        break;

                    case ".dylib":
                        yield return(new DependencyFile(libraryFile, DependencyFileType.DynamicLibrary));

                        break;
                    }
                }
                else if (TargetInfo.IsPosixPlatform(platform))
                {
                    switch (libraryFileExtension)
                    {
                    case ".a":
                        yield return(new DependencyFile(libraryFile, DependencyFileType.StaticLibrary));

                        break;

                    case ".so":
                        yield return(new DependencyFile(libraryFile, DependencyFileType.DynamicLibrary));

                        break;
                    }
                }
                else
                {
                    throw new NotSupportedException("Unknown target platform for depenedency linked libraries.");
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Enumerates list of files that should be copied to project build output directory.
        /// </summary>
        /// <param name="platform">One of the target platforms.</param>
        /// <param name="configuration">One of the target configurations.</param>
        public virtual IEnumerable <DependencyFile> EnumerateCopyFiles(TargetPlatform platform, TargetConfiguration configuration)
        {
            foreach (var copyFilePath in Directory.EnumerateFiles(GetLocation()))
            {
                if (!MatchesPlatformConfiguration(copyFilePath, platform, configuration))
                {
                    continue;
                }

                var copyFileExtension = (Path.GetExtension(copyFilePath) ?? "").ToLowerInvariant();
                if (TargetInfo.IsMicrosoftPlatform(platform))
                {
                    switch (copyFileExtension)
                    {
                    case ".dll":
                        yield return(new DependencyFile(copyFilePath, DependencyFileType.DynamicLibrary));

                        break;
                    }
                }
                else if (TargetInfo.IsApplePlatform(platform))
                {
                    switch (copyFileExtension)
                    {
                    case ".dylib":
                        yield return(new DependencyFile(copyFilePath, DependencyFileType.DynamicLibrary));

                        break;
                    }
                }
                else if (TargetInfo.IsPosixPlatform(platform))
                {
                    switch (copyFileExtension)
                    {
                    case ".so":
                        yield return(new DependencyFile(copyFilePath, DependencyFileType.DynamicLibrary));

                        break;
                    }
                }
                else
                {
                    throw new NotSupportedException("Unknown target platform for depenedency copy files.");
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Returns directory of the compilation result.
        /// </summary>
        /// <param name="platform">One of the target platforms.</param>
        /// <param name="configuration">One of the target configurations.</param>
        public virtual string GetOutputFileName(TargetPlatform platform, TargetConfiguration configuration)
        {
            Debug.Assert(platform != TargetPlatform.Unknown);
            string outputExtension = null, outputPrefix = null;

            if (TargetInfo.IsMicrosoftPlatform(platform))
            {
                switch (GetBuildType(platform, configuration))
                {
                case ProjectBuildType.Application:
                    outputPrefix    = "";
                    outputExtension = ".exe";
                    break;

                case ProjectBuildType.DynamicLibrary:
                    outputPrefix    = "";
                    outputExtension = ".dll";
                    break;

                case ProjectBuildType.StaticLibrary:
                    outputPrefix    = "";
                    outputExtension = ".lib";
                    break;
                }
            }
            else if (TargetInfo.IsApplePlatform(platform))
            {
                switch (GetBuildType(platform, configuration))
                {
                case ProjectBuildType.Application:
                    outputPrefix    = "";
                    outputExtension = ".app";
                    break;

                case ProjectBuildType.DynamicLibrary:
                    outputPrefix    = "";
                    outputExtension = ".dylib";
                    break;

                case ProjectBuildType.StaticLibrary:
                    outputPrefix    = "lib";
                    outputExtension = ".a";
                    break;
                }
            }
            else if (TargetInfo.IsPosixPlatform(platform))
            {
                switch (GetBuildType(platform, configuration))
                {
                case ProjectBuildType.Application:
                    outputPrefix    = "";
                    outputExtension = "";
                    break;

                case ProjectBuildType.DynamicLibrary:
                    outputPrefix    = "lib";
                    outputExtension = ".so";
                    break;

                case ProjectBuildType.StaticLibrary:
                    outputPrefix    = "lib";
                    outputExtension = ".a";
                    break;
                }
            }
            else
            {
                throw new NotSupportedException("Unknown target platform for project output path.");
            }
            return(outputPrefix + GetName() + outputExtension);
        }