Explorar el Código

- Moving Vec to new header file to impove compilation
- Improving the build/genmakefile.py to better support precopiled headers

Panagiotis Christopoulos Charitos hace 15 años
padre
commit
334cab43c8

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 333 - 363
build/debug/Makefile


+ 16 - 7
build/debug/gen.cfg.py

@@ -1,12 +1,21 @@
-sourcePaths = [ "../../src/Math/", "../../src/Util/Tokenizer/", "../../src/Misc/", "../../src/", "../../src/Renderer/", "../../src/Scene/", "../../src/Ui/", "../../src/Resources/", "../../src/Util/", "../../src/Scene/Controllers/", "../../src/Physics/", "../../src/Renderer/BufferObjects/", "../../src/Resources/Helpers/" ]
+sourcePaths = ["../../src/Math/", "../../src/Util/Tokenizer/", "../../src/Misc/", "../../src/", "../../src/Renderer/", "../../src/Scene/", "../../src/Ui/", "../../src/Resources/", "../../src/Util/", "../../src/Scene/Controllers/", "../../src/Physics/", "../../src/Renderer/BufferObjects/", "../../src/Resources/Helpers/"]
 
-includePaths = list(sourcePaths)
-includePaths.extend( [ "../../../bullet/src/", "../../../SDL/include", "../../../glew/include" ] )
+includePaths = []
+includePaths.append("./")
+includePaths.extend(list(sourcePaths))
+includePaths.extend([ "../../../bullet/src/", "../../../SDL/include", "../../../glew/include" ])
 
+#precompiledHeaders = ["../../src/Util/Common.h", "/usr/include/boost/filesystem.hpp", "/usr/include/boost/ptr_container/ptr_vector.hpp"]
 precompiledHeaders = []
-executableName = "AnKi.bin"
+
+executableName = "anki"
+
 compiler = "g++"
-commonFlags_ = ""
-compilerFlags = "-c -pedantic-errors -pedantic -ansi -Wall -Wextra -W -pipe -O0 -g3 -pg -fsingle-precision-constant -DDEBUG_ENABLED -DPLATFORM_LINUX -DREVISION=\\\"`svnversion -c ../..`\\\" "
-precompiledHeadersFlags = compilerFlags + " -x "
+
+defines__ = "-DDEBUG_ENABLED -DPLATFORM_LINUX -DREVISION=\\\"`svnversion -c ../..`\\\""
+
+precompiledHeadersFlags = defines__ + " -c -pedantic-errors -pedantic -ansi -Wall -Wextra -W -pipe -O0 -g3 -pg"
+
+compilerFlags = precompiledHeadersFlags + " -fsingle-precision-constant"
+
 linkerFlags = "-rdynamic -L../../../SDL/build/.libs -L../../../glew/lib -L../../../bullet/src/BulletSoftBody -L../../../bullet/src/BulletDynamics -L../../../bullet/src/BulletCollision -L../../../bullet/src/LinearMath -Wl,-Bstatic -lBulletSoftBody -lBulletDynamics -lBulletCollision -lLinearMath -lGLEW -lSDL_image -lGLU -lSDL -lboost_system -lboost_filesystem -Wl,-Bdynamic -lGL -ljpeg -lpng -ltiff -pg"

+ 4 - 5
build/genmakefile.py

@@ -145,7 +145,7 @@ for header in precompiledHeaders:
 	sFile = SourceFile()
 	(fnameWoExt, ext) = os.path.splitext(header)
 	sFile.cppFile = header
-	sFile.objFile = os.path.basename(fnameWoExt) + ".gch"
+	sFile.objFile = os.path.basename(fnameWoExt) + ".h.gch "
 	phFiles.append(sFile)
 
 
@@ -187,16 +187,15 @@ masterStr += "\t@$(CXX) $(OBJECTS) $(LFLAGS) -o $(EXECUTABLE)\n"
 masterStr += "\t@echo All Done!\n\n"
 
 
-for header in phFiles:
-  #            getCommandOutput(compiler + " -MM " + compilerFlags + " " + source_file.cppFile + " -MT " + source_file.objFile)
+for header in phFiles:  
 	dependStr = getCommandOutput(compiler + " -MM " + compilerFlags + " " + header.cppFile + " -MT " + header.objFile)
 	masterStr += dependStr
 	masterStr += "\t@echo Pre-compiling header " + header.cppFile + "...\n"
-	masterStr += "\t@$(CXX) $(INCPATH) $(PHFLAGS) " + header.objFile + "\n\n"
+	masterStr += "\t@$(CXX) $(INCPATH) $(PHFLAGS) " + header.cppFile + " -x c++-header " + header.objFile + "\n\n"
 
 
 # write source file target
-threadsNum = os.sysconf('SC_NPROCESSORS_ONLN')
+threadsNum = os.sysconf('SC_NPROCESSORS_ONLN') + 1
 print("I will invoke %d threads to make the dependencies..." % threadsNum)
 num = len(sourceFiles);
 itemsPerThread = num // threadsNum;

+ 6 - 7
src/Main.cpp

@@ -402,7 +402,7 @@ void mainLoop()
 	INFO("Exiting main loop (" << App::getTicks()-ticks << ")");
 }
 
-#include "ShaderPrePreprocessor.h"
+#include "Arr.h"
 //======================================================================================================================
 // main                                                                                                                =
 //======================================================================================================================
@@ -410,12 +410,11 @@ int main(int argc, char* argv[])
 {
 	new App(argc, argv);
 
-	ShaderPrePreprocessor s;
-	s.parseFile("shaders/HwSkinningTrffbGeneric.glsl");
-	for(uint i=0; i<s.getOutput().getTrffbVaryings().size(); i++)
-	{
-		INFO(s.getOutput().getTrffbVaryings()[i].name);
-	}
+	MALLINFO_BEGIN
+	Arr<int, 1000> arr;
+	arr[1000] = 100;
+	MALLINFO_END
+
 	return 0;
 
 	init();

+ 1 - 0
src/Misc/map.h

@@ -3,6 +3,7 @@
 
 #include "Common.h"
 #include "collision.h"
+#include "Vec.h"
 
 class Mesh;
 class Camera;

+ 1 - 0
src/Resources/Helpers/ShaderPrePreprocessor.h

@@ -3,6 +3,7 @@
 
 #include <limits>
 #include "Common.h"
+#include "Vec.h"
 
 
 /**

+ 1 - 0
src/Scene/Controllers/SkelAnimCtrl.h

@@ -2,6 +2,7 @@
 #define _SKEL_ANIM_CTRL_H_
 
 #include "Common.h"
+#include "Vec.h"
 #include "Controller.h"
 #include "Math.h"
 

+ 1 - 0
src/Scene/SceneNode.h

@@ -3,6 +3,7 @@
 
 #include <memory>
 #include "Common.h"
+#include "Vec.h"
 #include "Math.h"
 
 

+ 41 - 0
src/Util/Arr.h

@@ -0,0 +1,41 @@
+#ifndef ARR_H
+#define ARR_H
+
+#include <boost/array.hpp>
+#include "Common.h"
+
+
+/**
+ * This is a wrapper of boost::array that adds new functionality
+ */
+template<typename Type, size_t nn>
+class Arr: public boost::array<Type, nn>
+{
+	public:
+		Type& operator[](size_t n);
+		const Type& operator[](size_t n) const;
+};
+
+
+//======================================================================================================================
+// operator[]                                                                                                          =
+//======================================================================================================================
+template<typename Type, size_t nn>
+Type& Arr<Type, nn>::operator[](size_t n)
+{
+	DEBUG_ERR(n >= nn);
+	return boost::array<Type, nn>::operator [](n);
+}
+
+
+//======================================================================================================================
+// operator[]                                                                                                          =
+//======================================================================================================================
+template<typename Type, size_t nn>
+const Type& Arr<Type, nn>::operator[](size_t n) const
+{
+	DEBUG_ERR(n >= nn);
+	return boost::array<Type, nn>::operator [](n);
+}
+
+#endif

+ 2 - 36
src/Util/Common.h

@@ -3,12 +3,10 @@
 
 #include <cstdlib>
 #include <cstdio>
-#include <memory.h>
-#include <string.h>
+#include <cstring>
 #include <fstream>
-#include <stdio.h>
+#include <cstdio>
 #include <iostream>
-#include <time.h>
 #include <vector>
 
 using namespace std;
@@ -154,38 +152,6 @@ template <typename Type> inline void memZero(Type& t)
 }
 
 
-//======================================================================================================================
-// Vec                                                                                                                 =
-//======================================================================================================================
-/**
- * This is a wrapper of std::vector that adds new functionality
- */
-template<typename Type> class Vec: public vector<Type>
-{
-	public:
-		Vec(): vector<Type>() {}
-		Vec(size_t size): vector<Type>(size) {}
-		Vec(size_t size, Type val): vector<Type>(size,val) {}
-
-		Type& operator[](size_t n)
-		{
-			DEBUG_ERR(n >= vector<Type>::size());
-			return vector<Type>::operator [](n);
-		}
-
-		const Type& operator[](size_t n) const
-		{
-			DEBUG_ERR(n >= vector<Type>::size());
-			return vector<Type>::operator [](n);
-		}
-
-		size_t getSizeInBytes() const
-		{
-			return vector<Type>::size() * sizeof(Type);
-		}
-};
-
-
 //======================================================================================================================
 // Memory allocation information for Linux                                                                             =
 //======================================================================================================================

+ 1 - 0
src/Util/Input.h

@@ -3,6 +3,7 @@
 
 #include <SDL_scancode.h>
 #include "Common.h"
+#include "Vec.h"
 #include "App.h"
 #include "Math.h"
 

+ 1 - 0
src/Util/Util.h

@@ -2,6 +2,7 @@
 #define _UTIL_H_
 
 #include "Common.h"
+#include "Vec.h"
 
 /**
  * The namespace contains a few useful functions

+ 82 - 0
src/Util/Vec.h

@@ -0,0 +1,82 @@
+#ifndef VEC_H
+#define VEC_H
+
+#include <vector>
+#include "Common.h"
+
+
+/**
+ * This is a wrapper of std::vector that adds new functionality
+ */
+template<typename Type>
+class Vec: public vector<Type>
+{
+	public:
+		Vec();
+		Vec(size_t size);
+		Vec(size_t size, Type val);
+		Type& operator[](size_t n);
+		const Type& operator[](size_t n) const;
+		size_t getSizeInBytes() const;
+};
+
+
+//======================================================================================================================
+// Constructor []                                                                                                      =
+//======================================================================================================================
+template<typename Type>
+Vec<Type>::Vec():
+	vector<Type>()
+{}
+
+
+//======================================================================================================================
+// Constructor [size]                                                                                                  =
+//======================================================================================================================
+template<typename Type>
+Vec<Type>::Vec(size_t size):
+	vector<Type>(size)
+{}
+
+
+//======================================================================================================================
+// Constructor [size, val]                                                                                             =
+//======================================================================================================================
+template<typename Type>
+Vec<Type>::Vec(size_t size, Type val):
+	vector<Type>(size,val)
+{}
+
+
+//======================================================================================================================
+// operator[]                                                                                                          =
+//======================================================================================================================
+template<typename Type>
+Type& Vec<Type>::operator[](size_t n)
+{
+	DEBUG_ERR(n >= vector<Type>::size());
+	return vector<Type>::operator [](n);
+}
+
+
+//======================================================================================================================
+// operator[]                                                                                                          =
+//======================================================================================================================
+template<typename Type>
+const Type& Vec<Type>::operator[](size_t n) const
+{
+	DEBUG_ERR(n >= vector<Type>::size());
+	return vector<Type>::operator [](n);
+}
+
+
+//======================================================================================================================
+// getSizeInBytes                                                                                                      =
+//======================================================================================================================
+template<typename Type>
+size_t Vec<Type>::getSizeInBytes() const
+{
+	return vector<Type>::size() * sizeof(Type);
+}
+
+#endif

Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio