Skip to content

Commit

Permalink
basic libretro patch
Browse files Browse the repository at this point in the history
build linux64 :
make OSD="retro" verbose=1 RETRO=1 NOWERROR=1  OS="linux" TARGETOS="linux" CONFIG="libretro"  NO_USE_MIDI="1" PTR64=1 TARGET=mame  -j5

build crosswin64 :
make OSD="retro" verbose=1 RETRO=1 NOWERROR=1  OS="linux" TARGETOS="windows" CONFIG="libretro"  NO_USE_MIDI="1" PTR64=1 TARGET=mame GCC="mingw64-gcc"  -j5

build linux64 only atetris driver:
make OSD="retro" verbose=1 RETRO=1 NOWERROR=1  OS="linux" TARGETOS="linux" CONFIG="libretro"  NO_USE_MIDI="1" PTR64=1 TARGET=mame SUBTARGET=atetris SOURCES=src/mame/drivers/atetris.cpp -j5
  • Loading branch information
r-type committed Nov 12, 2016
1 parent f999805 commit 87fb6ac
Show file tree
Hide file tree
Showing 36 changed files with 9,363 additions and 10 deletions.
22 changes: 21 additions & 1 deletion scripts/genie.lua
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,10 @@ end
configurations {
"Debug",
"Release",
-- BEGIN libretro overrides to MAME's GENie build
"libretrodbg",
"libretro",
-- END libretro overrides to MAME's GENie build
}

if _ACTION == "xcode4" then
Expand Down Expand Up @@ -489,10 +493,14 @@ if string.sub(_ACTION,1,4) == "vs20" and _OPTIONS["osd"]=="sdl" then
end
end
-- Build SDL2 for Android
if _OPTIONS["osd"] == "retro" then
-- RETRO HACK no sdl for libretro android
else
if _OPTIONS["targetos"] == "android" then
_OPTIONS["with-bundled-sdl2"] = "1"
end

end
-- RETRO HACK END no sdl for libretro android
configuration {}

if _OPTIONS["osd"] == "uwp" then
Expand Down Expand Up @@ -529,6 +537,18 @@ configuration { "gmake or ninja" }

dofile ("toolchain.lua")

-- RETRO HACK
if _OPTIONS["osd"]=="retro" then
buildoptions {
"-fPIC",
}

defines {
"__LIBRETRO__",
}
end
-- RETRO HACK

if _OPTIONS["targetos"]=="windows" then
configuration { "x64" }
defines {
Expand Down
86 changes: 85 additions & 1 deletion scripts/src/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,17 @@ end
"EGL",
"GLESv1_CM",
"GLESv2",
"SDL2",
-- RETRO HACK no sdl for libretro android
-- "SDL2",
}
if _OPTIONS["osd"] == "retro" then

else
links {
"SDL2",
}
end
-- RETRO HACK END no sdl for libretro android
configuration { "pnacl" }
kind "ConsoleApp"
targetextension ".pexe"
Expand Down Expand Up @@ -184,17 +193,60 @@ end
os.getenv("EMSCRIPTEN") .. "/emcc " .. emccopts .. " $(TARGET) -o " .. _MAKE.esc(MAME_DIR) .. _OPTIONS["target"] .. _OPTIONS["subtarget"] .. ".js",
}
end
-- BEGIN libretro overrides to MAME's GENie build
configuration { "libretro*" }
kind "SharedLib"
targetsuffix "_libretro"
if _OPTIONS["targetos"]=="android-arm" then
targetsuffix "_libretro_android"
defines {
"SDLMAME_ARM=1",
}
elseif _OPTIONS["targetos"]=="ios-arm" then
targetsuffix "_libretro_ios"
targetextension ".dylib"
elseif _OPTIONS["targetos"]=="windows" then
targetextension ".dll"
elseif _OPTIONS["targetos"]=="osx" then
targetextension ".dylib"
else
targetsuffix "_libretro"
end

targetprefix ""

includedirs {
MAME_DIR .. "src/osd/libretro/libretro-internal",
}

files {
MAME_DIR .. "src/osd/libretro/libretro-internal/libretro.cpp"
}

-- Ensure the public API is made public with GNU ld
if _OPTIONS["targetos"]=="linux" then
linkoptions {
"-Wl,--version-script=" .. MAME_DIR .. "src/osd/libretro/libretro-internal/link.T",
}
end

-- END libretro overrides to MAME's GENie build
configuration { }

if _OPTIONS["targetos"]=="android" then
-- RETRO HACK no sdl for libretro android
if _OPTIONS["osd"] == "retro" then

else
includedirs {
MAME_DIR .. "3rdparty/SDL2/include",
}

files {
MAME_DIR .. "3rdparty/SDL2/src/main/android/SDL_android_main.c",
}
end
-- RETRO HACK END no sdl for libretro android
targetsuffix ""
if _OPTIONS["SEPARATE_BIN"]~="1" then
if _OPTIONS["PLATFORM"]=="arm" then
Expand Down Expand Up @@ -228,9 +280,15 @@ end
links {
"osd_" .. _OPTIONS["osd"],
}
-- RETRO HACK no qt
if _OPTIONS["osd"]=="retro" then

else
links {
"qtdbg_" .. _OPTIONS["osd"],
}
end
-- RETRO HACK END
if (STANDALONE~=true) then
links {
"frontend",
Expand Down Expand Up @@ -308,7 +366,33 @@ end
ext_includedir("flac"),
}

-- RETRO HACK
if _OPTIONS["osd"]=="retro" then

forcedincludes {
MAME_DIR .. "src/osd/libretro/retroprefix.h"
}

includedirs {
MAME_DIR .. "src/emu",
MAME_DIR .. "src/osd",
MAME_DIR .. "src/lib",
MAME_DIR .. "src/lib/util",
MAME_DIR .. "src/osd/libretro",
MAME_DIR .. "src/osd/modules/render",
MAME_DIR .. "3rdparty",
MAME_DIR .. "3rdparty/winpcap/Include",
MAME_DIR .. "3rdparty/bgfx/include",
MAME_DIR .. "3rdparty/bx/include",
MAME_DIR .. "src/osd/libretro/libretro-internal",
}

files {
MAME_DIR .. "src/osd/libretro/retromain.cpp",
MAME_DIR .. "src/osd/libretro/libretro-internal/libretro.cpp",
}
end
-- RETRO HACK
if (STANDALONE==true) then
standalone();
end
Expand Down
212 changes: 212 additions & 0 deletions scripts/src/osd/retro.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
-- license:BSD-3-Clause
-- copyright-holders:MAMEdev Team

---------------------------------------------------------------------------
--
-- sdl.lua
--
-- Rules for the building with SDL
--
---------------------------------------------------------------------------

dofile("retro_modules.lua")


function maintargetosdoptions(_target,_subtarget)
osdmodulestargetconf()
end

forcedincludes {
MAME_DIR .. "src/osd/libretro/retroprefix.h"
}

newoption {
trigger = "RETRO_INI_PATH",
description = "Default search path for .ini files",
}

BASE_TARGETOS = "unix"
SDLOS_TARGETOS = "unix"
SDL_NETWORK = ""
if _OPTIONS["targetos"]=="linux" then
SDL_NETWORK = "taptun"
elseif _OPTIONS["targetos"]=="openbsd" then
elseif _OPTIONS["targetos"]=="netbsd" then
SDL_NETWORK = "pcap"
elseif _OPTIONS["targetos"]=="haiku" then
elseif _OPTIONS["targetos"]=="asmjs" then
elseif _OPTIONS["targetos"]=="windows" then
BASE_TARGETOS = "win32"
SDLOS_TARGETOS = "win32"
-- SDL_NETWORK = "pcap"
elseif _OPTIONS["targetos"]=="macosx" then
SDLOS_TARGETOS = "macosx"
SDL_NETWORK = "pcap"
end

if BASE_TARGETOS=="unix" then

_OPTIONS["USE_QTDEBUG"] = "0"



if _OPTIONS["targetos"]~="haiku" and _OPTIONS["targetos"]~="android" then
links {
"m",
"pthread",
}
if _OPTIONS["targetos"]=="solaris" then
links {
"socket",
"nsl",
}
else
links {
"util",
}
end
end

end

project ("osd_" .. _OPTIONS["osd"])
targetsubdir(_OPTIONS["target"] .."_" .._OPTIONS["subtarget"])
uuid (os.uuid("osd_" .. _OPTIONS["osd"]))
-- kind (LIBTYPE)
kind "StaticLib"

buildoptions {
"-fPIC"
}

linkoptions{
"-shared -Wl,--version-script=" .. MAME_DIR .. "src/osd/libretro/libretro-internal/link.T -Wl,--no-undefined"
}

dofile("retro_cfg.lua")
osdmodulesbuild()

includedirs {
MAME_DIR .. "src/emu",
MAME_DIR .. "src/devices", -- accessing imagedev from debugger
MAME_DIR .. "src/osd",
MAME_DIR .. "src/lib",
MAME_DIR .. "src/lib/util",
MAME_DIR .. "src/osd/modules/file",
MAME_DIR .. "src/osd/modules/render",
MAME_DIR .. "3rdparty",
MAME_DIR .. "src/osd/libretro",
MAME_DIR .. "src/osd/libretro/libretro-internal",
}

if _OPTIONS["targetos"]=="windows" then
files {
-- MAME_DIR .. "src/osd/windows/main.cpp",
}
end


files {
MAME_DIR .. "src/osd/libretro/libretro-internal/libco/libco.c",
MAME_DIR .. "src/osd/libretro/libretro-internal/retro_init.cpp",
MAME_DIR .. "src/osd/libretro/osdretro.h",
MAME_DIR .. "src/osd/libretro/retroprefix.h",
MAME_DIR .. "src/osd/libretro/retromain.cpp",
MAME_DIR .. "src/osd/osdepend.h",
MAME_DIR .. "src/osd/libretro/video.cpp",
MAME_DIR .. "src/osd/libretro/window.cpp",
MAME_DIR .. "src/osd/libretro/window.h",
MAME_DIR .. "src/osd/modules/osdwindow.cpp",
MAME_DIR .. "src/osd/modules/osdwindow.h",
MAME_DIR .. "src/osd/modules/render/drawretro.cpp",
MAME_DIR .. "src/osd/modules/sound/retro_sound.cpp",
}


project ("ocore_" .. _OPTIONS["osd"])
targetsubdir(_OPTIONS["target"] .."_" .. _OPTIONS["subtarget"])
uuid (os.uuid("ocore_" .. _OPTIONS["osd"]))
-- kind (LIBTYPE)
kind "StaticLib"

removeflags {
"SingleOutputDir",
}

dofile("retro_cfg.lua")

buildoptions {
"-fPIC"
}


linkoptions{
"-shared -Wl,--version-script=src/osd/libretro/libretro-internal/link.T -Wl,--no-undefined"
}

includedirs {
MAME_DIR .. "src/emu",
MAME_DIR .. "src/osd",
MAME_DIR .. "src/lib",
MAME_DIR .. "src/lib/util",
MAME_DIR .. "src/osd/libretro",
MAME_DIR .. "src/osd/libretro/libretro-internal",
}

if _OPTIONS["targetos"]=="linux" then
BASE_TARGETOS = "unix"
SDLOS_TARGETOS = "unix"
SYNC_IMPLEMENTATION = "tc"
end

if _OPTIONS["targetos"]=="windows" then
BASE_TARGETOS = "win32"
SDLOS_TARGETOS = "win32"
SYNC_IMPLEMENTATION = "windows"
end

if _OPTIONS["targetos"]=="macosx" then
BASE_TARGETOS = "unix"
SDLOS_TARGETOS = "macosx"
SYNC_IMPLEMENTATION = "ntc"
end
files {
MAME_DIR .. "src/osd/modules/lib/osdlib_retro.cpp",
MAME_DIR .. "src/osd/osdcore.cpp",
MAME_DIR .. "src/osd/osdcore.h",
MAME_DIR .. "src/osd/strconv.cpp",
MAME_DIR .. "src/osd/strconv.h",
MAME_DIR .. "src/osd/osdsync.cpp",
MAME_DIR .. "src/osd/osdsync.h",
MAME_DIR .. "src/osd/modules/osdmodule.cpp",
MAME_DIR .. "src/osd/modules/osdmodule.h",
MAME_DIR .. "src/osd/modules/lib/osdlib.h",
}

if BASE_TARGETOS=="unix" then
files {
MAME_DIR .. "src/osd/modules/file/posixdir.cpp",
MAME_DIR .. "src/osd/modules/file/posixfile.cpp",
MAME_DIR .. "src/osd/modules/file/posixfile.h",
MAME_DIR .. "src/osd/modules/file/posixptty.cpp",
MAME_DIR .. "src/osd/modules/file/posixsocket.cpp",
}
elseif BASE_TARGETOS=="win32" then
includedirs {
MAME_DIR .. "src/osd/windows",
}
files {
MAME_DIR .. "src/osd/modules/file/windir.cpp",
MAME_DIR .. "src/osd/modules/file/winfile.cpp",
MAME_DIR .. "src/osd/modules/file/winfile.h",
MAME_DIR .. "src/osd/modules/file/winptty.cpp",
MAME_DIR .. "src/osd/modules/file/winsocket.cpp",
MAME_DIR .. "src/osd/windows/winutil.cpp", -- FIXME put the necessary functions somewhere more appropriate
}
else
files {
MAME_DIR .. "src/osd/modules/file/stdfile.cpp",
}
end


Loading

0 comments on commit 87fb6ac

Please sign in to comment.