diff options
author | 2016-02-15 19:55:52 +0100 | |
---|---|---|
committer | 2016-02-15 19:55:52 +0100 | |
commit | 2b781d87b1dc856b432ff0d11d7e7d818e0cf345 (patch) | |
tree | 745926e06f5803bfb5204e4adce8032478d8c180 /scripts/toolchain.lua | |
parent | b0607ac0576b3fd53149c99b5adec26311334098 (diff) | |
parent | 1ddc780160b8ba5bf0ab29b757e591700434e525 (diff) |
Merge pull request #623 from h0tw1r3/master
Improve cross compile support [Jeffrey Clark]
Diffstat (limited to 'scripts/toolchain.lua')
-rw-r--r-- | scripts/toolchain.lua | 55 |
1 files changed, 36 insertions, 19 deletions
diff --git a/scripts/toolchain.lua b/scripts/toolchain.lua index 27b571e18d0..40690b00831 100644 --- a/scripts/toolchain.lua +++ b/scripts/toolchain.lua @@ -4,6 +4,11 @@ -- local naclToolchain = "" +local toolchainPrefix = "" + +if _OPTIONS['TOOLCHAIN'] then + toolchainPrefix = _OPTIONS["TOOLCHAIN"] +end newoption { trigger = "gcc", @@ -204,15 +209,18 @@ function toolchain(_buildDir, _subDir) if not os.getenv("MINGW32") then print("Set MINGW32 envrionment variable.") end - premake.gcc.cc = "$(MINGW32)/bin/i686-w64-mingw32-gcc" - premake.gcc.cxx = "$(MINGW32)/bin/i686-w64-mingw32-g++" + if not toolchainPrefix then + toolchainPrefix = "$(MINGW32)/bin/i686-w64-mingw32-" + end + premake.gcc.cc = toolchainPrefix .. "gcc" + premake.gcc.cxx = toolchainPrefix .. "g++" -- work around GCC 4.9.2 not having proper linker for LTO=1 usage local version_4_ar = str_to_version(_OPTIONS["gcc_version"]) if (version_4_ar < 50000) then - premake.gcc.ar = "$(MINGW32)/bin/ar" + premake.gcc.ar = toolchainPrefix .. "ar" end if (version_4_ar >= 50000) then - premake.gcc.ar = "$(MINGW32)/bin/gcc-ar" + premake.gcc.ar = toolchainPrefix .. "gcc-ar" end location (_buildDir .. "projects/" .. _subDir .. "/".. _ACTION .. "-mingw32-gcc") end @@ -221,20 +229,22 @@ function toolchain(_buildDir, _subDir) if not os.getenv("MINGW64") then print("Set MINGW64 envrionment variable.") end - premake.gcc.cc = "$(MINGW64)/bin/x86_64-w64-mingw32-gcc" - premake.gcc.cxx = "$(MINGW64)/bin/x86_64-w64-mingw32-g++" + if not toolchainPrefix then + toolchainPrefix = "$(MINGW64)/bin/x86_64-w64-mingw32-" + end + premake.gcc.cc = toolchainPrefix .. "gcc" + premake.gcc.cxx = toolchainPrefix .. "g++" -- work around GCC 4.9.2 not having proper linker for LTO=1 usage local version_4_ar = str_to_version(_OPTIONS["gcc_version"]) if (version_4_ar < 50000) then - premake.gcc.ar = "$(MINGW64)/bin/ar" + premake.gcc.ar = toolchainPrefix .. "ar" end if (version_4_ar >= 50000) then - premake.gcc.ar = "$(MINGW64)/bin/gcc-ar" + premake.gcc.ar = toolchainPrefix .. "gcc-ar" end location (_buildDir .. "projects/" .. _subDir .. "/".. _ACTION .. "-mingw64-gcc") end - if "mingw-clang" == _OPTIONS["gcc"] then premake.gcc.cc = "clang" premake.gcc.cxx = "clang++" @@ -283,18 +293,17 @@ function toolchain(_buildDir, _subDir) if "osx" == _OPTIONS["gcc"] then if os.is("linux") then - local osxToolchain = "x86_64-apple-darwin13-" - premake.gcc.cc = osxToolchain .. "clang" - premake.gcc.cxx = osxToolchain .. "clang++" - premake.gcc.ar = osxToolchain .. "ar" + premake.gcc.cc = toolchainPrefix .. "clang" + premake.gcc.cxx = toolchainPrefix .. "clang++" + premake.gcc.ar = toolchainPrefix .. "ar" end location (_buildDir .. "projects/" .. _subDir .. "/".. _ACTION .. "-osx") end if "osx-clang" == _OPTIONS["gcc"] then - premake.gcc.cc = "clang" - premake.gcc.cxx = "clang++" - premake.gcc.ar = "ar" + premake.gcc.cc = toolchainPrefix .. "clang" + premake.gcc.cxx = toolchainPrefix .. "clang++" + premake.gcc.ar = toolchainPrefix .. "ar" location (_buildDir .. "projects/" .. _subDir .. "/".. _ACTION .. "-osx-clang") end @@ -911,6 +920,15 @@ function toolchain(_buildDir, _subDir) end function strip() + if not _OPTIONS["STRIP_SYMBOLS"]=="1" then + return true + end + + configuration { "osx-*", "Release" } + postbuildcommands { + "$(SILENT) echo Stripping symbols.", + "$(SILENT) " .. (_OPTIONS['TOOLCHAIN'] and toolchainPrefix) .. "strip \"$(TARGET)\"", + } configuration { "android-arm", "Release" } postbuildcommands { @@ -939,13 +957,12 @@ function strip() configuration { "mingw*", "x64", "Release" } postbuildcommands { "$(SILENT) echo Stripping symbols.", - "$(SILENT) $(MINGW64)/bin/strip -s \"$(TARGET)\"", + "$(SILENT) " .. (_OPTIONS['TOOLCHAIN'] and toolchainPrefix or "$(MINGW64)/bin/") .. "strip -s \"$(TARGET)\"", } - configuration { "mingw*", "x32", "Release" } postbuildcommands { "$(SILENT) echo Stripping symbols.", - "$(SILENT) $(MINGW32)/bin/strip -s \"$(TARGET)\"" + "$(SILENT) " .. (_OPTIONS['TOOLCHAIN'] and toolchainPrefix or "$(MINGW32)/bin/") .. "strip -s \"$(TARGET)\"", } configuration { "pnacl" } |