# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import xml.etree.ElementTree as ET import os from Common import get_project_name proj_name = get_project_name() from Common import indexFiles sourceList, _, __ = \ indexFiles('../src/' + proj_name + '/', ['.cpp', '.hpp'], ['deprecated/']) projectFilename = '../ide/Codelite/Codelite.project' sourceRootRelativePath = '../../src/' + proj_name + '/' projectEtree = ET.parse(projectFilename) projectRoot = projectEtree.getroot() virtualDirs = projectRoot.findall('VirtualDirectory') myprojectVirtualDir = None for virtualDir in virtualDirs: if virtualDir.get('Name') == proj_name: myprojectVirtualDir = virtualDir break if not myprojectVirtualDir: myprojectVirtualDir = ET.SubElement(projectRoot, 'VirtualDirectory')
def generate(destination, sourceList): addQuotes(sourceList) replacements = {} replacements[sourceListVector] = sourceList writeWithReplacements(boilerplateFilename, destination, replacements) def add_thirdparty(sourceList): thirdparty_sl, thirdparty_dl, _ = indexFiles( \ '../src/thirdparty/', ['.cpp', '.c', '.cc'], [], False) for source in thirdparty_sl: sourceList.append('../thirdparty/' + source) # Generate for main sources sourceList, dirList, _ = indexFiles( \ '../src/' + proj_name + '/', ['.cpp'], ['deprecated/', 'test/'], False) sourceList.append('Main.cpp') add_thirdparty(sourceList) sourceList.sort() print('Main Sources: ' + str(len(sourceList))) print('Main Directories: ' + str(len(dirList))) generate('../cmake/MainSrcList.cmake', sourceList) # Generate for test sources sourceList, dirList, _ = indexFiles( \ '../src/' + proj_name + '/', ['.cpp'], ['deprecated/'], False) sourceList.append('Test.cpp') add_thirdparty(sourceList) sourceList.sort() print('Test Sources: ' + str(len(sourceList))) print('Test Directories: ' + str(len(dirList)))
def add_thirdparty(sourceList): thirdparty_sl, thirdparty_dl, _ = indexFiles( \ '../src/thirdparty/', ['.cpp', '.c', '.cc'], [], False) for source in thirdparty_sl: sourceList.append('../thirdparty/' + source)
# distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import os from Common import get_project_name proj_name = get_project_name() searchPath = '../src/' + proj_name + '/' includePrefix = proj_name + '/' from Common import indexFiles headerFnames, _, _ = indexFiles(searchPath, ['.hpp'], []) import re ifndefPattern = re.compile('\s*#ifndef\s+(\S*)\s*') definePattern = re.compile('\s*#define\s+(\S*)\s*') endifPattern = re.compile('\s*#endif\s+//\s*(\S*)\s*') def makeGuardFromFname(fname): fname = fname.upper().replace('_', '').replace('.', '_').replace('/', '_') fname = ''.join(c for c in fname if c in \ 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_') return fname
# You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import xml.etree.ElementTree as ET import os from Common import indexFiles sourceList, _, __ = \ indexFiles('../src/pegr/', ['.cpp'], ['deprecated/']) includeList, _, __ = \ indexFiles('../src/pegr/', ['.hpp'], ['deprecated/']) projFilename = '../ide/VS/VS.vcxproj' filtFilename = '../ide/VS/VS.vcxproj.filters' sourceRootRelativePath = '../../src/pegr/' def convertToProjectPath(path): return os.path.join(sourceRootRelativePath, path).replace('/', '\\') sourceList = \ [(convertToProjectPath(source), source) for source in sourceList] includeList = \ [(convertToProjectPath(include), include) for include in includeList]
# Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import os from Common import indexFiles from Common import writeWithReplacements from Common import get_project_name dirListVector = '### DIRECTORY LIST ###' boilerplateFilename = 'IncludeListBoilerplate.cmake' def addQuotesAndPrefix(list): for i in range(len(list)): list[i] = '"thirdparty/' + str(list[i]) + '"' def generate(destination, dirList): addQuotesAndPrefix(dirList) replacements = {} replacements[dirListVector] = dirList writeWithReplacements(boilerplateFilename, destination, replacements) # Generate for main sources _, dirList, __ = indexFiles('../src/thirdparty/', \ [''], [], False, 1) dirList.sort() print('Third-party Projects: ' + str(len(dirList))) generate('../cmake/IncludesList.cmake', dirList)
import os from Common import indexFiles from Common import writeWithReplacements from Common import get_project_name proj_name = get_project_name() luasListVector = '/*### LUA TESTS LIST ###*/' cppsListVector = '/*### TESTS LIST ###*/' cppsFwdDeclVector = '/*### TESTS FWD ###*/' boilerplateFilename = 'TestsBoilerplate.hpp' outputFilename = '../src/' + proj_name + '/test/Tests.hpp' cppSourcesDir = '../src/' + proj_name + '/test/' luaSourcesDir = '../run/test/tests/' cppsFiles, _, __ = indexFiles(cppSourcesDir, ['.cpp'], [], True) luasFiles, _, __ = indexFiles(luaSourcesDir, ['.lua'], [], True) import re patternCppTestAnnot = re.compile('\s*//@Test\s+(.*)') patternCppFunc = re.compile('\s*void\s+(\S+)\s*\(\s*\).*') patternLuaNameAnnot = re.compile('--@Name\s+(.*)') cppFuncs = {} for item in cppsFiles: filename = cppSourcesDir + item with open(filename, 'r') as sourceFile: annotName = None for line in sourceFile:
# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import os searchPath = '../src/pegr/' includePrefix = 'pegr/' from Common import indexFiles headerFnames, _, filenameToPath = \ indexFiles(searchPath, ['.hpp', '.cpp'], []) lowercaseFnameToPath = {} for filename, path in filenameToPath.items(): lowercaseFnameToPath[filename.lower()] = path filenameToPath = lowercaseFnameToPath import re includePattern = re.compile('#include\s+["<](\S*)[">]') for headerFname in headerFnames: with open(searchPath + headerFname, 'r') as headerFile: headerLines = headerFile.readlines() changesMade = False