initial build system

working to compile from cygwin in Windows with SFML-1.6
This commit is contained in:
Josh Holtrop 2012-08-13 23:07:37 -04:00
parent 4c22f07923
commit 31d9ab8f10
4 changed files with 115 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
bin

6
Makefile Normal file
View File

@ -0,0 +1,6 @@
all:
@scons
clean:
@scons -c

63
SConstruct Normal file
View File

@ -0,0 +1,63 @@
# vim:filetype=python
import os
client_name = 'treacherous-terrain'
server_name = client_name + '-server'
# determine our build platform
platform = 'windows' if os.path.exists('/bin/cygwin1.dll') else 'unix'
# common environment settings
#SFML_VERSION = '2.0-rc'
SFML_VERSION = '1.6'
BIN_DIR = 'bin'
CXX = 'g++'
CPPFLAGS = []
CXXFLAGS = ['-Wall', '-O2']
LINKFLAGS = []
LIBPATH = []
LIBS_client = ['sfml-network', 'sfml-system', 'sfml-window']
LIBS_server = ['sfml-network']
libs_to_copy = []
if platform == 'windows':
# Windows-specific environment settings
CXX = 'i686-pc-mingw32-g++'
MINGW_DIR = '/usr/i686-pc-mingw32/sys-root/mingw/bin'
SFML_PATH = '/c/apps/SFML-%s' % SFML_VERSION
if 'SFML_PATH' in os.environ:
SFML_PATH = os.environ['SFML_PATH']
CPPFLAGS.append('-I%s/include' % SFML_PATH)
LIBPATH.append('%s/lib' % SFML_PATH)
LINKFLAGS.append('-static-libstdc++')
LIBS_client.append('mingw32')
LIBS_server.append('mingw32')
libs_to_copy.append('%s/libgcc_s_dw2-1.dll' % MINGW_DIR)
# our sources
sources_client = [Glob('src/common/*.cc'), Glob('src/client/*.cc')]
sources_server = [Glob('src/common/*.cc'), Glob('src/server/*.cc')]
# create the scons environments
env_client = Environment(
CXX = CXX,
CPPFLAGS = CPPFLAGS,
CXXFLAGS = CXXFLAGS,
LINKFLAGS = LINKFLAGS,
LIBPATH = LIBPATH,
LIBS = LIBS_client)
env_server = Environment(
CXX = CXX,
CPPFLAGS = CPPFLAGS,
CXXFLAGS = CXXFLAGS,
LINKFLAGS = LINKFLAGS,
LIBPATH = LIBPATH,
LIBS = LIBS_server)
for lib_path in libs_to_copy:
installed_libs = env_client.Install(BIN_DIR, lib_path)
env_client.Depends('%s/%s' % (BIN_DIR, client_name), installed_libs)
env_client.Program('%s/%s' % (BIN_DIR, client_name), sources_client)
# turn this back on when we have any server sources present
#env_server.Program('%s/%s' % (BIN_DIR, server_name), sources_server)

45
src/client/Client.cc Normal file
View File

@ -0,0 +1,45 @@
#include <getopt.h>
#include <SFML/Window.hpp>
int main(int argc, char *argv[])
{
bool fullscreen = false;
for (;;)
{
int c = getopt_long(argc, argv, "f", NULL, NULL);
if (c == -1)
break;
switch (c)
{
case 'f':
fullscreen = true;
break;
}
}
sf::VideoMode mode = fullscreen
? sf::VideoMode::GetDesktopMode()
: sf::VideoMode(800, 600, 32);
long style = fullscreen
? sf::Style::Fullscreen
: sf::Style::Resize | sf::Style::Close;
sf::Window window(mode, "Treacherous Terrain", style);
while (window.IsOpened())
{
sf::Event event;
while (window.GetEvent(event))
{
if (event.Type == sf::Event::Closed)
window.Close();
if ( (event.Type == sf::Event::KeyPressed)
&& (event.Key.Code == sf::Key::Escape) )
window.Close();
}
window.Display();
}
return 0;
}