-
Notifications
You must be signed in to change notification settings - Fork 0
/
lib.go
38 lines (35 loc) · 784 Bytes
/
lib.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// dcc - dependency-driven C/C++ compiler front end
//
// Copyright © A.Newman 2015.
//
// This source code is released under version 2 of the GNU Public License.
// See the file LICENSE for details.
//
package main
import (
"os"
)
// Lib ceates a static library from the inputs iff the inputs are
// newer than any existing target.
//
func Lib(target string, inputs []string) error {
createLib := func() error {
return platform.CreateLibrary(target, inputs)
}
if IgnoreDependencies {
return createLib()
}
targetInfo, err := Stat(target)
if os.IsNotExist(err) {
return createLib()
} else if err != nil {
return err
}
newestInput, err := NewestOf(inputs)
if err == nil {
if newestInput.After(targetInfo.ModTime()) {
return createLib()
}
}
return err
}