• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Run Script Build Phase & Linking
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Run Script Build Phase & Linking


  • Subject: Run Script Build Phase & Linking
  • From: David Dolinar <email@hidden>
  • Date: Wed, 4 Jan 2006 14:22:13 -0700

Hi,

I have a project which links *every* *single* *time* I choose "Build & Run" regardless of if I have made changes or not. I have tracked down the cause of the excessive linking to a Run Script build phase which takes one input file and one output file. The script is ran EVERY TIME even though the output file has a newer modification date then the input file. As I understand it XCode should not be doing this. Is this a known bug or am I doing something wrong? Any help would be appreciated.

Here is the ruby script:

def update_library(source_file, dest_file)
	name = File.basename(source_file)

#	print "Base name: #{name}\n"
	# if source file doesn't exist return an error
	if (!File.exists?(source_file))
		print "Error: #{source_file} doesn't exist"
		return 1
	end

	# see if we need to update
	if (!File.exists?(dest_file))
		# ranlib file doesn't exist
		needs_update = true
		print "#{name} needs to be copied...\n"
	elsif (File.stat(source_file).mtime != File.stat(dest_file).mtime)
		# ranlib
		needs_update = true
		print "#{name} needs to be updated...\n"
		print "removing #{dest_file}\n"
		File.delete(dest_file)
	else
		print "#{name} is up to date\n"
		needs_update = false
	end

	# update library into build directory
	if (needs_update)
		print "copying #{source_file}\n"
		system("cp '#{source_file}' '#{dest_file}'")
		print "running ranlib on #{dest_file}\n"
		system("ranlib '#{dest_file}'")

		source_atime = File.atime(source_file)
		source_mtime = File.mtime(source_file)
		File.utime(source_atime, source_mtime+1, dest_file)
	end
	return 0
end

error = 0
num_files = ENV['SCRIPT_INPUT_FILE_COUNT'].to_i
# print "#{num_files}\n"
num_files.times do |i|
	source_file = ENV['SCRIPT_INPUT_FILE_' + i.to_s]
	dest_file = ENV['SCRIPT_OUTPUT_FILE_' + i.to_s]
#	print "Updating #{source_file} to #{dest_file}\n"
	if (error == 0)
		error = update_library(source_file, dest_file)
	end
end

exit(error)



-- David Dolinar, Software Developer
-- Directory Resources, LLC

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Run Script Build Phase & Linking
      • From: Gunnar Proppe <email@hidden>
    • Re: Run Script Build Phase & Linking
      • From: Fritz Anderson <email@hidden>
  • Prev by Date: Re: Xcode & Visual C++
  • Next by Date: Re: Xcode & Visual C++
  • Previous by thread: Re: Xcode & Visual C++
  • Next by thread: Re: Run Script Build Phase & Linking
  • Index(es):
    • Date
    • Thread