Changeset 2241


Ignore:
Timestamp:
Jan 21, 2013, 2:11:58 PM (7 years ago)
Author:
sam
Message:

core: pass the project directory to the binary build and get rid of
that 2-year old "temporary Win32 hack".

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/build/vs2010/Lol.Core.Rules.props

    r1822 r2241  
    1414      <AdditionalIncludeDirectories Condition="'$(Platform)'=='x64'">$(GlIncludes);$(SdlIncludes);$(D3d9Includes);$(XinputIncludes);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
    1515      <PreprocessorDefinitions>NOMINMAX;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     16      <PreprocessorDefinitions>LOL_CONFIG_PROJECTDIR="$(ProjectDir.Replace('\',"\\"))";%(PreprocessorDefinitions)</PreprocessorDefinitions>
     17      <PreprocessorDefinitions>LOL_CONFIG_SOLUTIONDIR="$(SolutionDir.Replace('\',"\\"))";%(PreprocessorDefinitions)</PreprocessorDefinitions>
    1618      <PreprocessorDefinitions Condition="'$(Platform)'=='Win32'">WIN32;$(Win32Defines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
    1719      <PreprocessorDefinitions Condition="'$(Platform)'=='x64'">WIN32;$(Win32Defines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
  • trunk/src/image/codec/gdiplus-image.cpp

    r2237 r2241  
    8686#if !LOL_RELEASE
    8787            if (status != Gdiplus::InvalidParameter)
    88                 Log::Error("error %d loading %s\n", status, path);
     88                Log::Error("error %d loading %s\n",
     89                           status, &fullpath[0]);
    8990#endif
    9091            delete bitmap;
  • trunk/src/lol/sys/init.h

    r2237 r2241  
    2222{
    2323
     24/*
     25 * Module-specific macros. These can be overridden by the build process,
     26 * typically with compiler command-line flags.
     27 */
     28
     29#if !defined LOL_CONFIG_PROJECTDIR
     30#   define LOL_CONFIG_PROJECTDIR ""
     31#endif
     32
     33#if !defined LOL_CONFIG_SOLUTIONDIR
     34#   define LOL_CONFIG_SOLUTIONDIR ""
     35#endif
     36
    2437namespace System
    2538{
    2639
    27 extern void Init(Array<char const *> &args);
     40extern void Init(int argc, char *argv[],
     41                 char const *projectdir = LOL_CONFIG_PROJECTDIR,
     42                 char const *solutiondir = LOL_CONFIG_SOLUTIONDIR);
     43
    2844extern void SetDataDir(char const *dir);
    2945extern char const *GetDataDir();
    30 
    31 static inline void Init(int argc, char *argv[])
    32 {
    33     Array<char const *> args;
    34 
    35     for (int i = 0; i < argc; i++)
    36         args << argv[i];
    37 
    38     Init(args);
    39 }
    4046
    4147} /* namespace System */
  • trunk/src/sys/init.cpp

    r2237 r2241  
    2121{
    2222
    23 void Init(Array<char const *> &args)
    24 {
    25     /* Try to guess the data directory from the executable location. */
    26     if (args.Count() > 0)
    27     {
    2823#if defined _WIN32
    2924#   define SEPARATOR '\\'
     
    3126#   define SEPARATOR '/'
    3227#endif
    33         char const *last_slash = strrchr(args[0], SEPARATOR);
     28
     29void Init(int argc, char *argv[],
     30          char const *projectdir, char const *solutiondir)
     31{
     32    bool got_rootdir = false;
     33
     34    /* Find the common prefix between project dir and solution dir. */
     35    for (int i = 0; ; i++)
     36    {
     37        if (projectdir[i] != solutiondir[i] || projectdir[i] == '\0')
     38        {
     39            /* FIXME: at this point we should check whether the binary
     40             * was launched from this subdirectory; from now we just
     41             * assume it was. */
     42            if (i)
     43            {
     44                String rootdir = projectdir;
     45                if (rootdir.Last() != SEPARATOR)
     46                    rootdir += SEPARATOR;
     47                SetDataDir(&rootdir[0]);
     48                got_rootdir = true;
     49            }
     50            break;
     51        }
     52    }
     53
     54    /* Try to guess the data directory from the executable location. */
     55    if (!got_rootdir && argc > 0)
     56    {
     57        char const *last_slash = strrchr(argv[0], SEPARATOR);
    3458
    3559        if (last_slash)
    3660        {
    37             String dir;
    38             dir.Resize(last_slash - args[0] + 1);
    39             memcpy(&dir[0], args[0], last_slash - args[0] + 1);
    40 
     61            String dir(argv[0], last_slash - argv[0] + 1);
    4162            SetDataDir(&dir[0]);
     63            got_rootdir = true;
    4264        }
    4365    }
  • trunk/test/BtPhysTest.cpp

    r2237 r2241  
    88#if defined HAVE_CONFIG_H
    99#   include "config.h"
    10 #endif
    11 
    12 #if defined _WIN32
    13 #   include <direct.h>
    1410#endif
    1511
     
    480476    Application app("BtPhysTest", ivec2(1280, 720), 60.0f);
    481477
    482 #if defined _MSC_VER && !defined _XBOX
    483     _chdir("..");
    484 #elif defined _WIN32 && !defined _XBOX
    485     _chdir("../..");
    486 #endif
    487 
    488478    new BtPhysTest(argc > 1);
    489479    app.ShowPointer(false);
  • trunk/tools/neercs/neercs.cpp

    r2237 r2241  
    77#if defined HAVE_CONFIG_H
    88#   include "config.h"
    9 #endif
    10 
    11 #if defined _WIN32
    12 #   include <direct.h>
    139#endif
    1410
     
    7571    Application app("Neercs", ivec2(800, 600), 60.0f);
    7672
    77 #if defined _MSC_VER && !defined _XBOX
    78     _chdir("../..");
    79 #elif defined _WIN32 && !defined _XBOX
    80     _chdir("../..");
    81 #endif
    82 
    8373    new Neercs(argc, argv);
    8474    app.ShowPointer(false);
  • trunk/tutorial/01_triangle.cpp

    r2237 r2241  
    1818using namespace std;
    1919using namespace lol;
    20 
    21 #if defined _WIN32
    22 #   include <direct.h>
    23 #endif
    2420
    2521extern char const *lolfx_01_triangle;
     
    7975    Application app("Tutorial 1: Triangle", ivec2(640, 480), 60.0f);
    8076
    81 #if defined _MSC_VER && !defined _XBOX
    82     _chdir("..");
    83 #elif defined _WIN32 && !defined _XBOX
    84     _chdir("../..");
    85 #endif
    86 
    8777    new DebugFps(5, 5);
    8878    new Triangle();
  • trunk/tutorial/02_cube.cpp

    r2237 r2241  
    1818using namespace std;
    1919using namespace lol;
    20 
    21 #if defined _WIN32
    22 #   include <direct.h>
    23 #endif
    2420
    2521extern char const *lolfx_02_cube;
     
    140136    Application app("Tutorial 2: Cube", ivec2(640, 480), 60.0f);
    141137
    142 #if defined _MSC_VER && !defined _XBOX
    143     _chdir("..");
    144 #elif defined _WIN32 && !defined _XBOX
    145     _chdir("../..");
    146 #endif
    147 
    148138    new DebugFps(5, 5);
    149139    new Cube();
  • trunk/tutorial/03_noise.cpp

    r2237 r2241  
    1818using namespace std;
    1919using namespace lol;
    20 
    21 #if defined _WIN32
    22 #   include <direct.h>
    23 #endif
    2420
    2521extern char const *lolfx_03_noise;
     
    9086    Application app("Tutorial 3: Noise", ivec2(1280, 720), 60.0f);
    9187
    92 #if defined _MSC_VER && !defined _XBOX
    93     _chdir("..");
    94 #elif defined _WIN32 && !defined _XBOX
    95     _chdir("../..");
    96 #endif
    97 
    9888    new NoiseDemo();
    9989
  • trunk/tutorial/08_fbo.cpp

    r2237 r2241  
    1818using namespace std;
    1919using namespace lol;
    20 
    21 #if defined _WIN32
    22 #   include <direct.h>
    23 #endif
    2420
    2521extern char const *lolfx_08_fbo;
     
    143139    Application app("Tutorial 08: Framebuffer Object", ivec2(640, 480), 60.0f);
    144140
    145 #if defined _MSC_VER && !defined _XBOX
    146     _chdir("..");
    147 #elif defined _WIN32 && !defined _XBOX
    148     _chdir("../..");
    149 #endif
    150 
    151141    new FBO();
    152142
  • trunk/tutorial/11_fractal.cpp

    r2237 r2241  
    1818#include "core.h"
    1919#include "loldebug.h"
    20 
    21 #if defined _WIN32
    22 #   include <direct.h>
    23 #endif
    2420
    2521using namespace lol;
     
    557553    Application app("Tutorial 3: Fractal", window_size, 60.0f);
    558554
    559 #if defined _MSC_VER && !defined _XBOX
    560     _chdir("..");
    561 #elif defined _WIN32 && !defined _XBOX
    562     _chdir("../..");
    563 #endif
    564 
    565555    new DebugFps(5, 5);
    566556    new Fractal(window_size);
Note: See TracChangeset for help on using the changeset viewer.