#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL.  You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation.  Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation.  All Rights
# Reserved.
#

if {#} != 1
	echo "CopyExports requires 1 parameters:"
	echo "Parameter 1: path relative to {SourceRootDir} of the file which contains"
	echo "             the list of files to be copied, one per line.  This path"
	echo "             may not begin with a colon"
	echo
	Exit 1
end if


Set SourceList "{SourceRootDir}{1}"

Set ScriptsDir "{SourceRootDir}mozilla:build:mac:"

#set sourceList "{SourceRootDir}mozilla:{1}"

if {verbose}
	echo "Source list is in file ¶"{SourceList}¶""
	echo "Scripts directory is ¶"{ScriptsDir}¶""
end if

# for each line in the source file, remove it if it starts with #, otherwise quote it

for curLine in `streamedit "{sourceList}" -e '/¥#Å/ Delete; /¥/ Replace /(Å)¨1/ "¶""¨1"¶""'`
	
	echo "{curLine}"
	
	# ignore empty lines
	if `evaluate "{{curLine}}" != ""`
		
		echo "{curLine}"
		
		# strip out trailing comments
		if `evaluate "{curLine}" =~ /(Å)¨1[ ¶t]+(#Å)¨2/`
			set sourceLine "{¨1}"
			# echo "Discarding comment {¨2}"
		else
			set sourceLine "{curLine}"
		end if
		
		if `evaluate "{sourceLine}" =~ /([Â ¶t]+)¨1[ ¶t]+[:]*(Å)¨2/`
		
			if {verbose}
				echo "Cur line is {sourceLine}"
			end if
		
			set exportFile "{¨1}"
			set theTarget "{¨2}"
			
			if {verbose}
				echo "Export file name is {exportFile}"
				echo "Target directory is {theTarget}"
			end if
			
			"{ScriptsDir}CopyList.script" "{exportFile}" "{theTarget}"
		
		end if
	
	end if

end for
