diff options
| author | 2016-02-15 19:55:52 +0100 | |
|---|---|---|
| committer | 2016-02-15 19:55:52 +0100 | |
| commit | 2b781d87b1dc856b432ff0d11d7e7d818e0cf345 (patch) | |
| tree | 745926e06f5803bfb5204e4adce8032478d8c180 /scripts | |
| parent | b0607ac0576b3fd53149c99b5adec26311334098 (diff) | |
| parent | 1ddc780160b8ba5bf0ab29b757e591700434e525 (diff) | |
Merge pull request #623 from h0tw1r3/master
Improve cross compile support [Jeffrey Clark]
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/genie.lua | 14 | ||||
| -rw-r--r-- | scripts/src/3rdparty.lua | 5 | ||||
| -rw-r--r-- | scripts/src/osd/sdl.lua | 70 | ||||
| -rw-r--r-- | scripts/src/osd/sdl_cfg.lua | 2 | ||||
| -rw-r--r-- | scripts/src/tools.lua | 111 | ||||
| -rw-r--r-- | scripts/toolchain.lua | 55 |
6 files changed, 211 insertions, 46 deletions
diff --git a/scripts/genie.lua b/scripts/genie.lua index 4384b9f379b..dd955bd0ce9 100644 --- a/scripts/genie.lua +++ b/scripts/genie.lua @@ -198,6 +198,11 @@ newoption { } newoption { + trigger = "TOOLCHAIN", + description = "Toolchain prefix" +} + +newoption { trigger = "PROFILE", description = "Enable profiling.", } @@ -427,6 +432,10 @@ if(_OPTIONS["USE_BGFX"]~=nil) then USE_BGFX = tonumber(_OPTIONS["USE_BGFX"]) end +if(_OPTIONS["TOOLCHAIN"] == nil) then + _OPTIONS['TOOLCHAIN'] = "" +end + GEN_DIR = MAME_BUILD_DIR .. "generated/" if (_OPTIONS["target"] == nil) then return false end @@ -1300,10 +1309,7 @@ else startproject (_OPTIONS["subtarget"]) end mainProject(_OPTIONS["target"],_OPTIONS["subtarget"]) - -if (_OPTIONS["STRIP_SYMBOLS"]=="1") then - strip() -end +strip() if _OPTIONS["with-tools"] then group "tools" diff --git a/scripts/src/3rdparty.lua b/scripts/src/3rdparty.lua index ef46f1cab24..34376515c64 100644 --- a/scripts/src/3rdparty.lua +++ b/scripts/src/3rdparty.lua @@ -280,6 +280,11 @@ end buildoptions { "-Wno-enum-conversion", } + if _OPTIONS["targetos"]=="macosx" then + buildoptions_c { + "-Wno-unknown-attributes", + } + end end configuration { } diff --git a/scripts/src/osd/sdl.lua b/scripts/src/osd/sdl.lua index 6acb5a2d262..591b75d0b29 100644 --- a/scripts/src/osd/sdl.lua +++ b/scripts/src/osd/sdl.lua @@ -54,14 +54,20 @@ function maintargetosdoptions(_target,_subtarget) end if _OPTIONS["targetos"]=="windows" then - if _OPTIONS["SDL_LIBVER"]=="sdl2" then - links { - "SDL2.dll", - } + if _OPTIONS["USE_LIBSDL"]~="1" then + if _OPTIONS["SDL_LIBVER"]=="sdl2" then + links { + "SDL2.dll", + } + else + links { + "SDL.dll", + } + end else - links { - "SDL.dll", - } + local str = backtick(sdlconfigcmd() .. " --libs | sed 's/ -lSDLmain//'") + addlibfromstring(str) + addoptionsfromstring(str) end links { "psapi", @@ -93,6 +99,11 @@ function maintargetosdoptions(_target,_subtarget) configuration { "mingw*" or "vs*" } targetprefix "sdl" + if USE_BGFX == 1 then + links { + "psapi" + } + end configuration { } end @@ -100,7 +111,7 @@ end function sdlconfigcmd() if not _OPTIONS["SDL_INSTALL_ROOT"] then - return _OPTIONS["SDL_LIBVER"] .. "-config" + return _OPTIONS['TOOLCHAIN'] .. "pkg-config " .. _OPTIONS["SDL_LIBVER"] else return path.join(_OPTIONS["SDL_INSTALL_ROOT"],"bin",_OPTIONS["SDL_LIBVER"]) .. "-config" end @@ -192,16 +203,16 @@ if not _OPTIONS["SDL_FRAMEWORK_PATH"] then end newoption { - trigger = "MACOSX_USE_LIBSDL", - description = "Use SDL library on OS (rather than framework)", + trigger = "USE_LIBSDL", + description = "Use SDL library on OS (rather than framework/dll)", allowed = { - { "0", "Use framework" }, + { "0", "Use framework/dll" }, { "1", "Use library" }, }, } -if not _OPTIONS["MACOSX_USE_LIBSDL"] then - _OPTIONS["MACOSX_USE_LIBSDL"] = "0" +if not _OPTIONS["USE_LIBSDL"] then + _OPTIONS["USE_LIBSDL"] = "0" end @@ -255,7 +266,7 @@ if BASE_TARGETOS=="unix" then "-weak_framework Metal", } end - if _OPTIONS["MACOSX_USE_LIBSDL"]~="1" then + if _OPTIONS["USE_LIBSDL"]~="1" then linkoptions { "-F" .. _OPTIONS["SDL_FRAMEWORK_PATH"], } @@ -269,7 +280,7 @@ if BASE_TARGETOS=="unix" then } end else - local str = backtick(sdlconfigcmd() .. " --libs | sed 's/-lSDLmain//'") + local str = backtick(sdlconfigcmd() .. " --libs --static | sed 's/-lSDLmain//'") addlibfromstring(str) addoptionsfromstring(str) end @@ -529,14 +540,20 @@ if _OPTIONS["with-tools"] then } if _OPTIONS["targetos"] == "windows" then - if _OPTIONS["SDL_LIBVER"] == "sdl2" then - links { - "SDL2.dll", - } + if _OPTIONS["USE_LIBSDL"]~="1" then + if _OPTIONS["SDL_LIBVER"] == "sdl2" then + links { + "SDL2.dll", + } + else + links { + "SDL.dll", + } + end else - links { - "SDL.dll", - } + local str = backtick(sdlconfigcmd() .. " --libs | sed 's/ -lSDLmain//'") + addlibfromstring(str) + addoptionsfromstring(str) end links { "psapi", @@ -553,6 +570,13 @@ if _OPTIONS["with-tools"] then MAME_DIR .. "src/osd/sdl/SDLMain_tmpl.mm", } end + + configuration { "mingw*" or "vs*" } + targetextension ".exe" + + configuration { } + + strip() end @@ -594,4 +618,6 @@ if _OPTIONS["targetos"] == "macosx" and _OPTIONS["with-tools"] then files { MAME_DIR .. "src/osd/sdl/aueffectutil.mm", } + + strip() end diff --git a/scripts/src/osd/sdl_cfg.lua b/scripts/src/osd/sdl_cfg.lua index dd902d1fe60..431443ac059 100644 --- a/scripts/src/osd/sdl_cfg.lua +++ b/scripts/src/osd/sdl_cfg.lua @@ -81,7 +81,7 @@ if BASE_TARGETOS=="unix" then "SDLMAME_UNIX", } if _OPTIONS["targetos"]=="macosx" then - if _OPTIONS["MACOSX_USE_LIBSDL"]~="1" then + if _OPTIONS["USE_LIBSDL"]~="1" then buildoptions { "-F" .. _OPTIONS["SDL_FRAMEWORK_PATH"], } diff --git a/scripts/src/tools.lua b/scripts/src/tools.lua index 19942651f0c..421f5cc76b5 100644 --- a/scripts/src/tools.lua +++ b/scripts/src/tools.lua @@ -50,6 +50,13 @@ files { MAME_DIR .. "src/tools/romcmp.cpp", } +configuration { "mingw*" or "vs*" } + targetextension ".exe" + +configuration { } + +strip() + -------------------------------------------------- -- chdman -------------------------------------------------- @@ -104,6 +111,13 @@ files { MAME_DIR .. "src/version.cpp", } +configuration { "mingw*" or "vs*" } + targetextension ".exe" + +configuration { } + +strip() + -------------------------------------------------- -- jedutil -------------------------------------------------- @@ -145,6 +159,13 @@ files { MAME_DIR .. "src/tools/jedutil.cpp", } +configuration { "mingw*" or "vs*" } + targetextension ".exe" + +configuration { } + +strip() + -------------------------------------------------- -- unidasm -------------------------------------------------- @@ -201,6 +222,12 @@ files { MAME_DIR .. "src/emu/emucore.cpp", } +configuration { "mingw*" or "vs*" } + targetextension ".exe" + +configuration { } + +strip() -------------------------------------------------- -- ldresample @@ -255,6 +282,13 @@ files { MAME_DIR .. "src/tools/ldresample.cpp", } +configuration { "mingw*" or "vs*" } + targetextension ".exe" + +configuration { } + +strip() + -------------------------------------------------- -- ldverify -------------------------------------------------- @@ -308,6 +342,13 @@ files { MAME_DIR .. "src/tools/ldverify.cpp", } +configuration { "mingw*" or "vs*" } + targetextension ".exe" + +configuration { } + +strip() + -------------------------------------------------- -- regrep -------------------------------------------------- @@ -349,6 +390,13 @@ files { MAME_DIR .. "src/tools/regrep.cpp", } +configuration { "mingw*" or "vs*" } + targetextension ".exe" + +configuration { } + +strip() + -------------------------------------------------- -- srcclean --------------------------------------------------- @@ -390,6 +438,13 @@ files { MAME_DIR .. "src/tools/srcclean.cpp", } +configuration { "mingw*" or "vs*" } + targetextension ".exe" + +configuration { } + +strip() + -------------------------------------------------- -- src2html -------------------------------------------------- @@ -431,6 +486,13 @@ files { MAME_DIR .. "src/tools/src2html.cpp", } +configuration { "mingw*" or "vs*" } + targetextension ".exe" + +configuration { } + +strip() + -------------------------------------------------- -- split -------------------------------------------------- @@ -483,6 +545,13 @@ files { MAME_DIR .. "src/tools/split.cpp", } +configuration { "mingw*" or "vs*" } + targetextension ".exe" + +configuration { } + +strip() + -------------------------------------------------- -- pngcmp -------------------------------------------------- @@ -524,6 +593,13 @@ files { MAME_DIR .. "src/tools/pngcmp.cpp", } +configuration { "mingw*" or "vs*" } + targetextension ".exe" + +configuration { } + +strip() + -------------------------------------------------- -- nltool -------------------------------------------------- @@ -578,6 +654,13 @@ files { MAME_DIR .. "src/lib/netlist/prg/nltool.cpp", } +configuration { "mingw*" or "vs*" } + targetextension ".exe" + +configuration { } + +strip() + -------------------------------------------------- -- nlwav -------------------------------------------------- @@ -610,6 +693,13 @@ files { MAME_DIR .. "src/lib/netlist/prg/nlwav.cpp", } +configuration { "mingw*" or "vs*" } + targetextension ".exe" + +configuration { } + +strip() + -------------------------------------------------- -- castool -------------------------------------------------- @@ -664,6 +754,13 @@ files { MAME_DIR .. "src/tools/castool.cpp", } +configuration { "mingw*" or "vs*" } + targetextension ".exe" + +configuration { } + +strip() + -------------------------------------------------- -- floptool -------------------------------------------------- @@ -719,6 +816,13 @@ files { MAME_DIR .. "src/tools/floptool.cpp", } +configuration { "mingw*" or "vs*" } + targetextension ".exe" + +configuration { } + +strip() + -------------------------------------------------- -- imgtool -------------------------------------------------- @@ -822,3 +926,10 @@ files { MAME_DIR .. "src/tools/imgtool/modules/bml3.cpp", MAME_DIR .. "src/tools/imgtool/modules/hp48.cpp", } + +configuration { "mingw*" or "vs*" } + targetextension ".exe" + +configuration { } + +strip() 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" } |
