forked from libgit2/node-gitteh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwscript
83 lines (62 loc) · 2.51 KB
/
wscript
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
import Options
import os
from subprocess import Popen
from os.path import exists, abspath
srcdir = '.'
blddir = 'build'
VERSION = '0.0.1'
def set_options(opt):
opt.tool_options('compiler_cxx')
opt.add_option("--debug",
action = "store_true",
default = False,
help = "Compile gitteh and libgit2 (if using bundled version) with debug flags.")
opt.add_option("--use-bundled-libgit2",
action = "store_true",
default = False,
help = "Don't use libgit2 installed on system, configure and compile an internal copy instead.")
def configure_libgit2(ctx):
o = Options.options
if o.use_bundled_libgit2 or not ctx.check(lib = "git2", uselib_store = "GIT2"):
# Checkout libgit2 submodule if it isn't already.
if exists(".git"):
if not exists("vendor/libgit2") or not os.listdir("vendor/libgit2"):
print "Checking out libgit2 submodule."
if Popen("{0} submodule update --init".format(ctx.env.GIT), shell = True).wait() != 0:
ctx.fatal("Couldn't initialize libgit2 submodule.")
print "Configuring libgit2..."
command = "./waf configure"
if(o.debug):
command = command + " --debug"
if Popen(command, shell = True, cwd = "vendor/libgit2").wait() != 0:
ctx.fatal("Libgit2 failed to configure.")
ctx.env.LIBPATH_GIT2 = abspath("vendor/libgit2/build/shared")
ctx.env.LIB_GIT2 = "git2"
ctx.env.RPATH_GIT2 = abspath("vendor/libgit2/build/shared")
ctx.env.internalLibgit2 = True
ctx.env.append_value("CPPPATH_GIT2", [abspath("vendor/libgit2/include")])
else:
ctx.env.internalLibgit2 = False
def build_libgit2(bld):
if Popen("./waf build", cwd = "vendor/libgit2", shell = True).wait() != 0:
# TODO: is there some way of crashing out with an error message from build
# context?
#bld.fatal("Errors building libgit2.")
pass
def clean_libgit2(bld):
Popen("./waf clean", cwd = "vendor/libgit2", shell = True).wait()
def configure(ctx):
ctx.check_tool('compiler_cxx')
ctx.check_tool('node_addon')
o = Options.options
ctx.find_program("git", var="GIT", mandatory = True)
configure_libgit2(ctx)
if o.debug:
ctx.env.append_value("CXXFLAGS", ["-ggdb", "-O0", "-Wall"])
def build(ctx):
if(ctx.env.internalLibgit2):
build_libgit2(ctx)
obj = ctx.new_task_gen('cxx', 'shlib', 'node_addon')
obj.target = 'gitteh'
obj.source = 'src/gitteh.cc src/commit.cc src/tree.cc src/repository.cc src/index.cc src/index_entry.cc src/tag.cc src/rev_walker.cc src/ref.cc src/blob.cc'
obj.uselib = 'GIT2'