Class: L::C::TargetCSource

Inherits:
R::Target show all
Defined in:
lib/rub/l/c.rb

Overview

A C source file.

Instance Method Summary collapse

Methods inherited from R::Target

#clean?, #description, #hash_input, #hash_output, #hash_outputs, #hash_self, #register

Constructor Details

#initialize(opt, f, input = []) ⇒ TargetCSource

Returns a new instance of TargetCSource.



296
297
298
299
300
301
302
303
304
# File 'lib/rub/l/c.rb', line 296

def initialize(opt, f, input = [])
	#TargetC.initialize
	
	@f = C.path(f)
	@opt = opt
	@input = input
	
	register
end

Instance Method Details

#buildObject



355
356
357
358
359
360
# File 'lib/rub/l/c.rb', line 355

def build
	@depsbuilt and return

	@depsbuilt = true
	build_dependancies
end

#included_files(opt, set = Set.new) ⇒ Object



306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
# File 'lib/rub/l/c.rb', line 306

def included_files(opt, set=Set.new)
	set.include?(@f) and return

	set << @f
	@incs ||= @f.readlines.map do |l|
		l =~ /\s*#\s*include\s*("(.*)"|<(.*)>)/ or next
		if $3 and !D[:l_c_system_headers]
			next
		end
		
		p  = Pathname.new( $2 || $3 )
		ip = opt.compiler.include_directories(opt)
		
		if $2
			ip << @f.dirname
		end
		
		h = nil
		ip.each do |d|
			hg = d.join(p)
			
			if hg.exist?
				h = hg
				break
			end
		end
		
		h # Ignoring missing headers for now.
	end.compact
	
	@incs.each do |h|
		icd = R::find_target(h) || TargetCSource.new(opt, h, @input)
		
		if icd.respond_to? :included_files
			icd.included_files opt, set
		else
			set << h
		end
	end
end

#inputObject



347
348
349
# File 'lib/rub/l/c.rb', line 347

def input
	@input + included_files(@opt)
end

#outputObject



351
352
353
# File 'lib/rub/l/c.rb', line 351

def output
	Set[@f]
end