diff --git a/SConstruct b/SConstruct index 4032508ab..473ff7f07 100644 --- a/SConstruct +++ b/SConstruct @@ -500,6 +500,11 @@ opts.AddVariables( local filesystem.""", '', PathVariable.PathAccept), + BoolVariable( + 'legacy_headers', + """Create symbolic links for headers that were installed to the + 'kernel' subdirectory in previous versions of Cantera.""", + False), PathVariable( 'graphvisdir', """The directory location of the graphviz program, dot. dot is @@ -897,6 +902,38 @@ if env['addInstallTargets']: inst = env.RecursiveInstall('$inst_incdir', 'include/cantera') installTargets.extend(inst) + # Make symlinks to replicate old header directory structure + if env['legacy_headers']: + inst = env.Command(pjoin(instRoot, 'include', 'cantera', 'kernel'), [], + Mkdir("$TARGET")) + installTargets.extend(inst) + + if env['OS'] == 'Windows': + cmd = Copy("$TARGET", "$SOURCE") + else: + def RelativeSymlink(target, source, env): + if os.path.exists(target[0].path): + os.remove(target[0].path) + srcpath = psplit(source[0].abspath) + tgtpath = psplit(target[0].abspath) + nCommon = max(i for i,(dir1,dir2) in enumerate(zip(srcpath, tgtpath)) + if dir1 == dir2) + relsrc = os.sep.join(['..'] + srcpath[nCommon-1:]) + os.symlink(relsrc, target[0].abspath) + + cmd = RelativeSymlink + + for name in os.listdir('include/cantera'): + if not os.path.isdir(pjoin('include/cantera', name)): + continue + for filename in os.listdir(pjoin('include/cantera', name)): + if not filename.endswith('.h'): + continue + headerdir = pjoin(instRoot, 'include', 'cantera') + inst = env.Command(pjoin(headerdir, 'kernel', filename), + pjoin(headerdir, name, filename), cmd) + installTargets.extend(inst) + # Install C++ samples inst = env.RecursiveInstall(pjoin('$inst_sampledir', 'cxx'), 'samples/cxx') diff --git a/site_scons/buildutils.py b/site_scons/buildutils.py index dfdbd1c6b..a3f227e58 100644 --- a/site_scons/buildutils.py +++ b/site_scons/buildutils.py @@ -350,6 +350,7 @@ def psplit(s): Split a path given as a string into a list. This is the inverse of os.path.join. """ + s = s.strip('/\\') head, tail = os.path.split(s) path = [tail] while head: @@ -394,6 +395,7 @@ optionWrapper = textwrap.TextWrapper(initial_indent=' ', subsequent_indent=' ', width=72) + def formatOption(env, opt): """ Print a nicely formatted description of a SCons configuration