Skip to content

Commit

Permalink
Add Code::Blocks project file for Windows, update scripts
Browse files Browse the repository at this point in the history
There's one central SETUP_dev_win.sh script, which lets you
choose whether you want to develop using Code::Blocks for Windows,
or using Visual Studio, and downloads the respective SDK files.
Also the script copies the relevant project file to the root dir.
  • Loading branch information
anrieff committed Jun 2, 2018
1 parent d30340e commit 5bb52e2
Show file tree
Hide file tree
Showing 10 changed files with 217 additions and 24 deletions.
99 changes: 99 additions & 0 deletions projfiles/CodeBlocks-win.cbp
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="fray" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="bin/Debug/fray" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-g" />
</Compiler>
</Target>
<Target title="Release">
<Option output="bin/Release/fray" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="0" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O3" />
<Add option="-ffast-math" />
<Add option="-march=native" />
<Add option="-fno-rtti" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-std=c++11" />
<Add option="-Wall" />
<Add directory="SDK/SDL-1.2.15/include" />
<Add directory="SDK/OpenEXR-mingw/include/OpenEXR" />
</Compiler>
<Linker>
<Add library="mingw32" />
<Add library="SDLmain" />
<Add library="SDL.dll" />
<Add library="user32" />
<Add library="gdi32" />
<Add library="winmm" />
<Add library="dxguid" />
<Add library="IlmImf" />
<Add library="Imath" />
<Add library="Iex" />
<Add library="Half" />
<Add library="IlmThread" />
<Add library="zlibstatic" />
<Add directory="SDK/SDL-1.2.15/lib" />
<Add directory="SDK/OpenEXR-mingw/lib" />
</Linker>
<Unit filename="src/bbox.h" />
<Unit filename="src/bitmap.cpp" />
<Unit filename="src/bitmap.h" />
<Unit filename="src/camera.cpp" />
<Unit filename="src/camera.h" />
<Unit filename="src/color.h" />
<Unit filename="src/constants.h" />
<Unit filename="src/cxxptl-sdl.cpp" />
<Unit filename="src/cxxptl-sdl.h" />
<Unit filename="src/environment.cpp" />
<Unit filename="src/environment.h" />
<Unit filename="src/geometry.cpp" />
<Unit filename="src/geometry.h" />
<Unit filename="src/heightfield.cpp" />
<Unit filename="src/heightfield.h" />
<Unit filename="src/lights.cpp" />
<Unit filename="src/lights.h" />
<Unit filename="src/main.cpp" />
<Unit filename="src/matrix.cpp" />
<Unit filename="src/matrix.h" />
<Unit filename="src/mesh.cpp" />
<Unit filename="src/mesh.h" />
<Unit filename="src/random_generator.cpp" />
<Unit filename="src/random_generator.h" />
<Unit filename="src/scene.cpp" />
<Unit filename="src/scene.h" />
<Unit filename="src/sdl.cpp" />
<Unit filename="src/sdl.h" />
<Unit filename="src/shading.cpp" />
<Unit filename="src/shading.h" />
<Unit filename="src/triangle.cpp" />
<Unit filename="src/triangle.h" />
<Unit filename="src/util.cpp" />
<Unit filename="src/util.h" />
<Unit filename="src/vector.h" />
<Extensions>
<code_completion />
<envvars />
<debugger />
<lib_finder disable_auto="1" />
</Extensions>
</Project>
</CodeBlocks_project_file>
52 changes: 52 additions & 0 deletions scripts/SETUP_dev_win.sh
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash

# Usage: SETUP_dev.sh <vc|cb>"

compiler="$1"

if [ ! -f "sdl_win.sh" ]; then
echo "Invalid directory, you should run this from within scripts/"
exit 2
fi

if [ ! "x$compiler" == "xvc" -a ! "x$compiler" == "xcb" ]; then
echo "Choose your compiler/IDE:"
echo ""
echo " 1) Microsoft Visual Studio 2017"
echo " 2) Code::Blocks 17.12"
echo ""
echo -n "? "
read choice
if [ "x$choice" == "x1" ]; then
compiler="vc"
elif [ "x$choice" == "x2" ]; then
compiler="cb"
else
echo "Invalid choice"
exit 1
fi
fi
echo "Compiler is $compiler"

PROJ="../projfiles"

if [ $compiler == "vc" ]; then
./sdl_win.sh
./openexr_win.sh
./zlib_win.sh

echo ">> Copying project files..."
cp $PROJ/fray.vcxproj* ..

echo ">> All set up! Open fray.vcxproj (in the root project dir) and happy hacking!"
fi

if [ $compiler == "cb" ]; then
./sdl_win_cb.sh
./openexr_win_cb.sh

echo ">> Copying project files..."
cp $PROJ/CodeBlocks-win.cbp ../fray.cbp

echo ">> All set up! Open fray.cbp (in the root project dir) and happy hacking!"
fi
27 changes: 27 additions & 0 deletions scripts/openexr_win_cb.sh
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh

if [ -z $BASH_SOURCE ]; then
echo "ERROR \$BASH_SOURCE is required"
exit 1
fi

BASH_DIR=$(dirname $BASH_SOURCE)
SDK_DIR=$BASH_DIR/../SDK

if [ ! -d $SDK_DIR ]; then
mkdir $SDK_DIR
fi

echo ">> Downloading OpenEXR 2.2.1 into $SDK_DIR"
curl -L "http://raytracing-bg.net/lib/openexr-devel-mingw32.zip" --output $SDK_DIR/openexr.zip

if [ $? -ne 0 ]; then
echo ">> ERROR: cURL failed to download OpenEXR archive"
else

echo ">> Extracting OpenEXR sdk in $SDK_DIR/OpenEXR"
# unzip doesn't handle relative paths well
unzip -q -u $SDK_DIR/openexr.zip -d $SDK_DIR

rm $SDK_DIR/openexr.zip
fi
4 changes: 4 additions & 0 deletions scripts/sdl_win.sh
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -26,4 +26,8 @@ else
mv -T $SDK_DIR/SDL-1.2.15 $SDK_DIR/SDL mv -T $SDK_DIR/SDL-1.2.15 $SDK_DIR/SDL


rm $SDK_DIR/sdl.zip rm $SDK_DIR/sdl.zip

echo ">> Moving header files"
mkdir $SDK_DIR/SDL/include/SDL
mv $SDK_DIR/SDL/include/*.h $SDK_DIR/SDL/include/SDL
fi fi
33 changes: 33 additions & 0 deletions scripts/sdl_win_cb.sh
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/sh

if [ -z $BASH_SOURCE ]; then
echo "ERROR \$BASH_SOURCE is required"
exit 1
fi

BASH_DIR=$(dirname $BASH_SOURCE)
SDK_DIR=$BASH_DIR/../SDK

if [ ! -d $SDK_DIR ]; then
mkdir $SDK_DIR
fi

echo ">> Downloading SDL 1.2 into $SDK_DIR"
curl http://libsdl.org/release/SDL-devel-1.2.15-mingw32.tar.gz --output $SDK_DIR/sdl.tar.gz

if [ $? -ne 0 ]; then
echo ">> ERROR: cURL failed to download SDL archive"
else

echo ">> Extracting SDL SDK in $SDK_DIR/SDL"
# unzip doesn't handle relative paths well
pushd .
cd $SDK_DIR
tar xzf sdl.tar.gz
popd

rm $SDK_DIR/sdl.tar.gz

echo ">> Copying SDL.dll"
cp $SDK_DIR/SDL-1.2.15/bin/SDL.dll ..
fi
4 changes: 0 additions & 4 deletions src/cxxptl-sdl.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@
#include "cxxptl-sdl.h" #include "cxxptl-sdl.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#ifdef _WIN32
#include <SDL.h>
#else
#include <SDL/SDL.h> #include <SDL/SDL.h>
#endif // _WIN32


#ifdef _WIN32 #ifdef _WIN32
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
Expand Down
5 changes: 0 additions & 5 deletions src/cxxptl-sdl.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -22,13 +22,8 @@
* @Brief SDL port of the CXXPTL library * @Brief SDL port of the CXXPTL library
*/ */
#pragma once #pragma once
#ifdef _WIN32
#include <SDL_thread.h>
#include <SDL_mutex.h>
#else
#include <SDL/SDL_thread.h> #include <SDL/SDL_thread.h>
#include <SDL/SDL_mutex.h> #include <SDL/SDL_mutex.h>
#endif


/** /**
* @File cxxptl_sdl.h * @File cxxptl_sdl.h
Expand Down
9 changes: 2 additions & 7 deletions src/main.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -21,16 +21,11 @@
* @File main.cpp * @File main.cpp
* @Brief Raytracer main file * @Brief Raytracer main file
*/ */
#ifdef _WIN32
#include <SDL.h>
#include <SDL_events.h>
#ifdef main #ifdef main
#undef main # undef main
#endif // main #endif
#else
#include <SDL/SDL.h> #include <SDL/SDL.h>
#include <SDL/SDL_events.h> #include <SDL/SDL_events.h>
#endif // _WIN32
#include <math.h> #include <math.h>
#include <string.h> #include <string.h>
#include <vector> #include <vector>
Expand Down
4 changes: 0 additions & 4 deletions src/random_generator.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@
***************************************************************************/ ***************************************************************************/


#include <math.h> #include <math.h>
#ifdef _WIN32
#include <SDL.h>
#else
#include <SDL/SDL.h> #include <SDL/SDL.h>
#endif // _WIN32
#include "random_generator.h" #include "random_generator.h"
#include "constants.h" #include "constants.h"


Expand Down
4 changes: 0 additions & 4 deletions src/sdl.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@
* @File sdl.cpp * @File sdl.cpp
* @Brief Implements the interface to SDL (mainly drawing to screen functions) * @Brief Implements the interface to SDL (mainly drawing to screen functions)
*/ */
#ifndef _WIN32
#include <SDL/SDL.h> #include <SDL/SDL.h>
#else
#include <SDL.h>
#endif // _WIN32
#include <stdio.h> #include <stdio.h>
#include "sdl.h" #include "sdl.h"
#include "bitmap.h" #include "bitmap.h"
Expand Down

0 comments on commit 5bb52e2

Please sign in to comment.