# -*- mode: python -*-
# DOOM build script
# TTimo <ttimo@idsoftware.com> 
# http://scons.sourceforge.net

#*****************************************************************************
#                    The Dark Mod GPL Source Code
# 
# This file is part of the The Dark Mod Source Code, originally based 
# on the Doom 3 GPL Source Code as published in 2011.
# 
# The Dark Mod Source Code is free software: you can redistribute it 
# and/or modify it under the terms of the GNU General Public License as 
# published by the Free Software Foundation, either version 3 of the License, 
# or (at your option) any later version. For details, see LICENSE.TXT.
# 
# Project: The Dark Mod (http://www.thedarkmod.com/)
# 
#*****************************************************************************

import scons_utils

Import( 'GLOBALS' )
Import( GLOBALS )
Import( 'g_env_game' )

renderer_string = ' \
	AmbientOcclusionStage.cpp \
	BloomStage.cpp \
	BufferObject.cpp \
	Cinematic.cpp \
	CinematicID.cpp \
	CinematicFFMpeg.cpp \
	FrameBuffer.cpp \
	GLSLProgram.cpp \
	GLSLProgramManager.cpp \
	GuiModel.cpp \
	Image_files.cpp \
	Image_init.cpp \
	Image_load.cpp \
	Image_process.cpp \
	Image_program.cpp \
	ImmediateRendering.cpp \
	Interaction.cpp \
	Material.cpp \
	MegaTexture.cpp \
	Model.cpp \
	ModelDecal.cpp \
	ModelManager.cpp \
	ModelOverlay.cpp \
	Model_beam.cpp \
	Model_ase.cpp \
	Model_liquid.cpp \
	Model_lwo.cpp \
	Model_ma.cpp \
	Model_md3.cpp \
	Model_md5.cpp \
	Model_prt.cpp \
	Model_sprite.cpp \
	Profiling.cpp \
	RenderEntity.cpp \
	RenderSystem.cpp \
	RenderSystem_init.cpp \
	qgl.cpp \
	glad.c \
	glad_glx.c \
	RenderWorld.cpp \
	RenderWorld_demo.cpp \
	RenderWorld_load.cpp \
	RenderWorld_portals.cpp \
	VertexCache.cpp \
	cg_explicit.cpp \
	draw_arb2.cpp \
	draw_common.cpp \
	draw_exp_stub.cpp \
	draw_glsl.cpp \
	draw_glsl_multi.cpp \
	draw_stencil.cpp \
	tr_backend.cpp \
	tr_deform.cpp \
	tr_font.cpp \
	tr_guisurf.cpp \
	tr_light.cpp \
	tr_lightrun.cpp \
	tr_main.cpp \
	tr_orderIndexes.cpp \
	tr_polytope.cpp \
	tr_render.cpp \
	tr_rendertools.cpp \
	tr_shadowbounds.cpp \
	tr_stencilshadow.cpp \
	tr_subview.cpp \
	tr_trace.cpp \
	tr_trisurf.cpp \
	tr_turboshadow.cpp'
renderer_list = scons_utils.BuildList( 'renderer', renderer_string )

tests_string = ' \
    TestRun.cpp'
tests_list = scons_utils.BuildList( 'tests', tests_string)

framework_string = ' \
	CVarSystem.cpp \
	CmdSystem.cpp \
	Common.cpp \
	Compressor.cpp \
	Console.cpp \
	DemoFile.cpp \
	DeclAF.cpp \
	DeclEntityDef.cpp \
	DeclFX.cpp \
	DeclManager.cpp \
	DeclParticle.cpp \
	DeclSkin.cpp \
	DeclTable.cpp \
	EditField.cpp \
	EventLoop.cpp \
	File.cpp \
	FileSystem.cpp \
	minizip/minizip_extra.c \
	I18N.cpp \
	KeyInput.cpp \
	UsercmdGen.cpp \
	Session_menu.cpp \
	Session.cpp'
framework_list = scons_utils.BuildList( 'framework', framework_string )

cm_string = ' \
	CollisionModel_contacts.cpp \
	CollisionModel_contents.cpp \
	CollisionModel_debug.cpp \
	CollisionModel_files.cpp \
	CollisionModel_load.cpp \
	CollisionModel_rotate.cpp \
	CollisionModel_trace.cpp \
	CollisionModel_translate.cpp'
cm_list = scons_utils.BuildList( 'cm', cm_string )

compiler_string = ' \
	compiler_common.cpp'
compiler_list = scons_utils.BuildList( 'tools/compilers', compiler_string )

dmap_string = ' \
	dmap.cpp \
	facebsp.cpp \
	gldraw.cpp \
	glfile.cpp \
	leakfile.cpp \
	map.cpp \
	optimize.cpp \
	output.cpp \
	portals.cpp \
	shadowopt3.cpp \
	tritjunction.cpp \
	tritools.cpp \
	ubrush.cpp \
	usurface.cpp'
dmap_list = scons_utils.BuildList( 'tools/compilers/dmap', dmap_string )

aas_string = ' \
	AASBuild.cpp \
	AASBuild_file.cpp \
	AASBuild_gravity.cpp \
	AASBuild_ledge.cpp \
	AASBuild_merge.cpp \
	AASCluster.cpp \
	AASFile.cpp \
	AASFile_optimize.cpp \
	AASFile_sample.cpp \
	AASReach.cpp \
	AASFileManager.cpp \
	Brush.cpp \
	BrushBSP.cpp'
aas_list = scons_utils.BuildList( 'tools/compilers/aas', aas_string )

roq_string = ' \
	NSBitmapImageRep.cpp \
	codec.cpp \
	roq.cpp \
	roqParam.cpp'
roq_list = scons_utils.BuildList( 'tools/compilers/roqvq', roq_string )

renderbump_list = [ 'tools/compilers/renderbump/renderbump.cpp' ]

particle_string = ' \
	ParticleCollisionStatic.cpp'
particle_list = scons_utils.BuildList( 'tools/compilers/particle', particle_string )

snd_string = ' \
	snd_cache.cpp \
	snd_decoder.cpp \
	snd_efxfile.cpp \
	snd_efxpresets.cpp \
	snd_emitter.cpp \
	snd_shader.cpp \
	snd_system.cpp \
	snd_wavefile.cpp \
	snd_world.cpp'
snd_list = scons_utils.BuildList( 'sound', snd_string )

ui_string = ' \
	BindWindow.cpp \
	ChoiceWindow.cpp \
	DeviceContext.cpp \
	EditWindow.cpp \
	FieldWindow.cpp \
	GuiScript.cpp \
	ListGUI.cpp \
	ListWindow.cpp \
	MarkerWindow.cpp \
	RegExp.cpp \
	RenderWindow.cpp \
	SimpleWindow.cpp \
	SliderWindow.cpp \
	UserInterface.cpp \
	Window.cpp \
	Winvar.cpp'
ui_list = scons_utils.BuildList( 'ui', ui_string )

sys_string = ' \
	sys_local.cpp \
	posix/platform_linux.cpp \
	posix/posix_net.cpp \
	posix/posix_main.cpp \
	posix/posix_signal.cpp \
	posix/posix_threads.cpp \
	linux/main.cpp \
	stub/util_stub.cpp \
	linux/glimp.cpp \
	posix/posix_input.cpp \
	linux/input.cpp'
sys_list = scons_utils.BuildList( 'sys', sys_string )

tools_string = ' \
	guied/GEWindowWrapper_stub.cpp'
tools_list = scons_utils.BuildList( 'tools', tools_string )



# Compile the rest of the core engine
core_list = framework_list + renderer_list + tests_list + ui_list + cm_list \
	+ compiler_list + dmap_list + renderbump_list + aas_list + roq_list + particle_list \
	+ snd_list + sys_list + tools_list + [ 'TypeInfo/TypeInfoGen.cpp' ]
for i in range( len( core_list ) ):
	core_list[ i ] = '../../' + core_list[ i ]

local_env = g_env_game.Clone()
if ( local_curl == 0 ):
	local_env.Append( CPPDEFINES = [ 'ID_ENABLE_CURL=0' ] )
local_env_noopt = scons_utils.CloneWithoutOptimization(local_env, None)

ret_list = []
for f in core_list:
	ret_list += local_env.StaticObject( source = f )
ret_list += local_env_noopt.StaticObject( '../../tools/compilers/dmap/optimize_gcc.cpp' )	# disabled optimization
Return( 'ret_list' )
