|
54 | 54 | prune => boolean(), |
55 | 55 | start_module => module() | undefined, |
56 | 56 | application_module => module() | undefined, |
57 | | - include_lines => boolean() |
| 57 | + include_lines => boolean(), |
| 58 | + arch => atom() |
58 | 59 | }. |
59 | 60 |
|
60 | 61 | -export_type([ |
|
68 | 69 | prune => false, |
69 | 70 | start_module => undefined, |
70 | 71 | application_module => undefined, |
71 | | - include_lines => true |
| 72 | + include_lines => true, |
| 73 | + arch => undefined, |
| 74 | + platform => generic_unix |
72 | 75 | }). |
73 | 76 |
|
74 | 77 | %% |
|
88 | 91 | %% prune => false, |
89 | 92 | %% start_module => undefined, |
90 | 93 | %% application_module => undefined, |
91 | | -%% include_lines => false |
| 94 | +%% include_lines => false, |
| 95 | +%% arch => undefined, |
| 96 | +%% platform => generic_unix |
92 | 97 | %% }' |
93 | 98 | %% |
94 | 99 | %% @end |
@@ -122,15 +127,20 @@ create(OutputPath, InputPaths, Options) -> |
122 | 127 | prune := Prune, |
123 | 128 | start_module := StartModule, |
124 | 129 | application_module := ApplicationModule, |
125 | | - include_lines := IncludeLines |
| 130 | + include_lines := IncludeLines, |
| 131 | + arch := Arch, |
| 132 | + platform := Platform |
126 | 133 | } = maps:merge(?DEFAULT_OPTIONS, Options), |
127 | | - ParsedFiles = parse_files(InputPaths, StartModule, IncludeLines), |
| 134 | + Files0 = parse_files(InputPaths, StartModule, IncludeLines), |
| 135 | + Files1 = filter_jit(Files0, Arch, Platform), |
| 136 | + Files2 = |
| 137 | + if |
| 138 | + Prune -> prune(Files1, ApplicationModule); |
| 139 | + true -> Files1 |
| 140 | + end, |
128 | 141 | write_packbeam( |
129 | 142 | OutputPath, |
130 | | - case Prune of |
131 | | - true -> prune(ParsedFiles, ApplicationModule); |
132 | | - _ -> ParsedFiles |
133 | | - end |
| 143 | + Files2 |
134 | 144 | ). |
135 | 145 |
|
136 | 146 | %%----------------------------------------------------------------------------- |
@@ -782,9 +792,14 @@ ends_with(String, Suffix) -> |
782 | 792 |
|
783 | 793 | %% @private |
784 | 794 | filter_chunks(Chunks, IncludeLines) -> |
785 | | - AllowedChunks = allowed_chunks(IncludeLines), |
| 795 | + AllowedChunks0 = allowed_chunks(IncludeLines), |
| 796 | + AllowedChunks1 = |
| 797 | + case lists:keymember("avmN", 1, Chunks) of |
| 798 | + true -> AllowedChunks0 -- ["Code", "Type"]; |
| 799 | + false -> AllowedChunks0 -- ["avmN"] |
| 800 | + end, |
786 | 801 | lists:filter( |
787 | | - fun({Tag, _Data}) -> lists:member(Tag, AllowedChunks) end, |
| 802 | + fun({Tag, _Data}) -> lists:member(Tag, AllowedChunks1) end, |
788 | 803 | Chunks |
789 | 804 | ). |
790 | 805 |
|
@@ -853,3 +868,60 @@ deduplicate([]) -> |
853 | 868 | []; |
854 | 869 | deduplicate([H | T]) -> |
855 | 870 | [H | [X || X <- deduplicate(T), X /= H]]. |
| 871 | + |
| 872 | +filter_jit(Files0, undefined, generic_unix) -> |
| 873 | + Files0; |
| 874 | +filter_jit(Files0, aarch64, generic_unix) -> |
| 875 | + lists:filter( |
| 876 | + fun(File) -> |
| 877 | + filter_jit0(File, [ |
| 878 | + "jit.beam", "jit_stream_mmap.beam", "jit_aarch64.beam", "jit_aarch64_asm.beam" |
| 879 | + ]) |
| 880 | + end, |
| 881 | + Files0 |
| 882 | + ); |
| 883 | +filter_jit(Files0, x86_64, generic_unix) -> |
| 884 | + lists:filter( |
| 885 | + fun(File) -> |
| 886 | + filter_jit0(File, [ |
| 887 | + "jit.beam", "jit_stream_mmap.beam", "jit_x86_64.beam", "jit_x86_64_asm.beam" |
| 888 | + ]) |
| 889 | + end, |
| 890 | + Files0 |
| 891 | + ); |
| 892 | +filter_jit(Files0, armv6m, generic_unix) -> |
| 893 | + lists:filter( |
| 894 | + fun(File) -> |
| 895 | + filter_jit0(File, [ |
| 896 | + "jit.beam", "jit_stream_mmap.beam", "jit_armv6m.beam", "jit_armv6m_asm.beam" |
| 897 | + ]) |
| 898 | + end, |
| 899 | + Files0 |
| 900 | + ); |
| 901 | +filter_jit(Files0, armv6m, rp2) -> |
| 902 | + lists:filter( |
| 903 | + fun(File) -> |
| 904 | + filter_jit0(File, [ |
| 905 | + "jit.beam", "jit_stream_flash.beam", "jit_armv6m.beam", "jit_armv6m_asm.beam" |
| 906 | + ]) |
| 907 | + end, |
| 908 | + Files0 |
| 909 | + ); |
| 910 | +filter_jit(Files0, armv6m, stm32) -> |
| 911 | + lists:filter( |
| 912 | + fun(File) -> |
| 913 | + filter_jit0(File, [ |
| 914 | + "jit.beam", "jit_stream_flash.beam", "jit_armv6m.beam", "jit_armv6m_asm.beam" |
| 915 | + ]) |
| 916 | + end, |
| 917 | + Files0 |
| 918 | + ). |
| 919 | + |
| 920 | +filter_jit0(File, JITModules) -> |
| 921 | + ModuleName = lists:flatten(get_element_name(File)), |
| 922 | + case ModuleName of |
| 923 | + "jit" ++ _ -> |
| 924 | + lists:member(ModuleName, JITModules); |
| 925 | + _ -> |
| 926 | + true |
| 927 | + end. |
0 commit comments