1
0
forked from 0ad/0ad

# complete revamp of build system in preparation for automated self tests.

* now splits everything up into independent static libraries.
* fixed a great deal of incorrect #include statements. all headers must
now be specified with their full path relative to source. exception: if
file being included and including file are in the same directory, no
path needed.
use <> when relying on the build system's include path (e.g. for system
headers and external libraries, e.g. boost), otherwise "".

* temporarily renamed maths/Vector2D to Vector2D_Maths to avoid
conflict. these should be merged.
* hacked around VC linker stupidness when building static libs; texture
codecs must now be registered manually.

This was SVN commit r3931.
This commit is contained in:
janwas 2006-06-02 03:56:24 +00:00
parent 5f7855f7f0
commit 5814e10126
44 changed files with 108 additions and 78 deletions

View File

@ -28,6 +28,8 @@ gee@pyro.nu
// seem to be defined anywhere in the predefined header.
#include "ps/Overlay.h"
#include "ps/Pyrogenesis.h" // deprecated DECLARE_ERROR
//--------------------------------------------------------
// Forward declarations
//--------------------------------------------------------

View File

@ -55,13 +55,10 @@
// headers made available everywhere for convenience
//
// note: must not include
#include "lib/types.h"
#include "lib/string_s.h" // CRT secure string
#include "lib/self_test.h"
#include "lib/debug.h"
#include "ps/Pyrogenesis.h" // MICROLOG and old error system
#include <assert.h> // assert()
//
// memory headers

View File

@ -436,7 +436,7 @@ uintptr_t comp_alloc(ContextType type, CompressionMethod method)
#ifndef NO_ZLIB
case CM_DEFLATE:
cassert(sizeof(ZLibCompressor) <= MAX_COMPRESSOR_SIZE);
#include "nommgr.h" // protect placement new
#include "lib/nommgr.h" // protect placement new
c = new(c_mem) ZLibCompressor(type);
#include "lib/mmgr.h"
break;

View File

@ -349,7 +349,7 @@ success:
}
// rationale: don't call this "free" because that would run afoul of the
// memory tracker's redirection macro and require #include "nommgr.h".
// memory tracker's redirection macro and require #include "lib/nommgr.h".
void dealloc(u8* p, size_t size)
{
#ifndef NDEBUG

View File

@ -85,7 +85,7 @@ public:
return (aiocb*)pool_alloc(&pool, 0);
}
// weird name to avoid trouble with mem tracker macros
// (renaming is less annoying than #include "nommgr.h")
// (renaming is less annoying than #include "lib/nommgr.h")
void free_(void* cb)
{
pool_free(&pool, cb);

View File

@ -23,7 +23,7 @@
#include "precompiled.h"
#include "file_internal.h"
#include "byte_order.h" // FOURCC
#include "lib/byte_order.h" // FOURCC
static const u32 vtbl_magic = FOURCC('F','P','V','T');

View File

@ -473,7 +473,7 @@ static void tree_root_init()
// must not be called more than once without intervening tree_shutdown.
debug_assert(!tree_root);
#include "nommgr.h" // placement new
#include "lib/nommgr.h" // placement new
void* mem = node_alloc();
if(mem)
tree_root = new(mem) TDir("", "", 0);

View File

@ -35,7 +35,7 @@
#endif
#include "lib/ogl.h"
#include "sysdep/sysdep.h" // sys_cursor_*
#include "lib/sysdep/sysdep.h" // sys_cursor_*
#include "lib/res/res.h"
#include "ogl_tex.h"
#include "cursor.h"

View File

@ -220,6 +220,17 @@ extern void tex_set_global_orientation(int orientation);
// open/close
//
/**
* manually register codecs. must be called before first use of a
* codec (e.g. loading a texture).
*
* this would normally be taken care of by TEX_CODEC_REGISTER, but
* no longer works when building as a static library.
* workaround: hard-code a list of codecs in tex_codec.cpp and
* call their registration functions.
**/
extern void tex_codec_register_all();
/**
* load the specified image from file into a Tex object.
*

View File

@ -123,6 +123,17 @@ LibError tex_codec_transform(Tex* t, uint transforms)
// helper functions used by codecs
//-----------------------------------------------------------------------------
void tex_codec_register_all()
{
#define REGISTER_CODEC(name) extern void name##_register(); name##_register()
REGISTER_CODEC(bmp);
REGISTER_CODEC(dds);
REGISTER_CODEC(jpg);
REGISTER_CODEC(png);
REGISTER_CODEC(tga);
#undef REGISTER_CODEC
}
// allocate an array of row pointers that point into the given texture data.
// <file_orientation> indicates whether the file format is top-down or
// bottom-up; the row array is inverted if necessary to match global

View File

@ -140,7 +140,12 @@ struct TexCodecVTbl
name##_is_hdr, name##_is_ext, name##_hdr_size,\
#name\
};\
static int dummy = tex_codec_register(&vtbl);
/*static int dummy = tex_codec_register(&vtbl);*/\
/* note: when building as a static library, pre-main initializers */\
/* will not run! as a workaround, we build an externally visible */\
/* registration function that must be called via */\
/* tex_codec_register_all - see comments there. */\
void name##_register() { tex_codec_register(&vtbl); }
/**

View File

@ -25,7 +25,7 @@
#include "lib/lib.h"
#if CPU_IA32
# include "sysdep/ia32.h"
# include "lib/sysdep/ia32.h"
#endif
char cpu_type[CPU_TYPE_LEN] = "";

View File

@ -31,7 +31,7 @@
#include "lib/posix.h"
#include "lib/sysdep/cpu.h"
#include "wdbg.h"
#include "byte_order.h" // FOURCC
#include "lib/byte_order.h" // FOURCC
#include "lib/app_hooks.h"

View File

@ -34,7 +34,7 @@
#include "lib/sdl.h"
#include "lib/lib.h"
#include "lib/posix.h"
#include "ogl.h" // needed to pull in the delay-loaded opengl32.dll
#include "lib/ogl.h" // needed to pull in the delay-loaded opengl32.dll
#include "SDL_vkeys.h"

View File

@ -9,7 +9,9 @@ that of Atlas depending on commandline parameters.
*/
#include "precompiled.h"
// not for any PCH effort, but instead for the (common) definitions
// included there.
#include "lib/precompiled.h"
#include "lib/input.h"
#include "lib/sdl.h"

View File

@ -25,14 +25,14 @@ namespace
Noise2D::Noise2D(int f)
{
freq = f;
grads = new CVector2D*[freq];
grads = new CVector2D_Maths*[freq];
for(int i=0; i<freq; i++)
{
grads[i] = new CVector2D[freq];
grads[i] = new CVector2D_Maths[freq];
for(int j=0; j<freq; j++)
{
float a = randFloat() * 2 * M_PI;
grads[i][j] = CVector2D(cos(a), sin(a));
grads[i][j] = CVector2D_Maths(cos(a), sin(a));
}
}
}
@ -63,10 +63,10 @@ float Noise2D::operator()(float x, float y)
int ix1 = (ix+1) % freq;
int iy1 = (iy+1) % freq;
float s = grads[ix][iy].Dot(CVector2D(fx, fy));
float t = grads[ix1][iy].Dot(CVector2D(fx-1, fy));
float u = grads[ix][iy1].Dot(CVector2D(fx, fy-1));
float v = grads[ix1][iy1].Dot(CVector2D(fx-1, fy-1));
float s = grads[ix][iy].Dot(CVector2D_Maths(fx, fy));
float t = grads[ix1][iy].Dot(CVector2D_Maths(fx-1, fy));
float u = grads[ix][iy1].Dot(CVector2D_Maths(fx, fy-1));
float v = grads[ix1][iy1].Dot(CVector2D_Maths(fx-1, fy-1));
float ex = easeCurve(fx);
float ey = easeCurve(fy);

View File

@ -18,13 +18,13 @@
#include "Vector3D.h"
#include "MathUtil.h"
class Noise2D
class Noise2D
{
/// Frequency in X and Y
int freq;
/// freq*freq random gradient vectors in the unit cube
CVector2D** grads;
CVector2D_Maths** grads;
public:
Noise2D(int freq);
~Noise2D();

View File

@ -1,6 +1,6 @@
//***********************************************************
//
// Name: CVector2D.h
// Name: Vector2D.h
// Author: Matei Zaharia
//
// Description: Provides an interface for a vector in R4 and
@ -15,13 +15,13 @@
#include <math.h>
///////////////////////////////////////////////////////////////////////////////
// CVector2D:
class CVector2D
// CVector2D_Maths:
class CVector2D_Maths
{
public:
CVector2D() {}
CVector2D(float x,float y) { X=x; Y=y; }
CVector2D(const CVector2D& p) { X=p.X; Y=p.Y; }
CVector2D_Maths() {}
CVector2D_Maths(float x,float y) { X=x; Y=y; }
CVector2D_Maths(const CVector2D_Maths& p) { X=p.X; Y=p.Y; }
operator float*() {
return &X;
@ -31,49 +31,49 @@ public:
return &X;
}
CVector2D operator-() const {
return CVector2D(-X, -Y);
CVector2D_Maths operator-() const {
return CVector2D_Maths(-X, -Y);
}
CVector2D operator+(const CVector2D& t) const {
return CVector2D(X+t.X, Y+t.Y);
CVector2D_Maths operator+(const CVector2D_Maths& t) const {
return CVector2D_Maths(X+t.X, Y+t.Y);
}
CVector2D operator-(const CVector2D& t) const {
return CVector2D(X-t.X, Y-t.Y);
CVector2D_Maths operator-(const CVector2D_Maths& t) const {
return CVector2D_Maths(X-t.X, Y-t.Y);
}
CVector2D operator*(float f) const {
return CVector2D(X*f, Y*f);
CVector2D_Maths operator*(float f) const {
return CVector2D_Maths(X*f, Y*f);
}
CVector2D operator/(float f) const {
CVector2D_Maths operator/(float f) const {
float inv=1.0f/f;
return CVector2D(X*inv, Y*inv);
return CVector2D_Maths(X*inv, Y*inv);
}
CVector2D& operator+=(const CVector2D& t) {
CVector2D_Maths& operator+=(const CVector2D_Maths& t) {
X+=t.X; Y+=t.Y;
return *this;
}
CVector2D& operator-=(const CVector2D& t) {
CVector2D_Maths& operator-=(const CVector2D_Maths& t) {
X-=t.X; Y-=t.Y;
return *this;
}
CVector2D& operator*=(float f) {
CVector2D_Maths& operator*=(float f) {
X*=f; Y*=f;
return *this;
}
CVector2D& operator/=(float f) {
CVector2D_Maths& operator/=(float f) {
float invf=1.0f/f;
X*=invf; Y*=invf;
return *this;
}
float Dot(const CVector2D& a) const {
float Dot(const CVector2D_Maths& a) const {
return X*a.X + Y*a.Y;
}

View File

@ -81,8 +81,6 @@
#include "ps/Network/Server.h"
#include "ps/Network/Client.h"
#include "GameSetup/Config.h"
#include "Atlas.h"
#include "GameSetup.h"
#include "Config.h"
@ -957,6 +955,8 @@ void Init(int argc, char* argv[], uint flags)
SDL_WM_SetCaption("0 A.D.", "0 A.D.");
}
tex_codec_register_all();
uint quality = SANE_TEX_QUALITY_DEFAULT; // TODO: set value from config file
SetTextureQuality(quality);

View File

@ -5,8 +5,8 @@
#include "scripting/DOMEvent.h"
#include "scripting/JSConversions.h"
#include "scripting/ScriptableObject.h"
#include "Network/Client.h"
#include "Network/JSEvents.h"
#include "Client.h"
#include "JSEvents.h"
#include "ps/CStr.h"
#include "ps/CLogger.h"
#include "ps/CConsole.h"

View File

@ -1,8 +1,8 @@
#ifndef _Network_NetClient_H
#define _Network_NetClient_H
#include <CStr.h>
#include <Network/Session.h>
#include "ps/CStr.h"
#include "Session.h"
#include "simulation/TurnManager.h"
#include "simulation/ScriptObject.h"

View File

@ -1,7 +1,7 @@
#ifndef _Network_JSEvents_H
#define _Network_JSEvents_H
#include "Network/ServerSession.h"
#include "ServerSession.h"
enum ENetworkJSEvents
{

View File

@ -6,7 +6,7 @@
#include <map>
#include "simulation/Entity.h"
#include "Vector2D.h"
#include "ps/Vector2D.h"
#define ALLNETMSGS_IMPLEMENT
#include "NetMessage.h"

View File

@ -3,7 +3,7 @@
#include "lib/types.h"
#include "Serialization.h"
#include "Network/SocketBase.h"
#include "SocketBase.h"
// We need the enum from AllNetMessages.h, but we can't create any classes in
// AllNetMessages, since they in turn require CNetMessage to be defined

View File

@ -4,7 +4,7 @@
#include "Serialization.h"
#include <errno.h>
#include <CLogger.h>
#include "ps/CLogger.h"
#include "NetLog.h"
DEFINE_ERROR(CONFLICTING_OP_IN_PROGRESS, "A conflicting operation is already in progress");

View File

@ -2,10 +2,10 @@
#include <algorithm>
#include "Network/Server.h"
#include "Network/ServerSession.h"
#include "Network/Network.h"
#include "Network/JSEvents.h"
#include "Server.h"
#include "ServerSession.h"
#include "Network.h"
#include "JSEvents.h"
#include "scripting/ScriptableObject.h"

View File

@ -1,7 +1,7 @@
#ifndef _Network_NetServer_H
#define _Network_NetServer_H
#include "Network/Session.h"
#include "Session.h"
#include "ps/GameAttributes.h"
#include "simulation/TurnManager.h"
#include "ps/scripting/JSMap.h"

View File

@ -1,7 +1,7 @@
#include "precompiled.h"
#include "Network/ServerSession.h"
#include "Network/Server.h"
#include "ServerSession.h"
#include "Server.h"
#include "ps/CLogger.h"
#include "ps/CConsole.h"

View File

@ -10,7 +10,7 @@
#ifndef _Network_ServerSession_H
#define _Network_ServerSession_H
#include "Network/Session.h"
#include "Session.h"
#include "scripting/ScriptableObject.h"
class CNetServer;

View File

@ -1,6 +1,6 @@
#include "precompiled.h"
#include <Network/Session.h>
#include "Session.h"
CNetSession::~CNetSession()
{

View File

@ -1,8 +1,8 @@
#ifndef _Network_NetSession_H
#define _Network_NetSession_H
#include <Network/Network.h>
#include <Network/SessionManager.h>
#include "Network.h"
#include "SessionManager.h"
/*
CNetSession

View File

@ -1,8 +1,8 @@
#include "precompiled.h"
#include <Network/Session.h>
#include <Network/Network.h>
#include <CLogger.h>
#include "Session.h"
#include "Network.h"
#include "ps/CLogger.h"
using namespace std;

View File

@ -4,7 +4,7 @@
#include "precompiled.h"
#include "JSInterface_Selection.h"
#include "scripting/JSCollection.h"
#include "ps/scripting/JSCollection.h"
#include "ps/Interact.h"
JSBool JSI_Selection::getSelection( JSContext* UNUSED(cx), JSObject* UNUSED(obj),

View File

@ -8,7 +8,7 @@
#include "lib/res/file/vfs_optimizer.h" // ArchiveBuilderCancel
#include "scripting/ScriptingHost.h"
#include "scripting/JSConversions.h"
#include "scripting/JSInterface_VFS.h"
#include "ps/scripting/JSInterface_VFS.h"
// shared error handling code
#define JS_CHECK_FILE_ERR(err)\

View File

@ -25,6 +25,7 @@
#include "graphics/Texture.h"
#include "graphics/LightEnv.h"
#include "graphics/Terrain.h"
#include "ps/Pyrogenesis.h" // MICROLOG
#include "ps/CLogger.h"
#include "ps/Game.h"
#include "ps/Profile.h"

View File

@ -21,6 +21,7 @@
#include "ps/Game.h"
#include "ps/Profile.h"
#include "ps/Pyrogenesis.h" // MICROLOG
#include "simulation/LOSManager.h"

View File

@ -1,7 +1,7 @@
#ifndef __ASTAR_ENGINE_H__
#define __ASTAR_ENGINE_H__
#include "Vector2D.h"
#include "ps/Vector2D.h"
#include "ps/Player.h"
#include "lib/types.h"
#include <queue>

View File

@ -9,7 +9,7 @@
#include "BaseFormation.h"
#include "EntitySupport.h"
#include "Vector2D.h"
#include "ps/Vector2D.h"
class CVector2D;
class CEntity;

View File

@ -6,7 +6,7 @@
#include "BaseFormation.h"
#include "EntityFormation.h"
#include "Vector2D.h"
#include "ps/Vector2D.h"
CFormationManager::~CFormationManager()
{

View File

@ -13,7 +13,7 @@
#include "ps/Singleton.h"
#include "EntityHandles.h"
#include "Vector2D.h"
#include "ps/Vector2D.h"
#include "AStarEngine.h"
#define g_Pathfinder CPathfindEngine::GetSingleton()

View File

@ -23,7 +23,7 @@
#define PATHFIND_SPARSE_INCLUDED
#include "EntityHandles.h"
#include "Vector2D.h"
#include "ps/Vector2D.h"
#include "Collision.h"
struct sparsePathTree

View File

@ -1,7 +1,7 @@
#include "precompiled.h"
#include "JSInterface_Entity.h"
#include "scripting/JSInterface_BaseEntity.h"
#include "JSInterface_BaseEntity.h"
#include "maths/scripting/JSInterface_Vector3D.h"
#include "simulation/EntityHandles.h"
#include "simulation/Entity.h"

View File

@ -1,7 +1,7 @@
#include "precompiled.h"
#include "CMusicPlayer.h"
#include "CLogger.h"
#include "ps/CLogger.h"
#include <sstream>
#include <list>

View File

@ -9,7 +9,7 @@
# ifdef __WXWINDOWS__
# undef new
# else
# include "nommgr.h"
# include "lib/nommgr.h"
# endif
#endif