programming

cross platform build systems

cross platform builds are a pain in the ass. especially if you want to kick out the native ide projects for some of those builds.

i almost had to kill a few people to get one at job. however, it is finally in place and seems to be working ok.

the one for job is quite nice (other than the perl madness). you have a single file you muck with and it can generate the builds for all the platforms.

ok fine, but that is a lot of work. maybe the best bet is to just acknowledge that builds are not simple and they are just not going to magically work without some effort. if that is the case, why not have a custom build for each?

unfortunately many of these ide build files don't understand the concept of freak'n wildcards. that means as your files are added\removed\moved each day, you want to start killing people as all your other platforms are constantly out of sync.

so the solution.. add wildcards to the ide builds. of course that's difficult or impossible with most ide's, so lets just make a script do the work.

so for instance.. on vc7/windows, how about we write a custom python script that depends on nothing else and will generate our vcproj exactly how we want from some wildcards. note the special case for the precompiled header.

btw, pardon the fact that i don't remember python anymore. i also had to change the escholons to [[[ and ]]] to make the blog happy.


import glob;

projectname="lamebuildtest_vc7w2k"
projectguid="9EFF4886-7ECF-40C6-99E2-7B69A6E92434" #lazy bastard
outputdirectory="........outputlamebuildtestlib\\vc7w2k"
intermediatedirectory="........intermediatelamebuildtestbuildvc7w2kdebug"
additionalincludedirectories="......"
precompiledheaderthrough="lamebuildtest/code/lbt.hpp"

hpp_files=glob.glob("..\..\code\*.hpp")
cpp_files=glob.glob("..\..\code\*.cpp")

print '[[[?xml version="1.0" encoding="Windows-1252"?]]]'
print '[[[VisualStudioProject'
print ' ProjectType="Visual C++"'
print ' Version="7.10"'
print ' Name="'+projectname+'"'
print ' ProjectGUID="{'+projectguid+'}"'
print ' RootNamespace="'+projectname+'"'
print ' Keyword="Win32Proj"]]]'
print ' [[[Platforms]]]'
print ' [[[Platform'
print ' Name="Win32"/]]]'
print ' [[[/Platforms]]]'
print ' [[[Configurations]]]'

print ' [[[Configuration'
print ' Name="Debug|Win32"'
print ' OutputDirectory="'+outputdirectory+'"'
print ' IntermediateDirectory="'+outputdirectory+'"'
print ' ConfigurationType="4"'
print ' CharacterSet="2"]]]'

print ' [[[Tool'
print ' Name="VCCLCompilerTool"'
print ' Optimization="0"'
print ' AdditionalIncludeDirectories="'+additionalincludedirectories+'"'
print ' PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"'
print ' MinimalRebuild="TRUE"'
print ' BasicRuntimeChecks="3"'
print ' RuntimeLibrary="5"'
print ' ForceConformanceInForLoopScope="TRUE"'
print ' RuntimeTypeInfo="TRUE"'
print ' UsePrecompiledHeader="3"'
print ' PrecompiledHeaderThrough="'+precompiledheaderthrough+'"'
print ' ProgramDataBaseFileName="$(IntDir)/$(ProjectName)DEBUG.pdb"'
print ' WarningLevel="3"'
print ' Detect64BitPortabilityProblems="TRUE"'
print ' DebugInformationFormat="3"/]]]'

print ' [[[Tool'
print ' Name="VCLibrarianTool"'
print ' OutputFile="$(OutDir)/$(ProjectName)DEBUG.lib"/]]]'

print ' [[[/Configuration]]]'

print ' [[[/Configurations]]]'

print ' [[[Files]]]'
print ' [[[Filter'
print ' Name="Source Files"'
print ' Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"'
print ' UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"]]]'

for i,v in enumerate(cpp_files):
print ' [[[File'
print ' RelativePath="'+v+'"]]]'

if v=='..\..\code\lbt.cpp':
print ' [[[FileConfiguration'
print ' Name="Debug|Win32"]]]'
print ' [[[Tool'
print ' Name="VCCLCompilerTool"'
print ' UsePrecompiledHeader="1"/]]]'
print ' [[[/FileConfiguration]]]'

print ' [[[/File]]]'
print ' [[[/Filter]]]'

print ' [[[Filter'
print ' Name="Header Files"'
print ' Filter="h;hpp;hxx;hm;inl;inc;xsd"'
print ' UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752B2FF}"]]]'
for i,v in enumerate(hpp_files):
print ' [[[File'
print ' RelativePath="'+v+'"]]]'
print ' [[[/File]]]'
print ' [[[/Filter]]]'
print ' [[[/Files]]]'

print '[[[/VisualStudioProject]]]'

the idea is that you keep a custom script in the same directory as each of your platform builds. you never try to get fancy and factor common code into some sort of lame library either. the scripts are meant to be ugly and dirty, just like builds really are.