Skip to content

Commit 5aef640

Browse files
committed
Forward port changes from v0.6 release branch
Merge v0.6.3 into main.
2 parents 8b294df + 3a107ae commit 5aef640

25 files changed

+2656
-12
lines changed

.github/workflows/build-libraries.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ permissions:
1616

1717
jobs:
1818
build-libraries:
19-
runs-on: "ubuntu-24.04"
20-
container: erlang:27
19+
runs-on: "ubuntu-22.04"
2120
strategy:
2221
fail-fast: false
2322

@@ -27,6 +26,11 @@ jobs:
2726
with:
2827
submodules: 'recursive'
2928

29+
- uses: erlef/setup-beam@v1
30+
with:
31+
otp-version: "24"
32+
elixir-version: "1.11"
33+
3034
- name: "APT update"
3135
run: sudo apt update -y
3236

.github/workflows/build-linux-artifacts.yaml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,39 @@ on:
1414
permissions:
1515
contents: write
1616

17+
env:
18+
otp_version: 24
19+
elixir_version: 1.14
20+
1721
jobs:
1822
compile_tests:
19-
runs-on: ubuntu-24.04
20-
container: erlang:27
23+
runs-on: ubuntu-22.04
2124
steps:
2225
- name: Checkout repo
2326
uses: actions/checkout@v4
2427

28+
- uses: erlef/setup-beam@v1
29+
with:
30+
otp-version: ${{ env.otp_version }}
31+
elixir-version: ${{ env.elixir_version }}
32+
2533
- name: apt update
2634
run: sudo apt update
2735

2836
- name: Install required packages
29-
run: sudo apt install -y cmake gperf zlib1g-dev ninja-build
37+
run: sudo apt install -y gperf
3038

3139
- name: Compile test modules
3240
run: |
3341
set -e
3442
mkdir build_tests
3543
cd build_tests
36-
cmake .. -G Ninja -DAVM_WARNINGS_ARE_ERRORS=ON
37-
ninja erlang_test_modules test_etest test_estdlib test_eavmlib test_alisp
44+
cmake ..
45+
make erlang_test_modules
46+
make test_etest
47+
make test_estdlib
48+
make test_eavmlib
49+
make test_alisp
3850
3951
- name: Upload test modules
4052
uses: actions/upload-artifact@v4

.github/workflows/esp32-build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
- 'v5.0.6'
4141
- 'v5.1.4'
4242
- 'v5.2.2'
43-
- 'v5.3-beta2'
43+
- 'v5.3-rc1'
4444

4545
exclude:
4646
- esp-idf-target: "esp32c3"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ xcode/**
1111
src/platforms/esp32/build/**
1212
src/platforms/esp32/build/**/*.d
1313
src/platforms/esp32/test/build/**
14+
src/platforms/esp32/test/__pycache__/**
1415
src/platforms/esp32/components/**
1516
src/platforms/esp32/managed_components/**
1617
src/platforms/esp32/sdkconfig

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
- Added a limited implementation of the OTP `ets` interface
1111
- Added `code:all_loaded/0` and `code:all_available/0`
1212

13-
## [0.6.3] - Unreleased
13+
## [0.6.3] - 20-07-2024
1414

1515
### Added
1616

@@ -23,6 +23,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2323
- Support for `erlang:apply/2`
2424
- Support for `lists:keystore/4`
2525
- Support for `erlang:size/1` bif
26+
- Support for USB serial output on ESP32 (needs to be manually enabled)
27+
- Support for `lists:filtermap/2`
28+
- Support for standard library `queue` module
29+
- Support for `maps:from_keys/2` NIF
30+
- Support for standard library `sets` module
2631

2732
### Changed
2833

@@ -41,6 +46,7 @@ See issue [#1193](https://github.com/atomvm/AtomVM/issues/1193).
4146
- Fix error that is raised when a function is undefined
4247
- Fix a bug that could yield crashes when functions are sent in messages
4348
- Fix bug where failing guards would corrupt x0 and x1
49+
- Fix a memory leak when raising out of memory error while executing PUT_MAP_ASSOC instruction
4450

4551
## [0.6.2] - 25-05-2024
4652

libs/estdlib/src/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ set(ERLANG_MODULES
5050
logger
5151
logger_std_h
5252
proplists
53+
queue
54+
sets
5355
socket
5456
ssl
5557
string

libs/estdlib/src/lists.erl

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
flatten/1,
5151
search/2,
5252
filter/2,
53+
filtermap/2,
5354
join/2,
5455
seq/2, seq/3,
5556
sort/1, sort/2,
@@ -469,6 +470,47 @@ search(Pred, [H | T]) ->
469470
filter(Pred, L) when is_function(Pred, 1) ->
470471
[X || X <- L, Pred(X)].
471472

473+
% Taken from `otp/blob/master/lib/stdlib/src/lists.erl`
474+
475+
%%-----------------------------------------------------------------------------
476+
%% @param Fun the filter/map fun
477+
%% @param List1 the list where given fun will be applied
478+
%% @returns Returns the result of application of given fun over given list items
479+
%% @doc Calls `Fun(Elem)' on successive elements `Elem' of `List1' in order to update or
480+
%% remove elements from `List1'.
481+
%%
482+
%% `Fun/1' must return either a Boolean or a tuple `{true, Value}'. The function
483+
%% returns the list of elements for which `Fun' returns a new value, where a value
484+
%% of `true' is synonymous with `{true, Elem}'.
485+
%%
486+
%% Example:
487+
%% `1> lists:filtermap(fun(X) -> case X rem 2 of 0 -> {true, X div 2}; _ -> false end end, [1,2,3,4,5]).'
488+
%% `[1,2]'
489+
%%
490+
%% @end
491+
%%-----------------------------------------------------------------------------
492+
-spec filtermap(Fun, List1) -> List2 when
493+
Fun :: fun((Elem) -> boolean() | {'true', Value}),
494+
List1 :: [Elem],
495+
List2 :: [Elem | Value],
496+
Elem :: term(),
497+
Value :: term().
498+
499+
filtermap(F, List) when is_function(F, 1) ->
500+
filtermap_1(F, List).
501+
502+
filtermap_1(F, [Hd | Tail]) ->
503+
case F(Hd) of
504+
true ->
505+
[Hd | filtermap_1(F, Tail)];
506+
{true, Val} ->
507+
[Val | filtermap_1(F, Tail)];
508+
false ->
509+
filtermap_1(F, Tail)
510+
end;
511+
filtermap_1(_F, []) ->
512+
[].
513+
472514
%%-----------------------------------------------------------------------------
473515
%% @param Sep the separator
474516
%% @param List list

libs/estdlib/src/maps.erl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
filter/2,
5353
fold/3,
5454
foreach/2,
55+
from_keys/2,
5556
map/2,
5657
merge/2,
5758
remove/2,
@@ -385,6 +386,17 @@ foreach(_Fun, Map) when not is_map(Map) ->
385386
foreach(_Fun, _Map) ->
386387
error(badarg).
387388

389+
%%-----------------------------------------------------------------------------
390+
%% @param List the list of keys of the map that will be created
391+
%% @param Value the value that will be used as value for all map items
392+
%% @returns a map having all provided keys having provided value as value
393+
%% @doc Creates a map with specified keys intialized to given value
394+
%% @end
395+
%%-----------------------------------------------------------------------------
396+
-spec from_keys(list(), term()) -> map().
397+
from_keys(List, _Value) when is_list(List) ->
398+
erlang:nif_error(undefined).
399+
388400
%%-----------------------------------------------------------------------------
389401
%% @param Fun the function to apply to every entry in the map
390402
%% @param Map the map to which to apply the map function

0 commit comments

Comments
 (0)