]> code.delx.au - gnu-emacs-elpa/blob - Rakefile
Merge pull request #424 from ljos/de/activate-extra-mode
[gnu-emacs-elpa] / Rakefile
1 # -*- Ruby -*-
2
3 require 'fileutils'
4
5 $EMACS=ENV["EMACS"] || "emacs"
6
7 def find_version
8 File.read("yasnippet.el", :encoding => "UTF-8") =~ /;; Package-version: *([0-9.]+?) *$/
9 $version = $1
10 end
11 find_version
12 FileUtils.mkdir_p('pkg')
13
14 desc "run tests in batch mode"
15 task :tests do
16 batch_run_line = "(yas-batch-run-tests t)"
17 sh "#{$EMACS} -Q -L . -l yasnippet-tests.el -nw" +
18 " --batch --eval '#{batch_run_line}'"
19 end
20
21 desc "convert some textmate bundles to yasnippets"
22 task :convert_bundles do
23 Dir.glob "extras/bundles/*-tmbundle" do |bundle_dir|
24 puts "Converting from #{bundle_dir}"
25 mode_prefix = File.basename(bundle_dir).match(/[^-]*/)[0]
26 raise "Couldn't guess mode name for #{bundle_dir}" unless mode_prefix
27 output = "./extras/imported/#{mode_prefix}-mode"
28 FileUtils.mkdir_p output
29 sh "./extras/textmate_import.rb -d #{bundle_dir} -o #{output} -q"
30 end
31 end
32
33 desc "create a release package"
34 task :package do
35 release_dir = "pkg/yasnippet-#{$version}"
36 FileUtils.mkdir_p(release_dir)
37 files = ['snippets', 'yasnippet.el']
38 FileUtils.cp_r files, release_dir
39 File.open(File.join(release_dir,'yasnippet-pkg.el'), 'w') do |file|
40 file.puts <<END
41 (define-package "yasnippet"
42 "#{$version}"
43 "A template system for Emacs")
44 END
45 end
46 sh "git clean -f snippets"
47 FileUtils.cd 'pkg' do
48 sh "tar cf yasnippet-#{$version}.tar yasnippet-#{$version}"
49 end
50 end
51
52 desc "create a release package and upload it to google code"
53 task :release => [:package, 'doc:archive'] do
54 raise "Not implemented for github yet!"
55 end
56
57 rule '.html' => '.rst' do |t|
58 sh "doc/compile-doc.py #{t.source} > #{t.name}"
59 end
60 desc "Generate document"
61 task :doc => FileList['doc/*.rst'].ext('html')
62
63 namespace :doc do
64 task :archive do
65 release_dir = "pkg/yasnippet-#{$version}"
66 FileUtils.mkdir_p(release_dir)
67 sh "tar cjf pkg/yasnippet-doc-#{$version}.tar.bz2 " +
68 "--exclude=doc/.svn --exclude=doc/images/.svn doc/*.html doc/images"
69 end
70
71 task :upload do
72 if File.exists? 'doc/gh-pages'
73 Dir.chdir 'doc/gh-pages' do
74 sh "git checkout gh-pages"
75 end
76 Dir.glob("doc/*.{html,css}").each do |file|
77 FileUtils.cp file, 'doc/gh-pages'
78 end
79 Dir.glob("doc/images/*").each do |file|
80 FileUtils.cp file, 'doc/gh-pages/images'
81 end
82 Dir.chdir 'doc/gh-pages' do
83 sh "git commit -a -m 'Automatic documentation update.'"
84 sh "git push"
85 end
86 end
87 end
88 end
89
90 desc "Compile yasnippet.el into yasnippet.elc"
91
92 rule '.elc' => '.el' do |t|
93 sh "#{$EMACS} --batch -L . --eval \"(byte-compile-file \\\"#{t.source}\\\")\""
94 end
95 task :compile => FileList["yasnippet.el"].ext('elc')
96
97 task :default => :doc