]> git.wincent.com - wikitext.git/commitdiff
Fix subtle Rakefile breakage
authorWincent Colaiuta <win@wincent.com>
Tue, 3 Feb 2009 22:48:00 +0000 (23:48 +0100)
committerWincent Colaiuta <win@wincent.com>
Tue, 3 Feb 2009 22:52:42 +0000 (23:52 +0100)
As mentioned in b12cb25, the 1.4.0 release was broken due to a misfire
during "rake package".

The diagnosis was as follows; before each of the following tests, a
"rake clobber" was executed to start with a clean slate:

   - "rake gem": "make" does appear to be executed,
     but produced gem is incomplete
   - "rake make; rake gem": produced gem is complete
   - "rake package": "make" does appear to be executed,
     but produced gem is incomplete
   - "rake make; rake package": you can see "clobber"
     task getting executed, then "make"; you would
     expect this automated "make" not to work seeing
     as it is broken in two other cases above, but
     the built gem is complete and it works!

Specifically, in the incomplete gems, the generated
extension Makefile has these lines:

  SRCS = ary.c parser.c str.c token.c wikitext.c
  OBJS = ary.o parser.o str.o token.o wikitext.o

Instead of the desired:

  SRCS = ary.c parser.c str.c token.c wikitext.c wikitext_ragel.c
  OBJS = ary.o parser.o str.o token.o wikitext.o wikitext_ragel.o

Note that the Makefile in the sourcetree in all of these tests
was correct; it was only the file generated from the gems that
was incorrect.

Further inspection showed that the wikitext_ragel.c file was not
included in the gem. This was the key; the file was missing
from inside the gem even though it was correctly generated outside
while building the gem. Naturally, the Makefile was also missing the
file ("mkmf" generates the SRCS and OBJS lines based on what it
finds in the directory).

The reason the file was missing was that the "files" entry in the
Gem specification was evaluated too early, before the dependencies
in the tasks had been executed, and before the "wikitext_ragel.c"
file even existed.

Running "rake make" manually beforehand was enough to make
everything work because it ensured that the "wikitext_ragel.c"
file was present at the time the Gem specification was evaluated;
even though the file was later clobbered and rebuilt it didn't
matter because the "files" entry was correct.

It would have been nice for the gem build to fail due to the
missing file. I would have been alerted then to the fact that
1.4.0 was broken; I'm going to see if I can make the build process
barf in the face of a missing file like that.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
Rakefile

index 7cd161c940165e5abaf60c0b4296ede385428674..1b5d24d6f8760d657cd109068d8dda82f5194f2e 100644 (file)
--- a/Rakefile
+++ b/Rakefile
@@ -1,4 +1,4 @@
-# Copyright 2007-2008 Wincent Colaiuta
+# Copyright 2007-2009 Wincent Colaiuta
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation, either version 3 of the License, or
@@ -59,7 +59,7 @@ file ragel => ['ext/wikitext_ragel.rl'] do
   end
 end
 
-file extension_makefile => ['ext/extconf.rb', 'ext/depend'] do
+file extension_makefile => ['ext/extconf.rb', 'ext/depend', ragel] do
   Dir.chdir('ext') do
     if RUBY_PLATFORM =~ /darwin/
       sh "env ARCHFLAGS='-arch i386' ruby extconf.rb"
@@ -107,11 +107,14 @@ SPEC = Gem::Specification.new do |s|
   ENDDESC
   s.require_paths     = ['ext', 'lib']
   s.has_rdoc          = true
-  s.files             = FileList['spec/*', 'ext/*.{rb,c,h}', 'ext/depend', 'lib/wikitext/*', 'rails/init.rb'].to_a
+  s.files             = FileList['spec/*', 'ext/wikitext_ragel.c', 'ext/*.{rb,c,h}', 'ext/depend', 'lib/wikitext/*', 'rails/init.rb'].to_a
   s.extensions        = ['ext/extconf.rb']
 end
 
+task :gem => [:make]
+
 task :package => [:clobber, :all, :gem]
 Rake::GemPackageTask.new(SPEC) do |t|
   t.need_tar      = true
 end
+