@@ -115,49 +115,6 @@ func multilineList[T any](values []T) build.Expr {
115115 }
116116}
117117
118- func multilineGlob (glob rule.GlobValue , macro bool ) build.Expr {
119- var patternsValue build.Expr
120- if len (glob .Patterns ) < 2 {
121- patternsValue = rule .ExprFromValue (glob .Patterns )
122- } else {
123- patternsValue = multilineList (glob .Patterns )
124- }
125- globArgs := []build.Expr {patternsValue }
126- if len (glob .Excludes ) > 0 {
127- excludesValue := multilineList (glob .Excludes )
128- globArgs = append (globArgs , & build.AssignExpr {
129- LHS : & build.LiteralExpr {Token : "exclude" },
130- Op : "=" ,
131- RHS : excludesValue ,
132- })
133- }
134- token := "glob"
135- if macro {
136- token = "native.glob"
137- }
138- return & build.CallExpr {
139- X : & build.LiteralExpr {Token : token },
140- List : globArgs ,
141- ForceMultiLine : len (glob .Excludes ) > 0 ,
142- }
143- }
144-
145- func explicitPlusGlobExpr (
146- explicit []string ,
147- glob rule.GlobValue ,
148- macro bool ,
149- ) build.Expr {
150- if len (explicit ) == 0 {
151- return multilineGlob (glob , macro )
152- }
153-
154- return & build.BinaryExpr {
155- X : multilineList (explicit ),
156- Op : "+" ,
157- Y : multilineGlob (glob , macro ),
158- }
159- }
160-
161118func (erlangApp * ErlangApp ) pathFor (from , include string ) string {
162119 directPath := filepath .Join (filepath .Dir (from ), include )
163120 privatePath := filepath .Join ("src" , include )
@@ -317,18 +274,7 @@ func (erlangApp *ErlangApp) BeamFilesRules(args language.GenerateArgs, erlParser
317274 othersRule = rule .NewRule (erlangBytecodeKind , "other_beam" )
318275 othersRule .SetAttr ("app_name" , erlangApp .Name )
319276 othersRule .SetAttr ("erlc_opts" , "//:" + erlcOptsRuleName )
320- othersSrcsGen := mutable_set .Map (others .Filter (func (v * ErlangAppFileParsed ) bool {
321- return v .IsGenFile
322- }), (* ErlangAppFileParsed ).path ).Values (strings .Compare )
323- otherSrcsExcludes := mutable_set .Map (mutable_set .Union (transforms , behaviours ), (* ErlangAppFileParsed ).path ).Values (strings .Compare )
324- othersRule .SetAttr ("srcs" , explicitPlusGlobExpr (
325- othersSrcsGen ,
326- rule.GlobValue {
327- Patterns : []string {"src/**/*.erl" },
328- Excludes : otherSrcsExcludes ,
329- },
330- erlangConfig .GenerateBeamFilesMacro ,
331- ))
277+ othersRule .SetAttr ("srcs" , multilineList (others .Values (comparePaths )))
332278 othersRule .SetAttr ("hdrs" , []string {":public_and_private_hdrs" })
333279 othersRule .SetAttr ("dest" , "ebin" )
334280 if len (beamFilesGroupRules ) > 0 {
@@ -480,18 +426,7 @@ func (erlangApp *ErlangApp) testBeamFilesRules(args language.GenerateArgs, erlPa
480426 othersRule .SetAttr ("testonly" , true )
481427 othersRule .SetAttr ("app_name" , erlangApp .Name )
482428 othersRule .SetAttr ("erlc_opts" , "//:" + testErlcOptsRuleName )
483- othersSrcsGen := mutable_set .Map (others .Filter (func (v * ErlangAppFileParsed ) bool {
484- return v .IsGenFile
485- }), (* ErlangAppFileParsed ).path ).Values (strings .Compare )
486- otherSrcsExcludes := mutable_set .Map (mutable_set .Union (transforms , behaviours ), (* ErlangAppFileParsed ).path ).Values (strings .Compare )
487- othersRule .SetAttr ("srcs" , explicitPlusGlobExpr (
488- othersSrcsGen ,
489- rule.GlobValue {
490- Patterns : []string {"src/**/*.erl" },
491- Excludes : otherSrcsExcludes ,
492- },
493- erlangConfig .GenerateBeamFilesMacro ,
494- ))
429+ othersRule .SetAttr ("srcs" , multilineList (others .Values (comparePaths )))
495430 othersRule .SetAttr ("hdrs" , []string {":public_and_private_hdrs" })
496431 othersRule .SetAttr ("dest" , "test" )
497432 if len (beamFilesGroupRules ) > 0 {
@@ -555,121 +490,52 @@ func (erlangApp *ErlangApp) allSrcsRules(args language.GenerateArgs) (rules []*r
555490 erlangConfig := erlangConfigForRel (args .Config , args .Rel )
556491
557492 srcs := rule .NewRule ("filegroup" , "srcs" )
558- if erlangConfig .GenerateFewerBytecodeRules {
559- srcsGen := mutable_set .Map (erlangApp .Srcs .Filter (func (v * ErlangAppFileParsed ) bool {
560- return v .IsGenFile
561- }), (* ErlangAppFileParsed ).path ).Values (strings .Compare )
562- srcs .SetAttr ("srcs" , explicitPlusGlobExpr (
563- srcsGen ,
564- rule.GlobValue {
565- Patterns : []string {
566- "src/**/*.erl" ,
567- "src/**/*.app.src" ,
568- },
569- },
570- erlangConfig .GenerateBeamFilesMacro ,
571- ))
572- } else {
573- srcsSrcs := mutable_set .Union (
574- mutable_set .Map (erlangApp .Srcs , (* ErlangAppFileParsed ).path ),
575- mutable_set .Map (erlangApp .AppSrc , (* ErlangAppFile ).path ),
576- ).Values (strings .Compare )
577- if len (srcsSrcs ) > 0 {
578- srcs .SetAttr ("srcs" , multilineList (srcsSrcs ))
579- }
493+ srcsSrcs := mutable_set .Union (
494+ mutable_set .Map (erlangApp .Srcs , (* ErlangAppFileParsed ).path ),
495+ mutable_set .Map (erlangApp .AppSrc , (* ErlangAppFile ).path ),
496+ ).Values (strings .Compare )
497+ if len (srcsSrcs ) > 0 {
498+ srcs .SetAttr ("srcs" , multilineList (srcsSrcs ))
580499 }
581500 if erlangConfig .Testonly {
582501 srcs .SetAttr ("testonly" , true )
583502 }
584503 rules = append (rules , srcs )
585504
586505 private_hdrs := rule .NewRule ("filegroup" , "private_hdrs" )
587- if erlangConfig .GenerateFewerBytecodeRules {
588- privateHdrsGen := mutable_set .Map (erlangApp .PrivateHdrs .Filter (func (v * ErlangAppFile ) bool {
589- return v .IsGenFile
590- }), (* ErlangAppFile ).path ).Values (strings .Compare )
591- private_hdrs .SetAttr ("srcs" , explicitPlusGlobExpr (
592- privateHdrsGen ,
593- rule.GlobValue {
594- Patterns : []string {"src/**/*.hrl" },
595- },
596- erlangConfig .GenerateBeamFilesMacro ,
597- ))
598- } else {
599- if ! erlangApp .PrivateHdrs .IsEmpty () {
600- private_hdrs .SetAttr ("srcs" , multilineList (
601- erlangApp .PrivateHdrs .Values (comparePaths2 )))
602- }
506+ if ! erlangApp .PrivateHdrs .IsEmpty () {
507+ private_hdrs .SetAttr ("srcs" , multilineList (
508+ erlangApp .PrivateHdrs .Values (comparePaths2 )))
603509 }
604510 if erlangConfig .Testonly {
605511 private_hdrs .SetAttr ("testonly" , true )
606512 }
607513 rules = append (rules , private_hdrs )
608514
609515 public_hdrs := rule .NewRule ("filegroup" , "public_hdrs" )
610- if erlangConfig .GenerateFewerBytecodeRules {
611- publicHdrsGen := mutable_set .Map (erlangApp .PublicHdrs .Filter (func (v * ErlangAppFile ) bool {
612- return v .IsGenFile
613- }), (* ErlangAppFile ).path ).Values (strings .Compare )
614- public_hdrs .SetAttr ("srcs" , explicitPlusGlobExpr (
615- publicHdrsGen ,
616- rule.GlobValue {
617- Patterns : []string {"include/**/*.hrl" },
618- },
619- erlangConfig .GenerateBeamFilesMacro ,
620- ))
621- } else {
622- if ! erlangApp .PublicHdrs .IsEmpty () {
623- public_hdrs .SetAttr ("srcs" , multilineList (
624- erlangApp .PublicHdrs .Values (comparePaths2 )))
625- }
626-
516+ if ! erlangApp .PublicHdrs .IsEmpty () {
517+ public_hdrs .SetAttr ("srcs" , multilineList (
518+ erlangApp .PublicHdrs .Values (comparePaths2 )))
627519 }
628520 if erlangConfig .Testonly {
629521 public_hdrs .SetAttr ("testonly" , true )
630522 }
631523 rules = append (rules , public_hdrs )
632524
633525 priv := rule .NewRule ("filegroup" , "priv" )
634- if erlangConfig .GenerateFewerBytecodeRules {
635- privGen := mutable_set .Map (erlangApp .Priv .Filter (func (v * ErlangAppFile ) bool {
636- return v .IsGenFile
637- }), (* ErlangAppFile ).path ).Values (strings .Compare )
638- priv .SetAttr ("srcs" , explicitPlusGlobExpr (
639- privGen ,
640- rule.GlobValue {
641- Patterns : []string {"priv/**/*" },
642- },
643- erlangConfig .GenerateBeamFilesMacro ,
644- ))
645- } else {
646- if ! erlangApp .Priv .IsEmpty () {
647- priv .SetAttr ("srcs" , multilineList (
648- erlangApp .Priv .Values (comparePaths2 )))
649- }
526+ if ! erlangApp .Priv .IsEmpty () {
527+ priv .SetAttr ("srcs" , multilineList (
528+ erlangApp .Priv .Values (comparePaths2 )))
650529 }
651530 if erlangConfig .Testonly {
652531 priv .SetAttr ("testonly" , true )
653532 }
654533 rules = append (rules , priv )
655534
656535 licenses := rule .NewRule ("filegroup" , "license_files" )
657- if erlangConfig .GenerateFewerBytecodeRules {
658- licensesGen := mutable_set .Map (erlangApp .LicenseFiles .Filter (func (v * ErlangAppFile ) bool {
659- return v .IsGenFile
660- }), (* ErlangAppFile ).path ).Values (strings .Compare )
661- licenses .SetAttr ("srcs" , explicitPlusGlobExpr (
662- licensesGen ,
663- rule.GlobValue {
664- Patterns : []string {"LICENSE*" },
665- },
666- erlangConfig .GenerateBeamFilesMacro ,
667- ))
668- } else {
669- if ! erlangApp .LicenseFiles .IsEmpty () {
670- licenses .SetAttr ("srcs" , multilineList (
671- erlangApp .LicenseFiles .Values (comparePaths2 )))
672- }
536+ if ! erlangApp .LicenseFiles .IsEmpty () {
537+ licenses .SetAttr ("srcs" , multilineList (
538+ erlangApp .LicenseFiles .Values (comparePaths2 )))
673539 }
674540 if erlangConfig .Testonly {
675541 licenses .SetAttr ("testonly" , true )
0 commit comments