From 8e63e8eae43292fbeb219740eadd798bde76760c Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Wed, 16 Dec 2009 16:56:08 +0000 Subject: [PATCH] Build and install inplace the count_lines and compareSizes utils --- ghc.mk | 5 ++++ rules/build-perl.mk | 6 ++-- utils/compare_sizes/LICENSE | 31 ++++++++++++++++++++ utils/compare_sizes/{compareSizes.hs => Main.hs} | 6 +++- utils/compare_sizes/compareSizes.cabal | 19 ++++++++++++ utils/compare_sizes/ghc.mk | 8 +++++ .../count_lines/{count_lines => count_lines.lprl} | 5 ++++ utils/count_lines/ghc.mk | 5 ++++ 8 files changed, 81 insertions(+), 4 deletions(-) create mode 100644 utils/compare_sizes/LICENSE rename utils/compare_sizes/{compareSizes.hs => Main.hs} (97%) create mode 100644 utils/compare_sizes/compareSizes.cabal create mode 100644 utils/compare_sizes/ghc.mk rename utils/count_lines/{count_lines => count_lines.lprl} (98%) create mode 100644 utils/count_lines/ghc.mk diff --git a/ghc.mk b/ghc.mk index f47aece..9eaa7cd 100644 --- a/ghc.mk +++ b/ghc.mk @@ -398,6 +398,7 @@ ghc/stage2/package-data.mk: compiler/stage2/package-data.mk utils/haddock/dist/package-data.mk: compiler/stage2/package-data.mk utils/hsc2hs/dist-install/package-data.mk: compiler/stage2/package-data.mk +utils/compare_sizes/dist/package-data.mk: compiler/stage2/package-data.mk # add the final two package.conf dependencies: ghc-prim depends on RTS, # and RTS depends on libffi. @@ -553,6 +554,9 @@ BUILD_DIRS += \ $(GHC_TOUCHY_DIR) endif +BUILD_DIRS += utils/count_lines +BUILD_DIRS += utils/compare_sizes + ifneq "$(CLEANING)" "YES" # After compiler/, because these packages depend on it BUILD_DIRS += \ @@ -595,6 +599,7 @@ utils/runghc_dist_DISABLE = YES utils/hpc_dist_DISABLE = YES utils/hsc2hs_dist-install_DISABLE = YES utils/ghc-pkg_dist-install_DISABLE = YES +utils/compare_sizes_dist_DISABLE = YES compiler_stage2_DISABLE = YES compiler_stage3_DISABLE = YES ghc_stage2_DISABLE = YES diff --git a/rules/build-perl.mk b/rules/build-perl.mk index 669f3d7..f3ea2b6 100644 --- a/rules/build-perl.mk +++ b/rules/build-perl.mk @@ -23,12 +23,12 @@ define build-perl # $2 = distdir ifeq "$$($1_$2_TOPDIR)" "YES" -$1_$2_INPLACE = $(INPLACE_TOPDIR)/$$($1_$2_PROG) +$1_$2_INPLACE = $$(INPLACE_TOPDIR)/$$($1_$2_PROG) else -$1_$2_INPLACE = $(INPLACE_BIN)/$$($1_$2_PROG) +$1_$2_INPLACE = $$(INPLACE_BIN)/$$($1_$2_PROG) endif -$(call all-target,$$($1_$2_INPLACE)) +$(call all-target,$1_$2,$$($1_$2_INPLACE)) $(call clean-target,$1,$2,$1/$2 $$($1_$2_INPLACE)) .PHONY: clean_$1 diff --git a/utils/compare_sizes/LICENSE b/utils/compare_sizes/LICENSE new file mode 100644 index 0000000..b5059b7 --- /dev/null +++ b/utils/compare_sizes/LICENSE @@ -0,0 +1,31 @@ +The Glasgow Haskell Compiler License + +Copyright 2002, The University Court of the University of Glasgow. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +- Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. + +- Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +- Neither name of the University nor the names of its contributors may be +used to endorse or promote products derived from this software without +specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY COURT OF THE UNIVERSITY OF +GLASGOW AND THE CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +UNIVERSITY COURT OF THE UNIVERSITY OF GLASGOW OR THE CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +DAMAGE. diff --git a/utils/compare_sizes/compareSizes.hs b/utils/compare_sizes/Main.hs similarity index 97% rename from utils/compare_sizes/compareSizes.hs rename to utils/compare_sizes/Main.hs index a0397bf..302efaf 100644 --- a/utils/compare_sizes/compareSizes.hs +++ b/utils/compare_sizes/Main.hs @@ -89,7 +89,8 @@ getTree isFileInteresting root dir subdir dir' = dir subdir doEntry :: FilePath -> IO (Maybe Tree) doEntry e = liftM Just (getTree isFileInteresting root dir' e) - `catch` \_ -> -- XXX Do this better + `catchIO` \_ -> -- XXX We ought to check this is a + -- "not a directory" exception really if isFileInteresting e then do let fn = dir' e h <- openFile (root fn) ReadMode @@ -98,6 +99,9 @@ getTree isFileInteresting root dir subdir return $ Just $ File e fn size else return Nothing +catchIO :: IO a -> (IOError -> IO a) -> IO a +catchIO = catch + ---------------------------------------------------------------------- -- Comparing the trees diff --git a/utils/compare_sizes/compareSizes.cabal b/utils/compare_sizes/compareSizes.cabal new file mode 100644 index 0000000..32acb1d --- /dev/null +++ b/utils/compare_sizes/compareSizes.cabal @@ -0,0 +1,19 @@ +name: compareSizes +version: 0.1.0.0 +cabal-version: >= 1.6 +license: BSD3 +build-type: Simple +license-file: LICENSE +stability: experimental +synopsis: Size comparison util +description: Size comparison util +category: Development + +executable compareSizes + build-depends: + base >= 4 && < 5, + directory, + filepath + + main-is: Main.hs + diff --git a/utils/compare_sizes/ghc.mk b/utils/compare_sizes/ghc.mk new file mode 100644 index 0000000..1c9dbee --- /dev/null +++ b/utils/compare_sizes/ghc.mk @@ -0,0 +1,8 @@ + +utils/compare_sizes_USES_CABAL = YES +utils/compare_sizes_PACKAGE = compareSizes +utils/compare_sizes_MODULES = Main +utils/compare_sizes_dist_PROG = compareSizes$(exeext) + +$(eval $(call build-prog,utils/compare_sizes,dist,1)) + diff --git a/utils/count_lines/count_lines b/utils/count_lines/count_lines.lprl similarity index 98% rename from utils/count_lines/count_lines rename to utils/count_lines/count_lines.lprl index 1e0942c..cec3326 100644 --- a/utils/count_lines/count_lines +++ b/utils/count_lines/count_lines.lprl @@ -1,5 +1,7 @@ #! /usr/bin/perl +\begin{code} + use FindBin; %DirCount = (); @@ -65,3 +67,6 @@ foreach $m (sort (keys %ModCount)) { $totcmts += $ModComments{$m}; } printf "\n%-20s %6d %6d\n", 'TOTAL:', $tot, $totcmts; + +\end{code} + diff --git a/utils/count_lines/ghc.mk b/utils/count_lines/ghc.mk new file mode 100644 index 0000000..c467413 --- /dev/null +++ b/utils/count_lines/ghc.mk @@ -0,0 +1,5 @@ + +utils/count_lines_PERL_SRC = count_lines.lprl +utils/count_lines_dist_PROG = count_lines + +$(eval $(call build-perl,utils/count_lines,dist)) -- 1.7.10.4