mirror of
https://github.com/ptitSeb/Serious-Engine
synced 2024-11-21 18:10:26 +01:00
Merge pull request #48 from chewi/standalone-ecc
Allow ecc to be built independently using its own CMakeLists.txt file
This commit is contained in:
commit
0ab04baf9a
|
@ -20,8 +20,9 @@ if(NOT COMMAND add_compile_options)
|
||||||
endfunction()
|
endfunction()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
|
||||||
include(CheckCXXCompilerFlag)
|
include(CheckCXXCompilerFlag)
|
||||||
|
include(ParserAndScanner)
|
||||||
|
|
||||||
# ssam expects the libs to be in Debug/
|
# ssam expects the libs to be in Debug/
|
||||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Debug)
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Debug)
|
||||||
|
@ -312,40 +313,16 @@ else()
|
||||||
include_directories(External/libvorbis/include)
|
include_directories(External/libvorbis/include)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# We build ECC, then use it to generate C++ code for the game entities...
|
|
||||||
macro(add_parser_and_scanner _PARSER _SCANNER)
|
|
||||||
add_custom_command(
|
|
||||||
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/${_SCANNER}.cpp"
|
|
||||||
MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/${_SCANNER}.l"
|
|
||||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
|
||||||
COMMAND flex
|
|
||||||
ARGS -o${_SCANNER}.cpp ${_SCANNER}.l
|
|
||||||
)
|
|
||||||
|
|
||||||
add_custom_command(
|
|
||||||
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/${_PARSER}.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/${_PARSER}.hpp"
|
|
||||||
MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/${_PARSER}.y"
|
|
||||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
|
||||||
COMMAND bison
|
|
||||||
ARGS -o${_PARSER}.cpp ${_PARSER}.y -d
|
|
||||||
)
|
|
||||||
|
|
||||||
add_custom_command(
|
|
||||||
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/${_PARSER}.h"
|
|
||||||
MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/${_PARSER}.hpp"
|
|
||||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
|
||||||
COMMAND ${CMAKE_COMMAND}
|
|
||||||
ARGS -E copy ${_PARSER}.hpp ${_PARSER}.h
|
|
||||||
)
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
# Build ECC from source if there wasn't a prebuilt-one specified on the command line.
|
# Build ECC from source if there wasn't a prebuilt-one specified on the command line.
|
||||||
# Normally we build it here, but we might need a prebuilt, native binary if
|
# Normally we build it here, but we might need a prebuilt, native binary if
|
||||||
# we're cross-compiling the rest of the game.
|
# we're cross-compiling the rest of the game.
|
||||||
if(NOT ECC)
|
if(ECC)
|
||||||
add_parser_and_scanner("Ecc/Parser" "Ecc/Scanner")
|
# Use given ecc.
|
||||||
add_executable(ecc Ecc/Main.cpp Ecc/Parser.cpp Ecc/Parser.h Ecc/Scanner.cpp)
|
elseif(CMAKE_CROSSCOMPILING)
|
||||||
set(ECC "ecc")
|
message(FATAL_ERROR "ECC variable must point to native ecc binary when cross-compiling.")
|
||||||
|
else()
|
||||||
|
add_subdirectory(Ecc)
|
||||||
|
set(ECC ecc)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
macro(entity _NAME)
|
macro(entity _NAME)
|
||||||
|
|
18
Sources/Ecc/CMakeLists.txt
Normal file
18
Sources/Ecc/CMakeLists.txt
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
cmake_minimum_required(VERSION 2.8.7)
|
||||||
|
project(Ecc)
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
add_compile_options(/W4)
|
||||||
|
else()
|
||||||
|
add_compile_options(-Wall)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../cmake")
|
||||||
|
include(ParserAndScanner)
|
||||||
|
|
||||||
|
include_directories(
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
add_parser_and_scanner("Parser" "Scanner")
|
||||||
|
add_executable(ecc Main.cpp Parser.cpp Parser.h Scanner.cpp)
|
|
@ -178,7 +178,6 @@ void ReplaceFileRL(const char *strOld, const char *strNew)
|
||||||
// process each charachter
|
// process each charachter
|
||||||
for(int ich=0;ich<ctch;ich++)
|
for(int ich=0;ich<ctch;ich++)
|
||||||
{
|
{
|
||||||
char *pchOld = &strOldBuff[iOldch];
|
|
||||||
char *pchNew = &strNewBuff[ich];
|
char *pchNew = &strNewBuff[ich];
|
||||||
|
|
||||||
if((*pchNew == '{') || (*pchNew == '}') || *pchNew == ';')
|
if((*pchNew == '{') || (*pchNew == '}') || *pchNew == ';')
|
||||||
|
|
|
@ -15,7 +15,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
|
||||||
|
|
||||||
/* rcg10042001 */
|
/* rcg10042001 */
|
||||||
#ifdef PLATFORM_WIN32
|
#ifdef _WIN32
|
||||||
#define alloca _alloca
|
#define alloca _alloca
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
%{
|
%{
|
||||||
// rcg10042001 Changed to specify Ecc directory...
|
// rcg10042001 Changed to specify Ecc directory...
|
||||||
#include "Ecc/StdH.h"
|
#include "StdH.h"
|
||||||
#include "Ecc/Main.h"
|
#include "Main.h"
|
||||||
|
|
||||||
// turn off over-helpful bit of bison... --ryan.
|
// turn off over-helpful bit of bison... --ryan.
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
|
@ -984,7 +984,6 @@ procedure_implementation
|
||||||
sscanf($3.strString, "%s %s", strInputEventType, strInputEventName);
|
sscanf($3.strString, "%s %s", strInputEventType, strInputEventName);
|
||||||
|
|
||||||
char strStateID[256];
|
char strStateID[256];
|
||||||
const char *strBaseStateID = "-1";
|
|
||||||
if(strcmp(RemoveLineDirective(strProcedureName), "Main")==0){
|
if(strcmp(RemoveLineDirective(strProcedureName), "Main")==0){
|
||||||
strcpy(strStateID, "1");
|
strcpy(strStateID, "1");
|
||||||
if(strncmp(strInputEventType, "EVoid", 4)!=0 && _strCurrentThumbnail[2]!=0) {
|
if(strncmp(strInputEventType, "EVoid", 4)!=0 && _strCurrentThumbnail[2]!=0) {
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
%{
|
%{
|
||||||
// rcg10042001 Changed to specify Ecc directory...
|
#include "StdH.h"
|
||||||
#include "Ecc/StdH.h"
|
#include "Main.h"
|
||||||
#include "Ecc/Main.h"
|
#include "Parser.h"
|
||||||
#include "Ecc/Parser.h"
|
|
||||||
|
|
||||||
#define YY_NEVER_INTERACTIVE 1
|
#define YY_NEVER_INTERACTIVE 1
|
||||||
|
|
||||||
|
|
|
@ -21,11 +21,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#ifdef PLATFORM_WIN32
|
#ifdef _WIN32
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#endif
|
#else
|
||||||
|
|
||||||
#ifdef PLATFORM_UNIX
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
/* Copyright (c) 2002-2012 Croteam Ltd.
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of version 2 of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation
|
|
||||||
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License along
|
|
||||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
|
|
||||||
|
|
||||||
#include <io.h>
|
|
25
Sources/cmake/ParserAndScanner.cmake
Normal file
25
Sources/cmake/ParserAndScanner.cmake
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
macro(add_parser_and_scanner _PARSER _SCANNER)
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/${_SCANNER}.cpp"
|
||||||
|
MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/${_SCANNER}.l"
|
||||||
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
|
COMMAND flex
|
||||||
|
ARGS -o${_SCANNER}.cpp ${_SCANNER}.l
|
||||||
|
)
|
||||||
|
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/${_PARSER}.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/${_PARSER}.hpp"
|
||||||
|
MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/${_PARSER}.y"
|
||||||
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
|
COMMAND bison
|
||||||
|
ARGS -o${_PARSER}.cpp ${_PARSER}.y -d
|
||||||
|
)
|
||||||
|
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/${_PARSER}.h"
|
||||||
|
MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/${_PARSER}.hpp"
|
||||||
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
|
COMMAND ${CMAKE_COMMAND}
|
||||||
|
ARGS -E copy ${_PARSER}.hpp ${_PARSER}.h
|
||||||
|
)
|
||||||
|
endmacro()
|
Loading…
Reference in New Issue
Block a user