github.com/hwaf/hwaf@v0.0.0-20140814122253-5465f73b20f1/hlib/wscript.go (about)

     1  package hlib
     2  
     3  type Wscript_t struct {
     4  	Package   Package_t
     5  	Options   Options_t
     6  	Configure Configure_t
     7  	Build     Build_t
     8  }
     9  
    10  type Stmt interface {
    11  	is_stmt()
    12  }
    13  
    14  type Package_t struct {
    15  	Name     string
    16  	Authors  []Author
    17  	Managers []Manager
    18  	Version  Version
    19  	Deps     []Dep_t
    20  }
    21  
    22  type Author string
    23  type Manager string
    24  type Version string
    25  
    26  type Branches []string
    27  
    28  type Dep_t struct {
    29  	Name    string
    30  	Version Version
    31  	Type    DepType
    32  }
    33  
    34  type DepType int
    35  
    36  const (
    37  	UnknownDep DepType = 1 << iota
    38  	PublicDep
    39  	PrivateDep
    40  	RuntimeDep
    41  )
    42  
    43  func (d DepType) HasMask(mask DepType) bool {
    44  	return bool((d & mask) != 0)
    45  }
    46  
    47  type Visibility int
    48  
    49  const (
    50  	Local    Visibility = 0
    51  	Exported Visibility = 1
    52  )
    53  
    54  type Options_t struct {
    55  	Tools    []string
    56  	HwafCall []string
    57  	Stmts    []Stmt
    58  }
    59  
    60  type Configure_t struct {
    61  	Tools    []string
    62  	HwafCall []string
    63  	Env      Env_t
    64  	//Tags  []Value
    65  	Stmts []Stmt
    66  }
    67  
    68  type Env_t map[string]Value
    69  
    70  type Build_t struct {
    71  	Tools    []string
    72  	HwafCall []string
    73  	Targets  Targets_t
    74  	Stmts    []Stmt
    75  	Env      Env_t
    76  }
    77  
    78  type Targets_t []Target_t
    79  
    80  type Target_t struct {
    81  	Name           string
    82  	Features       []string
    83  	Source         []Value
    84  	Target         string
    85  	Group          string
    86  	Use            []Value
    87  	Defines        []Value
    88  	CFlags         []Value
    89  	CxxFlags       []Value
    90  	LinkFlags      []Value
    91  	ShlibFlags     []Value
    92  	StlibFlags     []Value
    93  	RPath          []Value
    94  	Includes       []Value
    95  	ExportIncludes []Value
    96  	InstallPath    []Value
    97  	Env            Env_t
    98  	KwArgs         map[string][]Value
    99  }
   100  
   101  // make Targets_t sortable
   102  
   103  func (tgts Targets_t) Len() int           { return len(tgts) }
   104  func (tgts Targets_t) Less(i, j int) bool { return tgts[i].Name < tgts[j].Name }
   105  func (tgts Targets_t) Swap(i, j int)      { tgts[i], tgts[j] = tgts[j], tgts[i] }
   106  
   107  type KeyValue struct {
   108  	Tag   string
   109  	Value []string
   110  }
   111  
   112  type Value struct {
   113  	Name string
   114  	Set  []KeyValue // first item is the "default"
   115  }
   116  
   117  func DefaultValue(name string, value []string) Value {
   118  	kv := KeyValue{
   119  		Tag:   "default",
   120  		Value: make([]string, len(value)),
   121  	}
   122  	copy(kv.Value, value)
   123  
   124  	return Value{
   125  		Name: name,
   126  		Set:  []KeyValue{kv},
   127  	}
   128  }
   129  
   130  // EOF