Example #1
0
        public override void SetUpEnvironment(ReadOnlyTargetRules Target, CppCompileEnvironment CompileEnvironment, LinkEnvironment LinkEnvironment)
        {
            // we want gcc toolchain 4.9, but fall back to 4.8 or 4.6 for now if it doesn't exist
            string NDKPath = Environment.GetEnvironmentVariable("NDKROOT");

            NDKPath = NDKPath.Replace("\"", "");

            AndroidToolChain ToolChain = new AndroidToolChain(Target.ProjectFile, false, Target.AndroidPlatform.Architectures, Target.AndroidPlatform.GPUArchitectures);

            // figure out the NDK version
            string NDKToolchainVersion = "unknown";
            string NDKDefine           = "100500";      // assume r10e
            string SourcePropFilename  = Path.Combine(NDKPath, "source.properties");

            if (File.Exists(SourcePropFilename))
            {
                string   RevisionString   = "";
                string[] PropertyContents = File.ReadAllLines(SourcePropFilename);
                foreach (string PropertyLine in PropertyContents)
                {
                    if (PropertyLine.StartsWith("Pkg.Revision"))
                    {
                        RevisionString = PropertyLine;
                        break;
                    }
                }

                int EqualsIndex = RevisionString.IndexOf('=');
                if (EqualsIndex > 0)
                {
                    string[] RevisionParts  = RevisionString.Substring(EqualsIndex + 1).Trim().Split('.');
                    int      RevisionMinor  = int.Parse(RevisionParts.Length > 1 ? RevisionParts[1] : "0");
                    char     RevisionLetter = Convert.ToChar('a' + RevisionMinor);
                    int      RevisionBeta   = 0;               // @TODO
                    NDKToolchainVersion = "r" + RevisionParts[0] + (RevisionMinor > 0 ? Char.ToString(RevisionLetter) : "");
                    NDKDefine           = RevisionParts[0] + string.Format("{0:00}", RevisionMinor + 1) + string.Format("{0:00}", RevisionBeta);
                }
            }
            else
            {
                string ReleaseFilename = Path.Combine(NDKPath, "RELEASE.TXT");
                if (File.Exists(ReleaseFilename))
                {
                    string[] PropertyContents = File.ReadAllLines(SourcePropFilename);
                    NDKToolchainVersion = PropertyContents[0];
                }
            }

            // PLATFORM_ANDROID_NDK_VERSION is in the form 150100, where 15 is major version, 01 is the letter (1 is 'a'), 00 indicates beta revision if letter is 00
            Log.TraceInformation("PLATFORM_ANDROID_NDK_VERSION = {0}", NDKDefine);
            CompileEnvironment.Definitions.Add("PLATFORM_ANDROID_NDK_VERSION=" + NDKDefine);

            string GccVersion    = "4.6";
            int    NDKVersionInt = ToolChain.GetNdkApiLevelInt();

            if (Directory.Exists(Path.Combine(NDKPath, @"sources/cxx-stl/gnu-libstdc++/4.9")))
            {
                GccVersion = "4.9";
            }
            else
            if (Directory.Exists(Path.Combine(NDKPath, @"sources/cxx-stl/gnu-libstdc++/4.8")))
            {
                GccVersion = "4.8";
            }

            Log.TraceInformation("NDK toolchain: {0}, NDK version: {1}, GccVersion: {2}, ClangVersion: {3}", NDKToolchainVersion, NDKVersionInt.ToString(), GccVersion, ToolChain.GetClangVersionString());

            CompileEnvironment.Definitions.Add("PLATFORM_DESKTOP=0");
            CompileEnvironment.Definitions.Add("PLATFORM_CAN_SUPPORT_EDITORONLY_DATA=0");

            CompileEnvironment.Definitions.Add("WITH_OGGVORBIS=1");

            CompileEnvironment.Definitions.Add("UNICODE");
            CompileEnvironment.Definitions.Add("_UNICODE");

            CompileEnvironment.Definitions.Add("PLATFORM_ANDROID=1");
            CompileEnvironment.Definitions.Add("ANDROID=1");

            CompileEnvironment.Definitions.Add("WITH_DATABASE_SUPPORT=0");
            CompileEnvironment.Definitions.Add("WITH_EDITOR=0");
            CompileEnvironment.Definitions.Add("USE_NULL_RHI=0");
            CompileEnvironment.Definitions.Add("REQUIRES_ALIGNED_INT_ACCESS");

            CompileEnvironment.IncludePaths.SystemIncludePaths.Add("$(NDKROOT)/sources/cxx-stl/gnu-libstdc++/" + GccVersion + "/include");

            // the toolchain will actually filter these out
            CompileEnvironment.IncludePaths.SystemIncludePaths.Add("$(NDKROOT)/sources/cxx-stl/gnu-libstdc++/" + GccVersion + "/libs/armeabi-v7a/include");
            CompileEnvironment.IncludePaths.SystemIncludePaths.Add("$(NDKROOT)/sources/cxx-stl/gnu-libstdc++/" + GccVersion + "/libs/arm64-v8a/include");
            CompileEnvironment.IncludePaths.SystemIncludePaths.Add("$(NDKROOT)/sources/cxx-stl/gnu-libstdc++/" + GccVersion + "/libs/x86/include");
            CompileEnvironment.IncludePaths.SystemIncludePaths.Add("$(NDKROOT)/sources/cxx-stl/gnu-libstdc++/" + GccVersion + "/libs/x86_64/include");

            LinkEnvironment.LibraryPaths.Add("$(NDKROOT)/sources/cxx-stl/gnu-libstdc++/" + GccVersion + "/libs/armeabi-v7a");
            LinkEnvironment.LibraryPaths.Add("$(NDKROOT)/sources/cxx-stl/gnu-libstdc++/" + GccVersion + "/libs/arm64-v8a");
            LinkEnvironment.LibraryPaths.Add("$(NDKROOT)/sources/cxx-stl/gnu-libstdc++/" + GccVersion + "/libs/x86");
            LinkEnvironment.LibraryPaths.Add("$(NDKROOT)/sources/cxx-stl/gnu-libstdc++/" + GccVersion + "/libs/x86_64");

            CompileEnvironment.IncludePaths.SystemIncludePaths.Add("$(NDKROOT)/sources/android/native_app_glue");
            CompileEnvironment.IncludePaths.SystemIncludePaths.Add("$(NDKROOT)/sources/android/cpufeatures");

            //@TODO: Tegra Gfx Debugger - standardize locations - for now, change the hardcoded paths and force this to return true to test
            if (UseTegraGraphicsDebugger(Target))
            {
                //LinkEnvironment.LibraryPaths.Add("ThirdParty/NVIDIA/TegraGfxDebugger");
                //LinkEnvironment.LibraryPaths.Add("F:/NVPACK/android-kk-egl-t124-a32/stub");
                //LinkEnvironment.AdditionalLibraries.Add("Nvidia_gfx_debugger_stub");
            }

            SetupGraphicsDebugger(Target, CompileEnvironment, LinkEnvironment);

            LinkEnvironment.AdditionalLibraries.Add("gnustl_shared");
            LinkEnvironment.AdditionalLibraries.Add("gcc");
            LinkEnvironment.AdditionalLibraries.Add("z");
            LinkEnvironment.AdditionalLibraries.Add("c");
            LinkEnvironment.AdditionalLibraries.Add("m");
            LinkEnvironment.AdditionalLibraries.Add("log");
            LinkEnvironment.AdditionalLibraries.Add("dl");
            if (!UseTegraGraphicsDebugger(Target))
            {
                LinkEnvironment.AdditionalLibraries.Add("GLESv2");
                LinkEnvironment.AdditionalLibraries.Add("EGL");
            }
            LinkEnvironment.AdditionalLibraries.Add("OpenSLES");
            LinkEnvironment.AdditionalLibraries.Add("android");
        }
        public override void SetUpEnvironment(ReadOnlyTargetRules Target, CppCompileEnvironment CompileEnvironment, LinkEnvironment LinkEnvironment)
        {
            // we want gcc toolchain 4.9, but fall back to 4.8 or 4.6 for now if it doesn't exist
            string NDKPath = Environment.GetEnvironmentVariable("NDKROOT");

            NDKPath = NDKPath.Replace("\"", "");

            AndroidToolChain ToolChain = new AndroidToolChain(Target.ProjectFile, false, Target.AndroidPlatform.Architectures, Target.AndroidPlatform.GPUArchitectures);

            // figure out the NDK version
            string NDKToolchainVersion = ToolChain.NDKToolchainVersion;
            string NDKDefine           = ToolChain.NDKDefine;

            // PLATFORM_ANDROID_NDK_VERSION is in the form 150100, where 15 is major version, 01 is the letter (1 is 'a'), 00 indicates beta revision if letter is 00
            Log.TraceInformation("PLATFORM_ANDROID_NDK_VERSION = {0}", NDKDefine);
            CompileEnvironment.Definitions.Add("PLATFORM_ANDROID_NDK_VERSION=" + NDKDefine);

            string GccVersion    = "4.6";
            int    NDKVersionInt = ToolChain.GetNdkApiLevelInt();

            if (Directory.Exists(Path.Combine(NDKPath, @"sources/cxx-stl/gnu-libstdc++/4.9")))
            {
                GccVersion = "4.9";
            }
            else
            if (Directory.Exists(Path.Combine(NDKPath, @"sources/cxx-stl/gnu-libstdc++/4.8")))
            {
                GccVersion = "4.8";
            }

            Log.TraceInformation("NDK toolchain: {0}, NDK version: {1}, GccVersion: {2}, ClangVersion: {3}", NDKToolchainVersion, NDKVersionInt.ToString(), GccVersion, ToolChain.GetClangVersionString());

            CompileEnvironment.Definitions.Add("PLATFORM_DESKTOP=0");
            CompileEnvironment.Definitions.Add("PLATFORM_CAN_SUPPORT_EDITORONLY_DATA=0");

            CompileEnvironment.Definitions.Add("WITH_OGGVORBIS=1");

            CompileEnvironment.Definitions.Add("UNICODE");
            CompileEnvironment.Definitions.Add("_UNICODE");

            CompileEnvironment.Definitions.Add("PLATFORM_ANDROID=1");
            CompileEnvironment.Definitions.Add("ANDROID=1");

            CompileEnvironment.Definitions.Add("WITH_DATABASE_SUPPORT=0");
            CompileEnvironment.Definitions.Add("WITH_EDITOR=0");
            CompileEnvironment.Definitions.Add("USE_NULL_RHI=0");
            CompileEnvironment.Definitions.Add("REQUIRES_ALIGNED_INT_ACCESS");

            DirectoryReference NdkDir = new DirectoryReference(NDKPath);

            CompileEnvironment.IncludePaths.SystemIncludePaths.Add(DirectoryReference.Combine(NdkDir, "sources/cxx-stl/gnu-libstdc++/" + GccVersion + "/include"));

            // the toolchain will actually filter these out
            CompileEnvironment.IncludePaths.SystemIncludePaths.Add(DirectoryReference.Combine(NdkDir, "sources/cxx-stl/gnu-libstdc++/" + GccVersion + "/libs/armeabi-v7a/include"));
            CompileEnvironment.IncludePaths.SystemIncludePaths.Add(DirectoryReference.Combine(NdkDir, "sources/cxx-stl/gnu-libstdc++/" + GccVersion + "/libs/arm64-v8a/include"));
            CompileEnvironment.IncludePaths.SystemIncludePaths.Add(DirectoryReference.Combine(NdkDir, "sources/cxx-stl/gnu-libstdc++/" + GccVersion + "/libs/x86/include"));
            CompileEnvironment.IncludePaths.SystemIncludePaths.Add(DirectoryReference.Combine(NdkDir, "sources/cxx-stl/gnu-libstdc++/" + GccVersion + "/libs/x86_64/include"));

            LinkEnvironment.LibraryPaths.Add(DirectoryReference.Combine(NdkDir, "sources/cxx-stl/gnu-libstdc++/" + GccVersion + "/libs/armeabi-v7a"));
            LinkEnvironment.LibraryPaths.Add(DirectoryReference.Combine(NdkDir, "sources/cxx-stl/gnu-libstdc++/" + GccVersion + "/libs/arm64-v8a"));
            LinkEnvironment.LibraryPaths.Add(DirectoryReference.Combine(NdkDir, "sources/cxx-stl/gnu-libstdc++/" + GccVersion + "/libs/x86"));
            LinkEnvironment.LibraryPaths.Add(DirectoryReference.Combine(NdkDir, "sources/cxx-stl/gnu-libstdc++/" + GccVersion + "/libs/x86_64"));

            CompileEnvironment.IncludePaths.SystemIncludePaths.Add(DirectoryReference.Combine(NdkDir, "sources/android/native_app_glue"));
            CompileEnvironment.IncludePaths.SystemIncludePaths.Add(DirectoryReference.Combine(NdkDir, "sources/android/cpufeatures"));

            //@TODO: Tegra Gfx Debugger - standardize locations - for now, change the hardcoded paths and force this to return true to test
            if (UseTegraGraphicsDebugger(Target))
            {
                //LinkEnvironment.LibraryPaths.Add("ThirdParty/NVIDIA/TegraGfxDebugger");
                //LinkEnvironment.LibraryPaths.Add("F:/NVPACK/android-kk-egl-t124-a32/stub");
                //LinkEnvironment.AdditionalLibraries.Add("Nvidia_gfx_debugger_stub");
            }

            SetupGraphicsDebugger(Target, CompileEnvironment, LinkEnvironment);

            LinkEnvironment.AdditionalLibraries.Add("gnustl_shared");
            LinkEnvironment.AdditionalLibraries.Add("gcc");
            LinkEnvironment.AdditionalLibraries.Add("z");
            LinkEnvironment.AdditionalLibraries.Add("c");
            LinkEnvironment.AdditionalLibraries.Add("m");
            LinkEnvironment.AdditionalLibraries.Add("log");
            LinkEnvironment.AdditionalLibraries.Add("dl");
            if (!UseTegraGraphicsDebugger(Target))
            {
                LinkEnvironment.AdditionalLibraries.Add("GLESv2");
                LinkEnvironment.AdditionalLibraries.Add("EGL");
            }
            LinkEnvironment.AdditionalLibraries.Add("OpenSLES");
            LinkEnvironment.AdditionalLibraries.Add("android");
        }
        public virtual void SetUpSpecificEnvironment(ReadOnlyTargetRules Target, CppCompileEnvironment CompileEnvironment, LinkEnvironment LinkEnvironment)
        {
            string NDKPath = Environment.GetEnvironmentVariable("NDKROOT");

            NDKPath = NDKPath.Replace("\"", "");

            AndroidToolChain ToolChain = new AndroidToolChain(Target.ProjectFile, false, Target.AndroidPlatform.Architectures, Target.AndroidPlatform.GPUArchitectures);

            // figure out the NDK version
            string NDKToolchainVersion = ToolChain.NDKToolchainVersion;
            string NDKDefine           = ToolChain.NDKDefine;

            string GccVersion = "4.9";

            // PLATFORM_ANDROID_NDK_VERSION is in the form 150100, where 15 is major version, 01 is the letter (1 is 'a'), 00 indicates beta revision if letter is 00
            Log.TraceInformation("PLATFORM_ANDROID_NDK_VERSION = {0}", NDKDefine);
            CompileEnvironment.Definitions.Add("PLATFORM_ANDROID_NDK_VERSION=" + NDKDefine);

            int NDKVersionInt = ToolChain.GetNdkApiLevelInt();

            Log.TraceInformation("NDK toolchain: {0}, NDK version: {1}, GccVersion: {2}, ClangVersion: {3}", NDKToolchainVersion, NDKVersionInt.ToString(), GccVersion, ToolChain.GetClangVersionString());
            ToolChain.ShowNDKWarnings();

            CompileEnvironment.Definitions.Add("PLATFORM_DESKTOP=0");
            CompileEnvironment.Definitions.Add("PLATFORM_CAN_SUPPORT_EDITORONLY_DATA=0");

            CompileEnvironment.Definitions.Add("WITH_OGGVORBIS=1");

            CompileEnvironment.Definitions.Add("UNICODE");
            CompileEnvironment.Definitions.Add("_UNICODE");

            CompileEnvironment.Definitions.Add("PLATFORM_ANDROID=1");
            CompileEnvironment.Definitions.Add("ANDROID=1");

            CompileEnvironment.Definitions.Add("WITH_EDITOR=0");
            CompileEnvironment.Definitions.Add("USE_NULL_RHI=0");

            DirectoryReference NdkDir = new DirectoryReference(NDKPath);

            //CompileEnvironment.SystemIncludePaths.Add(DirectoryReference.Combine(NdkDir, "sources/cxx-stl/llvm-libc++/include"));

            // the toolchain will actually filter these out
            LinkEnvironment.LibraryPaths.Add(DirectoryReference.Combine(NdkDir, "sources/cxx-stl/llvm-libc++/libs/armeabi-v7a"));
            LinkEnvironment.LibraryPaths.Add(DirectoryReference.Combine(NdkDir, "sources/cxx-stl/llvm-libc++/libs/arm64-v8a"));
            LinkEnvironment.LibraryPaths.Add(DirectoryReference.Combine(NdkDir, "sources/cxx-stl/llvm-libc++/libs/x86"));
            LinkEnvironment.LibraryPaths.Add(DirectoryReference.Combine(NdkDir, "sources/cxx-stl/llvm-libc++/libs/x86_64"));

            CompileEnvironment.SystemIncludePaths.Add(DirectoryReference.Combine(NdkDir, "sources/android/native_app_glue"));
            CompileEnvironment.SystemIncludePaths.Add(DirectoryReference.Combine(NdkDir, "sources/android/cpufeatures"));

            //@TODO: Tegra Gfx Debugger - standardize locations - for now, change the hardcoded paths and force this to return true to test
            if (UseTegraGraphicsDebugger(Target))
            {
                //LinkEnvironment.LibraryPaths.Add("ThirdParty/NVIDIA/TegraGfxDebugger");
                //LinkEnvironment.LibraryPaths.Add("F:/NVPACK/android-kk-egl-t124-a32/stub");
                //LinkEnvironment.AdditionalLibraries.Add("Nvidia_gfx_debugger_stub");
            }

            if (!UseTegraGraphicsDebugger(Target))
            {
                LinkEnvironment.AdditionalLibraries.Add("GLESv2");
                LinkEnvironment.AdditionalLibraries.Add("EGL");
            }
            LinkEnvironment.AdditionalLibraries.Add("android");
            LinkEnvironment.AdditionalLibraries.Add("OpenSLES");
        }