[default to __default and edit web page Yoshikuni Jujo **20081129120106] { move ./web_page/samples/second_sample ./web_page/samples/use_rule move ./web_page/samples/second_sample_FunSetRaw ./web_page/samples/use_rule_FunSetRaw adddir ./web_page/samples/use_default hunk ./Development/Hake/Variables.hs 39 -defaultTrgtStr = "default" +defaultTrgtStr = "__default" addfile ./web_page/samples/use_default/Hakefile hunk ./web_page/samples/use_default/Hakefile 1 +import Development.Hake +import Development.Hake.FunSetRaw + +main = hake [ + + dflt [ "hello" ] + , + rule "" ".c" $ \t (s:_) -> [ [ "cc", "-o", t, s ] ] + + ] addfile ./web_page/samples/use_default/hello.c hunk ./web_page/samples/use_default/hello.c 1 +#include + +int +main (int argc, char *argv[]) +{ + printf( "Hello, world!\n" ); + return 0; + } hunk ./web_page/short_tutorial.xhtml.ehs 21 +

3. use default sample

+

3.1.

+

3.2.

hunk ./web_page/short_tutorial/Hakefile 11 -getV :: String -> String -> String -getV k = fromJust . lookup 1 . snd . fromJust . matchRegexPR (k ++ "\\s*:\\s*(.+)") - -targets :: [ String ] -targets = [ firstSampleXhtml, useRuleXhtml, useDefaultXhtml ] - -firstSampleXhtml :: String +firstSampleXhtml, useRuleXhtml, useDefaultXhtml :: String hunk ./web_page/short_tutorial/Hakefile 13 +useRuleXhtml = "use_rule.xhtml" +useDefaultXhtml = "use_default.xhtml" hunk ./web_page/short_tutorial/Hakefile 16 -useRuleXhtml :: String -useRuleXhtml = "use_rule.xhtml" +firstSampleXhtmlMoreFile, useRuleXhtmlMoreFile, useDefaultXhtmlMoreFile :: [ String ] +firstSampleXhtmlMoreFile = [ "Hakefile_first_sample" ] +useRuleXhtmlMoreFile = [ "Hakefile_use_rule" , "Hakefile_use_rule_FunSetRaw" ] +useDefaultXhtmlMoreFile = [ "Hakefile_use_default" ] hunk ./web_page/short_tutorial/Hakefile 21 -useDefaultXhtml :: String -useDefaultXhtml = "use_default.xhtml" +targets :: [ String ] +targets = [ firstSampleXhtml, useRuleXhtml, useDefaultXhtml ] hunk ./web_page/short_tutorial/Hakefile 24 -firstSampleXhtmlMoreFile :: [ String ] -firstSampleXhtmlMoreFile = [ - "Hakefile_first_sample" +moreFile :: [ String ] +moreFile = firstSampleXhtmlMoreFile ++ useRuleXhtmlMoreFile ++ useDefaultXhtmlMoreFile + +deps :: [ (String, [String]) ] +deps = [ + (firstSampleXhtml, firstSampleXhtmlMoreFile) + , (useRuleXhtml, useRuleXhtmlMoreFile) + , (useDefaultXhtml, useDefaultXhtmlMoreFile) hunk ./web_page/short_tutorial/Hakefile 34 -useRuleXhtmlMoreFile = [ - "Hakefile_use_rule" - , "Hakefile_use_rule_FunSetRaw" - ] +copyFileRuleList :: [ Rule ] +copyFileRuleList = map (uncurry copyFileRule . mkCopyPairOfHakefile) moreFile hunk ./web_page/short_tutorial/Hakefile 37 -moreFile :: [ String ] -moreFile = firstSampleXhtmlMoreFile ++ useRuleXhtmlMoreFile +mkCopyPairOfHakefile :: String -> (String, String) +mkCopyPairOfHakefile hfn + = (hfn, "../samples/" ++ getFirstBrReg "Hakefile_(.+)" hfn ++ "/Hakefile") hunk ./web_page/short_tutorial/Hakefile 48 - hake $ [ + hake $ ([ hunk ./web_page/short_tutorial/Hakefile 82 - file [ "Hakefile_first_sample" ] [ "../samples/first_sample/Hakefile" ] $ \t (s:_) -> do - copyFile s t - return ExitSuccess - , - file [ "Hakefile_use_rule" ] [ "../samples/second_sample/Hakefile" ] $ \t (s:_) -> do - copyFile s t - return ExitSuccess - , - file [ "Hakefile_use_rule_FunSetRaw" ] [ "../samples/second_sample_FunSetRaw/Hakefile" ] $ \t (s:_) -> do - copyFile s t - return ExitSuccess - , hunk ./web_page/short_tutorial/Hakefile 84 - return ExitSuccess - - ] `addDeps` [ - - (firstSampleXhtml, firstSampleXhtmlMoreFile) - , - (useRuleXhtml, useRuleXhtmlMoreFile) - - ] - + return ExitSuccess ] ++ + copyFileRuleList) `addDeps` deps + hunk ./web_page/short_tutorial/Hakefile 105 + +copyFileRule :: FilePath -> FilePath -> Rule +copyFileRule trgt src + = file [ trgt ] [ src ] $ \t (s:_) -> do + putStrLn $ "cp " ++ src ++ " " ++ trgt + copyFile s t + return ExitSuccess + +getV :: String -> String -> String +getV k = fromJust . lookup 1 . snd . fromJust . matchRegexPR (k ++ "\\s*:\\s*(.+)") + +getFirstBrReg :: String -> String -> String +getFirstBrReg reg = fromJust . lookup 1 . snd . fromJust . matchRegexPR reg hunk ./web_page/short_tutorial/use_default.xhtml.ehs 7 -

This page is under construction now. <%==$ getClockTime %>

+ +

3. use default sample

+

updated at <%==$ getClockTime %>

+

You can use default target.

+ +

3.1. dflt function

+

> cat Hakefile

+
<%== readFile "../samples/use_default/Hakefile" %>
+ +

3.2. try

+
> hake
+cc -o hello hello.c
+> ./hello
+Hello, world!
+ hunk ./web_page/short_tutorial/use_rule.xhtml.ehs 14 - readFile "../samples/second_sample/hello.c" %> + readFile "../samples/use_rule/hello.c" %> hunk ./web_page/short_tutorial/use_rule.xhtml.ehs 17 -
<%== readFile "../samples/second_sample/Hakefile" %>
+
<%== readFile "../samples/use_rule/Hakefile" %>
hunk ./web_page/short_tutorial/use_rule.xhtml.ehs 22 -
<%== readFile "../samples/second_sample_FunSetRaw/Hakefile" %>
+
<%== readFile "../samples/use_rule_FunSetRaw/Hakefile" %>
}