1
0
forked from 0ad/0ad

Build: generate Atlas project files (with "update-workspaces --atlas") (for VS2003 only).

Premake: allow slight separation of files' locations on disk vs in the
project tree.
Atlas: require fewer include directories.

This was SVN commit r2956.
This commit is contained in:
Ykkrosh 2005-10-17 01:11:12 +00:00
parent 953d2621dd
commit f2b662d12d
40 changed files with 329 additions and 57 deletions

View File

@ -10,6 +10,12 @@ function sourcesfromdirs(root, dirs)
return res
end
function trimrootdir(root, dirs)
for i=1, getn(dirs) do
dirs[i] = strsub(dirs[i], strlen(root))
end
end
function tconcat(table, values)
for i=1, getn(values) do
tinsert(table, values[i])

Binary file not shown.

View File

@ -1,3 +1,6 @@
addoption("atlas", "Include Atlas scenario editor packages")
addoption("sced", "Include ScEd package")
dofile("../functions.lua")
-- Set up the Project
@ -11,7 +14,9 @@ if (OS == "windows") then
project.nasmpath = "../../../build/bin/nasm"
end
function setuppackage (projectname)
---------------- Main game package (pyrogenesis/sced) ----------------
function setuppackage_engine (projectname)
-- Start the package part
package = newpackage()
@ -20,7 +25,6 @@ function setuppackage (projectname)
package.name = "sced"
exename = "sced"
objdirprefix = "obj/ScEd_"
package.build = 0 -- Don't build Sced by default
else
package.name = "pyrogenesis"
exename = "ps"
@ -254,7 +258,244 @@ function setuppackage (projectname)
end
end
setuppackage("pyrogenesis")
if (OS == "windows") then
setuppackage("sced")
---------------- Main Atlas package ----------------
function setuppackage_atlas(package_name, target_type, source_dirs, include_dirs, flags)
package = newpackage()
package.name = package_name
objdirprefix = "obj/"..package_name.."_"
package.kind = target_type
package.language = "c++"
-- Package target for debug and release build
package.config["Debug"].target = package_name.."_d"
package.config["Release"].target = package_name
package.config["Debug"].objdir = objdirprefix.."Debug"
package.config["Release"].objdir = objdirprefix.."Release"
sourceroot = "../../../source/tools/atlas/"
librariesroot = "../../../libraries/"
sources = sourcesfromdirs(sourceroot, source_dirs)
if (flags["extrasource"]) then
foreach(flags["extrasource"], function (i,v)
tinsert(sources, sourceroot..v)
end)
end
-- We don't want three pointless levels of directories in each project,
-- so remove the sourceroot directory from the filenames (where those
-- names are used by Premake to construct the project tree), but set
-- 'filesprefix' (with Premake altered to recognise that) so the project
-- will still point to the correct filenames.
trimrootdir(sourceroot, sources)
package.filesprefix = sourceroot
package.files = sources
package.includepaths = {}
foreach(include_dirs, function (i,v)
tinsert(package.includepaths, sourceroot .. v)
end)
package.libpaths = {}
if (OS == "windows") then
package.buildflags = { "no-rtti" }
else
package.buildflags = { }
end
-- PremakeWiki says with-symbols and optimize are automatically set for
-- Debug and Release builds, respectively. doesn't happen though, so do it manually.
package.config["Debug"].buildflags = { "with-symbols", "no-edit-and-continue" }
package.config["Release"].buildflags = { "with-symbols", "no-runtime-checks", "no-edit-and-continue", "optimize" }
package.config["Release"].defines = { "NDEBUG" }
-- Platform Specifics
if (OS == "windows") then
tinsert(package.defines, "_UNICODE")
-- Directories under 'libraries', each containing 'lib' and 'include':
external_libraries = {}
if (flags["boost"]) then tinsert(external_libraries, "boost") end
if (flags["devil"]) then tinsert(external_libraries, "devil/src") end
if (flags["xerces"]) then tinsert(external_libraries, "xerces") end
if (flags["zlib"]) then tinsert(external_libraries, "zlib") end
external_libraries.n = nil; -- remove the array size, else it'll be interpreted as a directory
-- Add '<libraries root>/<libraryname>/lib' and '/include' to the includepaths and libpaths
foreach(external_libraries, function (i,v)
tinsert(package.includepaths, librariesroot..v.."/include")
tinsert(package.libpaths, librariesroot..v.."/lib")
end)
-- Handle wx specially
if (flags["wx"]) then
tinsert(package.includepaths, librariesroot.."wxwidgets/include/msvc")
tinsert(package.includepaths, librariesroot.."wxwidgets/include")
tinsert(package.libpaths, librariesroot.."wxwidgets/lib/vc_lib")
end
-- Link to required libraries
package.links = { "winmm", "comctl32", "rpcrt4" }
package.config["Debug"].links = { "wxmsw26ud_gl" }
package.config["Release"].links = { "wxmsw26u_gl" }
if (flags["depends"]) then
tconcat(package.links, flags["depends"])
end
-- required to use WinMain() on Windows, otherwise will default to main()
tinsert(package.buildflags, { "no-main" })
if (flags["pch"]) then
package.pchHeader = "stdafx.h"
package.pchSource = "stdafx.cpp"
end
else -- Non-Windows, = Unix
-- TODO
end
end
---------------- Atlas 'frontend' tool-launching packages ----------------
function setuppackage_atlas_frontend (package_name)
package = newpackage()
package.name = package_name
objdirprefix = "obj/Frontend/"..package_name.."_"
package.kind = "winexe"
package.language = "c++"
-- Package target for debug and release build
package.config["Debug"].target = package_name.."_d"
package.config["Release"].target = package_name
package.config["Debug"].objdir = objdirprefix.."Debug"
package.config["Release"].objdir = objdirprefix.."Release"
sourceroot = "../../../source/tools/atlas/AtlasFrontends/"
package.filesprefix = sourceroot
package.files = {
package_name..".cpp",
package_name..".rc"
}
package.includepaths = { sourceroot..".." }
package.config["Debug"].buildflags = { "with-symbols", "no-edit-and-continue" }
package.config["Release"].buildflags = { "with-symbols", "no-runtime-checks", "no-edit-and-continue", "optimize" }
package.config["Release"].defines = { "NDEBUG" }
-- Platform Specifics
if (OS == "windows") then
tinsert(package.defines, "_UNICODE")
tinsert(package.links, "AtlasUI")
-- required to use WinMain() on Windows, otherwise will default to main()
tinsert(package.buildflags, { "no-main" })
else -- Non-Windows, = Unix
-- TODO
end
package.config["Testing"] = package.config["Debug"]
end
---------------- Atlas packages ----------------
function setuppackages_atlas()
setuppackage_atlas("AtlasObject", "lib", {
-- src
"AtlasObject"
},{
-- include
},{
xerces = 1
})
setuppackage_atlas("AtlasUI", "dll", {
-- src
"AtlasUI/ActorEditor",
"AtlasUI/ArchiveViewer",
"AtlasUI/ColourTester",
"AtlasUI/CustomControls/Buttons",
"AtlasUI/CustomControls/DraggableListCtrl",
"AtlasUI/CustomControls/EditableListCtrl",
"AtlasUI/CustomControls/FileHistory",
"AtlasUI/CustomControls/HighResTimer",
"AtlasUI/CustomControls/SnapSplitterWindow",
"AtlasUI/CustomControls/VirtualDirTreeCtrl",
"AtlasUI/CustomControls/Windows",
"AtlasUI/FileConverter",
"AtlasUI/General",
"AtlasUI/Misc",
"AtlasUI/ScenarioEditor",
"AtlasUI/ScenarioEditor/Sections/Common",
"AtlasUI/ScenarioEditor/Sections/Map",
"AtlasUI/ScenarioEditor/Sections/Terrain",
"AtlasUI/ScenarioEditor/Tools",
"AtlasUI/ScenarioEditor/Tools/Common"
},{
-- include
"",
"AtlasUI",
"AtlasUI/CustomControls"
},{
pch = 1,
boost = 1,
devil = 1,
wx = 1,
xerces = 1,
depends = { "AtlasObject", "DatafileIO" },
extrasource = { "AtlasUI/Misc/icons.rc" }
})
setuppackage_atlas("DatafileIO", "lib", {
-- src
"DatafileIO",
"DatafileIO/BAR",
"DatafileIO/DDT",
"DatafileIO/SCN",
"DatafileIO/Stream",
"DatafileIO/XMB"
},{
-- include
"DatafileIO"
},{
pch = 1,
devil = 1,
xerces = 1,
zlib = 1
})
setuppackage_atlas_frontend("ActorEditor")
setuppackage_atlas_frontend("ArchiveViewer")
setuppackage_atlas_frontend("ColourTester")
setuppackage_atlas_frontend("FileConverter")
end
--------------------------------
setuppackage_engine("pyrogenesis")
if (options["sced"]) then
setuppackage_engine("sced")
end
if (options["atlas"]) then
setuppackages_atlas()
end

View File

@ -201,7 +201,7 @@ static const char* checkCppFlags(const char* flag, void* data)
return NULL;
}
static void writeSourcePaths(FILE* file, const char* path, int stage)
static void writeSourcePaths(FILE* file, const char* path, const char* prefix, int stage)
{
if (stage == WST_OPENGROUP && strlen(path) > 0)
fprintf(file, " %s", path);

View File

@ -321,6 +321,8 @@ static int finishProject()
for (j = 0; j < package->numFiles; ++j)
package->files[j] = getStringFromArray(files, j);
package->filesprefix = getString(pkg, "filesprefix");
package->name = getString(pkg, "name");
package->script = getString(pkg, "script");
package->path = getString(pkg, "path");

View File

@ -46,6 +46,7 @@ typedef struct _Package
const char* url;
const char** files;
int numFiles;
const char* filesprefix;
Config** config;
int numConfigs;
void* data;

View File

@ -449,14 +449,14 @@ const char* translatePath(const char* path, int type)
//-----------------------------------------------------------------------------
void walkSourceList(FILE* file, Package* package, const char* path, void (*cb)(FILE*, const char*, int))
void walkSourceList(FILE* file, Package* package, const char* path, void (*cb)(FILE*, const char*, const char*, int))
{
const char** i;
// Open the group
strcpy(buffer, path);
if (buffer[strlen(buffer)-1] == '/') buffer[strlen(buffer)-1] = '\0';
cb(file, buffer, WST_OPENGROUP);
cb(file, buffer, package->filesprefix, WST_OPENGROUP);
for (i = package->files; *i; ++i)
{
@ -496,13 +496,13 @@ void walkSourceList(FILE* file, Package* package, const char* path, void (*cb)(F
const char* source = (*i);
const char* ptr = strrchr(source, '/');
if (strncmp(path, source, strlen(path)) == 0 && ptr <= source + strlen(path))
cb(file, source, WST_SOURCEFILE);
cb(file, source, package->filesprefix, WST_SOURCEFILE);
}
// Close the group
strcpy(buffer, path);
if (buffer[strlen(buffer)-1] == '/') buffer[strlen(buffer)-1] = '\0';
cb(file, buffer, WST_CLOSEGROUP);
cb(file, buffer, package->filesprefix, WST_CLOSEGROUP);
}
//-----------------------------------------------------------------------------

View File

@ -39,7 +39,7 @@ extern const char* replaceChars(const char* str, const char* replace);
extern const char* replaceExtension(const char* path, const char* extension);
extern const char* reversePath(const char* path, const char* subdir, int type);
extern const char* translatePath(const char* buffer, int type);
extern void walkSourceList(FILE* file, Package* package, const char* path, void (*cb)(FILE*, const char*, int));
extern void walkSourceList(FILE* file, Package* package, const char* path, void (*cb)(FILE*, const char*, const char*, int));
extern void writeList(FILE* file, const char** list, const char* prefix, const char* postfix, const char* infix, const char* (*check)(const char*,void*), void* data);
extern const char* getCwd();
extern int setCwd(const char* path);

View File

@ -155,7 +155,7 @@ static int writeWorkspace()
//-----------------------------------------------------------------------------
static void vcFiles(FILE* file, const char* path, int stage)
static void vcFiles(FILE* file, const char* path, const char* prefix, int stage)
{
const char* ptr = strrchr(path, '/');
int i,j;

View File

@ -238,8 +238,9 @@ static const char* checkLibs(const char* file, void* data)
return package->config[*((int*)data)]->target;
}
static void vcFiles(FILE* file, const char* path, int stage)
static void vcFiles(FILE* file, const char* path, const char* prefix, int stage)
{
static char fullpath[4096];
char indent[128];
char* ptr;
int i=0, j=0;
@ -273,7 +274,9 @@ static void vcFiles(FILE* file, const char* path, int stage)
case WST_SOURCEFILE:
fprintf(file, "%s<File\n", indent);
fprintf(file, "%s RelativePath=\"%s\">\n", indent, translatePath(path, WIN32));
strcpy(fullpath, prefix?translatePath(prefix, WIN32):"");
strcat(fullpath, translatePath(path, WIN32));
fprintf(file, "%s RelativePath=\"%s\">\n", indent, fullpath);
for (i=0;i<project->numPackages;i++)
{
Package *package=project->package[i];

View File

@ -18,15 +18,15 @@ cd tmp
REM Just copy *.sln/etc indiscriminately, because it might include both pyrogenesis.sln and sced.sln (or might not)
..\premake --target vs6
..\premake --target vs6 %*
move *.dsw ..\..\workspaces\vc6
move *.dsp ..\..\workspaces\vc6
..\premake --target vs7
..\premake --target vs7 %*
move *.sln ..\..\workspaces\vc7
move *.vcproj ..\..\workspaces\vc7
..\premake --target vs2003
..\premake --target vs2003 %*
move *.sln ..\..\workspaces\vc2003
move *.vcproj ..\..\workspaces\vc2003

View File

@ -5,7 +5,7 @@
#include "ActorEditorListCtrl.h"
#include "AtlasObject/AtlasObject.h"
#include "AtlasObject/AtlasObjectText.h"
#include "Datafile.h"
#include "General/Datafile.h"
#include "wx/ffile.h"

View File

@ -1,4 +1,4 @@
#include "AtlasWindow.h"
#include "Windows/AtlasWindow.h"
class ActorEditorListCtrl;

View File

@ -3,7 +3,7 @@
#include "ActorEditorListCtrl.h"
#include "AtlasObject/AtlasObject.h"
#include "FieldEditCtrl.h"
#include "EditableListCtrl/FieldEditCtrl.h"
ActorEditorListCtrl::ActorEditorListCtrl(wxWindow* parent)
: DraggableListCtrl(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize,

View File

@ -1,4 +1,4 @@
#include "DraggableListCtrl.h"
#include "DraggableListCtrl/DraggableListCtrl.h"
class ActorEditor;

View File

@ -2,7 +2,7 @@
#include "AnimListEditor.h"
#include "FieldEditCtrl.h"
#include "EditableListCtrl/FieldEditCtrl.h"
#include "AtlasObject/AtlasObject.h"
//////////////////////////////////////////////////////////////////////////

View File

@ -1,6 +1,6 @@
#include "AtlasDialog.h"
#include "Windows/AtlasDialog.h"
#include "DraggableListCtrl.h"
#include "DraggableListCtrl/DraggableListCtrl.h"
class AnimListEditorListCtrl;

View File

@ -2,7 +2,7 @@
#include "PropListEditor.h"
#include "FieldEditCtrl.h"
#include "EditableListCtrl/FieldEditCtrl.h"
#include "AtlasObject/AtlasObject.h"
//////////////////////////////////////////////////////////////////////////

View File

@ -1,6 +1,6 @@
#include "AtlasDialog.h"
#include "Windows/AtlasDialog.h"
#include "DraggableListCtrl.h"
#include "DraggableListCtrl/DraggableListCtrl.h"
class PropListEditorListCtrl;

View File

@ -2,7 +2,7 @@
#include "ArchiveViewer.h"
#include "Version.h"
#include "Misc/Version.h"
#include <algorithm>

View File

@ -3,7 +3,7 @@
#include "ColourTesterColourCtrl.h"
#include "ColourTesterImageCtrl.h"
#include "Datafile.h"
#include "General/Datafile.h"
#include <sstream>

View File

@ -2,7 +2,7 @@
#include "ColourTesterFileCtrl.h"
#include "Datafile.h"
#include "General/Datafile.h"
#include "ColourTesterImageCtrl.h"
BEGIN_EVENT_TABLE(ColourTesterFileCtrl, wxVirtualDirTreeCtrl)

View File

@ -2,7 +2,7 @@
#include "DraggableListCtrl.h"
#include "AtlasWindowCommandProc.h"
#include "General/AtlasWindowCommandProc.h"
#include "DraggableListCtrlCommands.h"
const int ScrollSpeed = 8; // when dragging off the top or bottom of the control

View File

@ -5,7 +5,7 @@
Use just like a normal listctrl.
*/
#include "EditableListCtrl.h"
#include "EditableListCtrl/EditableListCtrl.h"
class DragCommand;

View File

@ -3,7 +3,7 @@
#include "DraggableListCtrlCommands.h"
#include "DraggableListCtrl.h"
#include "EditableListCtrl.h"
#include "EditableListCtrl/EditableListCtrl.h"
//////////////////////////////////////////////////////////////////////////

View File

@ -1,4 +1,4 @@
#include "AtlasWindowCommand.h"
#include "General/AtlasWindowCommand.h"
#include "AtlasObject/AtlasObject.h"

View File

@ -2,12 +2,12 @@
#include "EditableListCtrl.h"
#include "AtlasWindowCommandProc.h"
#include "EditableListCtrlCommands.h"
#include "FieldEditCtrl.h"
#include "General/AtlasWindowCommandProc.h"
#include "AtlasObject/AtlasObject.h"
#include "AtlasObject/AtlasObjectText.h"
#include "AtlasClipboard.h"
#include "General/AtlasClipboard.h"
const int BlanksAtEnd = 2;

View File

@ -3,7 +3,7 @@
#include "wx/listctrl.h"
#include "IAtlasSerialiser.h"
#include "General/IAtlasSerialiser.h"
#include <vector>

View File

@ -1,4 +1,4 @@
#include "AtlasWindowCommand.h"
#include "General/AtlasWindowCommand.h"
#include "AtlasObject/AtlasObject.h"

View File

@ -9,11 +9,11 @@
#include "QuickComboBox.h"
#include "QuickFileCtrl.h"
#include "AtlasDialog.h"
#include "EditableListCtrl.h"
#include "Windows/AtlasDialog.h"
#include "EditableListCtrl/EditableListCtrl.h"
#include "AtlasObject/AtlasObject.h"
#include "AtlasObject/AtlasObjectText.h"
#include "Datafile.h"
#include "General/Datafile.h"
#include "wx/colour.h"
#include "wx/colordlg.h"

View File

@ -2,9 +2,9 @@
#include "ListCtrlValidator.h"
#include "AtlasWindowCommandProc.h"
#include "EditableListCtrl.h"
#include "EditableListCtrlCommands.h"
#include "General/AtlasWindowCommandProc.h"
#include "EditableListCtrl/EditableListCtrl.h"
#include "EditableListCtrl/EditableListCtrlCommands.h"
#include "AtlasObject/AtlasObject.h"
#include "AtlasObject/AtlasObjectText.h"

View File

@ -1,7 +1,7 @@
#include "wx/dialog.h"
#include "AtlasWindowCommandProc.h"
#include "IAtlasSerialiser.h"
#include "General/AtlasWindowCommandProc.h"
#include "General/IAtlasSerialiser.h"
class FieldEditCtrl_Dialog;

View File

@ -3,7 +3,7 @@
#include "AtlasWindow.h"
#include "AtlasObject/AtlasObject.h"
#include "AtlasWindowCommand.h"
#include "General/AtlasWindowCommand.h"
#include "wx/artprov.h"
#include "wx/config.h"

View File

@ -1,9 +1,9 @@
#ifndef ATLASWINDOW_H__
#define ATLASWINDOW_H__
#include "AtlasWindowCommandProc.h"
#include "General/AtlasWindowCommandProc.h"
#include "IAtlasSerialiser.h"
#include "General/IAtlasSerialiser.h"
#include "CustomControls/FileHistory/FileHistory.h"
#include "wx/filename.h"

View File

@ -2,7 +2,7 @@
#include "FileConverter.h"
#include "Version.h"
#include "Misc/Version.h"
#include "AtlasObject/AtlasObject.h"
#include "DatafileIO/XMB/XMB.h"

View File

@ -2,9 +2,9 @@
#include "AtlasWindowCommandProc.h"
#include "AtlasWindow.h"
#include "AtlasWindowCommand.h"
#include "AtlasDialog.h"
#include "Windows/AtlasWindow.h"
#include "Windows/AtlasDialog.h"
AtlasWindowCommandProc* AtlasWindowCommandProc::GetFromParentFrame(wxWindow* object)
{

View File

@ -2,7 +2,7 @@
#include "DLLInterface.h"
#include "Datafile.h"
#include "General/Datafile.h"
#include "ActorEditor/ActorEditor.h"
#include "ColourTester/ColourTester.h"
#include "ScenarioEditor/ScenarioEditor.h"

View File

@ -2,8 +2,8 @@
#include "Map.h"
#include "ActionButton.h"
#include "Datafile.h"
#include "Buttons/ActionButton.h"
#include "General/Datafile.h"
#include "GameInterface/Messages.h"
@ -38,7 +38,12 @@ static void GenerateRMS(void* data)
wxChar* argv[] = { _T("rmgen.exe"), 0, _T("_atlasrm"), 0 };
wxString scriptName = ((wxTextCtrl*)data)->GetValue();
argv[1] = const_cast<wxChar*>(scriptName.c_str());
wxString cwd = wxFileName::GetCwd();
wxFileName::SetCwd(Datafile::GetDataDirectory());
wxExecute(argv, wxEXEC_SYNC);
wxFileName::SetCwd(cwd);
POST_COMMAND(LoadMap(L"_atlasrm.pmp"));
}

View File

@ -2,8 +2,8 @@
#include "Terrain.h"
#include "ActionButton.h"
#include "Datafile.h"
#include "Buttons/ActionButton.h"
#include "General/Datafile.h"
#include "ScenarioEditor/Tools/Common/Brushes.h"
#include "GameInterface/Messages.h"

View File

@ -0,0 +1,14 @@
#include "precompiled.h"
#include "MessageHandler.h"
#include "../MessagePasserImpl.h"
namespace AtlasMessage {
MESSAGEHANDLER(MessageTrace)
{
((MessagePasserImpl<mCommand>*)g_MessagePasser_Command)->SetTrace(msg->enable);
((MessagePasserImpl<mInput>*)g_MessagePasser_Input)->SetTrace(msg->enable);
}
}