
gen Action do
    puts "running action" if var[:act_verbose]
end

task :do_nothing

file "auto.rf" do |t|
    open(t.name, "w") { |f|
	f << <<-EOF
	    task "auto.t" do |t|
		sys.touch t.name
	    end
	EOF
    }
end

file "version.t" do |t|
    open(t.name, "w") { |f| f.puts "1.0" }
end

gen Action do
    rant.build "version.t"
end

auto_t_task = source "auto.rf"
rant.abort unless auto_t_task.name == "auto.t"

task :clean do
    sys.rm_f %w(auto.t auto.rf version.t)
    sys.rm_rf %w(basedir.t)
end

gen Directory, "tmp.t"
task "tmp.t/Rantfile" => "tmp.t" do |t|
    open(t.name, "w") { |f|
	f << <<-EOF
	file "test.t" do |t| sys.touch t.name end
	EOF
    }
end

task :subdir_tmp do
    subdirs %w(tmp.t)
end

task :build_test_t do |t|
    rant.build "tmp.t/test.t"
    # just ensure we're NOT in the tmp.t directory
    #STDERR.puts Dir.pwd
    test(?d, "tmp.t") or t.fail
end

desc "Make some path (basedir.t/a/b)."
gen Directory, "basedir.t", "a/b"

gen Action do
    if var[:make_path]
        make Directory, "basedir.t"
        make "basedir.t/a/b"
    end
end

task :make_file do |t|
    make "make_file.t" do |t|
        sys.touch t.name
    end
end

file "make_files_dep.t" do |t|
    sys.touch t.name
end

gen Action do
    if var[:make_files]
        make "make_files.t" => "make_files_dep.t" do |t|
            sys.touch t.name
        end
    end
    if var[:make_gen_with_block]
        import "subfile"
        make SubFile, "a.t/a.t" do |t|
            sys.touch t.name
        end
    end
end

task :dep_on_make_files => ["make_files.t"]

task "print_name.t" do |t|
    puts t.full_name
end

file "depends_name.t" => "print_name.t" do |t|
    import "sys/more"
    sys.write_to_file t.name, File.read(t.source) + "a\n"
end

task "call-make" do |t|
    make "print_name.t"
    puts t.full_name
end

# vim: ft=ruby
