Skip to content

Commit

Permalink
add sc_report.hpp to source files.
Browse files Browse the repository at this point in the history
A bit of PEP8 for source file synchronize. python3 ready.
  • Loading branch information
scamille committed Sep 9, 2015
1 parent 730d5d4 commit 5224660
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 94 deletions.
3 changes: 2 additions & 1 deletion source_files/QT_engine.pri
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file is automatically generated by synchronize.py
# To change the list of source files, update the QT_ files and run D:\dev\git\simulationcraft\source_files\synchronize.py
# To change the list of source files, update the QT_ files and run synchronize.py


HEADERS += engine/util/xml.hpp
Expand All @@ -12,6 +12,7 @@
HEADERS += engine/util/generic.hpp
HEADERS += engine/util/concurrency.hpp
HEADERS += engine/util/cache.hpp
HEADERS += engine/report/sc_report.hpp
HEADERS += engine/dbc/generated/specialization.hpp
HEADERS += engine/dbc/dbc.hpp
PRECOMPILED_HEADER += engine/simulationcraft.hpp
Expand Down
2 changes: 1 addition & 1 deletion source_files/QT_engine_main.pri
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file is automatically generated by synchronize.py
# To change the list of source files, update the QT_ files and run D:\dev\git\simulationcraft\source_files\synchronize.py
# To change the list of source files, update the QT_ files and run synchronize.py


SOURCES += engine/sc_main.cpp
2 changes: 1 addition & 1 deletion source_files/QT_gui.pri
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file is automatically generated by synchronize.py
# To change the list of source files, update the QT_ files and run D:\dev\git\simulationcraft\source_files\synchronize.py
# To change the list of source files, update the QT_ files and run synchronize.py


HEADERS += qt/util/sc_textedit.hpp
Expand Down
3 changes: 2 additions & 1 deletion source_files/VS_engine.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!--
This file is automatically generated by synchronize.py
To change the list of source files, update the QT_ files and run D:\dev\git\simulationcraft\source_files\synchronize.py
To change the list of source files, update the QT_ files and run synchronize.py
-->

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
Expand All @@ -15,6 +15,7 @@ To change the list of source files, update the QT_ files and run D:\dev\git\simu
<ClInclude Include="..\engine\util\generic.hpp" />
<ClInclude Include="..\engine\util\concurrency.hpp" />
<ClInclude Include="..\engine\util\cache.hpp" />
<ClInclude Include="..\engine\report\sc_report.hpp" />
<ClInclude Include="..\engine\dbc\generated\specialization.hpp" />
<ClInclude Include="..\engine\dbc\dbc.hpp" />
<ClInclude Include="..\engine\simulationcraft.hpp" />
Expand Down
2 changes: 1 addition & 1 deletion source_files/VS_engine_main.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!--
This file is automatically generated by synchronize.py
To change the list of source files, update the QT_ files and run D:\dev\git\simulationcraft\source_files\synchronize.py
To change the list of source files, update the QT_ files and run synchronize.py
-->

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
Expand Down
2 changes: 1 addition & 1 deletion source_files/VS_gui.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!--
This file is automatically generated by synchronize.py
To change the list of source files, update the QT_ files and run D:\dev\git\simulationcraft\source_files\synchronize.py
To change the list of source files, update the QT_ files and run synchronize.py
-->

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
Expand Down
2 changes: 1 addition & 1 deletion source_files/engine_main_make
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file is automatically generated by synchronize.py
# To change the list of source files, update the QT_ files and run D:\dev\git\simulationcraft\source_files\synchronize.py
# To change the list of source files, update the QT_ files and run synchronize.py

SRC += \
sc_main.cpp \
3 changes: 2 additions & 1 deletion source_files/engine_make
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file is automatically generated by synchronize.py
# To change the list of source files, update the QT_ files and run D:\dev\git\simulationcraft\source_files\synchronize.py
# To change the list of source files, update the QT_ files and run synchronize.py

SRC += \
util$(PATHSEP)xml.hpp \
Expand All @@ -12,6 +12,7 @@ SRC += \
util$(PATHSEP)generic.hpp \
util$(PATHSEP)concurrency.hpp \
util$(PATHSEP)cache.hpp \
report$(PATHSEP)sc_report.hpp \
dbc$(PATHSEP)generated$(PATHSEP)specialization.hpp \
dbc$(PATHSEP)dbc.hpp \
simulationcraft.hpp \
Expand Down
173 changes: 87 additions & 86 deletions source_files/synchronize.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,135 +6,134 @@
# 3) output: reformatted, Qt, Visual Studio ( cli only ), POSIX Makefile

import re
import datetime
import sys
import os

def parse_qt( filename ):
f = open( filename, "r" )

def parse_qt(filename):
f = open(filename, "r")
out = []
if f:
for line in f:
match = re.search ( r"(\s*)(SOURCES|HEADERS|PRECOMPILED_HEADER)(\s*\+?\=\s*)([\w\/]*?)([\w]*)(\.\w*)", line )
match = re.search(r"(\s*)(SOURCES|HEADERS|PRECOMPILED_HEADER)(\s*\+?\=\s*)([\w\/]*?)([\w]*)(\.\w*)", line)
if match:
out.append( ( match.group(2), match.group(4) + match.group(5) + match.group(6), match.group(4), match.group(5), match.group(6) ) )
out.append((match.group(2), match.group(4) + match.group(5) + match.group(6), match.group(4), match.group(5), match.group(6)))
f.close()
return out


def header( system ):
def header(system):
if system == "VS":
h = "<!--\n"
else:
h = "# "
h += "This file is automatically generated by " + os.path.basename(__file__) + "\n"

# if system != "VS":
# h += "# "
# h += "Last updated: " + str(datetime.datetime.now() ) + "\n\n"

if system != "VS":
h += "# "
h += "To change the list of source files, update the QT_ files and run " + sys.argv[0]
h += "To change the list of source files, update the QT_ files and run " + os.path.basename(sys.argv[0])
if system == "VS":
h += "\n-->"
h += "\n\n"
return h

def write_to_file( filename, out ):
f = open( filename, "w" )

def write_to_file(filename, out):
f = open(filename, "w")
if f:
f.write( out )
f.write(out)
f.close()

def create_qt_str( input ):
prepare = header( "QT" )
for entry in input:

def create_qt_str(entries):
prepare = header("QT")
for entry in entries:
if entry[0] == "SOURCES" or entry[0] == "HEADERS" or entry[0] == "PRECOMPILED_HEADER":
prepare += "\n " + entry[0] + " += " + entry[1]
return prepare


def create_make_str( input ):
modified_input = replace( input, r"engine/", r"" )
modified_input = replace( modified_input , r"/" , r"$(PATHSEP)" )
prepare = header( "Makefile" )
def create_make_str(entries):
modified_input = replace(entries, r"engine/", r"")
modified_input = replace(modified_input, r"/", r"$(PATHSEP)")
prepare = header("Makefile")
prepare += "SRC += \\"
for entry in modified_input:
if entry[0] == "SOURCES" or entry[0] == "HEADERS":
prepare += "\n " + entry[1] + " \\"
return prepare


def VS_no_precompiled_header():
return "<PrecompiledHeader>NotUsing</PrecompiledHeader>"

# Determine what precompiled header setting to use
def VS_use_precompiled_header( filename ):
if re.search( r"sc_player.cpp", filename ):


def VS_use_precompiled_header(filename):
"""Determine what precompiled header setting to use"""
if re.search(r"sc_player.cpp", filename):
return "<PrecompiledHeader>Create</PrecompiledHeader>"
transformed_filename = re.sub( r"\\", "/", filename )
with open( transformed_filename ) as f:
content = f.read()
if re.search( r"#include \"simulationcraft.hpp\"", content ):
return "" #"<PrecompiledHeader />"
else:
transformed_filename = re.sub(r"\\", "/", filename)
with open(transformed_filename) as f:
content = f.read()
if re.search(r"#include \"simulationcraft.hpp\"", content):
return "" # "<PrecompiledHeader />"
else:
return VS_no_precompiled_header()
print "could not open file for precompiled header settings!"

print("could not open file for precompiled header settings!")
return ""

def VS_header_str( filename, gui ):
if gui:
moced_name = "moc_" + re.sub( r".*\\(.*?).hpp", r"\1.cpp", filename )
return "\n\t\t<ClCompile Include=\"$(IntDir)" + moced_name + "\">\n\t\t\t" + VS_no_precompiled_header() + "\n\t\t</ClCompile>"
else:
return "\n\t\t<ClInclude Include=\"" + filename + "\" />";

def create_vs_str( input, gui = False ):
modified_input = replace( input, r"^", r"..\\" )
modified_input = replace( modified_input , r"/" , r"\\" )
prepare = header( "VS" )


def VS_header_str(filename, gui):
if gui:
moced_name = "moc_" + re.sub(r".*\\(.*?).hpp", r"\1.cpp", filename)
return "\n\t\t<ClCompile Include=\"$(IntDir)" + moced_name + "\">\n\t\t\t" + VS_no_precompiled_header() + "\n\t\t</ClCompile>"
else:
return "\n\t\t<ClInclude Include=\"" + filename + "\" />"


def create_vs_str(entries, gui=False):
modified_input = replace(entries, r"^", r"..\\")
modified_input = replace(modified_input, r"/", r"\\")
prepare = header("VS")
prepare += """<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
\t<ItemGroup>"""
for entry in modified_input:
if re.search( r"sc_io.cpp", entry[1] ):
prepare += "\n\t\t<ClCompile Include=\"" + entry[1] + "\">\n\t\t\t" + VS_use_precompiled_header( entry[1] ) + "\n\t\t</ClCompile>"
if re.search(r"sc_io.cpp", entry[1]):
prepare += "\n\t\t<ClCompile Include=\"" + entry[1] + "\">\n\t\t\t" + VS_use_precompiled_header(entry[1]) + "\n\t\t</ClCompile>"
elif entry[0] == "HEADERS":
prepare += VS_header_str( entry[1], gui )
prepare += VS_header_str(entry[1], gui)
elif entry[0] == "SOURCES":
prepare += "\n\t\t<ClCompile Include=\"" + entry[1] + "\">\n\t\t\t" + VS_use_precompiled_header( entry[1] ) + "\n\t\t</ClCompile>"
prepare += "\n\t\t<ClCompile Include=\"" + entry[1] + "\">\n\t\t\t" + VS_use_precompiled_header(entry[1]) + "\n\t\t</ClCompile>"
prepare += "\n\t</ItemGroup>"

if gui:

# Gui Resources
prepare += "\n\n\t<!--Resources -->"
prepare += "\n\t<ItemGroup>"
prepare += "\n\t\t<ResourceCompile Include=\"..\simcqt.rc\" />"
prepare += "\n\t</ItemGroup>"

prepare += "\n\n"

# Moc Defines
prepare += "\t<!-- Moc Definitions -->"

prepare += "\n\t<PropertyGroup Label=\"UserMacros\" Condition=\"'$(Configuration)'=='Debug-WebKit'\">"
prepare += "\n\t\t<MOC_DEFINES>-DUNICODE -DWIN32 -DWIN64 -DSC_USE_WEBKIT -DQT_VERSION_5 -DQT_DECLARATIVE_DEBUG -DQT_WIDGETS -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DQT_NETWORK_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_OPENGL_ES_2 -DQT_OPENGL_ES_2_ANGLE -DQT_WEBKIT_LIB -DQT_WEBKITWIDGETS_LIB -D_MSC_VER=1800 -D_WIN32 -D_WIN64</MOC_DEFINES>"
prepare += "\n\t</PropertyGroup>"

prepare += "\n\t<PropertyGroup Label=\"UserMacros\" Condition=\"'$(Configuration)'=='Debug-WebEngine'\">"
prepare += "\n\t\t<MOC_DEFINES>-DUNICODE -DWIN32 -DWIN64 -DSC_USE_WEBENGINE -DQT_VERSION_5 -DQT_DECLARATIVE_DEBUG -DQT_WIDGETS -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DQT_NETWORK_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_OPENGL_ES_2 -DQT_OPENGL_ES_2_ANGLE -D_MSC_VER=1800 -D_WIN32 -D_WIN64</MOC_DEFINES>"
prepare += "\n\t</PropertyGroup>"

prepare += "\n\t<PropertyGroup Label=\"UserMacros\" Condition=\"'$(Configuration)'=='WebEngine-PGO'\">"
prepare += "\n\t\t<MOC_DEFINES>-DUNICODE -DWIN32 -DWIN64 -DSC_USE_WEBENGINE -DQT_VERSION_5 -DQT_NO_DEBUG -DQT_WIDGETS -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DQT_NETWORK_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_OPENGL_ES_2 -DQT_OPENGL_ES_2_ANGLE -D_MSC_VER=1800 -D_WIN32 -D_WIN64</MOC_DEFINES>"
prepare += "\n\t</PropertyGroup>"

prepare += "\n\t<PropertyGroup Label=\"UserMacros\" Condition=\"'$(Configuration)'=='WebEngine'\">"
prepare += "\n\t\t<MOC_DEFINES>-DUNICODE -DWIN32 -DWIN64 -DSC_USE_WEBENGINE -DQT_VERSION_5 -DQT_NO_DEBUG -DQT_WIDGETS -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DQT_NETWORK_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_OPENGL_ES_2 -DQT_OPENGL_ES_2_ANGLE -D_MSC_VER=1800 -D_WIN32 -D_WIN64</MOC_DEFINES>"
prepare += "\n\t</PropertyGroup>"
prepare += "\n\t<PropertyGroup Label=\"UserMacros\" Condition=\"'$(Configuration)'=='WebKit'\">"

prepare += "\n\t<PropertyGroup Label=\"UserMacros\" Condition=\"'$(Configuration)'=='WebKit'\">"
prepare += "\n\t\t<MOC_DEFINES>-DUNICODE -DSC_USE_WEBKIT -DWIN32 -DWIN64 -DQT_VERSION_5 -DQT_NO_DEBUG -DQT_WEBKITWIDGETS_LIB -DQT_WIDGETS -DQT_MULTIMEDIAWIDGETS_LIB -DQT_OPENGL_LIB -DQT_QML_LIB -DQT_MULTIMEDIA_LIB -DQT_WEBKIT_LIB -DQT_WIDGETS_LIB -DQT_SENSORS_LIB -DQT_NETWORK_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_OPENGL_ES_2 -DQT_OPENGL_ES_2_ANGLE -D_MSC_VER=1800 -D_WIN32 -D_WIN64</MOC_DEFINES>"
prepare += "\n\t</PropertyGroup>"

Expand All @@ -143,11 +142,11 @@ def create_vs_str( input, gui = False ):
prepare += "\n\t</PropertyGroup>"

prepare += "\n\n"

# Moc extra build steps
prepare += "\t<!-- Moc'ing GUI Header files -->"
prepare += "\n\t<ItemGroup>"

for entry in modified_input:
if entry[0] == "HEADERS":
prepare += """
Expand All @@ -158,44 +157,46 @@ def create_vs_str( input, gui = False ):
\t\t\t<AdditionalInputs>Rem;""" + entry[1] + """;%(AdditionalInputs)</AdditionalInputs>
\t\t\t<Outputs>$(IntDir)\\moc_%(Filename).cpp</Outputs>
\t\t</CustomBuild>"""



prepare += "\n\t</ItemGroup>"



prepare += "\n</Project>"
return prepare

def replace( input, separator, repl ):


def replace(entries, separator, repl):
r = []
for entry in input:
r.append( ( entry[0], re.sub( separator, repl, entry[1] ) ) )
for entry in entries:
r.append((entry[0], re.sub(separator, repl, entry[1])))
return r

def sort_by_name( input ):
input.sort( key=lambda entry : entry[3], reverse=True )
input.sort( key=lambda entry : entry[2], reverse=True )
input.sort( key=lambda entry : entry[4], reverse=True )

def create_file( file_type, build_systems ):
result = parse_qt( "QT_" + file_type + ".pri" )
def sort_by_name(entries):
entries.sort(key=lambda entry: entry[3], reverse=True)
entries.sort(key=lambda entry: entry[2], reverse=True)
entries.sort(key=lambda entry: entry[4], reverse=True)


def create_file(file_type, build_systems):
result = parse_qt("QT_" + file_type + ".pri")
# print result
sort_by_name( result )
sort_by_name(result)
if "make" in build_systems:
write_to_file( file_type + "_make", create_make_str( result ) )
write_to_file(file_type + "_make", create_make_str(result))
if "VS" in build_systems:
write_to_file( "VS_" + file_type + ".props", create_vs_str( result ) )
write_to_file("VS_" + file_type + ".props", create_vs_str(result))
if "VS_GUI" in build_systems:
write_to_file( "VS_" + file_type + ".props", create_vs_str( result, True ) )
write_to_file("VS_" + file_type + ".props", create_vs_str(result, True))
if "QT" in build_systems:
write_to_file( "QT_" + file_type + ".pri", create_qt_str( result ) )

write_to_file("QT_" + file_type + ".pri", create_qt_str(result))


def main():
create_file( "engine", ["make","VS", "QT"] )
create_file( "engine_main", ["make","VS", "QT"] )
create_file( "gui", ["QT","VS_GUI"] ) # TODO: finish mocing part of VS_GUI
print "done"

create_file("engine", ["make", "VS", "QT"])
create_file("engine_main", ["make", "VS", "QT"])
create_file("gui", ["QT", "VS_GUI"]) # TODO: finish mocing part of VS_GUI
print("done")


if __name__ == "__main__":
main()

0 comments on commit 5224660

Please sign in to comment.