@@ -51,7 +51,6 @@ BuildEnvironment = record(
51
51
# convenience storrage
52
52
app_includes = field (IncludesMapping , {}),
53
53
app_beams = field (ModuleArtifactMapping , {}),
54
- app_chunks = field (ModuleArtifactMapping , {}),
55
54
# input artifact mapping
56
55
input_mapping = field (InputArtifactMapping , {}),
57
56
)
@@ -61,11 +60,6 @@ DepInfo = record(
61
60
path = field (str ),
62
61
)
63
62
64
- Anchor = record (
65
- artifact = field (Artifact ),
66
- dirname = field (str ),
67
- )
68
-
69
63
def _prepare_build_environment (
70
64
ctx : AnalysisContext ,
71
65
toolchain : Toolchain ,
@@ -175,7 +169,6 @@ def _generate_input_mapping(build_environment: BuildEnvironment, input_artifacts
175
169
app_files = build_environment .app_files ,
176
170
app_includes = build_environment .app_includes ,
177
171
app_beams = build_environment .app_beams ,
178
- app_chunks = build_environment .app_chunks ,
179
172
)
180
173
181
174
def _generated_source_artifacts (ctx : AnalysisContext , toolchain : Toolchain , name : str ) -> PathArtifactMapping :
@@ -288,51 +281,6 @@ def _generate_beam_artifacts(
288
281
289
282
return updated_build_environment
290
283
291
- def _generate_chunk_artifacts (
292
- ctx : AnalysisContext ,
293
- toolchain : Toolchain ,
294
- build_environment : BuildEnvironment ,
295
- name : str ,
296
- src_artifacts : list [Artifact ]) -> BuildEnvironment :
297
- anchor = _make_dir_anchor (ctx , paths .join (_build_dir (toolchain ), name , "chunks" ))
298
-
299
- chunk_mapping = {
300
- module_name (src ): ctx .actions .declare_output (chunk_path (anchor , src ))
301
- for src in src_artifacts
302
- }
303
-
304
- updated_build_environment = BuildEnvironment (
305
- app_chunks = chunk_mapping ,
306
- # copied fields
307
- includes = build_environment .includes ,
308
- private_includes = build_environment .private_includes ,
309
- beams = build_environment .beams ,
310
- priv_dirs = build_environment .priv_dirs ,
311
- include_dirs = build_environment .include_dirs ,
312
- private_include_dir = build_environment .private_include_dir ,
313
- deps_files = build_environment .deps_files ,
314
- app_files = build_environment .app_files ,
315
- app_includes = build_environment .app_includes ,
316
- app_beams = build_environment .app_beams ,
317
- input_mapping = build_environment .input_mapping ,
318
- )
319
-
320
- preprocess_modules = toolchain .edoc_preprocess
321
- preprocess_all = "__all__" in preprocess_modules
322
-
323
- for erl in src_artifacts :
324
- preprocess = preprocess_all or module_name (erl ) in preprocess_modules
325
- _build_edoc (ctx , toolchain , updated_build_environment , erl , chunk_mapping [module_name (erl )], preprocess )
326
-
327
- return updated_build_environment
328
-
329
- def _make_dir_anchor (ctx : AnalysisContext , path : str ) -> Anchor :
330
- artifact = ctx .actions .write (
331
- paths .normalize (paths .join (path , ".hidden" )),
332
- cmd_args (["" ]),
333
- )
334
- return Anchor (dirname = paths .dirname (artifact .short_path ), artifact = artifact )
335
-
336
284
def _get_deps_files (
337
285
ctx : AnalysisContext ,
338
286
toolchain : Toolchain ,
@@ -449,48 +397,6 @@ def _build_erl(
449
397
ctx .actions .dynamic_output (dynamic = [final_dep_file ], inputs = [src ], outputs = [output .as_output ()], f = dynamic_lambda )
450
398
return None
451
399
452
- def _build_edoc (
453
- ctx : AnalysisContext ,
454
- toolchain : Toolchain ,
455
- build_environment : BuildEnvironment ,
456
- src : Artifact ,
457
- output : Artifact ,
458
- preprocess : bool ) -> None :
459
- """Build edoc from erl files."""
460
- eval_cmd = cmd_args (
461
- toolchain .otp_binaries .escript ,
462
- toolchain .edoc ,
463
- cmd_args (toolchain .edoc_options ),
464
- "-app" ,
465
- ctx .attrs .name ,
466
- "-files" ,
467
- src ,
468
- "-chunks" ,
469
- "-pa" ,
470
- toolchain .utility_modules ,
471
- "-o" ,
472
- cmd_args (output .as_output (), parent = 2 ),
473
- )
474
-
475
- if not preprocess :
476
- eval_cmd .add ("-no-preprocess" )
477
-
478
- private_include = build_environment .private_include_dir
479
- public_includes = build_environment .include_dirs .values ()
480
- eval_cmd .add (cmd_args (private_include , prepend = "-I" ))
481
- eval_cmd .add (cmd_args (public_includes , prepend = "-I" ))
482
- eval_cmd .add (cmd_args (public_includes , prepend = "-I" , parent = 2 ))
483
-
484
- _run_with_env (
485
- ctx ,
486
- toolchain ,
487
- eval_cmd ,
488
- always_print_stderr = True ,
489
- category = "edoc" ,
490
- identifier = action_identifier (toolchain , src .basename ),
491
- )
492
- return None
493
-
494
400
def _dependencies_to_args (
495
401
artifacts ,
496
402
final_dep_file : Artifact ,
@@ -636,18 +542,6 @@ def generated_erl_path(toolchain: Toolchain, appname: str, src: Artifact) -> str
636
542
"%s.erl" % (module_name (src ),),
637
543
)
638
544
639
- def anchor_path (anchor : Anchor , basename : str ) -> str :
640
- """ Returns the output path for hrl files. """
641
- return paths .join (anchor .dirname , basename )
642
-
643
- def beam_path (anchor : Anchor , src : Artifact ) -> str :
644
- """ Returns the output path for beam files. """
645
- return anchor_path (anchor , module_name (src ) + ".beam" )
646
-
647
- def chunk_path (anchor : Anchor , src : Artifact ) -> str :
648
- """Returns the output path for chunk files."""
649
- return anchor_path (anchor , module_name (src ) + ".chunk" )
650
-
651
545
def module_name (in_file : Artifact ) -> str :
652
546
""" Returns the basename of the artifact without extension """
653
547
end = in_file .basename .rfind ("." )
@@ -760,18 +654,20 @@ default_escript_args = cmd_args(
760
654
"minimal" ,
761
655
"-noinput" ,
762
656
"-noshell" ,
657
+ "-run" ,
658
+ "escript" ,
659
+ "start" ,
763
660
)
764
661
765
662
def _run_escript (ctx : AnalysisContext , toolchain : Toolchain , script : Artifact , args : cmd_args , ** kwargs ) -> None :
766
663
""" run escript with env and providing toolchain-configured utility modules"""
767
664
cmd = cmd_args (
768
665
toolchain .otp_binaries .erl ,
769
666
default_escript_args ,
770
- "-pa" ,
771
- toolchain .utility_modules ,
772
- "-run" ,
773
- "escript" ,
774
- "start" ,
667
+ )
668
+ if toolchain .utility_modules :
669
+ cmd .add ("-pa" , toolchain .utility_modules )
670
+ cmd .add (
775
671
"--" ,
776
672
script ,
777
673
args ,
@@ -809,7 +705,6 @@ def _peek_private_includes(
809
705
app_files = build_environment .app_files ,
810
706
app_includes = build_environment .app_includes ,
811
707
app_beams = build_environment .app_beams ,
812
- app_chunks = build_environment .app_chunks ,
813
708
input_mapping = build_environment .input_mapping ,
814
709
)
815
710
@@ -822,7 +717,6 @@ erlang_build = struct(
822
717
generated_source_artifacts = _generated_source_artifacts ,
823
718
generate_include_artifacts = _generate_include_artifacts ,
824
719
generate_beam_artifacts = _generate_beam_artifacts ,
825
- generate_chunk_artifacts = _generate_chunk_artifacts ,
826
720
),
827
721
utils = struct (
828
722
is_hrl = _is_hrl ,
@@ -832,7 +726,6 @@ erlang_build = struct(
832
726
is_config = _is_config ,
833
727
module_name = module_name ,
834
728
private_include_name = private_include_name ,
835
- make_dir_anchor = _make_dir_anchor ,
836
729
build_dir = _build_dir ,
837
730
run_with_env = _run_with_env ,
838
731
run_escript = _run_escript ,
0 commit comments