dsdev2 script

Found a bug in the language, the VM or the compiler? help us iron things out or give ideas for doing things better.
Post Reply
User avatar
Khan
Intermediate
Posts: 69
Joined: Fri Sep 17, 2004 9:31 am
Location: src/packages/collections/

dsdev2 script

Post by Khan » Wed Oct 27, 2004 4:52 pm

Following situation:
Let's say you hack one of the DS APIs like DSUnit or Collections. You make some changes to some classes and want to know if everything does as it should.
To do that you need DS to use the new files. You could copy them, but that's boring and you don't want to do that after every change. What you want is create a symlink in the DS installation to the edited files.

This scipt automates this for you

Code: Select all

#! /usr/bin/ruby

dsSrc = '/home/user/data/dragon/dragonscript'
dsPrefix = '/opt/dragonscript'
dsInst = "#{dsPrefix}/lib/dragonscript"
dsPackagesSrc = "#{dsSrc}/src/packages/"
status = `svn status #{dsSrc}`

sources = status.split(/\n/).select do |line|
	line =~ /^M\s+#{dsPackagesSrc}\w+\/(src|tests)\/\w+.ds/  #if formated like a modifyed ds file
end

packageNames = Dir.entries dsInst
packageNames.slice!(0..1) # remove .. and .

sources.each do |source|
	packageAndFile = source.split(dsPackagesSrc)[1] #get what's after src/packages	
	srcPackage, srcOrTest, file = packageAndFile.split '/'

	if srcOrTest == 'src'
		dstPackage = packageNames.detect do |each|
			each.downcase == srcPackage.downcase
		end
	elsif srcOrTest == 'tests'
		dstPackage = packageNames.detect do |each|
			each[-5..-1] == 'Tests' and
				each.chomp("Tests").downcase == srcPackage.downcase
		end
	end

	dstFilePath = "#{dsInst}/#{dstPackage}/#{file}"
	srcFilePath = source[1..-1].lstrip # chop of M and space
	
	unless File.symlink? dstFilePath
		File.delete dstFilePath
		File.symlink srcFilePath, dstFilePath
	end
end
This is the new and improved version of dsdev script called dsdev2 script. :)
It works with the new file structure.

Why are paths hardcoded and not read as commandline argument?
Pick the answer you like most.
  • Because I'm lazy.
  • Because I didn't want to bloat the script.
  • Because always passing arguments is boaring
  • That is left as an exercise to the user.
General notes:
  • works only for modifyed files
  • Before make install, do a rm -rf <prefix>
  • doesn't work on Windooze
Last edited by Khan on Fri Nov 19, 2004 11:21 pm, edited 4 times in total.

User avatar
Dragonlord
Forum Administrator
Posts: 609
Joined: Fri Jul 30, 2004 4:30 pm
Location: Switzerland
Contact:

Post by Dragonlord » Thu Oct 28, 2004 10:34 am

ehm... for what a script? 'make install' is what you need. do some changes, then whack in 'make install' and after a sec or two you can run your test script against the packages. but nice try though ^_^
Image
Oh to be a dragon, of silkworm size or immense...

User avatar
Khan
Intermediate
Posts: 69
Joined: Fri Sep 17, 2004 9:31 am
Location: src/packages/collections/

Post by Khan » Thu Oct 28, 2004 3:26 pm

Dragonlord wrote: do some changes, then whack in 'make install' and after a sec or two
compare:
change -> make install -> wait -> run -> change -> make install -> wait -> run
to:
change -> run -> change -> run

User avatar
Dragonlord
Forum Administrator
Posts: 609
Joined: Fri Jul 30, 2004 4:30 pm
Location: Switzerland
Contact:

Post by Dragonlord » Thu Oct 28, 2004 10:58 pm

yeah... i know... but complain with automake. it's their tool having some troubles doing correct dependency checking. with me it works most of the time but sometimes it chokes. and then i need a full build.

and make distclean is only needed after a svn update, and only when compilation fails or strange results happen, which should not be often the case. luckily DS is still rather small.
Image
Oh to be a dragon, of silkworm size or immense...

Post Reply