Browse Source

Wire -Ddefine support.

pull/1/head
Tarmo Pikaro 13 years ago committed by triton
parent
commit
e203d5fcea
  1. 4
      examples/Hello/Hello.h
  2. 6
      examples/Hello/premake4.lua
  3. 5
      src/Generator/CodeGenerator.cs
  4. 6
      src/Parser/Parser.cpp
  5. 2
      src/Parser/Parser.h

4
examples/Hello/Hello.h

@ -2,6 +2,10 @@
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#ifndef WIN32
#error "Generator should understand defines as well"
#endif
class Hello class Hello
{ {
public: public:

6
examples/Hello/premake4.lua

@ -9,10 +9,10 @@ solution "Hello"
debugdir ( "./bin/") debugdir ( "./bin/")
configuration "Debug" configuration "Debug"
defines { "DEBUG" } defines { "DEBUG", "WIN32" }
configuration "Release" configuration "Release"
defines { "NDEBUG" } defines { "NDEBUG", "WIN32" }
flags { "Optimize" } flags { "Optimize" }
project "Hello" project "Hello"
@ -36,7 +36,7 @@ project "Hello"
buildrule { buildrule {
description = "Compiling $(InputFile)...", description = "Compiling $(InputFile)...",
commands = { commands = {
'..\\..\\bin\\generator.exe -vs=10 -ns=CppCsBind -outdir=CppCsBind -I. hello.h', '..\\..\\bin\\generator.exe -D=WIN32 -vs=10 -ns=CppCsBind -outdir=CppCsBind -I. hello.h',
}, },
outputs = { "CppCsBind\\hello_wrapper.cpp" } outputs = { "CppCsBind\\hello_wrapper.cpp" }
} }

5
src/Generator/CodeGenerator.cs

@ -44,8 +44,13 @@ namespace Cxxi
{ {
Library = library, Library = library,
Verbose = false, Verbose = false,
<<<<<<< HEAD
IncludeDirs = options.IncludeDirs IncludeDirs = options.IncludeDirs
FileName = file, FileName = file,
=======
IncludeDirs = options.IncludeDirs,
Defines = options.Defines,
>>>>>>> 7304ce4... Wire -Ddefine support.
toolSetToUse = options.toolset2use toolSetToUse = options.toolset2use
}; };

6
src/Parser/Parser.cpp

@ -208,6 +208,12 @@ void Parser::Setup(ParserOptions^ Opts)
C->getHeaderSearchOpts().AddPath(s, frontend::Angled, true, false, true); C->getHeaderSearchOpts().AddPath(s, frontend::Angled, true, false, true);
} }
for each(System::String^% def in Opts->Defines)
{
String s = marshalString<E_UTF8>(def);
C->getPreprocessorOpts().addMacroDef(s);
}
// Initialize the default platform headers. // Initialize the default platform headers.
std::string ResourceDir = GetClangResourceDir("."); std::string ResourceDir = GetClangResourceDir(".");
C->getHeaderSearchOpts().ResourceDir = ResourceDir; C->getHeaderSearchOpts().ResourceDir = ResourceDir;

2
src/Parser/Parser.h

@ -37,10 +37,12 @@ public ref struct ParserOptions
ParserOptions() ParserOptions()
{ {
IncludeDirs = gcnew List<System::String^>(); IncludeDirs = gcnew List<System::String^>();
Defines = gcnew List<System::String^>();
} }
// Include directories // Include directories
List<System::String^>^ IncludeDirs; List<System::String^>^ IncludeDirs;
List<System::String^>^ Defines;
// C/C++ header file name. // C/C++ header file name.
System::String^ FileName; System::String^ FileName;

Loading…
Cancel
Save