From fb8011b241e5dc28d705dcbaf5397aa2f1aa7bd9 Mon Sep 17 00:00:00 2001
From: janneke <janneke>
Date: Mon, 12 Jul 2004 21:52:54 +0000
Subject: [PATCH] Updates.  Add targets: tar, dist, release.

---
 Documentation/SConscript      |  8 --------
 Documentation/user/SConscript | 24 +++++-------------------
 SConstruct                    | 30 +++++++++++++-----------------
 buildscripts/builder.py       | 17 +++++++++--------
 flower/SConscript             | 14 +++++---------
 input/SConscript              | 24 +++++-------------------
 lily/SConscript               | 27 +++------------------------
 ly/SConscript                 | 17 ++++-------------
 python/lilylib.py             |  2 +-
 scm/SConscript                | 17 ++++-------------
 10 files changed, 49 insertions(+), 131 deletions(-)

diff --git a/Documentation/SConscript b/Documentation/SConscript
index 56b9039c03..6b27c41580 100644
--- a/Documentation/SConscript
+++ b/Documentation/SConscript
@@ -1,13 +1,5 @@
 # -*-python-*-
 
-import glob
-import os
-
 Import ('env')
-here = os.getcwd ()
-reldir = str (Dir ('.').srcnode ())
-os.chdir (reldir)
 sources = ['index.html.in', 'texinfo.css']
-os.chdir (here)
-outdir = os.path.join (env['build'], reldir, env['out'])
 
diff --git a/Documentation/user/SConscript b/Documentation/user/SConscript
index 2798c17df6..d0c237277e 100644
--- a/Documentation/user/SConscript
+++ b/Documentation/user/SConscript
@@ -6,13 +6,8 @@ import re
 import sys
 
 Import ('env')
-here = os.getcwd ()
-reldir = str (Dir ('.').srcnode ())
-os.chdir (reldir)
-sources = glob.glob ('*.tely')
-pngs = glob.glob ('*.png')
-os.chdir (here)
-outdir = os.path.join (env['build'], reldir, env['out'])
+sources = env['src_glob'] (env, '*.tely')
+pngs = env['src_glob'] (env, '*.png')
 
 def verbose_opt (env, opt):
 	if env['verbose']:
@@ -26,19 +21,8 @@ mfbuild = os.path.join (env['absbuild'], 'mf', env['out'])
 lilybuild = os.path.join (env['absbuild'], 'lily', env['out'])
 userbuild = os.path.join (env['absbuild'], 'Documentation/user', env['out'])
 
-# more of these? -- howto?
-env.Depends ('lilypond.texi', os.path.join (mfbuild, 'feta16list.ly'))
-env.Depends ('lilypond.texi', os.path.join (mfbuild, 'parmesan16list.ly'))
-# or these
-env.Depends ('doc', os.path.join (mfbuild, 'feta20.enc'))
-env.Depends ('doc', os.path.join (mfbuild, 'feta20.enc'))
-
 env.Depends ('lilypond.texi', LILYPOND_BIN)
 env.Depends ('lilypond.texi', 'lilypond-internals.texi')
-
-##env.Depends ('lilypond.texi', 'fonts')
-
-# simple:
 env.Depends ('doc', mfbuild)
 
 png_stems = map (lambda x: os.path.splitext (x)[0], pngs)
@@ -69,7 +53,9 @@ def file_subst (file_name, find, subst):
 		h.write (t)
 		h.close ()
 
-docdir = os.path.join (env['srcdir'], 'Documentation')
+##docdir = os.path.join (env['srcdir'], 'Documentation')
+docdir = Dir ('.').srcnode ().abspath + '/..'
+reldir = 'foe'
 out = env['out']
 srcdir = env['srcdir']
 verbose = verbose_opt (env, ' --verbose')
diff --git a/SConstruct b/SConstruct
index 95c2253ccd..2b23ff6401 100644
--- a/SConstruct
+++ b/SConstruct
@@ -74,6 +74,13 @@ if not COMMAND_LINE_TARGETS:
 # All builds everything (all directories)
 env.Alias ('all', ['lily', 'mf', 'input', 'Documentation'])
 
+#?
+env.Depends ('Documentation', ['lily', 'mf'])
+env.Depends ('input', ['lily', 'mf'])
+env.Depends ('doc', ['lily', 'mf'])
+env.Depends ('doc', 'mf')
+env.Depends ('input', ['lily', 'mf'])
+
 
 ## FIXME: opts in function
 
@@ -298,7 +305,7 @@ def configure (env):
 			defines['HAVE_PANGO_CVS'] = '1'
 			defines['HAVE_PANGO_FC_FONT_MAP_ADD_DECODER_FIND_FUNC'] = '1'
 
-	# ugh - needed at all?  make Builder/Command for config.h!
+	# use Command
 	if not os.path.exists (outdir):
 		os.mkdir (outdir)
 
@@ -307,7 +314,6 @@ def configure (env):
 		config.write ('#define %s %s\n' % (i, defines[i]))
 	config.close ()
 
-
 	os.system (sys.executable \
 		   + ' ./stepmake/bin/make-version.py VERSION > '\
 		   + os.path.join (outdir, 'version.hh'))
@@ -332,16 +338,10 @@ def configure (env):
 # Hmm.  Must configure when building lily, to get compiler and linker
 # flags set-up.
 # FIXME
-if not os.path.exists (config_h) or 'config' in COMMAND_LINE_TARGETS\
-   or 'lily' in BUILD_TARGETS or 'all' in BUILD_TARGETS:
+if 1 or not os.path.exists (config_h) or 'config' in COMMAND_LINE_TARGETS:
 	env = configure (env)
 
-if os.path.exists ('parser'):
-	env.Append (LIBPATH = ['#/flower', '#/lily', '#/parser', '#/gui',],
-		    CPPPATH = [outdir, '#',])
-else:	
-	env.Append (LIBPATH = ['#/flower/' + out,],
-		    CPPPATH = [outdir, '#',])
+env.Append (LIBPATH = ['#/flower/' + out,], CPPPATH = [outdir, '#',])
 
 Export ('env')
 
@@ -382,9 +382,8 @@ SConscript ('buildscripts/builder.py')
 
 for d in subdirs:
 	b = os.path.join (build, d, out)
-	# Support clean sourctree build (srcdir build)
-	# and outdir build.
-	# TODO: figure out SConscript (dir, builddir, duplicate)) feature
+	# Support clean sourcetree build (--srcdir build)
+	# and ./out build.
 	if (build and build != '.') \
 	   or (out and out != '.'):
 		env.BuildDir (b, d, duplicate=0)
@@ -431,13 +430,10 @@ def symlink_tree (prefix):
 
 if env['debugging']:
 	prefix = os.path.join (out, 'usr')
-	if not os.path.exists (prefix):
+	if not os.path.exists (os.path.join (absbuild, prefix)):
 		symlink_tree (prefix)
 
 #### dist, tar
-src_files = ['ChangeLog', '.cvsignore', 'Documentation/index.html.in',
-	     'lily/beam.cc']
-
 def cvs_files (dir):
 	entries = open (os.path.join (dir, 'CVS/Entries')).readlines ()
 	files = filter (lambda x: x[0] != 'D', entries)
diff --git a/buildscripts/builder.py b/buildscripts/builder.py
index 889c347e02..2997b7f2f7 100644
--- a/buildscripts/builder.py
+++ b/buildscripts/builder.py
@@ -1,5 +1,6 @@
 # -*-python-*-
 
+import glob
 import os
 import re
 import string
@@ -166,13 +167,6 @@ def add_enc_src (target, source, env):
 	base = os.path.splitext (str (target[0]))[0]
 	return (target, source + [base + '.enc'])
 
-def encoding_opt (target):
-	base = os.path.splitext (os.path.basename (str (target[0])))[0]
-	enc = base + '.enc'
-	if os.path.exists (os.path.join (outdir, enc)):
-		return ' --encoding=' + enc
-	return ''
-
 # UGH, should fix --output option for mftrace
 verbose = verbose_opt (env, ' --verbose')
 a = ('(cd ${TARGET.dir} && '
@@ -190,7 +184,7 @@ pfa = Builder (action = a,
 	       emitter = add_enc_src)
 env.Append (BUILDERS = {'PFA': pfa})
 
-# FIXMExo
+# FIXME
 #verbose = verbose_opt (env, ' --verbose')
 verbose = ''
 DIFF_PY = os.path.join (srcdir, 'stepmake/bin/package-diff.py')
@@ -200,3 +194,10 @@ a = ('%(PYTHON)s %(DIFF_PY)s%(verbose)s'\
 patch = Builder (action = a, suffix = '.diff', src_suffix = '.tar.gz')
 env.Append (BUILDERS = {'PATCH': patch})
 
+def src_glob (env, s):
+	here = os.getcwd ()
+	os.chdir (env.Dir ('.').srcnode ().abspath)
+	result = glob.glob (s)
+	os.chdir (here)
+	return result
+env['src_glob'] = src_glob
diff --git a/flower/SConscript b/flower/SConscript
index ee17272806..e4d36036e6 100644
--- a/flower/SConscript
+++ b/flower/SConscript
@@ -1,15 +1,11 @@
 # -*-python-*-
 
-import glob
-import os
-
 Import ('env')
-here = os.getcwd ()
-reldir = str (Dir ('.').srcnode ())
-os.chdir (reldir)
-sources = glob.glob ('*.cc')
-os.chdir (here)
-outdir = os.path.join (env['build'], reldir, env['out'])
+sources = env['src_glob'] (env, '*.cc')
+outdir = Dir ('.').path
+
+# abs_srcdir = Dir ('.').srcnode ().abspath
+# abs_outdir = Dir ('.').abspath
 
 name = 'flower'
 e = env.Copy ()
diff --git a/input/SConscript b/input/SConscript
index 1e3c40092f..7185004e32 100644
--- a/input/SConscript
+++ b/input/SConscript
@@ -1,26 +1,12 @@
 # -*-python-*-
 
-import glob
 import os
 
 Import ('env')
-here = os.getcwd ()
-reldir = str (Dir ('.').srcnode ())
-os.chdir (reldir)
-sources = glob.glob ('*.ly')
-abc_sources = glob.glob ('*.abc')
-os.chdir (here)
-outdir = os.path.join (env['build'], reldir, env['out'])
+sources = env['src_glob'] (env, '*.ly')
+abc_sources = env['src_glob'] (env, '*.abc')
+abc = map (lambda x: os.path.splitext (x)[0], abc_sources)
+lys = map (env.Abc2ly, abc)
 
-stems = map (lambda x: os.path.splitext (x)[0], sources)
-abc_stems = map (lambda x: os.path.splitext (x)[0], abc_sources)
-lys = map (env.Abc2ly, abc_stems)
-examples = map (env.LilyPond, stems + abc_stems)
+examples = map (env.LilyPond, sources + abc)
 env.Alias ('doc', examples)
-
-LILYPOND_BIN = env['LILYPOND_BIN']
-
-mfbuild = os.path.join (env['absbuild'], 'mf', env['out'])
-#e.Depends ('doc', 'fonts')
-env.Depends ('doc', mfbuild)
-env.Depends ('doc', LILYPOND_BIN)
diff --git a/lily/SConscript b/lily/SConscript
index 69769b51dd..d9597c65bc 100644
--- a/lily/SConscript
+++ b/lily/SConscript
@@ -1,38 +1,17 @@
 # -*-python-*-
 
-import glob
-import os
-
 Import ('env')
-here = os.getcwd ()
-reldir = str (Dir ('.').srcnode ())
-os.chdir (reldir)
-sources = glob.glob ('*.cc') + ['parser.yy', 'lexer.ll']
-includes = glob.glob ('include/*.hh')
-os.chdir (here)
-outdir = os.path.join (env['build'], reldir, env['out'])
-
-name = 'lyparser'
+sources = env['src_glob'] (env, '*.cc') + ['parser.yy', 'lexer.ll']
+includes = env['src_glob'] (env, 'include/*.hh')
+outdir = Dir ('.').path
 
 e = env.Copy ()
-
-#let's do this after the split
-#sources = filter (lambda x: x != 'pangofc-afm-decoder.cc', sources)
-#pango = env.Copy ()
-#if pango['gui']:
-#	pango.ParseConfig ('pkg-config --cflags --libs gtk+-2.0')
-#	pango.ParseConfig ('pkg-config --cflags --libs pango')
-#pango.Object ('foo-' + 'pangofc-afm-decoder.o', 'pangofc-afm-decoder.cc')
-#
-#e.Object ('pangofc-afm-decoder.o', 'foo-pangofc-afm-deocder.o')
-
 e.Append (YACCFLAGS = '-d')
 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
 e.Append (LIBS = ['flower'])
 e.ParseConfig ('guile-config link')
 name = 'lilypond-bin'
diff --git a/ly/SConscript b/ly/SConscript
index c5f1d69bd2..88143d3250 100644
--- a/ly/SConscript
+++ b/ly/SConscript
@@ -1,16 +1,7 @@
 # -*-python-*-
 
-import glob
-import os
-
 Import ('env')
-here = os.getcwd ()
-reldir = str (Dir ('.').srcnode ())
-os.chdir (reldir)
-sources = glob.glob ('*.ly')
-os.chdir (here)
-outdir = os.path.join (env['build'], reldir, env['out'])
-
-lydir = os.path.join (env['sharedir_package_version'], 'ly')
-env.Install (lydir, sources)
-env.Alias ('install', lydir)
+sources = env['src_glob'] (env, '*.scm')
+dir = env['sharedir_package_version'] + '/ly'
+env.Install (dir, sources)
+env.Alias ('install', dir)
diff --git a/python/lilylib.py b/python/lilylib.py
index 220d30bae4..cca0c239d4 100644
--- a/python/lilylib.py
+++ b/python/lilylib.py
@@ -237,7 +237,7 @@ def command_name (cmd):
 
 	# deal with "((latex ) >& 1 ) .." too
 	cmd = re.match ("([\(\)]*)([^ ]*)", cmd).group(2)
-	return os.path.split (cmd)[1]
+	return os.basename (cmd)
 
 def error_log (name):
 	name = re.sub('[^a-z]','x', name)
diff --git a/scm/SConscript b/scm/SConscript
index adbeac354f..c0c45dd4df 100644
--- a/scm/SConscript
+++ b/scm/SConscript
@@ -1,16 +1,7 @@
 # -*-python-*-
 
-import glob
-import os
-
 Import ('env')
-here = os.getcwd ()
-reldir = str (Dir ('.').srcnode ())
-os.chdir (reldir)
-sources = glob.glob ('*.scm')
-os.chdir (here)
-outdir = os.path.join (env['build'], reldir, env['out'])
-
-scmdir = os.path.join (env['sharedir_package_version'], 'scm')
-env.Install (scmdir, sources)
-env.Alias ('install', scmdir)
+sources = env['src_glob'] (env, '*.scm')
+dir = env['sharedir_package_version'] + '/scm'
+env.Install (dir, sources)
+env.Alias ('install', dir)
-- 
2.39.5