Code Search for Developers
 
 
  

modifyBuild.py from marsyas at Krugle


Show modifyBuild.py syntax highlighted

#!/usr/bin/python
#	 modifyBuild.py:
# library for adding or removing
# ource files to the Marsyas build process.
#
# Do not call manually; instead use
#	 addMyMar, addNotmar, removeMyMar, or removeNotMar.
#
# action: 1 == add filename.   2 == remove filename.
import os
import sys

marsyasBaseDir = os.path.dirname(sys.argv[0])
marsyasBaseDir = os.path.abspath( marsyasBaseDir )
marsyasBaseDir = os.path.join(marsyasBaseDir+os.sep+'..'+os.sep)
marsyasBaseDir = os.path.abspath( marsyasBaseDir )

def modify_manager(filename,action):
	fileToEdit = os.path.join(marsyasBaseDir, 'marsyas', 'MarSystemManager.cpp')
	filelines = open( fileToEdit ).readlines()
	if (action==1):
		for line in filelines:
			if (line.find('\"'+filename+'.h"')>=0):
				print "New MarSystem already added?!"
				sys.exit()
	newfile = open( fileToEdit, 'w')
	for line in filelines:
		if (action==1):
			if (line[0:17] == '#include \"Gain.h\"'):
				insertLine = '#include \"' + filename + '.h\"'
				print "Adding line 1 of 2 to " + fileToEdit
				newfile.write(insertLine + '\n')
			if (line[0:25] == '\tregisterPrototype(\"Gain\"'):
				insertLine = '\tregisterPrototype(\"' + filename + '", new ' + filename +'(\"'+filename.lower()+'pr\"));'
				print "Adding line 2 of 2 to " + fileToEdit
				newfile.write(insertLine + '\n')
			newfile.write(line)
		if (action==2):
			if (line.find(filename)>=0):
				if (line[0:8] == '#include'):
					print "Removed line 1 of 2 from " + fileToEdit
					continue
				if (line[0:18] == '\tregisterPrototype'):
					print "Removed line 2 of 2 from " + fileToEdit
					continue
			newfile.write(line)
	newfile.close()

def modify_h_file (source_file, build_file, action):
	fileToEdit = build_file
	filelines = open( fileToEdit ).readlines()
	newfile = open( fileToEdit, 'w')
	for line in filelines:
		if (action==1):
			if (line[0:7] == '\tGain.h'):
				insertLine = '\t'+source_file + '.h \\'
				print "Adding line 1 of 1 (for .h) to " + fileToEdit
				newfile.write(insertLine + '\n')
			newfile.write(line)
		if (action==2):
			if (line.find(source_file)>=0):
				if (line.find('.h')>=0):
					print "Removed line 1 of 1 (for .h) from " + fileToEdit
					continue
			newfile.write(line)
	newfile.close()

def modify_cpp_file (source_file, build_file, action):
	fileToEdit = build_file
	filelines = open( fileToEdit ).readlines()
	newfile = open( fileToEdit, 'w')
	for line in filelines:
		if (action==1):
			if (line[0:9] == '\tGain.cpp'):
				insertLine = '\t'+source_file + '.cpp \\'
				print "Adding line 1 of 1 (for .cpp) to " + fileToEdit
				newfile.write(insertLine + '\n')
			newfile.write(line)
		if (action==2):
			if (line.find(source_file)>=0):
				if (line.find('.cpp')>=0):
					print "Removed line 1 of 1 (for .cpp) from " + fileToEdit
					continue
			newfile.write(line)
	newfile.close()

def modify_lib_release_makefile(source_file,action):
	fileToEdit = os.path.join(marsyasBaseDir, 'lib', 'release', 'Makefile.am')
	filelines = open( fileToEdit ).readlines()
	newfile = open( fileToEdit, 'w')
	for line in filelines:
		if (action==1):
			if (line[23:31] == 'Gain.cpp'):
				insertLine = '\t$(top_srcdir)/marsyas/'+source_file+'.cpp \\'
				print "Adding line 1 of 1 to " + fileToEdit
				newfile.write(insertLine+'\n')
			newfile.write(line)
		if (action==2):
			if (line[23:].find(source_file)>=0):
				print "Removed line 1 of 1 from " + fileToEdit
				continue
			newfile.write(line)
	newfile.close()



def process(source_filename, marsystem, action):
	if (marsystem):
		modify_manager(source_filename,action)

	modify_lib_release_makefile(source_filename,action)

	buildfile = os.path.join(marsyasBaseDir, 'marsyas', 'Makefile.am')
	modify_h_file(source_filename, buildfile, action)

	buildfile = os.path.join(marsyasBaseDir, 'marsyas', 'marsyas.pro')
	modify_h_file(source_filename, buildfile, action)

	buildfile = os.path.join(marsyasBaseDir, 'marsyas', 'marsyas.pro')
	modify_cpp_file(source_filename, buildfile, action)

	print "All done; please renerate autools with:"
	print "aclocal && automake"

	if (action==2):
		print "    Don't forget to remove your source files from the",
		print "Marsyas SVN tree!"






See more files for this project here

marsyas

Marsyas (Music Analysis, Retrieval and Synthesis for Audio Signals) is a framework for developing systems for audio processing. It provides an general architecture for connecting audio, soundfiles, signal processing blocks and machine learning.

Project homepage: http://sourceforge.net/projects/marsyas
Programming language(s): C++
License: other

  MATLAB/
    peakExtraction/
      ncut/
        a_times_b_cmplx.dll
        a_times_b_cmplx.mexglx
        a_times_b_cmplx.mexmac
        discretisation.m
        discretisationEigenVectorData.m
        eigs2.m
        mex_w_times_x_symmetric.dll
        mex_w_times_x_symmetric.mexglx
        mex_w_times_x_symmetric.mexmac
        ncut.m
        ncutW.m
        sparsifyc.dll
        sparsifyc.mexglx
        sparsifyc.mexmac
        spmtimesd.dll
        spmtimesd.mexglx
        spmtimesd.mexmac
      divisor.m
      getSnr.m
      harmo.m
      harmoGen.m
      playCluster.m
      plotCluster.m
      plotClusters.m
      plotGpPeaks.m
      plotHarmo.m
      plotPeaks.m
    LPCC_test.m
    LPC_test.m
    LSP_test.m
  PureData/
    MarLpc.pd
  Python/
    batch.py
    batchPan.py
    batchReferences.py
    ieee06.py
    scheduler_libs.py
  Makefile.am
  Makefile.in
  addClass.py
  addMarSystem.py
  createMarSystem.py
  dailytest.sh
  modifyBuild.py
  regtest_coffee.py
  regtest_sanity.py
  removeClass.py
  removeMarSystem.py