1--------------------------------------------------------------------------
2-- Copyright (c) 2007-2015 ETH Zurich.
3-- All rights reserved.
4--
5-- This file is distributed under the terms in the attached LICENSE file.
6-- If you do not find this file, copies can be found by writing to:
7-- ETH Zurich D-INFK, Universitaetstasse 6, CH-8092 Zurich. Attn: Systems Group.
8--
9-- Arguments to major Hake targets
10--
11--------------------------------------------------------------------------
12
13module Args where
14
15import HakeTypes
16import TreeDB
17
18data Args = Args {
19      buildFunction :: TreeDB -> String -> Args -> HRule,
20      target :: String,
21      driverType :: String,
22      cFiles :: [String],
23      generatedCFiles :: [String],
24      cxxFiles :: [String],
25      generatedCxxFiles :: [String],
26      assemblyFiles :: [String],
27      flounderDefs :: [String],
28      flounderBindings :: [String], -- built stubs for all enabled backends
29      flounderExtraDefs :: [(String, [String])],
30      flounderExtraBindings :: [(String, [String])], -- build stubs for specific backends
31      flounderTHCDefs :: [String], -- TODO: this can probably be subsumed into the above?
32      flounderTHCStubs :: [String], -- TODO: this can probably be subsumed into the above?
33      mackerelDevices :: [String],
34      addCFlags :: [String],
35      addCxxFlags :: [String],
36      omitCFlags :: [String],
37      omitCxxFlags :: [String],
38      addIncludes :: [String],
39      addGeneratedIncludes :: [String],
40      omitIncludes :: [String],
41      addLinkFlags :: [String],
42      addLibraries :: [String],
43      addModules :: [String],
44      addGeneratedDependencies :: [String],
45      architectures :: [String],
46      skateSchemaDefs :: [String],  -- just the Skate Schema headers
47      skateSchemas :: [String],      -- Schema headers and functions
48      installDirs :: InstallDirs
49}
50
51data InstallDirs = InstallDirs {
52    bindir :: String,
53    libdir :: String
54}
55
56defaultArgs = Args {
57      buildFunction = defaultBuildFn,
58      target = "",
59      driverType = "",
60      cFiles = [],
61      generatedCFiles = [],
62      cxxFiles = [],
63      generatedCxxFiles = [],
64      assemblyFiles = [],
65      flounderDefs = [],
66      flounderBindings = [],
67      flounderExtraDefs = [],
68      flounderExtraBindings = [],
69      flounderTHCDefs = [],
70      flounderTHCStubs = [],
71      mackerelDevices = [],
72      addCFlags = [],
73      addCxxFlags = [],
74      omitCFlags = [],
75      omitCxxFlags = [],
76      addIncludes = [],
77      addGeneratedIncludes = [],
78      omitIncludes = [],
79      addLinkFlags = [],
80      addLibraries = [],
81      addModules = [],
82      addGeneratedDependencies = [],
83      architectures = allArchitectures,
84      skateSchemaDefs = [],
85      skateSchemas = [],
86      installDirs = InstallDirs {
87            bindir = "/sbin",
88            libdir = "/lib"
89      }
90}
91
92allArchitectures = [ "x86_64", "x86_32", "armv7", "armv8", "k1om" ]
93allArchitectureFamilies = [ "x86_64", "x86_32", "arm", "k1om" ]
94-- architectures that currently support THC
95thcArchitectures = ["x86_64", "x86_32"]
96
97-- all known flounder backends that we might want to generate defs for
98allFlounderBackends
99    = [ "lmp", "ump", "ump_ipi", "loopback", "rpcclient", "msgbuf", "multihop", "ahci", "local" ]
100
101defaultBuildFn :: TreeDB -> String -> Args -> HRule
102defaultBuildFn _ f _ =
103    Error ("Bad use of default Args in " ++ f)
104
105showArgs :: String -> Args -> String
106showArgs prefix a =
107    prefix ++ "Args:"
108    ++ "\n  target:                " ++ (show $ target a)
109    ++ "\n  cFiles:                " ++ (show $ cFiles a)
110    ++ "\n  generatedCFiles:       " ++ (show $ generatedCFiles a)
111    ++ "\n  cxxFiles:              " ++ (show $ cxxFiles a)
112    ++ "\n  generatedCxxFiles      " ++ (show $ generatedCxxFiles a)
113    ++ "\n  assemblyFiles:         " ++ (show $ assemblyFiles a)
114    ++ "\n  flounderDefs:          " ++ (show $ flounderDefs a)
115    ++ "\n  flounderBindings:      " ++ (show $ flounderBindings a)
116    ++ "\n  flounderExtraDefs:     " ++ (show $ flounderExtraDefs a)
117    ++ "\n  flounderExtraBindings: " ++ (show $ flounderExtraBindings a)
118    ++ "\n  flounderTHCDefs:       " ++ (show $ flounderTHCDefs a)
119    ++ "\n  flounderTHCStubs:      " ++ (show $ flounderTHCStubs a)
120    ++ "\n  addCFlags:             " ++ (show $ addCFlags a)
121    ++ "\n  addCxxFlags:           " ++ (show $ addCxxFlags a)
122    ++ "\n  omitCFlags:            " ++ (show $ omitCFlags a)
123    ++ "\n  omitCxxFlags:          " ++ (show $ omitCxxFlags a)
124    ++ "\n  addIncludes:           " ++ (show $ addIncludes a)
125    ++ "\n  omitIncludes:          " ++ (show $ omitIncludes a)
126    ++ "\n  addLinkFlags:          " ++ (show $ addLinkFlags a)
127    ++ "\n  addLibraries:          " ++ (show $ addLibraries a)
128    ++ "\n  addModules:            " ++ (show $ addModules a)
129    ++ "\n  addDeps:               " ++ (show $ addGeneratedDependencies a)
130    ++ "\n  architectures:         " ++ (show $ architectures a)
131    ++ "\n  skateSchemaDefs:       " ++ (show $ skateSchemaDefs a)
132    ++ "\n  skateSchemas:          " ++ (show $ skateSchemas a)
133    ++ "\n"
134