Add maintainer debug build and better editor error handling

Now only in debug build it will build fcollada debug library, that is
not used, but when built, assume x86, and generates "int 0x3" do break
to the debugger in it's assert like function.
This commit is contained in:
pcpa 2012-11-03 16:34:49 -02:00
parent 911cc05b72
commit 879053ecfa
3 changed files with 288 additions and 7 deletions

110
0ad-debug.patch Normal file
View File

@ -0,0 +1,110 @@
diff -up 0ad-0.0.11-alpha/libraries/fcollada/src/Makefile.orig 0ad-0.0.11-alpha/libraries/fcollada/src/Makefile
--- 0ad-0.0.11-alpha/libraries/fcollada/src/Makefile.orig 2012-11-03 09:57:05.310706564 -0200
+++ 0ad-0.0.11-alpha/libraries/fcollada/src/Makefile 2012-11-03 09:58:41.665710254 -0200
@@ -9,10 +9,7 @@ endif
CXX ?= g++
CXXFLAGS += -fvisibility=hidden -W -Wall -Wno-unused-parameter -Wno-unused-function $(OS_DEFINE) $(PIC_FLAGS) $(CPPFLAGS)
-CXXFLAGS_DEBUG := -O0 -g -D_DEBUG -DRETAIL
CXXFLAGS_RELEASE := -O1 -DNDEBUG -DRETAIL
-# (-O2 with gcc 4.3 causes linker errors when using this library, for unknown reasons, so stick with -O1)
-CXXFLAGS_TEST := -O0 -g -D_DEBUG
LIBS += `pkg-config libxml-2.0 --libs`
INCLUDES += -IFCollada `pkg-config libxml-2.0 --cflags`
INCLUDES_TEST := -IFCollada/FColladaTest $(INCLUDES)
@@ -181,72 +178,19 @@ SOURCE = \
FColladaPlugins/FArchiveXML/FAXSceneExport.cpp \
FColladaPlugins/FArchiveXML/FAXSceneImport.cpp \
-TEST_SOURCE = \
- FCollada/FMath/FMArrayTest.cpp \
- FCollada/FMath/FMQuaternionTest.cpp \
- FCollada/FMath/FMTreeTest.cpp \
- FCollada/FUtils/FUBoundingTest.cpp \
- FCollada/FUtils/FUCrc32Test.cpp \
- FCollada/FUtils/FUEventTest.cpp \
- FCollada/FUtils/FUFileManagerTest.cpp \
- FCollada/FUtils/FUFunctorTest.cpp \
- FCollada/FUtils/FUObjectTest.cpp \
- FCollada/FUtils/FUStringBuilderTest.cpp \
- FCollada/FUtils/FUStringConversionTest.cpp \
- FCollada/FUtils/FUStringTest.cpp \
- FCollada/FUtils/FUTestBed.cpp \
- FCollada/FUtils/FUUniqueStringMapTest.cpp \
- FCollada/FColladaTest/FCTest.cpp \
- FCollada/FColladaTest/FCTestAnimation.cpp \
- FCollada/FColladaTest/FCTestArchiving.cpp \
- FCollada/FColladaTest/FCTestController.cpp \
- FCollada/FColladaTest/FCTestGeometryPolygonsTools.cpp \
- FCollada/FColladaTest/FCTestParameters.cpp \
- FCollada/FColladaTest/FCTestSceneGraph.cpp \
- FCollada/FColladaTest/FCTestAssetManagement/FCTAMCrossCloning.cpp \
- FCollada/FColladaTest/FCTestAssetManagement/FCTAssetManagement.cpp \
- FCollada/FColladaTest/FCTestExportImport/FCTEIAnimation.cpp \
- FCollada/FColladaTest/FCTestExportImport/FCTEICamera.cpp \
- FCollada/FColladaTest/FCTestExportImport/FCTEIEmitter.cpp \
- FCollada/FColladaTest/FCTestExportImport/FCTEIExtra.cpp \
- FCollada/FColladaTest/FCTestExportImport/FCTEIGeometry.cpp \
- FCollada/FColladaTest/FCTestExportImport/FCTEILight.cpp \
- FCollada/FColladaTest/FCTestExportImport/FCTEIMaterial.cpp \
- FCollada/FColladaTest/FCTestExportImport/FCTEIPhysics.cpp \
- FCollada/FColladaTest/FCTestExportImport/FCTEIVisualScene.cpp \
- FCollada/FColladaTest/FCTestExportImport/FCTestExportImport.cpp \
- FCollada/FColladaTest/FCTestXRef/FCTestXRef.cpp \
- FCollada/FColladaTest/FCTestXRef/FCTestXRefAcyclic.cpp \
- FCollada/FColladaTest/FCTestXRef/FCTestXRefSimple.cpp \
- FCollada/FColladaTest/FCTestXRef/FCTestXRefTree.cpp \
-
-OBJECTS_DEBUG = $(addprefix output/debug/,$(SOURCE:.cpp=.o))
OBJECTS_RELEASE = $(addprefix output/release/,$(SOURCE:.cpp=.o))
-OBJECTS_TEST = $(addprefix output/test/,$(SOURCE:.cpp=.o) $(TEST_SOURCE:.cpp=.o))
-OBJECTS_ALL = $(OBJECTS_DEBUG) $(OBJECTS_RELEASE) $(OBJECTS_TEST)
+OBJECTS_ALL = $(OBJECTS_RELEASE)
-all: output_dirs output/libFColladaSD.a output/libFColladaSR.a install
+all: output_dirs output/libFColladaSR.a install
output_dirs:
- bash -c 'mkdir -p output/{debug,release,test}/{FCollada/{FCDocument,FMath,FUtils,FColladaTest/{FCTestAssetManagement,FCTestExportImport,FCTestXRef}},FColladaPlugins/FArchiveXML}'
-
-test: FCollada/FColladaTest/ output/FColladaTest
- ( cd FCollada/FColladaTest/ ; ../../output/FColladaTest )
- cat FCollada/FColladaTest/FColladaTestLog.txt
+ bash -c 'mkdir -p output/release/{FCollada/{FCDocument,FMath,FUtils,FColladaTest/{FCTestAssetManagement,FCTestExportImport,FCTestXRef}},FColladaPlugins/FArchiveXML}'
-output/libFColladaSD.a: $(OBJECTS_DEBUG)
- @echo "$@"
- @ar -cr $@ $(OBJECTS_DEBUG); ranlib $@
-
output/libFColladaSR.a: $(OBJECTS_RELEASE)
@echo "$@"
@ar -cr $@ $(OBJECTS_RELEASE); ranlib $@
-output/FColladaTest: $(OBJECTS_TEST)
- $(CXX) -o $@ $(LDFLAGS) $(OBJECTS_TEST) $(LIBS)
-
-install: output/libFColladaSD.a output/libFColladaSR.a
- cp output/libFColladaSD.a ../lib/libFColladaSD.a
+install: output/libFColladaSR.a
cp output/libFColladaSR.a ../lib/libFColladaSR.a
dfile = $(@:.o=.d)
@@ -256,18 +200,10 @@ gendep = \
sed -e 's/\#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
-e '/^$$/ d' -e 's/$$/ :/' < $(dfile) >> $(Pfile) && \
rm -f $(dfile)
-output/debug/%.o: %.cpp
- @echo "$<"
- $(CXX) $(CXXFLAGS) $(CXXFLAGS_DEBUG) $(INCLUDES) -MD -MF $(dfile) -c $< -o $@
- $(gendep)
output/release/%.o: %.cpp
@echo "$<"
$(CXX) $(CXXFLAGS) $(CXXFLAGS_RELEASE) $(INCLUDES) -MD -MF $(dfile) -c $< -o $@
$(gendep)
-output/test/%.o: %.cpp
- @echo "$<"
- $(CXX) $(CXXFLAGS) $(CXXFLAGS_TEST) $(INCLUDES_TEST) -MD -MF $(dfile) -c $< -o $@
- $(gendep)
clean:
rm -rf output

134
0ad-saveas.patch Normal file
View File

@ -0,0 +1,134 @@
diff -up 0ad-0.0.11-alpha/source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.cpp.orig 0ad-0.0.11-alpha/source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.cpp
--- 0ad-0.0.11-alpha/source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.cpp.orig 2012-11-03 13:31:29.921199195 -0200
+++ 0ad-0.0.11-alpha/source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.cpp 2012-11-03 15:57:00.017533500 -0200
@@ -691,30 +691,20 @@ bool ScenarioEditor::OpenFile(const wxSt
void ScenarioEditor::OnOpen(wxCommandEvent& WXUNUSED(event))
{
- wxFileDialog dlg (NULL, wxFileSelectorPromptStr,
- Datafile::GetDataDirectory() + _T("/mods/public/maps/scenarios"), m_OpenFilename,
- _T("PMP files (*.pmp)|*.pmp|All files (*.*)|*.*"),
- wxFD_OPEN);
- // Set default filter
- dlg.SetFilterIndex(0);
-
- wxString cwd = wxFileName::GetCwd();
-
- if (dlg.ShowModal() == wxID_OK)
- {
- // TODO: Handle maps in subdirectories of maps/scenarios
- wxFileName filename(dlg.GetFilename());
- if (!OpenFile(filename.GetName(), filename.GetFullName()))
- {
- wxLogError(_("Map '%ls' does not exist"), filename.GetName().c_str());
- }
-
- // paranoia - MSDN says OFN_NOCHANGEDIR (used when we don't give wxCHANGE_DIR)
- // "is ineffective for GetOpenFileName", but it seems to work anyway
- wxCHECK_RET(cwd == wxFileName::GetCwd(), _T("cwd changed"));
+ wxFileName filename(m_OpenFilename);
+ wxFileName dirname(_T("/usr/share/0ad/mods/public/maps/scenarios"));
+ wxString string = wxGetTextFromUser(dirname.GetFullPath() + _T("/"),
+ _T("Choose filename"),
+ filename.GetName());
+ if (!string.IsEmpty()) {
+ filename.Assign(dirname.GetFullPath() + _("/") + string);
+ filename.SetExt(_T("pmp"));
+
+ if (!OpenFile(filename.GetName(), filename.GetFullName())) {
+ wxLogError(_("Map '%ls' does not exist"),
+ filename.GetName().c_str());
}
-
- // TODO: Make this a non-undoable command
+ }
}
void ScenarioEditor::OnImportHeightmap(wxCommandEvent& WXUNUSED(event))
@@ -778,40 +768,57 @@ void ScenarioEditor::OnSave(wxCommandEve
void ScenarioEditor::OnSaveAs(wxCommandEvent& WXUNUSED(event))
{
- wxFileDialog dlg (NULL, wxFileSelectorPromptStr,
- Datafile::GetDataDirectory() + _T("/mods/public/maps/scenarios"), m_OpenFilename,
- _T("PMP files (*.pmp)|*.pmp|All files (*.*)|*.*"),
- wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
- // Set default filter
- dlg.SetFilterIndex(0);
-
- if (dlg.ShowModal() == wxID_OK)
- {
- // On wxMSW the extension is automatically set to pmp if that filter is selected
- // but not on wxGTK or wxOSX. Set it explicitly since it's the only possible format.
- wxFileName filename(dlg.GetFilename());
- filename.SetExt(_T("pmp"));
- if (!filename.IsOk())
- { // Shouldn't happen
- wxLogError(_("Invalid filename '%ls'"), filename.GetFullName().c_str());
- return;
- }
+ wxFileName filename(m_OpenFilename);
+ wxFileName dirname(_T("/usr/share/0ad/mods/public/maps/scenarios"));
+ wxString string = wxGetTextFromUser(dirname.GetFullPath() + _T("/"),
+ _T("Choose filename"),
+ filename.GetName());
+ if (!string.IsEmpty()) {
+ filename.Assign(dirname.GetFullPath() + _("/") + string);
+ filename.SetExt(_T("pmp"));
+
+ if (!dirname.DirExists(dirname.GetFullPath())) {
+ wxLogError(_("Directory '%ls' does not exist"),
+ dirname.GetFullPath().c_str());
+ return;
+ }
+ if (!dirname.IsDirWritable(dirname.GetFullPath())) {
+ wxLogError(_("Directory '%ls' is not writable"),
+ dirname.GetFullPath().c_str());
+ return;
+ }
+ if (!filename.IsOk()) {
+ wxLogError(_("Invalid filename '%ls'"),
+ filename.GetFullName().c_str());
+ return;
+ }
+ if (filename.FileExists(filename.GetFullPath())) {
+ if (wxMessageBox(_("File ") + filename.GetFullPath() +
+ _(" exists, overwrite?"),
+ _("Confirm"), wxOK | wxCANCEL) != wxOK)
+ return;
+ if (!filename.IsFileWritable(filename.GetFullPath())) {
+ wxLogError(_("File '%ls' is not writable"),
+ filename.GetFullPath().c_str());
+ return;
+ }
+ }
- wxBusyInfo busy(_("Saving ") + filename.GetFullName());
- wxBusyCursor busyc;
+ wxBusyInfo busy(_("Saving ") + filename.GetFullName());
+ wxBusyCursor busyc;
- m_ToolManager.SetCurrentTool(_T(""));
+ m_ToolManager.SetCurrentTool(_T(""));
- // TODO: Handle maps in subdirectories of maps/scenarios
- std::wstring map(filename.GetFullName().wc_str());
- POST_MESSAGE(SaveMap, (map));
+ // TODO: Handle maps in subdirectories of maps/scenarios
+ std::wstring map(filename.GetFullName().wc_str());
+ POST_MESSAGE(SaveMap, (map));
- SetOpenFilename(filename.GetFullName());
+ SetOpenFilename(filename.GetFullName());
- // Wait for it to finish saving
- qPing qry;
- qry.Post();
- }
+ // Wait for it to finish saving
+ qPing qry;
+ qry.Post();
+ }
}
void ScenarioEditor::SetOpenFilename(const wxString& filename)

View File

@ -1,5 +1,15 @@
# http://trac.wildfiregames.com/wiki/BuildInstructions#Linux
# enable special maintainer debug build ?
%define with_debug 0
%if %{with_debug}
%define config debug
%define dbg _dbg
%else
%define config release
%define dbg %{nil}
%endif
# Remember to rerun licensecheck after every update:
# https://bugzilla.redhat.com/show_bug.cgi?id=818401#c46
# http://trac.wildfiregames.com/ticket/1682
@ -17,7 +27,7 @@
Name: 0ad
Version: 0.0.11
Release: 3%{?dist}
Release: 4%{?dist}
# BSD License:
# build/premake/*
# libraries/valgrind/* (not built/used)
@ -94,6 +104,19 @@ Patch1: %{name}-rpath.patch
# Build with newer libxml2
Patch2: %{name}-libxml2.patch
# Display more clear error messages when creating custom scenarios
# The suggested usage is:
# $ sudo mkdir /usr/share/0ad/public/maps
# $ sudo chmod 7777 /usr/share/0ad/public/maps
# $ 0ad -editor
# Supposing saved the map as mymap, can test it with:
# $ 0ad -autostart=mymap
Patch3: %{name}-saveas.patch
# Only do fcollada debug build with enabling debug maintainer mode
# It also prevents assumption there that it is building in x86
Patch4: %{name}-debug.patch
%description
0 A.D. (pronounced "zero ey-dee") is a free, open-source, cross-platform
real-time strategy (RTS) game of ancient warfare. In short, it is a
@ -115,6 +138,11 @@ hobbyist game developers, since 2001.
# 0ad <= 0.0.11 && libxml2 >= 2.9
%patch2 -p1
%endif
%patch3 -p1
%if !%{with_debug}
# disable debug build, and "int 0x3" to trap to debugger (x86 only)
%patch4 -p1
%endif
#-----------------------------------------------------------------------
%build
@ -137,22 +165,22 @@ build/workspaces/update-workspaces.sh \
%endif
%{?_smp_mflags}
make %{?_smp_mflags} -C build/workspaces/gcc config=release verbose=1
make %{?_smp_mflags} -C build/workspaces/gcc config=%{config} verbose=1
#-----------------------------------------------------------------------
# Depends on availablity of nvtt
%if !%{without_nvtt}
%check
LD_LIBRARY_PATH=binaries/system binaries/system/test -libdir binaries/system
LD_LIBRARY_PATH=binaries/system binaries/system/test%{dbg} -libdir binaries/system
%endif
#-----------------------------------------------------------------------
%install
install -d -m 755 %{buildroot}%{_bindir}
install -p -m 755 binaries/system/pyrogenesis %{buildroot}%{_bindir}/pyrogenesis
install -p -m 755 binaries/system/pyrogenesis%{dbg} %{buildroot}%{_bindir}/pyrogenesis%{dbg}
install -d -m 755 %{buildroot}%{_libdir}/%{name}
for name in AtlasUI Collada; do
for name in AtlasUI%{dbg} Collada%{dbg}; do
install -p -m 755 binaries/system/lib${name}.so %{buildroot}%{_libdir}/%{name}/lib${name}.so
done
@ -185,16 +213,20 @@ cat > %{buildroot}%{_bindir}/0ad <<EOF
#!/bin/sh
cd %{_datadir}/0ad
LD_LIBRARY_PATH=%{_libdir}/0ad %{_bindir}/pyrogenesis "\$@"
LD_LIBRARY_PATH=%{_libdir}/0ad %{_bindir}/pyrogenesis%{dbg} "\$@"
EOF
chmod +x %{buildroot}%{_bindir}/0ad
%if %{with_debug}
export STRIP=/bin/true
%endif
#-----------------------------------------------------------------------
%files
%doc README.txt LICENSE.txt
%doc license_gpl-2.0.txt license_lgpl-2.1.txt
%{_bindir}/0ad
%{_bindir}/pyrogenesis
%{_bindir}/pyrogenesis%{dbg}
%{_libdir}/%{name}
%{_datadir}/pixmaps/%{name}.png
%{_datadir}/applications/%{name}.desktop
@ -202,6 +234,11 @@ chmod +x %{buildroot}%{_bindir}/0ad
%{_mandir}/man6/*.6*
%changelog
* Sat Nov 3 2012 pcpa <paulo.cesar.pereira.de.andrade@gmail.com> - 0.0.11-4
- Add %%with_debug maintainer mode build
- Disable fcollada debug build if %%with_debug is false
- Add patch to not crash and display helful messages in editor (#872801)
* Tue Sep 11 2012 pcpa <paulo.cesar.pereira.de.andrade@gmail.com> - 0.0.11-3
- Clarify source tree licenses information in spec (#818401)
- Preserve time stamp of installed files (#818401)