Skip to content

Commit

Permalink
Use Perl for MD% sums.
Browse files Browse the repository at this point in the history
  • Loading branch information
ingy committed Aug 21, 2008
1 parent 6119682 commit 7d8fa91
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
28 changes: 17 additions & 11 deletions extras/Makefile
Expand Up @@ -3,11 +3,16 @@
RENDERER:=$(shell echo `js-cpan Test/Base/bin/render-template`)
TEST_TEMPLATE:=$(shell echo `js-cpan Test/Base/template/test.html`)
INDEX_TEMPLATE:=$(shell echo `js-cpan Test/Base/template/index.html`)
TEST_LOCAL=template/test.html
INDEX_LOCAL=template/index.html

TEST_TEMPLATE_MD5=$(word 1,$(shell md5sum $(TEST_TEMPLATE)))
TEST_LOCAL_MD5=$(word 1,$(shell md5sum template/test.html))
INDEX_TEMPLATE_MD5=$(word 1,$(shell md5sum $(INDEX_TEMPLATE)))
INDEX_LOCAL_MD5=$(word 1,$(shell md5sum template/index.html))
MD5SUM=perl -MDigest::MD5 -e \
'open X,shift;$$d=Digest::MD5->new;$$d->addfile(*X);print $$d->hexdigest'

TEST_TEMPLATE_MD5=$(word 1,$(shell $(MD5SUM) $(TEST_TEMPLATE)))
TEST_LOCAL_MD5=$(word 1,$(shell $(MD5SUM) $(TEST_LOCAL)))
INDEX_TEMPLATE_MD5=$(word 1,$(shell $(MD5SUM) $(INDEX_TEMPLATE)))
INDEX_LOCAL_MD5=$(word 1,$(shell $(MD5SUM) $(INDEX_LOCAL)))

ALL_T_HTML:=$(shell ls -1 t/*.t.js | perl -pe 's/js$$/html/;s/^t\///')

Expand All @@ -26,23 +31,24 @@ all: $(ALL_DIRS) $(ALL_TARGETS) $(ALL_LIBS)
clean:
rm -fr $(ALL_TARGETS) $(ALL_LIBS)
if [ "$(TEST_TEMPLATE_MD5)" = \
"$(TEST_LOCAL_MD5)" ]; then rm -f template/test.html; fi
"$(TEST_LOCAL_MD5)" ]; then rm -f $(TEST_LOCAL); fi
if [ "$(INDEX_TEMPLATE_MD5)" = \
"$(INDEX_LOCAL_MD5)" ]; then rm -f template/index.html; fi
"$(INDEX_LOCAL_MD5)" ]; then rm -f $(INDEX_LOCAL); fi
-find $(ALL_DIRS) -depth -type d | xargs rmdir 2> /dev/null


purge: clean
rm Makefile config.yaml

%.t.html: template/test.html
%.t.html: $(TEST_LOCAL)
perl $(RENDERER) $(notdir $<) $(@:%.t.html=t/%.t.js) > $@

index.html: template/index.html t/*.t.js
index.html: $(INDEX_LOCAL) t/*.t.js
perl $(RENDERER) $(notdir $<) $(@:%.t.html=t/%.t.js) > $@

lib/Test/Base.js: lib/Test
cp -f `js-cpan Test.Base` $@
ln -s ../../../lib/Test/Base.js $@
# cp -f `js-cpan Test.Base` $@

lib/Test/Builder.js: lib/Test
cp -f `js-cpan Test.Builder` $@
Expand All @@ -56,10 +62,10 @@ lib/Test/Harness/Browser.js: lib/Test/Harness
lib lib/Test lib/Test/Harness:
mkdir -p $@

template/test.html:
$(TEST_LOCAL):
cp -f $(TEST_TEMPLATE) $@

template/index.html:
$(INDEX_LOCAL):
cp -f $(INDEX_TEMPLATE) $@

template:
Expand Down
1 change: 1 addition & 0 deletions sample/Makefile
7 changes: 7 additions & 0 deletions sample/config.yaml
@@ -0,0 +1,7 @@
# This file is used to override the following defaults:

# index_title: A Sample Test.Base Testing Setup
# import_libs:
# - lib/Test/Sample.js
# template_include_path:
# - template

0 comments on commit 7d8fa91

Please sign in to comment.