File: SConstruct

package info (click to toggle)
supercollider 1%3A3.4.5-1wheezy1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 26,972 kB
  • sloc: cpp: 116,645; lisp: 64,914; ansic: 10,725; python: 3,548; perl: 766; ruby: 487; sh: 152; makefile: 117; xml: 13
file content (145 lines) | stat: -rw-r--r-- 5,062 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# -*- python -*- =======================================================
# FILE:         SConstruct
# CONTENTS:     scons build script for scved
# AUTHOR:       nesciv AT gmail DOT com
# AUTHOR:       alex AT x37v DOT info (followed the example of scvim)
# AUTHOR:       sk AT k-hornz DOT de (some of this SConstruct taken from sk's SConstruct for SuperCollider)
# ======================================================================

import os
import re
import pwd

PLATFORM = os.uname()[0].lower()

SC_FILE_RE = re.compile('.*\.sc$')

PY_FILE_RE = re.compile('.*\.py$')
LANG_FILE_RE = re.compile('.*\.lang$')
XML_FILE_RE = re.compile('.*\.xml$')
PLUGIN_FILE_RE = re.compile('.*\.gedit-plugin$')

ANY_FILE_RE = re.compile('.*')
HOME_DIR_RE = re.compile(os.environ.get('HOME') + '.*')

DEFAULT_PREFIX = '/usr/local/'
#DEFAULT_SC_HELP = os.path.join(DEFAULT_PREFIX, 'share/SuperCollider/Help/')


def pkg_data_dir(prefix, *args):
    if PLATFORM == 'darwin':
        base = '/Library/Application Support'
        if is_home_directory(prefix):
            base = os.path.join(prefix, base)
    else:
        base = os.path.join(prefix, 'share')
    return os.path.join(base, 'SuperCollider', *args)

def pkg_extension_dir(prefix, *args):
    return pkg_data_dir(prefix, 'Extensions', *args)

SWAP_FILE_MATCH = re.compile('.*.swp')

def install_dir(env, src_dir, dst_dir, filter_re, strip_levels=0):
    nodes = []
    for root, dirs, files in os.walk(src_dir):
        src_paths = []
        dst_paths = []
        if 'CVS' in dirs: dirs.remove('CVS')
        if '.svn' in dirs: dirs.remove('.svn')
        for d in dirs[:]:
            if filter_re.match(d):
                src_paths += flatten_dir(os.path.join(root, d))
                dirs.remove(d)
        for f in files:
			  #ditch swap files
            if not SWAP_FILE_MATCH.match(f) and filter_re.match(f):
                src_paths.append(os.path.join(root, f))
        dst_paths += map(
            lambda f:
            os.path.join(
            dst_dir,
            *f.split(os.path.sep)[strip_levels:]),
            src_paths)
        nodes += env.InstallAs(dst_paths, src_paths)
    return nodes

#def install_file(env, src_file, dst_dir, strip_levels=0):
    #nodes = []
    #dst_path = map(
        #lambda f:
        #os.path.join(
        #dst_dir,
        #*f.split(os.path.sep)[strip_levels:])
		#,src_file)
    #nodes += env.InstallAs(dst_path, src_file)
    #print src_file
    #print nodes
    #return nodes

def bin_dir(prefix):
    return os.path.join(prefix, 'bin')

def lib_dir(prefix):
    return os.path.join(prefix, 'lib')

def share_dir(prefix):
    return os.path.join(prefix, 'share')

def in_home_directory(dir):
	return HOME_DIR_RE.match(dir)

##build help, the help depends on having the home directory enviroment variable.. that could change
#build_help = Builder(action =
		#'export HOME=' + os.environ.get('HOME') + ' && ruby ' + os.getcwd() + '/bin/scvim_make_help -f -s $SOURCE -d $TARGET')

#create our options
opts = Options()
opts.Add(PathOption('PREFIX', 'Specify the prefix for the bin and share files',
	DEFAULT_PREFIX, PathOption.PathIsDir))

#create our enviroment, with our options and custom builders
env = Environment(options = opts)
#, BUILDERS = {'BuildHelp' : build_help})

#generate the help options
Help(opts.GenerateHelpText(env))


#get our variables from the options
PREFIX = env.get('PREFIX')

install_scedfiles = env.Alias('install-scedfiles', [
	#install_file( env, 'data/supercollider.lang', os.path.join( share_dir(PREFIX), 'gtksourceview-2.0/language-specs' ), 0 ),
	#install_file( env, 'data/supercollider.xml', os.path.join( share_dir(PREFIX), 'mime/packages' ), 0 ),
	#install_file( env, 'data/sced.gedit-plugin', os.path.join( lib_dir(PREFIX), 'gedit-2/plugins' ), 0 ),
	install_dir( env, 'data/', os.path.join( share_dir(PREFIX), 'gtksourceview-2.0/language-specs' ), LANG_FILE_RE, 1 ),
	install_dir( env, 'data/', os.path.join( share_dir(PREFIX), 'mime/packages' ), XML_FILE_RE, 1 ),
	install_dir( env, 'data/', os.path.join( lib_dir(PREFIX), 'gedit-2/plugins' ), PLUGIN_FILE_RE, 1 ),
	install_dir( env, 'sced/', os.path.join( lib_dir(PREFIX), 'gedit-2/plugins' ), PY_FILE_RE, 0 )
	])


update_mime = Builder(action =
		'update-mime-database ' + os.path.join( share_dir(PREFIX), 'mime/packages' ) )

#env.BUILDERS = update_mime

#install_doc = env.Alias('install-doc', env.Install(DOC_DIR, ['SCVim.scd']))
#build_help = env.Alias('build-help', env.BuildHelp(target = Dir(DOC_DIR),
	#source = Dir(SUPERCOLLIDER_HELP_DIR)))
#AlwaysBuild(Dir(DOC_DIR))
#Depends(build_help, install_doc)

env.Alias('install', [
	install_scedfiles,
])

#this should be commonly run by the user who wishes to use it if the CACHE_DIR
# and VIMFILE_DIR is in the user's homedir
#env.Alias('install-user', [install_vimfiles, install_doc])
#this should normally be run with sudo privileges
#env.Alias('install-system', [install_bin, install_rc, install_classes])

#for x in env.Glob('*', ondisk = False, strings = False, source = False):
#	print x.get_abspath()