From 969f271e946a4306a2364eba809cb091287fd1b1 Mon Sep 17 00:00:00 2001 From: hoijui Date: Thu, 18 Nov 2010 12:19:30 +0100 Subject: [PATCH 01/10] ensure new-line at end of native source files [minor] --- builder/templates/callback.c | 2 +- builder/templates/command_wrapper.c | 2 +- builder/templates/create_command.c | 2 +- builder/templates/event_wrapper.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/builder/templates/callback.c b/builder/templates/callback.c index 4b8a206..bf1fa95 100644 --- a/builder/templates/callback.c +++ b/builder/templates/callback.c @@ -63,4 +63,4 @@ static PyTypeObject PyAICallback_Type = { 0, /* tp_iter */ 0, /* tp_iternext */ callback_methods, /* tp_methods */ -}; \ No newline at end of file +}; diff --git a/builder/templates/command_wrapper.c b/builder/templates/command_wrapper.c index 69533dc..09a1145 100644 --- a/builder/templates/command_wrapper.c +++ b/builder/templates/command_wrapper.c @@ -41,4 +41,4 @@ command_reverse(int topic, void* data) {% endfor %} } return Py_None; -} \ No newline at end of file +} diff --git a/builder/templates/create_command.c b/builder/templates/create_command.c index 38d0292..87f1f0e 100644 --- a/builder/templates/create_command.c +++ b/builder/templates/create_command.c @@ -20,4 +20,4 @@ (({{structname}}*)data)->{{member}} = *(build_SAIFloat3(PyDict_GetItemString(command, "{{member}}"))); {% endif %} -{% endfor %} \ No newline at end of file +{% endfor %} diff --git a/builder/templates/event_wrapper.c b/builder/templates/event_wrapper.c index 57ce696..e98fb11 100644 --- a/builder/templates/event_wrapper.c +++ b/builder/templates/event_wrapper.c @@ -9,4 +9,4 @@ event_convert(int topic, void* data) } return NULL; } -/* End Event Wrapper */ \ No newline at end of file +/* End Event Wrapper */ From c2d07364bbf9083e6f451339e7df41123e8ce76d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20L=C3=B6scher?= Date: Mon, 1 Aug 2011 15:57:06 +0200 Subject: [PATCH 02/10] I started a new implementation of the Python AI interface with the use of regular expressions matching the current interface. The old interface was not compatible anymore. regex.py: contains all regular expressions to extract the neccesary informations out of the header files --- builder/regex.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 builder/regex.py diff --git a/builder/regex.py b/builder/regex.py new file mode 100644 index 0000000..78a33f6 --- /dev/null +++ b/builder/regex.py @@ -0,0 +1,20 @@ +import re + +### CATCH Functions +# Return Type, Function Name, Argumentlist +CALLBACK_FUNCTIONS = re.compile("([_ ,a-zA-Z0-9\*]+)\(CALLING_CONV ([\*a-zA-Z_0-9]+)\)\(([^\)]+)\);") + +### CATCH Arguments +# done via str.split(",") no regex needed + + +### CATCH Enums +# enum name, enum values +ENUMS = re.compile("enum ([a-zA-Z]+) \{([a-zA-Z0-9=,\n\t _]+)\};") + +### CATCH Enum values +# Name, Value +ENUM_VALUES = re.compile("([A-Z_]+)[ \t]+=[ \t]+([0-9]+),") + +### CATCH Structs +STRUCTS = re.compile("struct [^ ]+ \{[^\}]+\}; //\$ [A-Z_]+") \ No newline at end of file From e58de0f255a3023cb827120bcf5de66ba80d0ad9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20L=C3=B6scher?= Date: Wed, 10 Aug 2011 15:59:19 +0200 Subject: [PATCH 03/10] parser updated to work now with regular expressions --- builder/callback_parser.py | 146 +++++-------------------------------- 1 file changed, 17 insertions(+), 129 deletions(-) diff --git a/builder/callback_parser.py b/builder/callback_parser.py index 4d2d5e2..a71a475 100644 --- a/builder/callback_parser.py +++ b/builder/callback_parser.py @@ -20,6 +20,7 @@ # from helper import normstring, joinstrings +import regex, re def buildcall(funcname, args, rettype): BEGIN_THREADS="PyGILState_STATE state = PyGILState_Ensure();\n" @@ -138,138 +139,25 @@ def buildcall(funcname, args, rettype): def getcallback_functions(filename): f=open(filename, "r") - line = "" # line to be processed - skipnext=False # are we in an unfinished multiline comment? - retval= {} # return value - plainlist = {} + stream = f.read() - for actline in f.readlines(): - # ignore exter "c"{ - if 'extern "C"' in actline: - continue + ouput = re.findall(regex.CALLBACK_FUNCTIONS, stream) - # ignore lines starting with defines - if ("#" in actline): - continue - - # skip /* */ comments - cont=False # continue after while loop? - while (1): # for cases where "/* com */ /* com */"in one line - if not skipnext and "/*" in actline: - skipnext=True - cont=True - if skipnext and "*/" in actline: - skipnext=False - i = actline.find("*/") - actline=actline[(i+2):] - if skipnext: - cont=True - break - break - if cont: - cont=False - continue - - # remove // comments - if "//" in actline: - i = actline.find("//") - actline = actline[:i] + functionData = {} + functionCalls = {} - # ignore struct define line - if ("struct" in actline) and ("SSkirmishAICallback" in actline): - continue + for retType, functionName, arguments in output: + # build a list of tuples from the arguments string + # [(name, type), (name, type), ...] + argumentList = arguments.split(",") + retType = retType.strip() + for i, argument in enumerate(argumentList): + argType, argName = argument.strip().rsplit(" ", 1) + argumentList[i] = (argType, argName) - # join lines to one statement (in this case function definition in struct) - if actline.find(";")>0: - line+=actline - else: - line = line[:-1] if line.endswith("\n") else line - line = line+actline - continue - - # split lines on CALLING_CONV - # first thing before CALLING_CONV is return type - i=line.find("(CALLING_CONV") - rettype = line[:i].strip() - - # first thing after CALLING_CONV is function name - remains = line[(i+len("(CALLING_CONV")):] - i=remains.find("(") - funcname = remains[:i].strip()[1:-1] - - # the stuff in the brakets after the function name are the - # arguments with types - remains = remains[i+1:] - remains = normstring(remains[:remains.find(")")]) - args = remains.split(",") - arglist = [] + call = buildcall(functionName, argumentList, retType) - for arg in args: - aa=arg.strip().split(" ") - key = aa[-1] - value = joinstrings(aa[:-1]) - #if "[]" in key: - #key=key.replace("[]", " ") - #value+="*" - arglist.append((key, value)) - - plainlist[funcname]=(retval, arglist) - - call, reverse = buildcall(funcname, arglist, rettype) - - if not reverse: - retbuild = "" - if "int" in rettype: - retbuild = "Py_BuildValue(\"i\", retval)" - elif "char" in rettype: - retbuild = "Py_BuildValue(\"s\", retval)" - elif "float" in rettype: - retbuild = "Py_BuildValue(\"f\", retval)" - elif "bool" in rettype: - retbuild = "Py_BuildValue(\"i\", (int)retval)" - elif "SAIFloat3" in rettype: - retbuild = "Py_BuildValue(\"O\", convert_SAIFloat3(&retval))" - else: - retbuild = "Py_None" - call +="return "+retbuild+";" - else: - ptype, pname, size = reverse - if "command_reverse" in pname: - # special case: command struct my return a value - call += "PyObject *pyreturn="+pname+";\n" - call += "FREE(commandData);\n" - call += "return pyreturn;" - else: - # an array was filled and the amount of data is given in the return value - # in this case do not give back the size of the array but convert everything into - # alist and return the list - if not "MAP" in funcname: - listsize = "retval" - else: - listsize = str(size) - - if ptype=="float": - builditem="PyFloat_FromDouble(" - elif ptype=="int" or ptype=="unsigned short" or ptype=="unsigned char": - builditem="PyInt_FromLong(" - elif ptype=="const char*": - builditem="PyString_FromString(" - elif ptype=="struct SAIFloat3*": - builditem="convert_SAIFloat3(&" - else: - raw_input("error: "+ptype+call) - - prelude = "PyObject* list;\nint i;\n" - postlude = "list = PyList_New("+listsize+");\n" - postlude += "for (i=0;i<"+listsize+";i++) PyList_SetItem(list, i, "+builditem+pname+"[i]));\n" - postlude += "FREE("+pname+");\n" - postlude += "return list;" - call = prelude + call + postlude - - if funcname: - retval[funcname]=call - - # reset line - line="" - return retval, plainlist + functionCalls[functionName] = call + functionData[functionName] = (functionName, argumentList, retType) + return functionCalls, functionData \ No newline at end of file From df6e5dfe2e18262194090ec8df75b9bdb7f01203 Mon Sep 17 00:00:00 2001 From: abma Date: Wed, 10 Aug 2011 17:17:11 +0200 Subject: [PATCH 04/10] fix typo --- builder/callback_parser.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/builder/callback_parser.py b/builder/callback_parser.py index a71a475..1b0ca52 100644 --- a/builder/callback_parser.py +++ b/builder/callback_parser.py @@ -143,6 +143,7 @@ def getcallback_functions(filename): ouput = re.findall(regex.CALLBACK_FUNCTIONS, stream) + output = re.findall(regex.CALLBACK_FUNCTIONS, stream) functionData = {} functionCalls = {} @@ -160,4 +161,5 @@ def getcallback_functions(filename): functionCalls[functionName] = call functionData[functionName] = (functionName, argumentList, retType) - return functionCalls, functionData \ No newline at end of file + return functionCalls, functionData + From c064c0d8351675aa812a7304d2535ba99ab7aeeb Mon Sep 17 00:00:00 2001 From: abma Date: Thu, 8 Nov 2012 05:21:50 +0100 Subject: [PATCH 05/10] slightly improve regex --- builder/regex.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/builder/regex.py b/builder/regex.py index 78a33f6..279aa99 100644 --- a/builder/regex.py +++ b/builder/regex.py @@ -2,7 +2,7 @@ ### CATCH Functions # Return Type, Function Name, Argumentlist -CALLBACK_FUNCTIONS = re.compile("([_ ,a-zA-Z0-9\*]+)\(CALLING_CONV ([\*a-zA-Z_0-9]+)\)\(([^\)]+)\);") +CALLBACK_FUNCTIONS = re.compile("([_ ,a-zA-Z0-9\*]+)\(CALLING_CONV \*([a-zA-Z_0-9]+)\)\(([^\)]+)\);") ### CATCH Arguments # done via str.split(",") no regex needed @@ -17,4 +17,6 @@ ENUM_VALUES = re.compile("([A-Z_]+)[ \t]+=[ \t]+([0-9]+),") ### CATCH Structs -STRUCTS = re.compile("struct [^ ]+ \{[^\}]+\}; //\$ [A-Z_]+") \ No newline at end of file +STRUCTS = re.compile("struct [^ ]+ \{[^\}]+\}; //\$ [A-Z_]+[A-z\(\):, ]*") + + From 722eadb9c358951570968feb0f72c297364f5c9c Mon Sep 17 00:00:00 2001 From: abma Date: Thu, 8 Nov 2012 05:22:39 +0100 Subject: [PATCH 06/10] cleanup generator.py --- builder/generator.py | 49 +++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/builder/generator.py b/builder/generator.py index 71d8d17..640561b 100644 --- a/builder/generator.py +++ b/builder/generator.py @@ -22,8 +22,8 @@ import sys import os -from callback_parser import getcallback_functions -from event_parser import getevents, getcommands, parse_enums +import callback_parser +import event_parser from interface_builder import buildclasses, commandfuncs from helper import converter @@ -31,34 +31,36 @@ from template import Template -PATH = os.path.join("ExternalAI","Interface") -CALLBACKFILE = os.path.join(PATH,"SSkirmishAICallback.h") -EVENTFILE = os.path.join(PATH,"AISEvents.h") -COMMANDFILE = os.path.join(PATH, "AISCommands.h") +def makeabspath(prefix, headerfile): + return os.path.join(prefix, "ExternalAI","Interface", headerfile) + +CALLBACKFILE = "SSkirmishAICallback.h" +EVENTFILE = "AISEvents.h" +COMMANDFILE = "AISCommands.h" TEMPLATEDIR = None class Generator(object): def __init__(self, templatedir, springdir, outputdir, options=()): - self.templatedir=templatedir - self.springdir=springdir - self.outputdir=outputdir - - files = [CALLBACKFILE, EVENTFILE, COMMANDFILE] - for i, f in enumerate(files): - files[i]=os.path.join(springdir,f) + self.templatedir=templatedir + self.springdir=springdir + self.outputdir=outputdir + global CALLBACKFILE, EVENTFILE, COMMANDFILE + CALLBACKFILE = makeabspath(springdir, CALLBACKFILE) + EVENTFILE = makeabspath(springdir, EVENTFILE) + COMMANDFILE = makeabspath(springdir, COMMANDFILE) - self.clbfuncs, plainfuncs = getcallback_functions(files[0]) - self.classes= buildclasses(plainfuncs) - self.events = getevents(files[1]) - self.commands = getcommands(files[2]) - self.command_types = parse_enums(files[2]) - self.event_types = parse_enums(files[1]) - self.commandfuncs = commandfuncs(self.commands) - - - self.options = set(options) + self.clbfuncs, plainfuncs = callback_parser.getcallback_functions(CALLBACKFILE) + self.classes= buildclasses(plainfuncs) + self.events = event_parser.getevents(EVENTFILE) + self.commands = event_parser.getcommands(COMMANDFILE) + self.command_types = event_parser.parse_enums(COMMANDFILE) + self.event_types = event_parser.parse_enums(EVENTFILE) + self.commandfuncs = commandfuncs(self.commands) + + + self.options = set(options) def render(self): # render wrapper for handleEvent and callback functions @@ -107,3 +109,4 @@ def render(self): print "Generating Sources..." Generator(templatedir,springdir,outputdir).render() print "done" + From 2239e140fb279f5d8a1e3e470dc767d47a6edb7b Mon Sep 17 00:00:00 2001 From: abma Date: Thu, 8 Nov 2012 05:24:21 +0100 Subject: [PATCH 07/10] add .gitignore & fix include --- .gitignore | 5 +++++ builder/templates/wrappai.c | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..04e683c --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +*~ +/CMakeFiles +/Makefile +/cmake_install.cmake +/src-generated-builder diff --git a/builder/templates/wrappai.c b/builder/templates/wrappai.c index 08ac797..47ffde1 100644 --- a/builder/templates/wrappai.c +++ b/builder/templates/wrappai.c @@ -30,7 +30,6 @@ #include "CUtils/SharedLibrary.h" #include "ExternalAI/Interface/AISCommands.h" -#include "ExternalAI/Interface/SAIFloat3.h" #include "ExternalAI/Interface/AISEvents.h" #include "ExternalAI/Interface/SSkirmishAICallback.h" From 3bb68379372a1a7ccfdc1e3d5930a16da325867a Mon Sep 17 00:00:00 2001 From: Gajo Petrovic Date: Tue, 2 Oct 2018 23:23:59 +0900 Subject: [PATCH 08/10] cmake case changes --- CMakeLists.txt | 44 ++++++++++++++++++------------------- NullPythonAI/CMakeLists.txt | 2 +- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 112e76d..b06d5b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,9 +34,9 @@ # Native Skirmish AI configuration macro # This will be called from native AIs at AI/Skirmish/*/CMakeLists.txt. -macro (ConfigurePythonSkirmishAI) +macro (configure_python_skirmish_ai) set(myDir "${CMAKE_CURRENT_SOURCE_DIR}") - GetLastPathPart(dirName ${myDir}) + get_last_path_part(dirName ${myDir}) set(myName "${dirName}") set(mySourceDirRel "${${mySourceDirRel_var}}") # Common values are "" or "src" set(additionalSources ${${additionalSources_var}}) @@ -54,20 +54,20 @@ macro (ConfigurePythonSkirmishAI) # Compile and install if (BUILD_THIS_SKIRMISHAI) # Assemble meta data - GetVersionFromFile(myVersion "${myDir}/VERSION") + get_version_from_file(myVersion "${myDir}/VERSION") set(myTarget "${myName}") set(myInstLibsDir "${SKIRMISH_AI_LIBS}/${myName}/${myVersion}") set(myInstDataDir "${SKIRMISH_AI_DATA}/${myName}/${myVersion}") - MakeAbsolute(mySourceDir "${myDir}" "${mySourceDirRel}") + make_absolute(mySourceDir "${myDir}" "${mySourceDirRel}") - SkirmishAIMessage(STATUS "Found Skirmish AI: ${myName} ${myVersion}") + skirmish_ai_message(STATUS "Found Skirmish AI: ${myName} ${myVersion}") # Install the data files install(DIRECTORY "${myDir}/data/" DESTINATION ${myInstDataDir}) install(DIRECTORY "${myDir}/src/" DESTINATION ${myInstDataDir} FILES_MATCHING PATTERN REGEX ".*\\.py$") # Install the library endif (BUILD_THIS_SKIRMISHAI) -endmacro (ConfigurePythonSkirmishAI) +endmacro (configure_python_skirmish_ai) ### END: MACROS_AND_FUNCTIONS ################################################################################ @@ -90,22 +90,22 @@ if (AI_TYPES_PYTHON AND myName MATCHES "${AI_EXCLUDE_REGEX}") endif (AI_TYPES_PYTHON AND myName MATCHES "${AI_EXCLUDE_REGEX}") -FIND_PACKAGE(PythonInterp) -FIND_PACKAGE(PythonLibs) +find_package(PythonInterp) +find_package(PythonLibs) # Check dependencies of the interface are met if (PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND AND AI_TYPES_PYTHON) - SetGlobal(BUILD_PYTHON_AIINTERFACE TRUE) + set_global(BUILD_PYTHON_AIINTERFACE TRUE) else (PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND AND AI_TYPES_PYTHON) - SetGlobal(BUILD_PYTHON_AIINTERFACE FALSE) + set_global(BUILD_PYTHON_AIINTERFACE FALSE) message ("warning: Python AI Interface will not be built!") endif (PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND AND AI_TYPES_PYTHON) # Build if (BUILD_PYTHON_AIINTERFACE) - GetVersionFromFile(myVersion ${myDir}/VERSION) + get_version_from_file(myVersion ${myDir}/VERSION) - INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH}) + include_directories(${PYTHON_INCLUDE_PATH}) set(myTarget "${myName}-AIInterface") set(myNullPython "NullPythonAI") set(myInstLibsDir ${AI_INTERFACES_LIBS}/${myName}/${myVersion}) @@ -115,13 +115,13 @@ if (BUILD_PYTHON_AIINTERFACE) set(myBuilderDir "${CMAKE_CURRENT_BINARY_DIR}/src-generated-builder") set(engineHeadersDir "${CMAKE_SOURCE_DIR}/rts/ExternalAI/Interface") - MakeAbsolute(mySourceDir "${myDir}" "${mySourceDirRel}") + make_absolute(mySourceDir "${myDir}" "${mySourceDirRel}") - AIInterfaceMessage(STATUS "Found AI Interface: ${myTarget} ${myVersion}") - AIInterfaceMessage(STATUS "Found Skirmish AI: ${myNullPython} ${myVersion}") # SkirmishAIMessage() not defined here + ai_interface_message(STATUS "Found AI Interface: ${myTarget} ${myVersion}") + ai_interface_message(STATUS "Found Skirmish AI: ${myNullPython} ${myVersion}") # skirmish_ai_message() not defined here - SetGlobal(PYTHON_AIINTERFACE_VERS ${myVersion}) - SetGlobal(PYTHON_AIINTERFACE_TARGET ${myTarget}) + set_global(PYTHON_AIINTERFACE_VERS ${myVersion}) + set_global(PYTHON_AIINTERFACE_TARGET ${myTarget}) set(builderFiles "template/__init__.py" "template/context.py" @@ -141,10 +141,10 @@ if (BUILD_PYTHON_AIINTERFACE) "generator.py" "event_parser.py" "callback_parser.py") - FOREACH (FILE ${builderFiles}) + foreach (FILE ${builderFiles}) list (APPEND myGeneratedFilesSourceDir "builder/${FILE}") list (APPEND myGeneratedFilesmyBuilderDir "${myBuilderDir}/${FILE}") - ENDFOREACH(FILE) + endforeach(FILE) set(myGenerateFiles ${myGeneratedFilesmyBuilderDir} "${engineHeadersDir}/SSkirmishAICallback.h" @@ -172,14 +172,14 @@ if (BUILD_PYTHON_AIINTERFACE) OUTPUT "${myGeneratedDir}/PyAI/interface.py" DEPENDS ${myGenerateFiles} ) - SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "src/ai.c;src/PyAI/interface.py") + set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "src/ai.c;src/PyAI/interface.py") set_source_files_properties("${myGeneratedDir}/ai.c" PROPERTIES GENERATED TRUE) set_source_files_properties(${myGeneratedFilesmyBuilderDir} PROPERTIES GENERATED TRUE) aux_source_directory(${mySourceDir} mySources) - INCLUDE_DIRECTORIES(${mySourceDir}) + include_directories(${mySourceDir}) add_library(${myTarget} MODULE ${mySources} ${ai_common_SRC} ${CUtils_SRC} "${myGeneratedDir}/ai.c") - FixLibName(${myTarget}) + fix_lib_name(${myTarget}) set_target_properties(${myTarget} PROPERTIES OUTPUT_NAME "AIInterface") diff --git a/NullPythonAI/CMakeLists.txt b/NullPythonAI/CMakeLists.txt index 6247f82..bf72658 100644 --- a/NullPythonAI/CMakeLists.txt +++ b/NullPythonAI/CMakeLists.txt @@ -1,4 +1,4 @@ ### Generic Python Skirmish AI config # -ConfigurePythonSkirmishAI() +configure_python_skirmish_ai() From e16a712341c1e0288000fcf0f0c2bbdcf40db2fe Mon Sep 17 00:00:00 2001 From: abma Date: Sun, 9 Jan 2022 12:52:43 +0100 Subject: [PATCH 09/10] fix some cmakelint warnings --- CMakeLists.txt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b06d5b9..6f1e519 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,10 +46,10 @@ macro (configure_python_skirmish_ai) # Check if the user wants to compile the AI if (BUILD_PYTHON_AIINTERFACE AND NOT myName MATCHES "${AI_EXCLUDE_REGEX}") set(BUILD_THIS_SKIRMISHAI TRUE) - else (BUILD_PYTHON_AIINTERFACE AND NOT myName MATCHES "${AI_EXCLUDE_REGEX}") + else () set(BUILD_THIS_SKIRMISHAI FALSE) message("warning: ${myName} Skirmish AI will not be built!") - endif (BUILD_PYTHON_AIINTERFACE AND NOT myName MATCHES "${AI_EXCLUDE_REGEX}") + endif () # Compile and install if (BUILD_THIS_SKIRMISHAI) @@ -66,7 +66,7 @@ macro (configure_python_skirmish_ai) install(DIRECTORY "${myDir}/data/" DESTINATION ${myInstDataDir}) install(DIRECTORY "${myDir}/src/" DESTINATION ${myInstDataDir} FILES_MATCHING PATTERN REGEX ".*\\.py$") # Install the library - endif (BUILD_THIS_SKIRMISHAI) + endif () endmacro (configure_python_skirmish_ai) ### END: MACROS_AND_FUNCTIONS @@ -81,13 +81,13 @@ set(mySourceDirRel "src") # Check if the user wants to compile the interface if ("${AI_TYPES}" STREQUAL "ALL" OR "${AI_TYPES}" STREQUAL "PYTHON") set(AI_TYPES_PYTHON TRUE) -else ("${AI_TYPES}" STREQUAL "ALL" OR "${AI_TYPES}" STREQUAL "PYTHON") +else () set(AI_TYPES_PYTHON FALSE) -endif ("${AI_TYPES}" STREQUAL "ALL" OR "${AI_TYPES}" STREQUAL "PYTHON") +endif () if (AI_TYPES_PYTHON AND myName MATCHES "${AI_EXCLUDE_REGEX}") set(AI_TYPES_PYTHON FALSE) -endif (AI_TYPES_PYTHON AND myName MATCHES "${AI_EXCLUDE_REGEX}") +endif () find_package(PythonInterp) @@ -96,10 +96,10 @@ find_package(PythonLibs) # Check dependencies of the interface are met if (PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND AND AI_TYPES_PYTHON) set_global(BUILD_PYTHON_AIINTERFACE TRUE) -else (PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND AND AI_TYPES_PYTHON) +else () set_global(BUILD_PYTHON_AIINTERFACE FALSE) message ("warning: Python AI Interface will not be built!") -endif (PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND AND AI_TYPES_PYTHON) +endif () # Build if (BUILD_PYTHON_AIINTERFACE) @@ -194,4 +194,4 @@ if (BUILD_PYTHON_AIINTERFACE) install(DIRECTORY "${myDir}/${myNullPython}/src/" DESTINATION "${myInstAIDir}" FILES_MATCHING PATTERN REGEX ".*\\.py$") install(DIRECTORY "${myDir}/${myNullPython}/data/" DESTINATION "${myInstAIDir}" FILES_MATCHING PATTERN REGEX ".*\\.lua$") -endif (BUILD_PYTHON_AIINTERFACE) +endif () From b69a4ea06bb780d68b5934d5d6ce1b93a684514b Mon Sep 17 00:00:00 2001 From: abma Date: Sun, 9 Jan 2022 16:06:45 +0100 Subject: [PATCH 10/10] more cmake-lint warnings --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f1e519..61c8e10 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,7 +67,7 @@ macro (configure_python_skirmish_ai) install(DIRECTORY "${myDir}/src/" DESTINATION ${myInstDataDir} FILES_MATCHING PATTERN REGEX ".*\\.py$") # Install the library endif () -endmacro (configure_python_skirmish_ai) +endmacro () ### END: MACROS_AND_FUNCTIONS ################################################################################ @@ -144,7 +144,7 @@ if (BUILD_PYTHON_AIINTERFACE) foreach (FILE ${builderFiles}) list (APPEND myGeneratedFilesSourceDir "builder/${FILE}") list (APPEND myGeneratedFilesmyBuilderDir "${myBuilderDir}/${FILE}") - endforeach(FILE) + endforeach () set(myGenerateFiles ${myGeneratedFilesmyBuilderDir} "${engineHeadersDir}/SSkirmishAICallback.h"