++CMakeModules:
Revise TokenList2DsnLexer.cmake to take outCppFile and outHeaderFile optinally and enum mandatorily. Standardize the script's invocation technique within all the CMakeLists.txt files.
This commit is contained in:
parent
fb0bb79a8d
commit
6c5927c536
|
@ -4,6 +4,13 @@ KiCad ChangeLog 2010
|
||||||
Please add newer entries at the top, list the date and your name with
|
Please add newer entries at the top, list the date and your name with
|
||||||
email address.
|
email address.
|
||||||
|
|
||||||
|
2010-Aug-9 UPDATE Dick Hollenbeck <dick@softplc.com>
|
||||||
|
================================================================================
|
||||||
|
++CMakeModules:
|
||||||
|
Revise TokenList2DsnLexer.cmake to take outCppFile and outHeaderFile optinally
|
||||||
|
and enum mandatorily. Standardize the script's invocation technique within
|
||||||
|
all the CMakeLists.txt files.
|
||||||
|
|
||||||
2010-Aug-8 UPDATE Dick Hollenbeck <dick@softplc.com>
|
2010-Aug-8 UPDATE Dick Hollenbeck <dick@softplc.com>
|
||||||
================================================================================
|
================================================================================
|
||||||
++CMakeModules:
|
++CMakeModules:
|
||||||
|
|
|
@ -36,57 +36,71 @@
|
||||||
# Valid tokens: a a1 foo_1 foo_bar2
|
# Valid tokens: a a1 foo_1 foo_bar2
|
||||||
# Invalid tokens: 1 A _foo bar_ foO
|
# Invalid tokens: 1 A _foo bar_ foO
|
||||||
#
|
#
|
||||||
# Usage:
|
# Invocation Parameters are: enum, inputFile, outCppFile, outHeaderFile
|
||||||
#
|
#
|
||||||
# add_custom_command(
|
# enum - Required, name of the enum to generate.
|
||||||
# OUTPUT ${CMAKE_BINARY_DIR}/cmp_library_keywords.h
|
|
||||||
# ${CMAKE_BINARY_DIR}/cmp_library_keywords.cpp
|
|
||||||
# COMMAND ${CMAKE_COMMAND}
|
|
||||||
# -Denum=YOURTOK_T
|
|
||||||
# -DinputFile=${CMAKE_CURRENT_SOURCE_DIR}/cmp_library.keywords
|
|
||||||
# -P ${CMAKE_MODULE_PATH}/TokenList2DsnLexer.cmake
|
|
||||||
# DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/cmp_library.keywords
|
|
||||||
# )
|
|
||||||
#
|
#
|
||||||
# Input parameters:
|
# inputFile - Required, name of the token list file, or "*.keywords" file.
|
||||||
|
# Choose the basefilename carefully, it decides the class name
|
||||||
|
# used in the generated *_lexer.h file.
|
||||||
#
|
#
|
||||||
# enum - The name of the enum to generate, defaults to DSN_T, but
|
# outCppFile - Optional, full path and file name of where to save the generated
|
||||||
# you'll get collisions if you don't override it.
|
# cpp keywords file. If not defined, the output path is the same
|
||||||
# inputFile - The name of the token list file.
|
# path as the token list file path, with a file name of *_keywords.cpp
|
||||||
# outputPath - Optional output path to save the generated files. If not defined,
|
#
|
||||||
# the output path is the same path as the token list file path.
|
# outHeaderFile - Optional, full path and file name of where to save the generated
|
||||||
|
# *.h lexfer file. If not defined, the output path is the same
|
||||||
|
# path as the token list file path, with a file name of *_lexer.h
|
||||||
|
#
|
||||||
|
# Example Usage from within a CMakeLists.txt file is shown below. CMake itself
|
||||||
|
# is invoked as a child process to execute this script and parameters are passed on
|
||||||
|
# the command line, which is formulated as the "COMMAND" sequence below:
|
||||||
|
#
|
||||||
|
# add_custom_command(
|
||||||
|
# OUTPUT ${CMAKE_BINARY_DIR}/cmp_library_lexer.h
|
||||||
|
# ${CMAKE_BINARY_DIR}/cmp_library_keywords.cpp
|
||||||
|
# COMMAND ${CMAKE_COMMAND}
|
||||||
|
# -Denum=YOURTOK_T
|
||||||
|
# -DinputFile=${CMAKE_CURRENT_SOURCE_DIR}/cmp_library.keywords
|
||||||
|
# -DoutCppFile=${CMAKE_CURRENT_SOURCE_DIR}/cmp_library_keywords.cpp
|
||||||
|
# -DoutHeaderFile=${CMAKE_CURRENT_SOURCE_DIR}/cmp_library_lexer.h
|
||||||
|
# -P ${CMAKE_MODULE_PATH}/TokenList2DsnLexer.cmake
|
||||||
|
# DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/cmp_library.keywords
|
||||||
|
# COMMENT "creating ${CMAKE_CURRENT_SOURCE_DIR}/cmp_library_{lexer.h,keywords.cpp}
|
||||||
|
# from ${CMAKE_CURRENT_SOURCE_DIR}/cmp_library.keywords"
|
||||||
|
# )
|
||||||
|
|
||||||
|
#message( STATUS "TokenList2DsnLexer.cmake" ) # indicate we are running
|
||||||
|
|
||||||
set( tokens "" )
|
set( tokens "" )
|
||||||
set( lineCount 0 )
|
set( lineCount 0 )
|
||||||
set( dsnErrorMsg "DSN token file generator failure:" )
|
set( dsnErrorMsg "TokenList2DsnLexer.cmake failure:" )
|
||||||
|
|
||||||
|
|
||||||
if( NOT EXISTS ${inputFile} )
|
if( NOT EXISTS ${inputFile} )
|
||||||
message( FATAL_ERROR "${dsnErrorMsg} file ${inputFile} cannot be found." )
|
message( FATAL_ERROR "${dsnErrorMsg} file ${inputFile} cannot be found." )
|
||||||
endif( NOT EXISTS ${inputFile} )
|
endif()
|
||||||
|
|
||||||
if( NOT EXISTS ${outputPath} )
|
|
||||||
get_filename_component( outputPath "${inputFile}" PATH )
|
|
||||||
endif( NOT EXISTS ${outputPath} )
|
|
||||||
|
|
||||||
if( NOT DEFINED enum )
|
if( NOT DEFINED enum )
|
||||||
set( enum DSN_T )
|
message( FATAL_ERROR "${dsnErrorMsg} missing \"enum\" processing ${inputFile}." )
|
||||||
endif()
|
endif()
|
||||||
#message( STATUS "enum: ${enum}" )
|
|
||||||
|
|
||||||
|
get_filename_component( outputPath "${inputFile}" PATH )
|
||||||
|
|
||||||
# Separate the file name without extension from the full file path.
|
# the keywords filename without extension is important, it sets the classname into RESULT
|
||||||
get_filename_component( result "${inputFile}" NAME_WE )
|
get_filename_component( result "${inputFile}" NAME_WE )
|
||||||
|
string( TOUPPER "${result}" RESULT )
|
||||||
|
|
||||||
message( STATUS "Extracted file name ${result} from path ${inputFile}" )
|
#message( "enum:'${enum}' result:'${result}' outputPath:'${outputPath}' inputFile:'${inputFile}'" )
|
||||||
|
|
||||||
# Create include and source file name from the list file name.
|
if( NOT DEFINED outCppFile )
|
||||||
set( includeFileName "${outputPath}/${result}_lexer.h" )
|
set( outCppFile "${outputPath}/${result}_keywords.cpp" )
|
||||||
set( sourceFileName "${outputPath}/${result}_keywords.cpp" )
|
endif()
|
||||||
|
|
||||||
|
if( NOT DEFINED outHeaderFile )
|
||||||
|
set( outHeaderFile "${outputPath}/${result}_lexer.h" )
|
||||||
|
endif()
|
||||||
|
|
||||||
# Create tag for generating header file.
|
# Create tag for generating header file.
|
||||||
string( TOUPPER "${result}" RESULT )
|
|
||||||
set( headerTag "_${RESULT}_H_" )
|
set( headerTag "_${RESULT}_H_" )
|
||||||
|
|
||||||
set( includeFileHeader
|
set( includeFileHeader
|
||||||
|
@ -175,31 +189,31 @@ if( NOT ( tokensBefore EQUAL tokensAfter ) )
|
||||||
message( FATAL_ERROR "Duplicate tokens found in file <${inputFile}>." )
|
message( FATAL_ERROR "Duplicate tokens found in file <${inputFile}>." )
|
||||||
endif( NOT ( tokensBefore EQUAL tokensAfter ) )
|
endif( NOT ( tokensBefore EQUAL tokensAfter ) )
|
||||||
|
|
||||||
file( WRITE "${includeFileName}" "${includeFileHeader}" )
|
file( WRITE "${outHeaderFile}" "${includeFileHeader}" )
|
||||||
file( WRITE "${sourceFileName}" "${sourceFileHeader}" )
|
file( WRITE "${outCppFile}" "${sourceFileHeader}" )
|
||||||
|
|
||||||
set( lineCount 1 )
|
set( lineCount 1 )
|
||||||
|
|
||||||
foreach( token ${tokens} )
|
foreach( token ${tokens} )
|
||||||
if( lineCount EQUAL 1 )
|
if( lineCount EQUAL 1 )
|
||||||
file( APPEND "${includeFileName}" " T_${token} = 0" )
|
file( APPEND "${outHeaderFile}" " T_${token} = 0" )
|
||||||
else( lineCount EQUAL 1 )
|
else( lineCount EQUAL 1 )
|
||||||
file( APPEND "${includeFileName}" " T_${token}" )
|
file( APPEND "${outHeaderFile}" " T_${token}" )
|
||||||
endif( lineCount EQUAL 1 )
|
endif( lineCount EQUAL 1 )
|
||||||
|
|
||||||
file(APPEND "${sourceFileName}" " TOKDEF( ${token} )" )
|
file(APPEND "${outCppFile}" " TOKDEF( ${token} )" )
|
||||||
|
|
||||||
if( lineCount EQUAL tokensAfter )
|
if( lineCount EQUAL tokensAfter )
|
||||||
file( APPEND "${includeFileName}" "\n" )
|
file( APPEND "${outHeaderFile}" "\n" )
|
||||||
file( APPEND "${sourceFileName}" "\n" )
|
file( APPEND "${outCppFile}" "\n" )
|
||||||
else( lineCount EQUAL tokensAfter )
|
else( lineCount EQUAL tokensAfter )
|
||||||
file( APPEND "${includeFileName}" ",\n" )
|
file( APPEND "${outHeaderFile}" ",\n" )
|
||||||
file( APPEND "${sourceFileName}" ",\n" )
|
file( APPEND "${outCppFile}" ",\n" )
|
||||||
endif( lineCount EQUAL tokensAfter )
|
endif( lineCount EQUAL tokensAfter )
|
||||||
math( EXPR lineCount "${lineCount} + 1" )
|
math( EXPR lineCount "${lineCount} + 1" )
|
||||||
endforeach( token ${tokens} )
|
endforeach( token ${tokens} )
|
||||||
|
|
||||||
file( APPEND "${includeFileName}"
|
file( APPEND "${outHeaderFile}"
|
||||||
"};
|
"};
|
||||||
|
|
||||||
extern const KEYWORD ${result}_keywords[];
|
extern const KEYWORD ${result}_keywords[];
|
||||||
|
@ -316,7 +330,7 @@ class ${RESULT}_PARSER : public ${RESULT}_LEXER
|
||||||
"
|
"
|
||||||
)
|
)
|
||||||
|
|
||||||
file( APPEND "${sourceFileName}"
|
file( APPEND "${outCppFile}"
|
||||||
"};
|
"};
|
||||||
|
|
||||||
const unsigned ${result}_keyword_count = DIM( ${result}_keywords );
|
const unsigned ${result}_keyword_count = DIM( ${result}_keywords );
|
||||||
|
|
|
@ -93,16 +93,25 @@ set(PCB_COMMON_SRCS
|
||||||
add_library(pcbcommon ${PCB_COMMON_SRCS})
|
add_library(pcbcommon ${PCB_COMMON_SRCS})
|
||||||
|
|
||||||
# auto-generate netlist_lexer.h and netlist_keywords.cpp
|
# auto-generate netlist_lexer.h and netlist_keywords.cpp
|
||||||
|
set( inputFile ${CMAKE_CURRENT_SOURCE_DIR}/netlist.keywords )
|
||||||
|
set( outHeaderFile ${PROJECT_SOURCE_DIR}/include/netlist_lexer.h )
|
||||||
|
set( outCppFile ${CMAKE_CURRENT_SOURCE_DIR}/netlist_keywords.cpp )
|
||||||
|
set( enum NL_T )
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/netlist_lexer.h
|
OUTPUT ${outHeaderFile}
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/netlist_keywords.cpp
|
${outCppFile}
|
||||||
COMMAND ${CMAKE_COMMAND}
|
COMMAND ${CMAKE_COMMAND}
|
||||||
-Denum=NL_T
|
-Denum=${enum}
|
||||||
-DinputFile=${CMAKE_CURRENT_SOURCE_DIR}/netlist.keywords
|
-DinputFile=${inputFile}
|
||||||
|
-DoutHeaderFile=${outHeaderFile}
|
||||||
|
-DoutCppFile=${outCppFile}
|
||||||
-P ${CMAKE_MODULE_PATH}/TokenList2DsnLexer.cmake
|
-P ${CMAKE_MODULE_PATH}/TokenList2DsnLexer.cmake
|
||||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/netlist.keywords
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/netlist.keywords
|
||||||
COMMENT "creating ${CMAKE_CURRENT_SOURCE_DIR}/netlist_{lexer.h,keywords.cpp}
|
${CMAKE_MODULE_PATH}/TokenList2DsnLexer.cmake
|
||||||
from ${CMAKE_CURRENT_SOURCE_DIR}/netlist.keywords"
|
COMMENT "TokenList2DsnLexer.cmake creating:
|
||||||
|
${outHeaderFile} and
|
||||||
|
${outCppFile} from
|
||||||
|
${inputFile}"
|
||||||
)
|
)
|
||||||
|
|
||||||
# The dsntest may not build properly using MS Visual Studio.
|
# The dsntest may not build properly using MS Visual Studio.
|
||||||
|
|
|
@ -32,6 +32,7 @@ set(EESCHEMA_SRCS
|
||||||
class_text-label.cpp
|
class_text-label.cpp
|
||||||
classes_body_items.cpp
|
classes_body_items.cpp
|
||||||
cleanup.cpp
|
cleanup.cpp
|
||||||
|
cmp_library_keywords.cpp
|
||||||
cmp_library_lexer.cpp
|
cmp_library_lexer.cpp
|
||||||
controle.cpp
|
controle.cpp
|
||||||
cross-probing.cpp
|
cross-probing.cpp
|
||||||
|
@ -154,35 +155,50 @@ if(APPLE)
|
||||||
set(MACOSX_BUNDLE_GUI_IDENTIFIER org.kicad-eda.eeschema)
|
set(MACOSX_BUNDLE_GUI_IDENTIFIER org.kicad-eda.eeschema)
|
||||||
endif(APPLE)
|
endif(APPLE)
|
||||||
|
|
||||||
# Generate DSN lexer header and source files for the component library file
|
|
||||||
# format.
|
# auto-generate cmp_library_lexer.h and cmp_library_keywords.cpp for the component
|
||||||
|
# library format.
|
||||||
|
set( inputFile ${CMAKE_CURRENT_SOURCE_DIR}/cmp_library.keywords )
|
||||||
|
set( outHeaderFile ${CMAKE_CURRENT_SOURCE_DIR}/cmp_library_lexer.h )
|
||||||
|
set( outCppFile ${CMAKE_CURRENT_SOURCE_DIR}/cmp_library_keywords.cpp )
|
||||||
|
set( enum TLIB_T )
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/cmp_library_lexer.h
|
OUTPUT ${outHeaderFile}
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/cmp_library_keywords.cpp
|
${outCppFile}
|
||||||
COMMAND ${CMAKE_COMMAND}
|
COMMAND ${CMAKE_COMMAND}
|
||||||
-DinputFile=${CMAKE_CURRENT_SOURCE_DIR}/cmp_library.keywords
|
-Denum=${enum}
|
||||||
|
-DinputFile=${inputFile}
|
||||||
|
-DoutHeaderFile=${outHeaderFile}
|
||||||
|
-DoutCppFile=${outCppFile}
|
||||||
-P ${CMAKE_MODULE_PATH}/TokenList2DsnLexer.cmake
|
-P ${CMAKE_MODULE_PATH}/TokenList2DsnLexer.cmake
|
||||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/cmp_library.keywords
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/cmp_library.keywords
|
||||||
COMMENT "creating ${CMAKE_CURRENT_SOURCE_DIR}/cmp_library_{lexer.h,keywords.cpp}
|
${CMAKE_MODULE_PATH}/TokenList2DsnLexer.cmake
|
||||||
from ${CMAKE_CURRENT_SOURCE_DIR}/cmp_library.keywords"
|
COMMENT "TokenList2DsnLexer.cmake creating:
|
||||||
)
|
${outHeaderFile} and
|
||||||
|
${outCppFile} from
|
||||||
set_source_files_properties( cmp_library_lexer.cpp
|
${inputFile}"
|
||||||
PROPERTIES
|
|
||||||
OBJECT_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/cmp_library_lexer.h
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
set( inputFile ${CMAKE_CURRENT_SOURCE_DIR}/template_fieldnames.keywords )
|
||||||
|
set( outHeaderFile ${CMAKE_CURRENT_SOURCE_DIR}/template_fieldnames_lexer.h )
|
||||||
|
set( outCppFile ${CMAKE_CURRENT_SOURCE_DIR}/template_fieldnames_keywords.cpp )
|
||||||
|
set( enum TFIELD_T )
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/template_fieldnames_lexer.h
|
OUTPUT ${outHeaderFile}
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/template_fieldnames_keywords.cpp
|
${outCppFile}
|
||||||
COMMAND ${CMAKE_COMMAND}
|
COMMAND ${CMAKE_COMMAND}
|
||||||
-Denum=TFIELD_T
|
-Denum=${enum}
|
||||||
-DinputFile=${CMAKE_CURRENT_SOURCE_DIR}/template_fieldnames.keywords
|
-DinputFile=${inputFile}
|
||||||
|
-DoutHeaderFile=${outHeaderFile}
|
||||||
|
-DoutCppFile=${outCppFile}
|
||||||
-P ${CMAKE_MODULE_PATH}/TokenList2DsnLexer.cmake
|
-P ${CMAKE_MODULE_PATH}/TokenList2DsnLexer.cmake
|
||||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/template_fieldnames.keywords
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/cmp_library.keywords
|
||||||
COMMENT "creating ${CMAKE_CURRENT_SOURCE_DIR}/template_fieldnames_{lexer.h,keywords.cpp}
|
${CMAKE_MODULE_PATH}/TokenList2DsnLexer.cmake
|
||||||
from ${CMAKE_CURRENT_SOURCE_DIR}/template_fieldnames.keywords"
|
COMMENT "TokenList2DsnLexer.cmake creating:
|
||||||
|
${outHeaderFile} and
|
||||||
|
${outCppFile} from
|
||||||
|
${inputFile}"
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(eeschema WIN32 MACOSX_BUNDLE ${EESCHEMA_SRCS} ${EESCHEMA_EXTRA_SRCS}
|
add_executable(eeschema WIN32 MACOSX_BUNDLE ${EESCHEMA_SRCS} ${EESCHEMA_EXTRA_SRCS}
|
||||||
|
|
|
@ -3,4 +3,4 @@
|
||||||
* library file DSN lexer which will replace the current library and library
|
* library file DSN lexer which will replace the current library and library
|
||||||
* document file formats.
|
* document file formats.
|
||||||
*/
|
*/
|
||||||
#include "cmp_library_keywords.cpp"
|
#include "cmp_library_lexer.h"
|
||||||
|
|
Loading…
Reference in New Issue