-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplatform.go
More file actions
65 lines (58 loc) · 1.85 KB
/
platform.go
File metadata and controls
65 lines (58 loc) · 1.85 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// 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 (
"path/filepath"
)
// The Platform type defines a number of platform-specific values and
// functions. Code defines a single global value, platform, of type
// Platform which is defined in the platform_xxx.go file used for the
// target system.
//
type Platform struct {
DefaultCC string
DefaultCXX string
ObjectFileSuffix string
StaticLibPrefix string
StaticLibSuffix string
DynamicLibPrefix string
DynamicLibSuffix string
PluginPrefix string
PluginSuffix string
DefaultExecutable string
LibraryPaths []string
CreateLibrary func(string, []string) error
CreateDLL func(string, []string, []string, []string, []string) error
CreatePlugin func(string, []string, []string, []string, []string) error
SelectTarget func(*Platform, string) error
IsRoot func(string) bool
}
// StaticLibrary transforms a filename "stem" to the name of a
// static library on the host platform.
//
func (p *Platform) StaticLibrary(name string) string {
return p.StaticLibPrefix + name + p.StaticLibSuffix
}
// DynamicLibrary transforms a filename "stem" to the name of
// a dynamic library on the host platform.
//
func (p *Platform) DynamicLibrary(name string) string {
return p.DynamicLibPrefix + name + p.DynamicLibSuffix
}
// PluginFile transforms a filename "stem" to the name of
// a "plugin" on the host platform.
//
func (p *Platform) PluginFile(name string) string {
return p.PluginPrefix + name + p.PluginSuffix
}
// UnixIsRoot determines if a pathname represents the top-level,
// or "root", of the file system hierarchy.
//
func UnixIsRoot(path string) bool {
return filepath.Clean(path) == "/"
}