All pastes #1658497 Raw Edit

Mine

public python v1 · immutable
#1658497 ·published 2009-11-05 16:17 UTC
rendered paste body
import os,re,glob#---------------------------------##	removefilespattern	  ##---------------------------------#def removefilespattern(dir,pat):  for f in glob.glob(dir+'/'+pat):      os.popen('rm '+f)   return####################################---------------------------------##	      parsedir            ##---------------------------------#  def parsedir(startDir):  directories = [startDir]  dir = [startDir]  while len(directories)>0:    directory = directories.pop()    for name in os.listdir(directory):      fullpath = os.path.join(directory,name)      if os.path.isdir(fullpath):        directories.append(fullpath)  # It's a directory, store it.        dir.append(fullpath)  return dir###################################  #---------------------------------##           parsedirabs           ##---------------------------------#def parsedirabs(startDir):  directories = [startDir]  dir = [os.path.abspath(startDir)]  while len(directories)>0:    directory = directories.pop()    for name in os.listdir(directory):      fullpath = os.path.join(directory,name)      if os.path.isdir(fullpath):        directories.append(fullpath)  # It's a directory, store it.        dir.append(os.path.abspath(fullpath))  return dir####################################---------------------------------##           dirdepth              ##---------------------------------#def dirdepth(dir):  p = re.compile('[a-z]+')  print p.search(dir)  return####################################---------------------------------##           parsefiles            ##---------------------------------#def parsefiles(dir):  file = []  for name in os.listdir(dir):    fullpath = os.path.join(dir,name)    if os.path.isfile(fullpath) == True and os.path.isdir(fullpath) == False:      file.append(name)  return file####################################---------------------------------##           parsedirpat           ##---------------------------------#def parsedirpat(dir,pat):  file = []  for name in glob.glob(dir+'/'+pat):    file.append(name)  return file####################################---------------------------------##              VARS               ##---------------------------------##Dont Changelibfile = 'libModules.a'#Change if neededgdc = '/opt/gdc/bin/gdc'ar = '/usr/bin/ar'projecthome = '/home/fmanuel/projects/test/'#Absolutetargetentrypoint = '/home/fmanuel/projects/test/main.d'#######################################################################---------------------------------##           cmd0                  ##---------------------------------#def cmd0(inp,out):        cmd = gdc+' -c '+inp+'.d -o '+out+'.o -I '+projecthome        os.popen(cmd)        return cmd####################################---------------------------------##           cmd1                  ##---------------------------------#def cmd1(inp):	cmd = ar+' rcs '+libfile+' '+inp	os.popen(cmd)        return cmd####################################---------------------------------##           cmd2                  ##---------------------------------#def cmd2(main,target):	cmd = gdc+' '+main+' -o '+target+' -I '+projecthome+' -L '+projecthome+' -lModules'        os.popen(cmd)        return cmd###################################removefilespattern(projecthome+"/",'*.a')# Build object files on every dirobjfiles = []for d in parsedirabs(projecthome):	removefilespattern(d,'*.o')	print "DIR: "+d	files = parsedirpat(d,'*.d')	for f in files:		if f <> targetentrypoint:			nf = os.path.splitext(f)			print cmd0(nf[0],nf[0])			objfiles.append(nf[0]+".o")str = ' 'objfiles_str = str.join(objfiles)print cmd1(objfiles_str)print cmd2('main.d','main')