# -*-python-*-
-#
-# Experimental scons building
+
+'''
+Experimental scons (www.scons.org) building:
+
+Usage:
+ scons
+ scons install
+ scons -c # clean
+ scons -h # help
+
+ scons build=DIR # scrdir build, write to new tree =build
+ scons out=DIR # write output to deeper dir DIR
+
+Optionally, make a custom.py. I have
+
+import os
+out='out-scons'
+optimising=0
+debugging=1
+prefix=os.getcwd ()
+
+
+'''
+
+
# TODO:
-# * install
-# * build in out/ ?
-# * mf, Documentation, ly etc.
-# * --srcdir ? (mkdir =build; cd =build; scons -Y .. ;
-# ===> os.chdir (Dir ('.').srcdir ()); glob.glob (*.cc); os.chdir (cwd) ?
-#
+# * mf: pfa
+# *, Documentation, ly etc.
+
import re
import glob
env = Environment ()
-opts = Options (None, ARGUMENTS)
+# put your favourite stuff in custom.py
+opts = Options ('custom.py', ARGUMENTS)
opts.Add ('prefix', 'Install prefix', '/usr/')
-opts.Add ('outdir', 'Output directory', 'out')
+opts.Add ('out', 'Output directory', 'out-scons')
+opts.Add ('build', 'Build directory', '.')
opts.AddOptions (
BoolOption ('warnings', 'compile with -Wall and similiar',
1),
env = Environment (options = opts)
+env.CacheDir (os.path.join (env['build'], '=build-cache'))
+
+#ugh
+sys.path.append (os.path.join ('.', 'stepmake', 'bin'))
+import packagepython
+package = packagepython.Package ('.')
+
+env['version'] = packagepython.version_tuple_to_str (package.version)
+env['bindir'] = os.path.join (env['prefix'], 'bin')
+env['sharedir'] = os.path.join (env['prefix'], 'share')
+env['libdir'] = os.path.join (env['prefix'], 'lib')
+env['lilypondprefix'] = os.path.join (env['sharedir'], 'lilypond',
+ env['version'])
+
if env['debugging']:
env.Append (CFLAGS = '-g')
env.Append (CXXFLAGS = '-g')
env.Append (CFLAGS = '-W -Wall')
env.Append (CXXFLAGS = '-W -Wall -Wconversion')
+env['MFMODE'] = 'ljfour'
+
conf = Configure (env)
#ugh -- hardcode territory
if conf.CheckLib ('kpathsea'):
defines['KPATHSEA'] = '1'
-# ugh?
-config = open ('config.h', 'w')
-sort_helper = defines.keys ()
-sort_helper.sort ()
-#for i in defines.keys ():
-for i in sort_helper:
- config.write ('#define %s %s\n' % (i[1:], defines[i]))
-config.close ()
env = conf.Finish ()
-os.system (sys.executable \
- + ' ./stepmake/bin/make-version.py VERSION > version.hh')
-
Export ('env')
#this could happen after flower...
env.ParseConfig ('guile-config compile')
-builddir = ''
-outdir = env['outdir']
+build = env['build']
+out = env['out']
+##reldir = str (Dir ('.').srcnode ())
+reldir = os.getcwd ()
+outdir = os.path.join (env['build'], reldir, env['out'])
+if not os.path.exists (outdir):
+ os.mkdir (outdir)
+
+config = open (os.path.join (outdir, 'config.h'), 'w')
+sort_helper = defines.keys ()
+sort_helper.sort ()
+for i in sort_helper:
+ config.write ('#define %s %s\n' % (i[1:], defines[i]))
+config.close ()
+
+os.system (sys.executable \
+ + ' ./stepmake/bin/make-version.py VERSION > '\
+ + os.path.join (build, 'version.hh'))
if os.path.exists ('parser'):
env.Append (LIBPATH = ['#/flower', '#/lily', '#/parser', '#/gui',],
- CPPPATH = ['#',])
+ CPPPATH = [outdir, '#',])
else:
- env.Append (LIBPATH = ['#/flower/' + outdir,],
- CPPPATH = ['#',])
-
-
-#ugh: remove make config output
-if os.path.exists ('lily/out/config.h'):
- os.unlink ('lily/out/config.h')
+ env.Append (LIBPATH = ['#/flower/' + out,],
+ CPPPATH = [outdir, '#',])
-subdirs = ('flower', 'lily',)
+subdirs = ('flower', 'lily', 'mf')
+#subdirs = ('mf',)
#subdirs = ('flower', 'lily', 'parser', 'gui', 'main',)
for d in subdirs:
- alias = os.path.join (builddir, d, outdir)
- env.BuildDir (alias, d)
- SConscript (os.path.join (alias, 'SConscript'))
+ b = os.path.join (build, d, out)
+ # Support clean sourctree build (srcdir build)
+ # and outdir build.
+ # TODO: figure out SConscript (dir, builddir, duplicate)) feature
+ if (build and build != '.') \
+ or (out and out != '.'):
+ env.BuildDir (b, d, duplicate=0)
+ SConscript (os.path.join (b, 'SConscript'))
import glob
import os
-## this only works for BuildDir aliasing, not for scons -Y ../scrdir
here = os.getcwd ()
-os.chdir (str (Dir ('.').srcnode ()))
+reldir = str (Dir ('.').srcnode ())
+os.chdir (reldir)
sources = glob.glob ('*.cc')
os.chdir (here)
name = 'flower'
Import ('env')
e = env.Copy ()
-e.Append (CPPPATH = ['include'])
+outdir = os.path.join (env['build'], reldir, env['out'])
+e.Append (CPPPATH = [outdir, 'include'])
if env['static']:
e.Library (name, sources)
if not env['static'] or env['shared']:
import glob
import os
-## this only works for BuildDir aliasing, not for scons -Y ../scrdir
here = os.getcwd ()
-os.chdir (str (Dir ('.').srcnode ()))
+reldir = str (Dir ('.').srcnode ())
+os.chdir (reldir)
sources = glob.glob ('*.cc') + ['parser.yy', 'lexer.ll']
os.chdir (here)
e = env.Copy ()
e.Append (YACCFLAGS = '-d')
-e.Append (CPPPATH = ['include', '#/lily/include', '#/flower/include'])
+outdir = os.path.join (env['build'], reldir, env['out'])
+e.Append (CPPPATH = [outdir, '#/lily/include', '#/flower/include'])
e.Depends ('lexer.cc', 'parser.cc')
+e.Depends ('my-lily-lexer.o', 'parser.cc')
+e.Depends ('my-lily-parser.o', 'parser.cc')
# some stuff here from lily-as-lib
if not os.path.exists ('main.cc'):
e.Append (LIBS = ['flower'])
e.ParseConfig ('guile-config link')
name = 'lilypond-bin'
- e.Program (name, sources)
+ lily = e.Program (name, sources)
+ env.Install (env['bindir'], lily)
+ env.Alias ('install', env['bindir'])
#if !KPATHSEA
/* Urg: GNU make's $ (word) index starts at 1 */
int i = 1;
- while (global_path.try_add (p + to_string (".") + to_string (i)))
+ while (global_path.try_append (p + to_string (".") + to_string (i)))
i++;
#endif
}
--- /dev/null
+# -*-python-*-
+
+import glob
+import os
+import string
+import sys
+
+here = os.getcwd ()
+reldir = str (Dir ('.').srcnode ())
+os.chdir (reldir)
+#mf_sources = reduce (+,
+mf_sources = reduce (lambda x, y: x + y,
+ map (glob.glob,
+ ('feta[0-9]*.mf',
+ 'feta-braces-[a-z].mf',
+ 'feta-din*[0-9].mf',
+ 'feta-nummer*[0-9].mf',
+ 'parmesan[0-9]*.mf',)))
+os.chdir (here)
+
+Import ('env')
+MFMODE = env['MFMODE']
+#ugh
+outdir = os.path.join (env['build'], reldir, env['out'])
+tfm = Builder (action = ('cd ' + outdir + ' && ' \
+ + '(MFINPUTS=:' + str (Dir ('#/mf')) \
+ + ' mf "\\mode:=%(MFMODE)s; nonstopmode; ' \
+ + ' input $$(basename $SOURCE);"' \
+ + ' | grep -v "@\\|>>")') % vars (),
+ suffix = '.tfm',
+ src_suffix = '.mf')
+
+afm = Builder (action = (sys.executable
+ + ' buildscripts/mf-to-table.py ' \
+ + ' --package=. --outdir=%(outdir)s '\
+ + ' --afm %(outdir)s/$$(basename $TARGET .afm).afm' \
+ + ' --enc %(outdir)s/$$(basename $TARGET .afm).enc' \
+ + ' --tex %(outdir)s/$$(basename $TARGET .afm).tex' \
+ + ' --ly %(outdir)s/$$(basename $TARGET .afm).ly'\
+ + ' %(outdir)s/$$(basename $SOURCE)') % vars (),
+ suffix = '.afm',
+ src_suffix = '.log')
+
+# UGH, should fix --output option for mftrace
+pfa = Builder (action = ('mftrace -I%(outdir)s --pfa --simplify --keep-trying'\
+ + ' $$(basename $SOURCE .mf) ' \
+ + ' && mv $$(basename $TARGET) $TARGET') % vars (),
+ suffix = '.pfa',
+ src_suffix = '.mf')
+
+e = env.Copy (BUILDERS = {'Tfm' : tfm, 'Afm' : afm, 'Pfa' : pfa},
+ MFINPUTS = '#/mf')
+
+mf_sources = ('feta16.mf',)
+sources = map (lambda x: os.path.splitext (x)[0], mf_sources)
+
+##t = map (e.Tfm, mf_sources)
+#a = map (e.Afm, map (lambda x: outdir + os.path.splitext (x)[0] + '.log',
+# mf_sources))
+#p = map (e.Pfa, mf_sources)
+
+out_sources = map (lambda x: os.path.join (outdir, x), sources)
+
+#t = e.Tfm (os.path.join (outdir, 'feta16.tfm'))
+#a = e.Afm (os.path.join (outdir, 'feta16.afm'))
+#p = e.Pfa (os.path.join (outdir, 'feta16.pfa'))
+#t = e.Tfm ('feta16.tfm'))
+#a = e.Afm ('feta16.afm'))
+#p = e.Pfa ('feta16.pfa'))
+
+t = e.Tfm (os.path.join (outdir, 'feta16'))
+a = e.Afm (os.path.join (outdir, 'feta16'))
+p = e.Pfa (os.path.join (outdir, 'feta16'))
+
+#t = map (e.Tfm, out_sources)
+#a = map (e.Afm, out_sources)
+#p = map (e.Pfa, out_sources)
+
+e.Depends ('feta16.log', 'feta16.tfm')
+e.Depends ('feta16.afm', 'feta16.log')
+
+#map (lambda x: e.Depends (x + '.log', x + '.tfm'), out_sources)
+#map (lambda x: e.Depends (x + '.afm', x + '.log'), out_sources)
+
+tfmdir = os.path.join (env['lilypondprefix'], 'fonts/tfm')
+afmdir = os.path.join (env['lilypondprefix'], 'afm')
+pfadir = os.path.join (env['lilypondprefix'], 'fonts/type1')
+env.Install (tfmdir, t)
+env.Install (afmdir, a)
+env.Install (pfadir, p)
+env.Alias ('install', tfmdir)
+env.Alias ('install', afmdir)
+env.Alias ('install', pfadir)
+
+