forked from MurphyMc/Rogue
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuild.rogue
More file actions
113 lines (95 loc) · 3.08 KB
/
Copy pathBuild.rogue
File metadata and controls
113 lines (95 loc) · 3.08 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
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
# To run this build file, install Rogue from github.com/AbePralle/Rogue and type "rogo" at the command line.
#$ ROGUEC_ARGS = --api
#$ LIBRARIES = openssl( header:openssl/ssl.h )
# Optional comment directives - remove leading '#' (leaving '#$') to activate.
# In most cases the same directive can be specified multiple times for a cumulative effect.
# #$ ROGUEC = path/to/roguec
# #$ ROGUEC_ARGS = --whatever
# #$ CPP = g++ -Wall -std=gnu++11 -fno-strict-aliasing -Wno-invalid-offsetof
# #$ CPP_ARGS = -a -b -c
# #$ LIBRARIES = libalpha( header:"name.h" library:"libname.a" )
# #$ LIBRARIES = libbeta
# #$ LINK = -lalpha -lbeta
routine rogo_default
rogo_help
endRoutine
routine rogo_clean
System.run( "rm -rf .rogo" )
endRoutine
routine rogo_test
local cmd : String
if (File.is_newer_than("Test.rogue","test"))
cmd = @|roguec Test.rogue --execute --debug --test --target="C++,Console"
else
cmd = @|./test
endIf
println "> " + cmd
System.run( cmd )
endRoutine
routine rogo_version
local build = 1
local commit_id : String
block
local output = Process.run( "git rev-list --count HEAD" )
if (output.success)
build = output->String.trimmed->Int32
endIf
endBlock
block
forEach (line in LineReader(Process.run("git status --porcelain")->String))
if (not line.begins_with("??"))
++build
commit_id = "develop"
escapeBlock
endIf
endForEach
endBlock
if (not commit_id)
commit_id = Process.run( "git rev-parse --short HEAD" )->String.trimmed
endIf
local printer = PrintWriter( File("Source/RogueC/Version.rogue").writer )
printer.println( "$define ROGUE_RELEASE_BUILD " + build )
printer.println( "$define ROGUE_RELEASE_COMMIT_ID " + '"$"'(commit_id) )
printer.println( "$define ROGUE_RELEASE_TIMESTAMP " + Process.run("git show -s --format=%ct HEAD") )
printer.close
endRoutine
routine rogo_help
println "USAGE"
local lines = String[]
forEach (m in <<Global>>.methods)
if (m.name.begins_with(method_prefix))
local line = " rogo $" (m.name.after_first(method_prefix))
line += " <$>" (m.parameter_name(forEach in 0..<m.parameter_count))
lines.add( line )
endIf
endForEach
lines.sort( (a,b)=>(a<b) )
println (forEach in lines)
endRoutine
#------------------------------------------------------------------------------
# Process command line arguments and invoke appropriate function
#------------------------------------------------------------------------------
global ::method_prefix = ?:{ $moduleName.count:$moduleName "::" || "" } + "rogo_" : String
local args = @[]
args.add( forEach in System.command_line_arguments )
if (args.count)
run( args.remove_first, args )
else
rogo_default
endIf
routine run( cmd:String, args:Value )
try
local m = <<Global>>.find_method( method_prefix + cmd )
if (m)
if (m.parameter_count == 1 and args.count > 1)
# Wrap all args in a ValueList.
args = @[ args ]
endIf
m.call( Global, args )
else
rogo_help
endIf
catch (err:Error)
rogo_help
endTry
endRoutine