-
Notifications
You must be signed in to change notification settings - Fork 0
/
system-libs.jam
1247 lines (1020 loc) · 36.7 KB
/
system-libs.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
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Copyright 2016 DeviantArt Inc.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
#### system-libs
#
# rule system-libs ( names +
# : properties *
# : usage-requirements *
# )
#
# scans the search paths for the given library(s)
#
# names +
# -- name of lib to find, 'glob' pattern type - can use "?" and "*"
#
# properties *
# -- optionally the following properties
# can have <os>OS: conditional prefix
#
# <path>PATH
# - PATH to search
#
# <cc-search-dirs>
# - search library paths from: 'cc -print-search-dirs'
#
# <exclude>GLOB-PATTERN
# - GLOB-PATTERN of names to exclude - can use "?" and "*"
#
# <PROPERTY>VALUE
# - created lib will have <PROPERTY>VALUE
# as part of it's requirements
# conflicting libs will not be created
#
# <target-prefix>PREFIX
# - PREFIX for the created main target
#
# <threading-tag>TAG
# - postfix TAG of lib-names that indicate
# threading differentiation.
# Specifically the 'multi' threaded type
# boost-example: '-mt'
#
# <debug>
# - will print out debug info for each lib made
#
# <homebrew>FORMULA
# - FORMULA to find library in
# if formula's cellar has /include
# it will be added to usage-requirements
# will prompt operator to brew install the formula if
# it isn't installed
#
# <homebrew-version>VERSION
# - require homebrew formula of a specific version
# applies to previous <homebrew> property
#
# <homebrew-with>ARGSTR
# - require homebrew forumla to have --with-ARGSTR arg
# applies to previous <homebrew> property
#
# <apt>PACKAGE
# - apt PACKAGE to find library in
# if apt package has non-standard /include path
# it will be added to usage-requirements
#
# <headers-only>TARGET
# - create a headers only alias target named TARGET
#
# usage-requirements *
# -- created libs will have these usage requirements
#
# returns: library names created
#
#
# Future-Ideas:
#
# could work with 'xxxx-config' type executables
# - parsing -l -L, etc
#
# TODO: caching -- SLOW currently
import sequence ;
import set ;
import path : glob ;
import trim ;
import string : join ;
import feature ;
import regex ;
import project ;
import "class" : new ;
import generators ;
import type ;
import virtual-target ;
# default to 'no' -- ie, import libs into appforge
#feature.feature system-lib : no yes : optional ;
local rule cc-search-paths ( )
{
if ! $(.system-search-paths) {
.system-search-paths = [ SPLIT_BY_CHARACTERS
[ MATCH "libraries: =(.*)" :
[ trim.sh "cc -print-search-dirs" ] ]
: ":" ] ;
}
return $(.system-search-paths) ;
}
.OS = [ modules.peek : OS ] ;
shared-lib-exts = so dylib ;
static-lib-exts = a ;
lib-exts = $(static-lib-exts) $(shared-lib-exts) ;
local rule regex-glob-pattern ( glob-pattern )
{
local re =
[ regex.replace
[ regex.replace
$(glob-pattern)
"\\?" "[^.]"
]
"\\*" "[^.]*"
] ;
return $(re) ;
}
local rule glob-lib-pattern ( threading-tag ? : glob-pattern * )
{
threading-tag += "" ;
local version = "" .* ;
return lib$(glob-pattern)$(threading-tag)$(version).$(lib-exts)* ;
}
local rule regex-lib-pattern ( threading-tag ? : glob-pattern * )
{
if $(threading-tag) {
threading-tag = [ regex-glob-pattern $(threading-tag) ] ;
threading-tag += "" ;
}
threading-tag ?= "" ;
local regex-pattern = [ sequence.transform regex-glob-pattern
: $(glob-pattern) ] ;
local name-pattern = $(regex-pattern)$(threading-tag) ;
local relib = (.*/|)(lib($(name-pattern:J=|))(\\..*|)\\.($(lib-exts:J=|))(\\..*|)) ;
return $(relib) ;
}
local rule regex-match-files ( threading-tag ? : glob-pattern * : files * )
{
local matched ;
local re = [ regex-lib-pattern $(threading-tag) : $(glob-pattern) ] ;
for local file in $(files) {
if [ MATCH $(re) : $(file) ] {
matched += $(file) ;
}
}
return $(matched) ;
}
rule tokenize-gristlibs ( threading-tag ? : gristlibs * )
{
local result ;
local re = [ regex-lib-pattern $(threading-tag) : * ] ;
for local gl in $(gristlibs) {
local lib inc
file-name name
basename tag
headver tailver
unique-name version
ext link-type
threading-type
;
lib = $(gl:G=) ;
inc = [ MATCH ^<(.*)>$ : $(gl:G) ] ;
local m = [ MATCH $(re) : $(lib) ] ;
# (.*/|) # 1 basedir
# (lib # 2 filename
# (name-tag|name)) # 3 name
# (\..*|)\. # 4 headver
# (a|so|dylib) # 5 ext
# (\..*|)) # 6 tailver
file-name = $(m[2]) ;
name = $(m[3]) ;
basename = [ MATCH ^(.*)$(threading-tag:E=)$ : $(name) ] ;
basename ?= $(name) ;
tag = [ MATCH ^.*($(threading-tag:E=))$ : $(name) ] ;
headver = $(m[4]) ;
ext = $(m[5]) ;
tailver = $(m[6]) ;
# echo m: '$(lib)' -- '$(m)' ;
# echo file-name: '$(file-name)' name: '$(name)' basename: '$(basename)' tag: '$(tag)' headver: '$(headver)' tailver: '$(tailver)' ext: $(ext) ;
# in weird case that both ver exist, use tail
if $(tailver) != "" {
version = $(tailver) ;
}
else {
version = $(headver) ;
}
unique-name = $(name)|$(ext) ;
if $(ext) in $(shared-lib-exts) {
link-type = shared ;
}
else if $(ext) in $(static-lib-exts) {
link-type = static ;
}
if $(threading-tag)
{
if $(tag) = $(threading-tag) {
threading-tag-type = tagged ;
}
else {
threading-tag-type = untagged ;
}
}
else {
threading-tag-type = undefined ;
}
if $(unique-name)
&& $(link-type)
&& $(threading-tag-type)
{
result += $(unique-name) # 1 - used by best-match
$(version:E="") # 2 - used by best-match
$(basename) # 3 - used by find-lib
$(link-type) # 4 - used by find-lib
$(threading-tag-type) # 5 - used by find-lib
$(lib) # 6 - used by declare-lib
$(inc:E="") # 7 - used by declare-lib
;
}
}
return $(result) ;
}
rule version-order ( a b )
{
for local l in a b {
local postfix = [ MATCH ^\\.(.*)$ : $($(l)) ] ;
if $(postfix) {
$(l) = [ regex.split $(postfix) \\. ] ;
}
}
local result ;
for local i in 1 2 3 4 5 6 {
if ! $(result) {
if ! $(a[$(i)]) && $(b[$(i)]) {
result = ">" ;
}
else if $(a[$(i)]) && ! $(b[$(i)]) {
result = "<" ;
}
else if $(a[$(i)]) && $(b[$(i)]) {
if $(a[$(i)]) < $(b[$(i)]) {
result = "<" ;
}
else if $(a[$(i)]) > $(b[$(i)]) {
result = ">" ;
}
}
}
}
if $(result) = "<" {
return true ;
}
}
local rule map-tokens ( callback + : all-tokens * : * )
{
local results ;
local tokens = $(all-tokens) ;
while $(tokens) {
results += [ $(callback) $(tokens[1-7])
: $(tokens)
: $(all-tokens)
: $(3) : $(4) : $(5) : $(6) : $(7) : $(8)
] ;
tokens = $(tokens[8-]) ;
}
return $(results) ;
}
local rule best-version ( remaining-tokens + )
{
local result ;
local rule max-test ( unique version extras + : * )
{
if ! $(result) ||
( $(result[1]) = $(unique)
&& [ version-order $(max) $(version) ]
)
{
result = $(1) ;
max = $(version) ;
}
else if $(result) && $(result[1]) = $(unique) && $(max) = $(version) {
echo "WARNING: duplicate libs:" ;
echo "\n\t- '$(result[1-10])'" ;
echo "----" ;
echo "\n\t- '$(1)'" ;
}
}
map-tokens max-test : $(remaining-tokens) ;
return $(result) ;
}
local rule best-uniques ( all-tokens * )
{
local unique-names ;
local rule best ( unique extras + : tokens * : * )
{
if ! $(unique) in $(unique-names) {
unique-names += $(unique) ;
return [ best-version $(tokens) ] ;
}
}
return [ map-tokens best : $(all-tokens) ] ;
}
local rule alternate-type ( type )
{
switch $(type) {
case static : return shared ;
case shared : return static ;
case tagged : return untagged ;
case untagged : return tagged ;
}
}
local rule threading-type ( threading-tag-type )
{
switch $(threading-tag-type) {
case tagged : return multi ;
case untagged : return single ;
}
}
local rule collect-inc ( tokens + : * )
{
if $(tokens[-1]) != "" {
return <include>$(tokens[-1]) ;
}
}
local rule find-lib ( basename link-type threading-tag-type : all-tokens * )
{
local rule find ( unique
version
basename-token
link-type-token
threading-tag-type-token
lib
inc
: *
)
{
if $(basename) = $(basename-token)
&& $(link-type) = $(link-type-token)
&& $(threading-tag-type) = $(threading-tag-type-token)
{
return $(unique) ;
}
}
return [ map-tokens find : $(all-tokens) ] ;
}
feature.feature system-lib-rpath : no yes : optional incidental ;
type.register SYSTEM_LIB : : LIB ;
class prebuilt-system-lib-file-generator : generator
{
import property-set ;
rule run ( project name ? : property-set : sources * )
{
local f = [ $(property-set).get <file> ] ;
local add-rpath = [ $(property-set).get <system-lib-rpath> ] ;
# no-rpath?
# need to create target with a null action
# - in order to prevent builtin.jam from adding xdll-paths
if $(add-rpath) != yes {
# set action
module $(f) {
self.type = SYSTEM_LIB ;
self.action = [ new null-action ] ;
}
}
#echo creating-system-lib: $(f) [ $(f).name ] add-rpath: $(add-rpath) ;
return [ virtual-target.register $(f) ]
$(sources) # pass through any extra
;
}
}
generators.register
[ new prebuilt-system-lib-file-generator
system-lib.prebuilt
: : SYSTEM_LIB : <file>
] ;
local rule declare-lib ( unique
version
basename
link-type
threading-tag-type
lib
inc
: rem-tokens +
: all-tokens *
: requirements *
: usage-requirements *
: target-prefix ?
: debug ?
)
{
local explicit-link ;
local explicit-threading ;
local link-alternate ;
local threading-alternate ;
local link-threading-alternate ;
local link-requirements ;
local threading-requirements ;
local req-link ;
local req-threading ;
req-link = [ MATCH ^<link>(.*)$ : $(requirements) ] ;
threading-link = [ MATCH ^<threading>(.*)$ : $(requirements) ] ;
if $(threading-tag-type) != undefined
{
local tag = [ alternate-type $(threading-tag-type) ] ;
threading-alternate = [ find-lib
$(basename)
$(link-type)
$(tag)
: $(all-tokens) ] ;
link-threading-alternate = [ find-lib
$(basename)
[ alternate-type $(link-type) ]
$(tag)
: $(all-tokens) ] ;
}
# with the existence of threading 'alternates'
# explicit-threading exists
if $(threading-alternate) || $(link-threading-alternate) {
explicit-threading = [ threading-type $(threading-tag-type) ] ;
}
link-alternate = [ find-lib
$(basename)
[ alternate-type $(link-type) ]
$(threading-tag-type)
: $(all-tokens) ] ;
# with the existence of link 'alternates' explicit-link exists
if $(link-alternate) || $(link-threading-alternate) {
explicit-link = $(link-type) ;
}
# does linking require generated differentiation?
if ! $(req-link) && $(explicit-link) {
link-requirements += <link>$(explicit-link) ;
# do we need to differentiate this 'unecessarirly' for threading
# , due to differentiation in counter-link-type?
if ! $(threading-alternate) && $(link-threading-alternate) {
threading-requirements += <threading>single <threading>multi ;
}
}
# does threading require generated differentiation
if ! $(req-threading) && $(explicit-threading) {
if ! <threading>$(explicit-threading) in $(threading-requirements) {
threading-requirements += <threading>$(explicit-threading) ;
}
}
local rule debug-context ( )
{
echo "\t unique:" $(unique) ;
echo "\t version:" $(version) ;
echo "\t basename:" $(basename:) ;
echo "\t link-type:" $(link-type:) ;
echo "\t threading-tag-type:" $(threading-tag-type:) ;
echo "\t explicit-link:" $(explicit-link) ;
echo "\t explicit-threading:" $(explicit-threading) ;
echo "\t link-alternate:" $(link-alternate) ;
echo "\t threading-alternate:" $(threading-alternate) ;
echo "\t link-threading-alternate:" $(link-threading-alternate) ;
echo "\t req-link:" $(req-link) ;
echo "\t req-threading:" $(req-threading) ;
}
# do not make lib if this doesn't match required and there exists a match
if ! ( $(req-link) && $(explicit-link)
&& $(req-link) != $(explicit-link)
)
&& ! ( $(req-threading) && $(explicit-threading)
&& $(req-threading) != $(explicit-threading)
)
{
local default-req = <link>$(req-link) <threading>$(req-threading) ;
# does lib have an include path
if $(inc) != "" {
usage-requirements += <include>$(inc) ;
}
# this may generate multiple requirement matches
# -- compiler/linker is smart enough to do the right thing
# -- this is necessary due to boost.build's requirement matching rules
link-requirements += <link>$(req-link) ;
link-requirements ?= "" ;
threading-requirements += <threading>$(req-threading) ;
threading-requirements ?= "" ;
local project = [ project.current ] ;
for local link-requirement in $(link-requirements)
{
for local threading-requirement in $(threading-requirements)
{
local reqs = $(requirements) ;
if $(link-requirement) != ""
&& ! $(link-requirement) in $(reqs)
{
reqs += $(link-requirement) ;
}
if $(threading-requirement) != ""
&& ! $(threading-requirement) in $(reqs)
{
reqs += $(threading-requirement) ;
}
if $(debug) {
echo "from '$(lib)'" ;
debug-context ;
echo "\t----" ;
echo "\t system-lib " $(target-prefix:E=)$(basename) ;
echo "\t : : <file>$(lib)"
"\n\t $(reqs)"
"\n\t : :" $(usage-requirements:J="\n\t ")
"\n\t ;" ;
}
system-lib $(target-prefix:E=)$(basename)
: : <file>$(lib)
$(reqs)
: : $(usage-requirements) ;
$(project).mark-target-as-explicit
$(target-prefix:E=)$(basename) ;
}
}
return $(unique) ;
}
else if $(debug) {
echo "skipping '$(lib)'" ;
debug-context ;
}
}
local rule normalize-path ( path )
{
# readlink/normalize
local target = [ READLINK $(path) ] ;
if $(target) {
path = $(target) ;
}
return [ path.make $(path) ] ;
}
local rule gristlibs-from-path ( include-path ?
: names +
: exclude *
: threading-tag ?
: path )
{
# for key, which must be deterministic
local key-names = [ SORT $(names) ] ;
local key-exclude = [ SORT $(exclude) ] ;
key-exclude ?= "" ;
local key = .gristlibs-from-path
$(include-path:E="")
$(key-names:J="|")
$(key-exclude:J="|")
$(path) ;
key = $(key:J=|) ;
if ! $($(key)) {
# patterns can result in duplicates
local libs = [ sequence.unique
[ path.glob $(path) : [ glob-lib-pattern
$(threading-tag)
: $(names) ]
: [ glob-lib-pattern
$(threading-tag)
: $(exclude) ]
] ] ;
$(key) = $(libs:G=$(include-path:E="")) ;
$(key) ?= <none> ;
}
if $($(key)) != <none> {
return $($(key)) ;
}
}
# var for paths processed, cleared with every call to system-libs
local .gristlibs-paths-processed ;
local rule gristlibs-reset-paths ( )
{
.gristlibs-paths-processed = ;
}
local rule gristlibs-from-new-path ( include-path ?
: names +
: exclude *
: threading-tag ?
: path
)
{
path = [ normalize-path $(path) ] ;
if ! $(path) in $(.gristlibs-paths-processed) {
$(gristlibs-paths-processed) += $(path) ;
return [ gristlibs-from-path $(include-path)
: $(names)
: $(exclude)
: $(threading-tag)
: $(path) ] ;
}
}
local rule homebrew-cellar-path ( )
{
if ! $(.homebrew-cellar-path) {
.homebrew-cellar-path = [ SHELL "brew --cellar" : strip-eol ] ;
.homebrew-cellar-path ?= /usr/local/Cellar ;
}
return $(.homebrew-cellar-path) ;
}
local rule homebrew-cellar ( formula : version ? : with * )
{
local rule ver ( obj ) {
return [ MATCH "\"([^\"]*)\"" : $(obj) ] ;
}
# cache
if ! $(.homebrew.$(formula)) {
local result = [ SHELL "brew info --json=v1 $(formula)"
: exit-status : strip-eol ] ;
if $(result[2]) = 0 {
.homebrew.$(formula) = $(result[1]) ;
}
else {
.homebrew.$(formula) = <invalid-formula> ;
}
}
# use
local json = $(.homebrew.$(formula)) ;
# -- if invalid
if $(json) = <invalid-formula> {
echo "Error: homebrew error for formula '$(formula)'" ;
echo " - homebrew may not be installed " ;
echo " - homebrew could be out of date " ;
echo " - formula could not exist " ;
if $(with) {
echo ""
echo " Note: formula $(formula) needs" --with-$(with) ;
}
exit ;
}
local version-obj ;
# hopefully brew doesn't change order of items in it's json!
# -- this could stop working -- not a proper json parser
local version-objs = [ trim.sh "printf '%s' '$(json)' | jq '.[0].installed[0].version'" ] ;
# multiple versions?
if $(version-objs[2]) {
local find-version = $(version) ;
if ! $(find-version) {
find-version = [ MATCH "\"linked_keg\":\"([^\"]*)\"" : $(json) ] ;
if ! $(find-version) {
echo "Error: ambiguous homebrew formula '$(formula)'" ;
echo " - has multiple installed versions " ;
echo " - is not linked " ;
echo " - no <homebrew-version> argument given " ;
echo "" ;
echo " This ambiguity can be resolved by on of:" ;
echo " - providing <homebrew-version> argument " ;
echo " - linking one of the brew cellars " ;
echo " - deleting all but one cellar" ;
echo "" ;
echo " Run 'brew info $(formula)' for details" ;
if $(with) {
echo ""
echo " Note: formula $(formula) needs" --with-$(with) ;
}
exit ;
}
}
for local obj in $(version-objs) {
if $(find-version) = [ ver $(obj) ] {
version-obj += $(obj) ;
}
}
}
else {
version-obj = $(version-objs) ;
}
if ! $(version-obj)
|| ( $(version) && $(version) != [ ver $(version-obj) ] )
{
echo "Error: required homebrew formula '$(formula)'" ;
if ! $(version-obj) {
echo " - not installed " ;
}
else {
echo " - wrong version" ;
echo " want:" $(version) ;
echo " have:" [ ver $(version-obj) ] ;
}
echo "" ;
echo " Run 'brew info $(formula)' for details" ;
if $(with) {
echo "" ;
echo " Note: formula $(formula) needs" --with-$(with) ;
}
exit ;
}
# check -with ?
local missing-with = ;
if $(with) {
local options = [ MATCH "\"used_options\":\\[([^\\]]*)\\]"
: $(version-obj) ] ;
for local w in $(with) {
if ! [ MATCH --with-$(w) : $(options) ] {
missing-with += --with-$(with) ;
}
}
}
if $(missing-with) {
echo "Error: required homebrew formula '$(formula)'" ;
echo " - installed with missing options:"
"\n "$(missing-with) ;
echo "" ;
echo " Run 'brew info $(formula)' for details" ;
echo "" ;
echo " Note: formula $(formula) needs" --with-$(with) ;
exit ;
}
if ! $(version) {
version = [ ver $(version-obj) ] ;
}
return [ path.join [ homebrew-cellar-path ] $(formula) $(version) ] ;
}
local rule homebrew-gristlibs ( names +
: exclude *
: threading-tag ?
: formula
: version *
: with *
: debug ?
)
{
if $(version[2]) {
echo "Error: multiple <homebrew-version> properties found" ;
echo " - versions: " '$(version)' ;
echo " - formula:" '$(formula)' ;
exit ;
}
if $(.OS) = MACOSX {
local cellar = [ homebrew-cellar $(formula) : $(version) : $(with) ] ;
return [ gristlibs-from-new-path $(cellar)/include
: $(names)
: $(exclude)
: $(threading-tag)
: $(cellar)/lib ] ;
}
}
local rule apt-rawlibs ( pkg version ? )
{
local key = apt.$(pkg).$(version:E="").rawlibs ;
if ! $($(key)) {
local cmd res ver ;
cmd = "dpkg -L $(pkg) | grep -E 'lib[^/]*\\.($(lib-exts:J=|))[^/]*$'" ;
res = [ SHELL $(cmd) : strip-eol : exit-status ] ;
if $(res[2]) = 0 {
$(key) = [ SPLIT_BY_CHARACTERS $(res[1]) : "\n" ] ;
if $(version) {
ver = [ MATCH "^Version: (.*)$"
: [ SHELL "dpkg -s $(pkg) | grep '^Version: '"
: strip-eol ] ] ;
if $(ver) != $(version) {
echo "Error: required apt package '$(pkg)'" ;
echo " - wrong version" ;
echo " want:" $(version) ;
echo " have:" $(ver) ;
exit ;
}
}
}
else {
$(key) = <none> ;
}
}
if $($(key)) != <none> {
return $($(key)) ;
}
}
local rule apt-gristlibs ( names +
: exclude *
: threading-tag ?
: package
: version *
: debug ?
)
{
if $(version[2]) {
echo "Error: multiple <apt-version> properties found" ;
echo " - versions: " '$(version)' ;
echo " - package:" '$(package)' ;
exit ;
}
if $(.OS) = LINUX {
local rawlibs pos neg libs ;
rawlibs = [ apt-rawlibs $(package) $(version) ] ;
pos = [ regex-match-files $(threading-tag) : $(names)
: $(rawlibs) ] ;
if $(exclude) {
neg = [ regex-match-files $(threading-tag) : $(exclude)
: $(rawlibs) ] ;
}
if $(neg) {
libs = [ set.difference $(pos) : $(neg) ] ;
}
else {
libs = $(pos) ;
}
if $(debug) {
echo "apt pkg:" '$(package)' ;
echo " rawlibs:" '$(rawlibs:J="'\n\t '")' ;
echo " matched:" '$(pos:J="'\n\t '")' ;
echo " exclude:" '$(neg:J="'\n\t '")' ;
}
# no include, no grist
return $(libs) ;
}
}
# for testing
rule test-best-libs ( threading-tag ? : gristlibs * )
{
local result ;
local rule get-file ( * ) {
result += $(1[6]) ;
}
return [ map-tokens
get-file
: [ best-uniques
[ tokenize-gristlibs
$(threading-tag:E="")
: $(gristlibs) ] ]
] ;
}
rule system-libs ( names +
: properties *
: usage-requirements *
)
{
local value-properties =
exclude
link