-
Notifications
You must be signed in to change notification settings - Fork 0
/
platform_windows.go
54 lines (48 loc) · 1.7 KB
/
platform_windows.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// 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"
"path/filepath"
"strings"
)
var platform = Platform{
DefaultCC: "cl",
DefaultCXX: "cl",
ObjectFileSuffix: ".obj",
StaticLibSuffix: ".lib",
DynamicLibSuffix: ".dll",
DefaultExecutable: "program.exe",
LibraryPaths: filepath.SplitList(Getenv("LIB", "")),
CreateLibrary: WindowsCreateLibrary,
CreateDLL: WindowsCreateDLL,
CreatePlugin: WindowsCreateDLL,
IsRoot: WindowsIsRoot,
}
// WindowsCreateLibrary creates a static library from the supplied object files
// using Microsoft's LIB.EXE
func WindowsCreateLibrary(filename string, objectFiles []string) error {
args := append([]string{"/nologo", "/out:" + filename}, objectFiles...)
return Exec("lib", args, os.Stderr)
}
// WindowsCreateDLL creates a dynamic library from the supplied object files
// and library files using Microsoft's LINK.EXE.
func WindowsCreateDLL(filename string, objectFiles []string, libraryFiles []string, linkerOptions []string, frameworks []string) error {
args := append([]string{"/nologo", "/DLL", "/OUT:" + filename}, objectFiles...)
args = append(args, linkerOptions...)
args = append(args, libraryFiles...)
return Exec("link", args, os.Stderr)
}
// WindowsIsRoot determines if a pathname represents a "root"
// directory. A "root" is defined to be the top-level directory of a
// volume (aka drive).
func WindowsIsRoot(path string) bool {
path = filepath.Clean(path)
path = strings.TrimPrefix(path, filepath.VolumeName(path))
return path == "\\"
}