-
Notifications
You must be signed in to change notification settings - Fork 44
/
Jambase.jam
900 lines (729 loc) · 19.6 KB
/
Jambase.jam
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
#
# /+\
# +\ Portions copyright 1993-2002 Christopher Seiwald and Perforce Software, Inc.
# \+/
#
# This file is part of Jam - see jam.c for Copyright information.
#
# Helper rule used to get value of a variable bound to specific target.
# [ on <target> Var <var> ]
rule Var {
return $($(1)) ;
}
SPACE = " " ;
TAB = " " ;
NEWLINE = "
" ;
DOLLAR = $ ;
JAMBASE_VERSION = "JamPlus 3.0 Beta (2017.02.03)" ;
#
# OS specific variable settings
#
if $(NT)
{
MV ?= move /y ;
CP ?= copy ;
MKDIR ?= mkdir ;
MKDIR_RECURSIVE = 1 ;
RM ?= del /f/q ;
RMDIR ?= rmdir /s/q ;
SLASH ?= / ;
}
else if $(UNIX)
{
switch $(OS)
{
case CYGWIN :
JAMSHELL ?= sh -c ;
}
CHMOD ?= chmod ;
CHGRP ?= chgrp ;
CHOWN ?= chown ;
MKDIR_RECURSIVE = 1 ;
}
#
# General defaults; a lot like UNIX
#
CP ?= cp -f ;
DOT ?= . ;
DOTDOT ?= .. ;
JAMFILE ?= Jamfile.jam ;
JAMRULES ?= Jamrules.jam ;
LN ?= ln ;
MKDIR ?= mkdir -p ;
MV ?= mv -f ;
RM ?= rm -f ;
RMDIR ?= $(RM) ;
SLASH ?= / ;
SUBDIRRULES ?= ;
SUBDIRRESET ?= ASFLAGS HDRS C++FLAGS CCFLAGS ;
OSFULL = $(OS)$(OSVER)$(OSPLAT) $(OS)$(OSPLAT) $(OS)$(OSVER) $(OS) ;
#
# Base dependencies - first for "bootstrap" kinds of rules
#
NotFile all allclean clean clean:all ;
Always allclean clean clean:all ;
Depends clean : clean:all ;
#
# Rules
#
JAM_MODULES_PATH ?= @($(JAM_PROCESS_PATH)/../modules:R=) ;
rule IncludeModule MODULE_NAME : OPTIONS
{
local include_marker = included_module_$(MODULE_NAME:J=_) ;
if $($(include_marker)) && ! ( force in $(OPTIONS) ) {
return $(moduleName) ;
}
$(include_marker) = true ;
local moduleName = <jam:modules>$(MODULE_NAME).jam ;
local searchPaths = $(SUBDIR) $(CWD) $(CWD)/jam $(JAM_MODULES_USER_PATH) $(JAM_MODULES_PATH) ;
local searchPath ;
local foundPath ;
for searchPath in $(searchPaths) {
searchPath = $(moduleName:G=:R=$(searchPath)) ;
foundPath = [ Glob $(searchPath:D) : $(searchPath:D=) ] ;
if $(foundPath) {
break ;
}
}
if $(foundPath[1]:BL) = $(MODULE_NAME:BL) {
BINDING on $(moduleName) = $(foundPath[1]:BS) ;
LOCATE on $(moduleName) = $(foundPath[1]:D) ;
} else if ! ( optional in $(OPTIONS) ) {
if $(JAM_VERBOSE) {
Echo "include $(moduleName) -- Not found!" ;
}
return ;
}
if $(JAM_VERBOSE) {
Echo "include $(moduleName)" ;
}
include $(moduleName) ;
return $(moduleName) ;
}
rule FindMissingRule RULE_NAME
{
local components = [ Split $(RULE_NAME) : "." ] ;
local component ;
local path ;
for component in $(components) {
path += $(component) ;
IncludeModule $(path:LJ=/) ;
if [ RuleExists $(RULE_NAME) ] {
return $(RULE_NAME) ;
}
}
__MISSING_RULE_SCAN_LIST = $(RULE_NAME) ;
path = $(components:J=/) ;
local ruleName = $(components:J=.) ;
while true {
if ! $(path) {
return ;
}
ruleName = [ Subst $(path) : "/" : "." ] ;
ruleName = $(ruleName).* ;
if [ RuleExists $(ruleName) ] {
__MISSING_RULE_COMPONENTS = $(components) ;
return $(ruleName) ;
}
__MISSING_RULE_SCAN_LIST += $(ruleName) ;
path = $(path:P) ;
}
}
rule FGristDirectories DIRECTORIES
{
return $(DIRECTORIES:G=!dir!) ;
}
rule MakeLocate TARGETS : DIRECTORY
{
# MakeLocate targets : directory ;
# Sets special variable LOCATE on targets, and arranges
# with MkDir to create target directory.
# Note we grist the directory name with 'dir',
# so that directory path components and other
# targets don't conflict.
if ! $(DIRECTORY) {
DIRECTORY = $(LOCATE_TARGET) ;
}
# DIRECTORY = $(DIRECTORY:R=$(SUBDIR:E="")) ;
LOCATE on $(TARGETS) = $(DIRECTORY) ;
Depends $(TARGETS) : $(DIRECTORY[1]:G=!dir!) ;
MkDir $(DIRECTORY[1]:G=!dir!) ;
}
rule MkDir
{
# MkDir directory ;
# Make a directory and all its parent directories.
# Ignore timestamps on directories: we only care if they
# exist.
NoUpdate $(<) ;
# Don't create . or any directory already created.
if $(<:G=) = $(DOT)
{
NotFile $(<) ;
}
else if ! $($(<)-mkdir)
{
# Cheesy gate to prevent multiple invocations on same dir
# Arrange for jam dirs
# MkDir1 has the actions
$(<)-mkdir = true ;
MkDir1 $(<) ;
# Recursively make parent directories.
# $(<:P) = $(<)'s parent, & we recurse until root
local s = $(<:P) ;
# Don't try to create A: or A:\ on windows
if $(NT)
{
switch $(s)
{
case "*:" : s = ;
case "*:\\" : s = ;
case "*:/" : s = ;
}
}
if $(s) = $(<)
{
# The parent is the same as the dir.
# We're at the root, which some OS's can't stat, so we mark
# it as NotFile.
NotFile $(s) ;
}
else if $(s:G=)
{
if ! $(MKDIR_RECURSIVE)
{
# There's a parent; recurse.
Depends $(<) : $(s) ;
MkDir $(s) ;
}
}
}
}
rule RmTemps
{
Temporary $(>) ;
}
rule SubDir SUBDIR_PATH : TARGET_DIRECTORY
{
#
# SubDir TOP d1 d2 ... ;
#
# Support for a project tree spanning multiple directories.
#
# SubDir declares a Jamfile's location in a project tree, setting
# Jambase variables (SEARCH_SOURCE, LOCATE_TARGET) so that source
# files can be found.
#
# TOP is a user-select variable name for root of the tree, and
# d1 d2 ... are the directory elements that lead from the root
# of the tree to the directory of the Jamfile.
#
# TOP can be set externally, but normally the first SubDir call
# computes TOP as the path up from the current directory; the
# path contains one ../ for each of d1 d2 ...
#
# SubDir reads once the project-specific rules file Jamrules
# in the TOP directory, if present. This can be overridden
# with the variable TOPRULES.
#
# SubDir supports multiple, overlaid project trees: SubDir
# invocations with different TOPs can appear in the same Jamfile.
# The location established by the first SubDir call is used set
# the TOPs for the subsequent SubDir calls.
#
# SubDir's public variables:
#
# $(TOP) = path from CWD to root.
# $(SUBDIR) = path from CWD to the directory SubDir names.
# $(SUBDIR_TOKENS) = path from $(TOP) to $(SUBDIR) as dir names
# $(SEARCH_SOURCE) = $(SUBDIR)
# $(LOCATE_SOURCE) = $(ALL_LOCATE_TARGET) $(SUBDIR)
# $(LOCATE_TARGET) = $(ALL_LOCATE_TARGET) $(SUBDIR)
# $(SOURCE_GRIST) = $(SUBDIR_TOKENS) with !'s
#
if ! $(SUBDIR_PATH) { SUBDIR_PATH = $(ALL_SUBDIR_TOKENS) ; }
local _top = $(SUBDIR_PATH[1]) ;
local _tokens = $(SUBDIR_PATH[2-]) ;
ALL_SUBDIR_TOKENS = $(SUBDIR_PATH) ;
__SUBDIR_TARGET_DIRECTORY = $(TARGET_DIRECTORY) ;
#
# First time through sets up relative root and includes Jamrules.
#
if ! $(_top)
{
Exit SubDir syntax error ;
}
if ! $($(_top)-SET)
{
$(_top)-SET = true ;
# First time we've seen this TOP.
# We'll initialize a number of internal variables:
#
# $(TOP-UP) = directories from ROOT to a common point
# $(TOP-DOWN) = directories from common point to TOP
# $(TOP-ROOT) = root directory for UP/DOWN -- normally CWD
# $(SUBDIR_UP) = current value of $(TOP-UP)
# $(SUBDIR_DOWN) = current value of $(TOP-DOWN)
# $(SUBDIR_ROOT) = current value of $(TOP-ROOT)
#
if $($(_top))
{
# TOP externally set.
# We'll ignore the relative (UP/DOWN) path that
# got us here, and instead remember the hard ROOT.
$(_top)-UP = ;
$(_top)-DOWN = ;
$(_top)-ROOT = $($(_top)) ;
}
else
{
# TOP not preset.
# Establishing a new TOP. In the simplest case,
# (SUBDIR_UP/SUBDIR_DOWN/SUBDIR_ROOT unset), it's
# merely a certain number of directories down from
# the current directory, and FSubDirPath will set
# TOP to a path consisting of ../ for each of the
# elements of _tokens, because that represents how
# far below TOP the current directory sits.
#
# In the more complicated case, the starting directory
# isn't the directory of jam's invocation but an
# location established by previous SubDir call. The
# starting directory is SUBDIR_UP directories up from
# SUBDIR_ROOT, and then SUBDIR_DOWN directories down
# from that. If SUBDIR_ROOT is not set, that means
# SUBDIR_DOWN and SUBDIR_UP represent the path from
# the directory of jam's invocation.
#
# In the most complicated case, the _tokens also
# represents directories down, because TOP is being
# estalished in a directory other than TOP's root.
# Hopefully, _tokens and SUBDIR_DOWN represent the
# same final directory, relative to the new TOP and
# the previous SubDIr's TOP. To find the new TOP,
# we have to chop off any common directories from
# then ends of _tokens and SUBDIR_DOWN. To do so,
# we reverse each of them, call FStripCommon to
# remove the initial common elements, and then
# reverse them again. After this process, if
# both _tokens and SUBDIR_DOWN have elements, it
# means the directory names estalished by the two
# SubDir calls don't match, and a warning is issued.
# All hell will likely break loose at this point,
# since the whole SubDir scheme relies on the SubDir
# calls accurately naming the current directory.
# Strip common trailing elements of _tokens and SUBDIR_DOWN.
_tokens = [ FReverse $(_tokens) ] ;
SUBDIR_DOWN = [ FReverse $(SUBDIR_DOWN) ] ;
FStripCommon _tokens : SUBDIR_DOWN ;
SUBDIR_DOWN = [ FReverse $(SUBDIR_DOWN) ] ;
_tokens = [ FReverse $(_tokens) ] ;
if $(SUBDIR_DOWN) && $(_tokens)
{
Echo "Warning: SubDir $(SUBDIR_PATH) misplaced!" ;
}
# We'll remember the relative (UP/DOWN) path that
# got us here, plus any hard ROOT starting point
# for the UP/DOWN. If TOP is never set externally,
# ROOT will always be "" (directory of jam's invocation).
$(_top)-UP = $(SUBDIR_UP) $(_tokens) ;
$(_top)-DOWN = $(SUBDIR_DOWN) ;
$(_top)-ROOT = $(SUBDIR_ROOT:E="") ;
$(_top) = [ FSubDirPath $(_top) ] ;
$(_top) = $($(_top):R=$(CWD)) ;
$(_top)-ROOT = $($(_top)) ;
$(_top)-UP = ;
$(_top)-DOWN = ;
}
# Set subdir vars for the inclusion of the Jamrules,
# just in case they have SubDir rules of their own.
# Note that SUBDIR_DOWN is empty: it's all the way
# up where the Jamrules live. These gets overrided
# just after the inclusion.
SUBDIR_UP = $($(_top)-UP) ;
SUBDIR_DOWN = ;
SUBDIR_ROOT = $($(_top)-ROOT) ;
# Include $(TOPRULES) or $(TOP)/Jamrules.
# Include $(TOPRULES) if set.
# Otherwise include $(TOP)/Jamrules if present.
if $($(_top)RULES) {
include $($(_top)RULES) ;
} else {
NoCare $(JAMRULES:R=$($(_top)):G=$(_top)) ;
include $(JAMRULES:R=$($(_top)):G=$(_top)) ;
NoCare @($(_top).jamrules:R=$($(_top)):G=$(_top)) ;
include @($(_top).jamrules:R=$($(_top)):G=$(_top)) ;
}
}
# Get path from $(TOP) to named directory.
# Save dir tokens for other potential uses.
SUBDIR_UP = $($(_top)-UP) ;
SUBDIR_DOWN = $($(_top)-DOWN) $(_tokens) ;
SUBDIR_ROOT = $($(_top)-ROOT) ;
SUBDIR_TOKENS = $(SUBDIR_DOWN) ;
SUBDIR = [ FSubDirPath $(SUBDIR_PATH) ] ;
# Now set up SEARCH_SOURCE, LOCATE_TARGET, SOURCE_GRIST
# These can be reset if needed. For example, if the source
# directory should not hold object files, LOCATE_TARGET can
# subsequently be redefined.
if ! $(ALL_LOCATE_TARGET) {
ALL_LOCATE_TARGET = @(.build:R=$(CWD)) ;
if [ Glob $(ALL_LOCATE_TARGET) : buildenvironment.config ] {
Echo "* A Jam workspace has already been created at:" ;
Echo ;
Echo " " $(ALL_LOCATE_TARGET) ;
Echo ;
Echo * Please run Jam from within that directory. ;
Exit ;
}
}
if ! $(DEPCACHE.$(DEPCACHE)) && ! $(JAM_NO_DEP_CACHE) {
DEPCACHE.$(DEPCACHE) = $(ALL_LOCATE_TARGET:E=.)/.depcache ;
Clean clean $(JAM_AUTOMATIC_BUILD_CLEAN_TARGET) : $(DEPCACHE.$(DEPCACHE)) ;
}
SEARCH_SOURCE = $(SUBDIR) ;
LOCATE_SOURCE = [ FDirName $(ALL_LOCATE_TARGET) $(TARGET_DIRECTORY[1]) $(_top) $(SUBDIR_DOWN) $(TARGET_DIRECTORY[2]) ] ;
LOCATE_TARGET = [ FDirName $(ALL_LOCATE_TARGET) $(TARGET_DIRECTORY[1]) $(_top) $(SUBDIR_DOWN) $(TARGET_DIRECTORY[2]) ] ;
SOURCE_GRIST = [ FGrist $(ALL_SUBDIR_TOKENS) ] ;
SOURCE_GRIST = $(SOURCE_GRIST)$(target:E=) ;
## LOCAL CHANGE -- OPT_HEADER_CACHE_EXT. With the header
# cache, we can grist all files found during a header scan
# without incurring a performance penalty.
#
HDRGRIST = $(SOURCE_GRIST) ;
#
## LOCAL CHANGE
# Reset per-directory ccflags, hdrs, etc,
# listed in SUBDIRRESET.
# Note use of variable expanded assignment var
SUBDIR$(SUBDIRRESET) = ;
# Invoke user-specific SubDir extensions,
# rule names listed in SUBDIRRULES.
# Note use of variable expanded rule invocation
$(SUBDIRRULES) $(SUBDIR_PATH) ;
}
rule FSubDirPath
{
# FSubDirPath TOP d1 ... ;
# Returns path to named directory.
# If jam is invoked in a subdirectory of the TOP, then we
# need to prepend a ../ for every level we must climb up
# (TOP-UP), and then append the directory names we must
# climb down (TOP-DOWN), plus the named directories d1 ...
# If TOP was set externally, or computed from another TOP
# that was, we'll have to reroot the whole thing at TOP-ROOT.
local _r = [ FRelPath $($(<[1])-UP) : $($(<[1])-DOWN) $(<[2-]) ] ;
return $(_r:R=$($(<[1])-ROOT)) ;
}
local __SubIncludeStackIndex = 0 ;
rule SubInclude TOKENS : FILENAME
{
# SubInclude TOP d1 ... ;
#
# Include a subdirectory's Jamfile.
# We use SubDir to get there, in case the included Jamfile
# either doesn't have its own SubDir (naughty) or is a subtree
# with its own TOP.
TOKENS ?= $(ALL_SUBDIR_TOKENS) ;
if ! $($(TOKENS[1]))
{
Exit SubInclude $(TOKENS[1]) without prior SubDir $(TOKENS[1]) ;
}
local jamfile ;
if $(FILENAME)
{
jamfile = $(FILENAME:S=.jam) ;
}
else
{
jamfile = $(JAMFILE) ;
}
local include_marker = included_$(TOKENS:J=_)_$(jamfile) ;
if $($(include_marker))
{
return ;
}
$(include_marker) = true ;
__SubIncludeSaveTokens_$(__SubIncludeStackIndex) = $(ALL_SUBDIR_TOKENS) ;
__SubIncludeSaveTargetDirectory_$(__SubIncludeStackIndex) = $(__SUBDIR_TARGET_DIRECTORY) ;
__SubIncludeSaveCurrentJamfile_$(__SubIncludeStackIndex) = $(CURRENT_JAMFILE) ;
__SubIncludeStackIndex = [ Math $(__SubIncludeStackIndex) + 1 ] ;
SubDir $(TOKENS) ;
CURRENT_JAMFILE = $(jamfile:R=$(SUBDIR)) ;
if [ Search $(CURRENT_JAMFILE) ]
{
include $(CURRENT_JAMFILE) ;
}
else
{
local jamfile.lua ;
if $(FILENAME)
{
jamfile.lua = $(FILENAME:S=.lua) ;
}
else
{
jamfile.lua = $(JAMFILE.LUA) ;
}
jamfile.lua = $(jamfile.lua:R=$(SUBDIR)) ;
if [ Search $(jamfile.lua) ]
{
LuaFile $(jamfile.lua) ;
}
else
{
Exit * Unable to find $(CURRENT_JAMFILE). ;
}
}
__SubIncludeStackIndex = [ Math $(__SubIncludeStackIndex) - 1 ] ;
if $(__SubIncludeSaveTokens_$(__SubIncludeStackIndex))
{
SubDir $(__SubIncludeSaveTokens_$(__SubIncludeStackIndex)) : $(__SubIncludeSaveTargetDirectory_$(__SubIncludeStackIndex)) ;
__SubIncludeSaveTokens_$(__SubIncludeStackIndex) = ;
CURRENT_JAMFILE = $(__SubIncludeSaveCurrentJamfile_$(__SubIncludeStackIndex)) ;
__SubIncludeSaveCurrentJamfile_$(__SubIncludeStackIndex) = ;
}
}
rule SubIncludeRelative RELATIVE_PATH : REQUESTED_JAMFILE
{
SubInclude $(ALL_SUBDIR_TOKENS) $(RELATIVE_PATH) : $(REQUESTED_JAMFILE) ;
}
rule SubRules
{
# SubRules TOP d1 ... : Other-TOP ;
#
# Read another tree's Jamrules, by giving it's path according
# to this tree and it's own name.
if ! $($(<[1]))
{
Exit SubRules $(<[1]) without prior SubDir $(<[1]) ;
}
SubDir $(<) ;
SubDir $(>) ;
}
#
# Utility rules; no side effects on these
#
rule FGrist
{
return $(<:J=!) ;
}
rule FGristFiles
{
return $(<:G=$(SOURCE_GRIST:E)) ;
}
rule FReverse
{
# FReverse a1 a2 a3 ... ;
# return ... a3 a2 a1 ;
if $(1) { return [ FReverse $(1[2-]) ] $(1[1]) ; }
}
rule FSubDir
{
# If $(>) is the path to the current directory, compute the
# path (using ../../ etc) back to that root directory.
# Sets result in $(<)
if ! $(<[1])
{
return $(DOT) ;
}
else
{
local _i _d ;
_d = $(DOTDOT) ;
for _i in $(<[2-])
{
_d = $(_d:R=$(DOTDOT)) ;
}
return $(_d) ;
}
}
rule FStripCommon
{
# FStripCommon v1 : v2 ;
# Strip common initial elements of variables v1 and v2.
# Modifies the variable values themselves.
if $($(<)[1]) && $($(<)[1]) = $($(>)[1])
{
$(<) = $($(<)[2-]) ;
$(>) = $($(>)[2-]) ;
FStripCommon $(<) : $(>) ;
}
}
rule FRelPath
{
local _l _r ;
# first strip off common parts
_l = $(<) ;
_r = $(>) ;
FStripCommon _l : _r ;
# now make path to root and path down
_l = [ FSubDir $(_l) ] ;
_r = [ FDirName $(_r) ] ;
# Concatenate and save
# XXX This should be better
if $(_r) = $(DOT) {
return $(_l) ;
} else {
return $(_r:R=$(_l)) ;
}
}
#
# Operating system specific utility rules
# First, the (generic) UNIX versions
#
rule FQuote { return \\\"$(<)\\\" ; } #"
rule FDirName
{
# Turn individual elements in $(<) into a usable path.
local _i ;
local _s = $(DOT) ;
for _i in $(<)
{
_s = $(_i:R=$(_s)) ;
}
return $(_s) ;
}
#
# Actions
#
#
# First the defaults
#
actions piecemeal together existing removeemptydirs Clean
{
$(RM) $(>:C)
}
actions piecemeal together existing removeemptydirs CleanTree {
$(RM) -rf $(2:C)
}
if $(NT)
{
actions piecemeal together existing removeemptydirs Clean
{
$(RM) $(>:\\C)
}
actions piecemeal together existing removeemptydirs CleanTree {
rd /q /s "$(2:\\)"
}
}
actions quietly MkDir1
{
$(MKDIR) $(<:C)
}
if $(NT)
{
actions quietly MkDir1
{
if not exist $(<:\\C) $(MKDIR) $(<:\\C)
}
}
actions quietly updated piecemeal together removeemptydirs RmTemps
{
$(RM) $(>)
}
if $(NT)
{
actions quietly updated piecemeal together removeemptydirs RmTemps
{
$(RM) $(>:\\C)
}
}
########################################################################
########################################################################
actions WriteFile
{
^^($(1)|$(CONTENTS))
}
########################################################################
########################################################################
rule ActiveProject TARGET {
return [ C.ActiveTarget $(TARGET) ] ;
}
rule ActiveTarget TARGET {
return [ C.ActiveTarget $(TARGET) ] ;
}
rule AutoSourceGroup SOURCES
{
}
rule ExternalProject TARGET : PROJECT_PATH : OPTIONS {
}
rule NoWorkspace WORKSPACE_NAME
{
}
rule Project PROJECT_NAME : SOURCES
{
}
rule ProjectGroup TARGET : FOLDERNAME : PROJECTS
{
}
rule SearchSource SOURCES : SEARCH_PATH
{
SEARCH_PATH ?= $(SEARCH_SOURCE) ;
SEARCH on $(SOURCES) ?= $(SEARCH_PATH:R=$(SEARCH_SOURCE)) ;
}
rule SourceGroup TARGET : FOLDERNAME : SOURCES
{
}
rule Workspace WORKSPACE_NAME : TARGETS
{
}
rule WorkspaceConfig WORKSPACE_NAME : CONFIG_NAME : ACTUAL_CONFIG_NAME : COMMAND_LINE_OPTIONS {
}
#
# Now include the user's Jamfile.
#
{
VALID_CONFIGS ?= release releaseltcg debug ;
switch $(OS)
{
case NT :
VALID_PLATFORMS ?= win64 win32 ;
case MACOSX :
VALID_PLATFORMS ?= macosx64 macosx32 ;
case LINUX :
VALID_PLATFORMS ?= linux64 linux32 ;
}
CONFIG ?= $(C.CONFIG) ;
PLATFORM ?= $(C.PLATFORM) ;
COMPILER ?= $(C.COMPILER) ;
CONFIG ?= $(VALID_CONFIGS[1]) ;
if $(PLATFORM) = "" { PLATFORM = ; }
PLATFORM ?= $(VALID_PLATFORMS[1]) ;
C.CONFIG ?= $(CONFIG) ;
C.PLATFORM ?= $(PLATFORM) ;
C.COMPILER ?= $(COMPILER) ;
C.TOOLCHAIN ?= $(c.toolchain) ;
if $(C.TOOLCHAIN)
{
C ;
}
}
JAMFILE.LUA ?= Jamfile.lua ;
if [ Search $(JAMFILE) ] {
include $(JAMFILE) ;
} else if [ Search $(JAMFILE.LUA) ] {
LuaFile $(JAMFILE.LUA) ;
} else {
TARGET ?= $(JAM_COMMAND_LINE_TARGETS[1]) ;
if $(TARGET) = all
{
TARGET = ;
}
local splitTarget = [ Split $(TARGET) : ":" ] ;
if $(splitTarget[1]) = clean
{
JAM_AUTOMATIC_BUILD_CLEAN_TARGET = $(TARGET) ;
TARGET = $(splitTarget[2]) ;
}
WILDCARDS ?= $(JAM_COMMAND_LINE_TARGETS[2-]) ;
WILDCARDS ?= *@=*.c@=*.cpp@=*.m@=*.mm ;
local files = $(WILDCARDS:W) ;
if ($(files[1])) {
local target = $(TARGET:E=$(files[1]:B)) ;
C.OutputPath $(target) : $(CWD) ;
C.Application $(target) : $(files) ;
JAM_COMMAND_LINE_TARGETS = $(JAM_COMMAND_LINE_TARGETS[1]:E=$(target)) ;
}
}