33Code . require_file ( "analyze_funcs_diff.exs" , __DIR__ )
44defmodule AllFuncsUpdater do
55 @ 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
78 AtomVM has been built in the AtomVM/build directory.
89
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".
1014
1115 Updates priv/funcs.txt with all available functions from AtomVM sources.
1216
@@ -19,18 +23,22 @@ defmodule AllFuncsUpdater do
1923 implementation details. The final list is sorted with Erlang functions
2024 first, followed by Elixir functions.
2125 """
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"
2631 @ funcs_txt_path "priv/funcs.txt"
2732
28- def run do
33+ def default_atomvm_path , do: @ default_atomvm_path
34+
35+ def run ( atomvm_path \\ @ default_atomvm_path ) do
2936 IO . puts ( "Updating #{ @ funcs_txt_path } ..." )
37+ IO . puts ( "Using AtomVM path: #{ atomvm_path } " )
3038
3139 try do
32- nifs = extract_nifs ( )
33- beams = extract_beams ( )
40+ nifs = extract_nifs ( atomvm_path )
41+ beams = extract_beams ( atomvm_path )
3442
3543 all_funcs = ( read_current ( ) ++ nifs ++ beams )
3644 |> Enum . uniq ( )
@@ -59,8 +67,8 @@ defmodule AllFuncsUpdater do
5967 end
6068 end
6169
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 )
6472
6573 if File . exists? ( path ) do
6674 path
@@ -74,8 +82,11 @@ defmodule AllFuncsUpdater do
7482 end
7583 end
7684
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 ( )
7990 end
8091
8192 defp extract_from_dir ( path ) do
@@ -110,5 +121,13 @@ defmodule AllFuncsUpdater do
110121end
111122
112123# 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 )
114133FuncsDiffAnalyzer . run ( )
0 commit comments