Linux: 32-bit builds

This commit is contained in:
Souryo 2016-12-22 18:44:54 -05:00
parent 7df6390b41
commit 8378cb59ac
4 changed files with 96 additions and 66 deletions

2
.gitignore vendored
View File

@ -14,6 +14,8 @@ x64/
build/ build/
[Bb]in/ [Bb]in/
[Oo]bj/ [Oo]bj/
[Oo]bj.x86/
[Oo]bj.x64/
# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets # Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
!packages/*/build/ !packages/*/build/

View File

@ -86,9 +86,11 @@ namespace Mesen.GUI
//Extract all needed files //Extract all needed files
string suffix = IntPtr.Size == 4 ? ".x86" : ".x64"; string suffix = IntPtr.Size == 4 ? ".x86" : ".x64";
foreach(ZipArchiveEntry entry in zip.Entries) { foreach(ZipArchiveEntry entry in zip.Entries) {
if(entry.Name.Contains(suffix)) { if(entry.Name.StartsWith("MesenCore") && !Program.IsMono && entry.Name.Contains(suffix)) {
string baseFolder = Program.IsMono ? Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) : ConfigManager.HomeFolder; string outputFilename = Path.Combine(ConfigManager.HomeFolder, entry.Name.Replace(suffix, ""));
string outputFilename = Path.Combine(baseFolder, entry.Name.Replace(suffix, "")); ExtractFile(entry, outputFilename);
} else if(entry.Name.StartsWith("libMesenCore") && Program.IsMono && entry.Name.Contains(suffix)) {
string outputFilename = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), entry.Name.Replace(suffix, ""));
ExtractFile(entry, outputFilename); ExtractFile(entry, outputFilename);
} else if(entry.Name == "MesenUpdater.exe" || entry.Name == "MesenDB.txt") { } else if(entry.Name == "MesenUpdater.exe" || entry.Name == "MesenDB.txt") {
string outputFilename = Path.Combine(ConfigManager.HomeFolder, entry.Name); string outputFilename = Path.Combine(ConfigManager.HomeFolder, entry.Name);
@ -99,16 +101,14 @@ namespace Mesen.GUI
} else if(entry.Name == "Font.24.spritefont" || entry.Name == "Font.64.spritefont" || entry.Name == "LICENSE.txt") { } else if(entry.Name == "Font.24.spritefont" || entry.Name == "Font.64.spritefont" || entry.Name == "LICENSE.txt") {
string outputFilename = Path.Combine(ConfigManager.HomeFolder, "Resources", entry.Name); string outputFilename = Path.Combine(ConfigManager.HomeFolder, "Resources", entry.Name);
ExtractFile(entry, outputFilename); ExtractFile(entry, outputFilename);
} else if(entry.Name == "DroidSansMono.ttf") { } else if(entry.Name == "DroidSansMono.ttf" && Program.IsMono) {
if(Program.IsMono) { string outputFilename = Path.Combine(ConfigManager.FontFolder, entry.Name);
string outputFilename = Path.Combine(ConfigManager.FontFolder, entry.Name); bool needRestart = !File.Exists(outputFilename);
bool needRestart = !File.Exists(outputFilename); ExtractFile(entry, outputFilename);
ExtractFile(entry, outputFilename); if(needRestart) {
if(needRestart) { //If font is newly installed, restart Mesen (otherwise debugger will not be able to use the font and display incorrectly)
//If font is newly installed, restart Mesen (otherwise debugger will not be able to use the font and display incorrectly) System.Diagnostics.Process.Start("mono", "\"" + Assembly.GetEntryAssembly().Location + "\" /delayrestart");
System.Diagnostics.Process.Start("mono", "\"" + Assembly.GetEntryAssembly().Location + "\" /delayrestart"); return false;
return false;
}
} }
} }
} }

9
build.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/sh
MESENPLATFORM=x64 make clean
MESENPLATFORM=x64 make core -j 4
MESENPLATFORM=x86 make clean
MESENPLATFORM=x86 make core -j 4
cp ./InteropDLL/obj.x64/libMesenCore.x64.dll ./bin
cp ./InteropDLL/obj.x86/libMesenCore.x86.dll ./bin

125
makefile
View File

@ -2,12 +2,9 @@
#Both clang & gcc work fine - clang seems to output faster code #Both clang & gcc work fine - clang seems to output faster code
#The only external dependency is SDL2 - everything else is pretty standard. #The only external dependency is SDL2 - everything else is pretty standard.
#Run "make" to build, "make run" to run #Run "make" to build, "make run" to run
#To specify whether you want to build for x86 or x64:
COREOBJ=$(patsubst Core/%.cpp,Core/obj/%.o,$(wildcard Core/*.cpp)) #"MESENPLATFORM=x86 make" or "MESENPLATFORM=x64 make"
UTILOBJ=$(patsubst Utilities/%.cpp,Utilities/obj/%.o,$(wildcard Utilities/*.cpp)) $(patsubst Utilities/HQX/%.cpp,Utilities/obj/%.o,$(wildcard Utilities/HQX/*.cpp)) $(patsubst Utilities/xBRZ/%.cpp,Utilities/obj/%.o,$(wildcard Utilities/xBRZ/*.cpp)) $(patsubst Utilities/KreedSaiEagle/%.cpp,Utilities/obj/%.o,$(wildcard Utilities/KreedSaiEagle/*.cpp)) $(patsubst Utilities/Scale2x/%.cpp,Utilities/obj/%.o,$(wildcard Utilities/Scale2x/*.cpp)) #Default is x64
LINUXOBJ=$(patsubst Linux/%.cpp,Linux/obj/%.o,$(wildcard Linux/*.cpp))
LIBEVDEVOBJ=$(patsubst Linux/libevdev/%.c,Linux/obj/%.o,$(wildcard Linux/libevdev/*.c))
SEVENZIPOBJ=$(patsubst SevenZip/%.c,SevenZip/obj/%.o,$(wildcard SevenZip/*.c))
CPPC=clang++ CPPC=clang++
GCCOPTIONS=-fPIC -Wall --std=c++14 -O3 GCCOPTIONS=-fPIC -Wall --std=c++14 -O3
@ -15,67 +12,89 @@ GCCOPTIONS=-fPIC -Wall --std=c++14 -O3
CC=clang CC=clang
CCOPTIONS=-fPIC -Wall -O3 CCOPTIONS=-fPIC -Wall -O3
SHAREDLIB=libMesenCore.dll ifeq ($(MESENPLATFORM),x86)
RELEASEFOLDER=bin/x64/Release MESENPLATFORM=x86
GCCOPTIONS += -m32
CCOPTIONS += -m32
else
MESENPLATFORM=x64
GCCOPTIONS += -m64
CCOPTIONS += -m64
endif
OBJFOLDER=obj.$(MESENPLATFORM)
SHAREDLIB=libMesenCore.$(MESENPLATFORM).dll
RELEASEFOLDER=bin/$(MESENPLATFORM)/Release
COREOBJ=$(patsubst Core/%.cpp,Core/$(OBJFOLDER)/%.o,$(wildcard Core/*.cpp))
UTILOBJ=$(patsubst Utilities/%.cpp,Utilities/$(OBJFOLDER)/%.o,$(wildcard Utilities/*.cpp)) $(patsubst Utilities/HQX/%.cpp,Utilities/$(OBJFOLDER)/%.o,$(wildcard Utilities/HQX/*.cpp)) $(patsubst Utilities/xBRZ/%.cpp,Utilities/$(OBJFOLDER)/%.o,$(wildcard Utilities/xBRZ/*.cpp)) $(patsubst Utilities/KreedSaiEagle/%.cpp,Utilities/$(OBJFOLDER)/%.o,$(wildcard Utilities/KreedSaiEagle/*.cpp)) $(patsubst Utilities/Scale2x/%.cpp,Utilities/$(OBJFOLDER)/%.o,$(wildcard Utilities/Scale2x/*.cpp))
LINUXOBJ=$(patsubst Linux/%.cpp,Linux/$(OBJFOLDER)/%.o,$(wildcard Linux/*.cpp))
LIBEVDEVOBJ=$(patsubst Linux/libevdev/%.c,Linux/$(OBJFOLDER)/%.o,$(wildcard Linux/libevdev/*.c))
SEVENZIPOBJ=$(patsubst SevenZip/%.c,SevenZip/$(OBJFOLDER)/%.o,$(wildcard SevenZip/*.c))
all: ui all: ui
ui: $(SHAREDLIB) ui: InteropDLL/$(OBJFOLDER)/$(SHAREDLIB)
mkdir -p $(RELEASEFOLDER)/Dependencies mkdir -p $(RELEASEFOLDER)/Dependencies
rm -f $(RELEASEFOLDER)/Dependencies/* rm -f $(RELEASEFOLDER)/Dependencies/*
cp GUI.NET/Dependencies/* $(RELEASEFOLDER)/Dependencies/ cp GUI.NET/Dependencies/* $(RELEASEFOLDER)/Dependencies/
cp InteropDLL/obj/$(SHAREDLIB) $(RELEASEFOLDER)/Dependencies/libMesenCore.x64.dll cp InteropDLL/$(OBJFOLDER)/$(SHAREDLIB) $(RELEASEFOLDER)/Dependencies/$(SHAREDLIB)
zip $(RELEASEFOLDER)/Dependencies.zip $(RELEASEFOLDER)/Dependencies/* cd $(RELEASEFOLDER)/Dependencies && zip ../Dependencies.zip *
cd GUI.NET && xbuild /property:Configuration="Release" /property:Platform="x64" /property:PreBuildEvent="" /property:DefineConstants="HIDETESTMENU" cd GUI.NET && xbuild /property:Configuration="Release" /property:Platform="$(MESENPLATFORM)" /property:PreBuildEvent="" /property:DefineConstants="HIDETESTMENU"
core: InteropDLL/$(OBJFOLDER)/$(SHAREDLIB)
runtests: runtests:
cd TestHelper/obj && ./testhelper cd TestHelper/$(OBJFOLDER) && ./testhelper
rungametests: rungametests:
cd TestHelper/obj && ./testhelper ~/Mesen/TestGames cd TestHelper/$(OBJFOLDER) && ./testhelper ~/Mesen/TestGames
testhelper: $(SHAREDLIB) testhelper: InteropDLL/$(OBJFOLDER)/$(SHAREDLIB)
mkdir -p TestHelper/obj mkdir -p TestHelper/$(OBJFOLDER)
ar -rcs TestHelper/obj/libSevenZip.a $(SEVENZIPOBJ) ar -rcs TestHelper/$(OBJFOLDER)/libSevenZip.a $(SEVENZIPOBJ)
ar -rcs TestHelper/obj/libMesenLinux.a $(LINUXOBJ) $(LIBEVDEVOBJ) ar -rcs TestHelper/$(OBJFOLDER)/libMesenLinux.a $(LINUXOBJ) $(LIBEVDEVOBJ)
ar -rcs TestHelper/obj/libUtilities.a $(UTILOBJ) ar -rcs TestHelper/$(OBJFOLDER)/libUtilities.a $(UTILOBJ)
ar -rcs TestHelper/obj/libCore.a $(COREOBJ) ar -rcs TestHelper/$(OBJFOLDER)/libCore.a $(COREOBJ)
cd TestHelper/obj && $(CPPC) $(GCCOPTIONS) -Wl,-z,defs -Wno-parentheses -Wno-switch -o testhelper ../*.cpp ../../InteropDLL/ConsoleWrapper.cpp -L ./ -lCore -lMesenLinux -lUtilities -lSevenZip -pthread -lSDL2 -lstdc++fs cd TestHelper/$(OBJFOLDER) && $(CPPC) $(GCCOPTIONS) -Wl,-z,defs -Wno-parentheses -Wno-switch -o testhelper ../*.cpp ../../InteropDLL/ConsoleWrapper.cpp -L ./ -lCore -lMesenLinux -lUtilities -lSevenZip -pthread -lSDL2 -lstdc++fs
SevenZip/obj/%.o: SevenZip/%.c SevenZip/$(OBJFOLDER)/%.o: SevenZip/%.c
mkdir -p SevenZip/obj && cd SevenZip/obj && $(CC) $(CCOPTIONS) -c $(patsubst SevenZip/%, ../%, $<) mkdir -p SevenZip/$(OBJFOLDER) && cd SevenZip/$(OBJFOLDER) && $(CC) $(CCOPTIONS) -c $(patsubst SevenZip/%, ../%, $<)
Utilities/obj/%.o: Utilities/%.cpp Utilities/$(OBJFOLDER)/%.o: Utilities/%.cpp
mkdir -p Utilities/obj && cd Utilities/obj && $(CPPC) $(GCCOPTIONS) -c $(patsubst Utilities/%, ../%, $<) mkdir -p Utilities/$(OBJFOLDER) && cd Utilities/$(OBJFOLDER) && $(CPPC) $(GCCOPTIONS) -c $(patsubst Utilities/%, ../%, $<)
Utilities/obj/%.o: Utilities/HQX/%.cpp Utilities/$(OBJFOLDER)/%.o: Utilities/HQX/%.cpp
mkdir -p Utilities/obj && cd Utilities/obj && $(CPPC) $(GCCOPTIONS) -c $(patsubst Utilities/%, ../%, $<) mkdir -p Utilities/$(OBJFOLDER) && cd Utilities/$(OBJFOLDER) && $(CPPC) $(GCCOPTIONS) -c $(patsubst Utilities/%, ../%, $<)
Utilities/obj/%.o: Utilities/xBRZ/%.cpp Utilities/$(OBJFOLDER)/%.o: Utilities/xBRZ/%.cpp
mkdir -p Utilities/obj && cd Utilities/obj && $(CPPC) $(GCCOPTIONS) -c $(patsubst Utilities/%, ../%, $<) mkdir -p Utilities/$(OBJFOLDER) && cd Utilities/$(OBJFOLDER) && $(CPPC) $(GCCOPTIONS) -c $(patsubst Utilities/%, ../%, $<)
Utilities/obj/%.o: Utilities/KreedSaiEagle/%.cpp Utilities/$(OBJFOLDER)/%.o: Utilities/KreedSaiEagle/%.cpp
mkdir -p Utilities/obj && cd Utilities/obj && $(CPPC) $(GCCOPTIONS) -c $(patsubst Utilities/%, ../%, $<) mkdir -p Utilities/$(OBJFOLDER) && cd Utilities/$(OBJFOLDER) && $(CPPC) $(GCCOPTIONS) -c $(patsubst Utilities/%, ../%, $<)
Utilities/obj/%.o: Utilities/Scale2x/%.cpp Utilities/$(OBJFOLDER)/%.o: Utilities/Scale2x/%.cpp
mkdir -p Utilities/obj && cd Utilities/obj && $(CPPC) $(GCCOPTIONS) -c $(patsubst Utilities/%, ../%, $<) mkdir -p Utilities/$(OBJFOLDER) && cd Utilities/$(OBJFOLDER) && $(CPPC) $(GCCOPTIONS) -c $(patsubst Utilities/%, ../%, $<)
Core/obj/%.o: Core/%.cpp Core/$(OBJFOLDER)/%.o: Core/%.cpp
mkdir -p Core/obj && cd Core/obj && $(CPPC) $(GCCOPTIONS) -Wno-parentheses -Wno-switch -c $(patsubst Core/%, ../%, $<) mkdir -p Core/$(OBJFOLDER) && cd Core/$(OBJFOLDER) && $(CPPC) $(GCCOPTIONS) -Wno-parentheses -Wno-switch -c $(patsubst Core/%, ../%, $<)
Linux/obj/%.o: Linux/%.cpp Linux/$(OBJFOLDER)/%.o: Linux/%.cpp
mkdir -p Linux/obj && cd Linux/obj && $(CPPC) $(GCCOPTIONS) -Wno-parentheses -Wno-switch -c $(patsubst Linux/%, ../%, $<) mkdir -p Linux/$(OBJFOLDER) && cd Linux/$(OBJFOLDER) && $(CPPC) $(GCCOPTIONS) -Wno-parentheses -Wno-switch -c $(patsubst Linux/%, ../%, $<)
Linux/obj/%.o: Linux/libevdev/%.c Linux/$(OBJFOLDER)/%.o: Linux/libevdev/%.c
mkdir -p Linux/obj && cd Linux/obj && $(CC) $(CCOPTIONS) -Wno-parentheses -Wno-switch -c $(patsubst Linux/%, ../%, $<) mkdir -p Linux/$(OBJFOLDER) && cd Linux/$(OBJFOLDER) && $(CC) $(CCOPTIONS) -Wno-parentheses -Wno-switch -c $(patsubst Linux/%, ../%, $<)
$(SHAREDLIB): $(SEVENZIPOBJ) $(UTILOBJ) $(COREOBJ) $(LIBEVDEVOBJ) $(LINUXOBJ) InteropDLL/ConsoleWrapper.cpp InteropDLL/DebugWrapper.cpp InteropDLL/$(OBJFOLDER)/$(SHAREDLIB): $(SEVENZIPOBJ) $(UTILOBJ) $(COREOBJ) $(LIBEVDEVOBJ) $(LINUXOBJ) InteropDLL/ConsoleWrapper.cpp InteropDLL/DebugWrapper.cpp
mkdir -p InteropDLL/obj mkdir -p InteropDLL/$(OBJFOLDER)
ar -rcs InteropDLL/obj/libSevenZip.a $(SEVENZIPOBJ) ar -rcs InteropDLL/$(OBJFOLDER)/libSevenZip.a $(SEVENZIPOBJ)
ar -rcs InteropDLL/obj/libMesenLinux.a $(LINUXOBJ) $(LIBEVDEVOBJ) ar -rcs InteropDLL/$(OBJFOLDER)/libMesenLinux.a $(LINUXOBJ) $(LIBEVDEVOBJ)
ar -rcs InteropDLL/obj/libUtilities.a $(UTILOBJ) ar -rcs InteropDLL/$(OBJFOLDER)/libUtilities.a $(UTILOBJ)
ar -rcs InteropDLL/obj/libCore.a $(COREOBJ) ar -rcs InteropDLL/$(OBJFOLDER)/libCore.a $(COREOBJ)
cd InteropDLL/obj && $(CPPC) $(GCCOPTIONS) -Wl,-z,defs -Wno-parentheses -Wno-switch -shared -o $(SHAREDLIB) ../*.cpp -L . -lCore -lMesenLinux -lUtilities -lSevenZip -pthread -lSDL2 -lstdc++fs cd InteropDLL/$(OBJFOLDER) && $(CPPC) $(GCCOPTIONS) -Wl,-z,defs -Wno-parentheses -Wno-switch -shared -o $(SHAREDLIB) ../*.cpp -L . -lCore -lMesenLinux -lUtilities -lSevenZip -pthread -lSDL2 -lstdc++fs
run: run:
MONO_LOG_LEVEL=debug mono bin/x64/Release/Mesen.exe MONO_LOG_LEVEL=debug mono $(RELEASEFOLDER)/Mesen.exe
clean: clean:
rm SevenZip/obj -r -f rm SevenZip/$(OBJFOLDER) -r -f
rm Utilities/obj -r -f rm Utilities/$(OBJFOLDER) -r -f
rm Core/obj -r -f rm Core/$(OBJFOLDER) -r -f
rm Linux/obj -r -f rm Linux/$(OBJFOLDER) -r -f
rm InteropDLL/obj -r -f rm InteropDLL/$(OBJFOLDER) -r -f
rm TestHelper/obj -r -f rm TestHelper/$(OBJFOLDER) -r -f
rm $(RELEASEFOLDER) -r -f