3
3
Code . require_file ( "analyze_funcs_diff.exs" , __DIR__ )
4
4
defmodule AllFuncsUpdater do
5
5
@ moduledoc """
6
- Script assumes that AtomVM is in same parent directory as ExAtomVM and that
6
+ Script to update priv/funcs.txt with all available functions from AtomVM sources.
7
+ By default, assumes AtomVM is in the same parent directory as ExAtomVM and that
7
8
AtomVM has been built in the AtomVM/build directory.
8
9
9
- run using 'elixir scripts/update_all_funcs.exs' in project root.
10
+ Usage:
11
+ elixir scripts/update_all_funcs.exs [atomvm_path]
12
+
13
+ If atomvm_path is not provided, defaults to "../AtomVM".
10
14
11
15
Updates priv/funcs.txt with all available functions from AtomVM sources.
12
16
@@ -19,18 +23,22 @@ defmodule AllFuncsUpdater do
19
23
implementation details. The final list is sorted with Erlang functions
20
24
first, followed by Elixir functions.
21
25
"""
22
- @ nifs_gperf_path "../AtomVM/src/libAtomVM/nifs.gperf"
23
- @ estdlib_beam_path "../AtomVM/build/libs/estdlib/src/beams"
24
- @ erlang_beam_path "../AtomVM/build/libs/eavmlib/src/beams"
25
- @ elixir_beam_path "../AtomVM/build/libs/exavmlib/lib/beams"
26
+ @ default_atomvm_path "../AtomVM"
27
+ @ nifs_gperf_path "src/libAtomVM/nifs.gperf"
28
+ @ estdlib_beam_path "build/libs/estdlib/src/beams"
29
+ @ erlang_beam_path "build/libs/eavmlib/src/beams"
30
+ @ elixir_beam_path "build/libs/exavmlib/lib/beams"
26
31
@ funcs_txt_path "priv/funcs.txt"
27
32
28
- def run do
33
+ def default_atomvm_path , do: @ default_atomvm_path
34
+
35
+ def run ( atomvm_path \\ @ default_atomvm_path ) do
29
36
IO . puts ( "Updating #{ @ funcs_txt_path } ..." )
37
+ IO . puts ( "Using AtomVM path: #{ atomvm_path } " )
30
38
31
39
try do
32
- nifs = extract_nifs ( )
33
- beams = extract_beams ( )
40
+ nifs = extract_nifs ( atomvm_path )
41
+ beams = extract_beams ( atomvm_path )
34
42
35
43
all_funcs = ( read_current ( ) ++ nifs ++ beams )
36
44
|> Enum . uniq ( )
@@ -59,8 +67,8 @@ defmodule AllFuncsUpdater do
59
67
end
60
68
end
61
69
62
- defp extract_nifs do
63
- path = @ nifs_gperf_path
70
+ defp extract_nifs ( atomvm_path ) do
71
+ path = Path . join ( atomvm_path , @ nifs_gperf_path )
64
72
65
73
if File . exists? ( path ) do
66
74
path
@@ -74,8 +82,11 @@ defmodule AllFuncsUpdater do
74
82
end
75
83
end
76
84
77
- defp extract_beams do
78
- [ @ estdlib_beam_path , @ erlang_beam_path , @ elixir_beam_path ] |> Enum . flat_map ( & extract_from_dir / 1 ) |> Enum . uniq ( )
85
+ defp extract_beams ( atomvm_path ) do
86
+ [ @ estdlib_beam_path , @ erlang_beam_path , @ elixir_beam_path ]
87
+ |> Enum . map ( & Path . join ( atomvm_path , & 1 ) )
88
+ |> Enum . flat_map ( & extract_from_dir / 1 )
89
+ |> Enum . uniq ( )
79
90
end
80
91
81
92
defp extract_from_dir ( path ) do
@@ -110,5 +121,13 @@ defmodule AllFuncsUpdater do
110
121
end
111
122
112
123
# Run the script
113
- AllFuncsUpdater . run ( )
124
+ atomvm_path = case System . argv ( ) do
125
+ [ path ] -> path
126
+ [ ] -> AllFuncsUpdater . default_atomvm_path ( )
127
+ _ ->
128
+ IO . puts ( "Usage: elixir scripts/update_all_funcs.exs [atomvm_path]" )
129
+ System . halt ( 1 )
130
+ end
131
+
132
+ AllFuncsUpdater . run ( atomvm_path )
114
133
FuncsDiffAnalyzer . run ( )
0 commit comments