-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathre_build_GitLink.wl
130 lines (104 loc) · 3.89 KB
/
re_build_GitLink.wl
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
(* ::Package:: *)
(* Wolfram Language Package *)
$Debug = False;
Needs[ "CCompilerDriver`" ];
$GitLink = FileNameJoin[ { DirectoryName[ $InputFileName, 2 ], "src" } ];
$workspace = DirectoryName[ $InputFileName, 3 ];
$libgit2 = FileNameJoin[ { $workspace, "libgit2" } ];
$libssh2 = FileNameJoin[ { $workspace, "LIBSSH2" } ];
$openssl = FileNameJoin[ { $workspace, "OpenSSL" } ];
$mathlink = FileNameJoin[ { $InstallationDirectory, "SystemFiles", "Links", "MathLink", "DeveloperKit", $SystemID } ];
AntLog[ StringRepeat[ "=", 75 ] ];
AntLog[ " component == \"" <> AntProperty[ "component" ] <> "\"" ];
AntLog[ " system_id == \"" <> AntProperty[ "system_id" ] <> "\"" ];
AntLog[ "" ];
AntLog[ " files_directory == \"" <> AntProperty[ "files_directory" ] <> "\"" ];
AntLog[ "scratch_directory == \"" <> AntProperty[ "scratch_directory" ] <> "\"" ];
AntLog[ "" ];
AntLog[ " $GitLink == \"" <> $GitLink <> "\"" ];
AntLog[ " $libgit2 == \"" <> $libgit2 <> "\"" ];
AntLog[ " $libssh2 == \"" <> $libssh2 <> "\"" ];
AntLog[ " $openssl == \"" <> $openssl <> "\"" ];
AntLog[ "" ];
AntLog[ " $mathlink == \"" <> $mathlink <> "\"" ];
AntLog[ StringRepeat[ "=", 75 ] ];
AntLog[ "" ];
$GitLinkLib = CreateLibrary[
FileNames[ "*.cpp", { $GitLink }, Infinity ],
"gitLink",
"CleanIntermediate" -> True,
"CompileOptions" -> Switch[ $OperatingSystem,
"MacOSX", "-std=c 14 -stdlib=libc -mmacosx-version-min=10.9 -framework Security",
"Unix", "-Wno-deprecated -std=c 14",
"Windows", "/EHsc " <> If[ $Debug, "/MTd", "/MT" ]
],
"CompilerInstallation" -> If[ $OperatingSystem == "Windows",
Environment[ "COMPILER_INSTALLATION" ],
Automatic
],
"CompilerName" -> Automatic,
"Debug" -> $Debug,
"Defines" -> {
Switch[ $OperatingSystem,
"MacOSX", "MAC",
"Unix", "UNIX",
"Windows", "WIN"
],
If[ $SystemWordLength === 64, "SIXTYFOURBIT", Nothing ],
If[ $Debug, "DEBUG", Nothing ]
},
"IncludeDirectories" -> Flatten[ {
FileNameJoin[ { $libgit2, "Source", "include" } ],
Select[ FileNames[ "*", $GitLink ], DirectoryQ ]
} ],
"Language" -> "C ",
"Libraries" -> Switch[ $OperatingSystem,
"MacOSX",
{ "git2", "z", "iconv", "crypto", "ssh2" },
"Unix",
{ "git2", "z", "rt", "pthread", "ssh2", "ssl"},
"Windows",
{ "git2", "advapi32", "ole32", "rpcrt4", "shlwapi", "user32", "winhttp", "crypt32", "libssh2" }
],
"LibraryDirectories" -> Switch[ $OperatingSystem,
"MacOSX",
{
FileNameJoin[ { $libssh2, "lib" } ],
FileNameJoin[ { $openssl, "lib" } ],(*for crypto library*)
$libgit2 <> If[ $Debug, ".debug", "" ]
},
"Unix",
{
FileNameJoin[ { $openssl, "lib" } ],
FileNameJoin[ { $libssh2, "lib" } ],
$libgit2 <> If[ $Debug, ".debug", "" ]
},
"Windows",
{
FileNameJoin[ { $libssh2, "lib" } ],
$libgit2 <> If[ $Debug, ".debug", "" ]
}
],
"LinkerOptions" -> Switch[$OperatingSystem,
"MacOSX", { "-install_name", "@rpath/gitLink.dylib", "-rpath", "@loader_path"},
"Unix", { "-rpath='$ORIGIN'" },
"Windows", { "/NODEFAULTLIB:msvcrt" }
],
"ShellCommandFunction" -> Global`AntLog,
"ShellOutputFunction" -> Global`AntLog,
"SystemIncludeDirectories" -> {
FileNameJoin[ { $mathlink, "CompilerAdditions" } ],
FileNameJoin[ { $InstallationDirectory, "SystemFiles", "IncludeFiles", "C" } ]
},
"SystemLibraryDirectories" -> {
If[ $OperatingSystem == "MacOSX" , "-F", "" ] <> FileNameJoin[ { $mathlink, "CompilerAdditions" } ],
FileNameJoin[ { $InstallationDirectory, "SystemFiles", "Libraries", $SystemID } ]
},
"TargetDirectory" -> FileNameJoin[ { AntProperty[ "files_directory" ], AntProperty[ "component" ], "LibraryResources", AntProperty[ "system_id" ] } ],
"TargetSystemID" -> AntProperty[ "system_id" ],
"WorkingDirectory" -> AntProperty[ "scratch_directory" ]
];
If[ FailureQ[ $GitLinkLib ],
AntFail[ "Library was not generated." ],
AntLog[ "$GitLinkLib == \"" <> $GitLinkLib <> "\"" ]
];