Skip to content
Newer
Older
100644 54 lines (45 sloc) 1.26 KB
d75bfbc @JEG2 Adding submission packaging code.
authored
1 require "fileutils"
2 require "pathname"
3
4 SUBMISSION_DIR = Pathname("icfp-96554412")
5 SRC_DIR = SUBMISSION_DIR + "src"
6
7 def copy_all_to_src(dir)
8 from = Pathname(dir)
9 to = SRC_DIR + dir
10 files = `git ls-files #{from}`
11 to.mkpath unless to.exist?
12 files.each_line do |file|
13 file.strip!
14 target = SRC_DIR + file
15 target.dirname.mkpath
16 FileUtils.cp(file, target)
17 end
18 end
19
20 def add_file(name, content, executable = true)
21 path = SUBMISSION_DIR + name
22 File.write(path, content.gsub(/^\s+/, ""))
23 FileUtils.chmod("+x", path)
24 end
25
26 desc "Prepare code for submission"
27 task :prepare do
28 SUBMISSION_DIR.rmtree if SUBMISSION_DIR.exist?
29 SRC_DIR.mkpath
30
31 %w[bin data lib spec].each do |dir|
32 copy_all_to_src(dir)
33 end
6a19f0e @JEG2 Fixing a packaging bug.
authored
34 FileUtils.cp("README.md", SUBMISSION_DIR + "README")
35 FileUtils.cp("Rakefile", SRC_DIR + "Rakefile")
d75bfbc @JEG2 Adding submission packaging code.
authored
36
37 add_file("install", <<-END_BASH)
38 #!/bin/bash
39 END_BASH
40 add_file("lifter", <<-END_BASH)
41 #!/bin/bash
42 DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
43 exec "$DIR/src/bin/run"
44 END_BASH
45 add_file("PACKAGES-TESTING", <<-END_BASH, false)
46 ruby1.9.1
47 END_BASH
48
6f4d63f @JEG2 Fixing the build.
authored
49 system("cd #{SUBMISSION_DIR} && ln -s src/data maps")
50 system("cd #{SUBMISSION_DIR} && tar -czf ../#{SUBMISSION_DIR}.tgz .")
d75bfbc @JEG2 Adding submission packaging code.
authored
51 end
52
53 task default: :prepare
Something went wrong with that request. Please try again.