Skip to content

Commit

Permalink
Forward port changes from v0.6 release branch
Browse files Browse the repository at this point in the history
Merge v0.6.3 into main.
  • Loading branch information
bettio committed Jul 25, 2024
2 parents 8b294df + 3a107ae commit 5aef640
Show file tree
Hide file tree
Showing 25 changed files with 2,656 additions and 12 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/build-libraries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ permissions:

jobs:
build-libraries:
runs-on: "ubuntu-24.04"
container: erlang:27
runs-on: "ubuntu-22.04"
strategy:
fail-fast: false

Expand All @@ -27,6 +26,11 @@ jobs:
with:
submodules: 'recursive'

- uses: erlef/setup-beam@v1
with:
otp-version: "24"
elixir-version: "1.11"

- name: "APT update"
run: sudo apt update -y

Expand Down
22 changes: 17 additions & 5 deletions .github/workflows/build-linux-artifacts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,39 @@ on:
permissions:
contents: write

env:
otp_version: 24
elixir_version: 1.14

jobs:
compile_tests:
runs-on: ubuntu-24.04
container: erlang:27
runs-on: ubuntu-22.04
steps:
- name: Checkout repo
uses: actions/checkout@v4

- uses: erlef/setup-beam@v1
with:
otp-version: ${{ env.otp_version }}
elixir-version: ${{ env.elixir_version }}

- name: apt update
run: sudo apt update

- name: Install required packages
run: sudo apt install -y cmake gperf zlib1g-dev ninja-build
run: sudo apt install -y gperf

- name: Compile test modules
run: |
set -e
mkdir build_tests
cd build_tests
cmake .. -G Ninja -DAVM_WARNINGS_ARE_ERRORS=ON
ninja erlang_test_modules test_etest test_estdlib test_eavmlib test_alisp
cmake ..
make erlang_test_modules
make test_etest
make test_estdlib
make test_eavmlib
make test_alisp
- name: Upload test modules
uses: actions/upload-artifact@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/esp32-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- 'v5.0.6'
- 'v5.1.4'
- 'v5.2.2'
- 'v5.3-beta2'
- 'v5.3-rc1'

exclude:
- esp-idf-target: "esp32c3"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ xcode/**
src/platforms/esp32/build/**
src/platforms/esp32/build/**/*.d
src/platforms/esp32/test/build/**
src/platforms/esp32/test/__pycache__/**
src/platforms/esp32/components/**
src/platforms/esp32/managed_components/**
src/platforms/esp32/sdkconfig
Expand Down
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added a limited implementation of the OTP `ets` interface
- Added `code:all_loaded/0` and `code:all_available/0`

## [0.6.3] - Unreleased
## [0.6.3] - 20-07-2024

### Added

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

### Changed

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

## [0.6.2] - 25-05-2024

Expand Down
2 changes: 2 additions & 0 deletions libs/estdlib/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ set(ERLANG_MODULES
logger
logger_std_h
proplists
queue
sets
socket
ssl
string
Expand Down
42 changes: 42 additions & 0 deletions libs/estdlib/src/lists.erl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
flatten/1,
search/2,
filter/2,
filtermap/2,
join/2,
seq/2, seq/3,
sort/1, sort/2,
Expand Down Expand Up @@ -469,6 +470,47 @@ search(Pred, [H | T]) ->
filter(Pred, L) when is_function(Pred, 1) ->
[X || X <- L, Pred(X)].

% Taken from `otp/blob/master/lib/stdlib/src/lists.erl`

%%-----------------------------------------------------------------------------
%% @param Fun the filter/map fun
%% @param List1 the list where given fun will be applied
%% @returns Returns the result of application of given fun over given list items
%% @doc Calls `Fun(Elem)' on successive elements `Elem' of `List1' in order to update or
%% remove elements from `List1'.
%%
%% `Fun/1' must return either a Boolean or a tuple `{true, Value}'. The function
%% returns the list of elements for which `Fun' returns a new value, where a value
%% of `true' is synonymous with `{true, Elem}'.
%%
%% Example:
%% `1> lists:filtermap(fun(X) -> case X rem 2 of 0 -> {true, X div 2}; _ -> false end end, [1,2,3,4,5]).'
%% `[1,2]'
%%
%% @end
%%-----------------------------------------------------------------------------
-spec filtermap(Fun, List1) -> List2 when
Fun :: fun((Elem) -> boolean() | {'true', Value}),
List1 :: [Elem],
List2 :: [Elem | Value],
Elem :: term(),
Value :: term().

filtermap(F, List) when is_function(F, 1) ->
filtermap_1(F, List).

filtermap_1(F, [Hd | Tail]) ->
case F(Hd) of
true ->
[Hd | filtermap_1(F, Tail)];
{true, Val} ->
[Val | filtermap_1(F, Tail)];
false ->
filtermap_1(F, Tail)
end;
filtermap_1(_F, []) ->
[].

%%-----------------------------------------------------------------------------
%% @param Sep the separator
%% @param List list
Expand Down
12 changes: 12 additions & 0 deletions libs/estdlib/src/maps.erl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
filter/2,
fold/3,
foreach/2,
from_keys/2,
map/2,
merge/2,
remove/2,
Expand Down Expand Up @@ -385,6 +386,17 @@ foreach(_Fun, Map) when not is_map(Map) ->
foreach(_Fun, _Map) ->
error(badarg).

%%-----------------------------------------------------------------------------
%% @param List the list of keys of the map that will be created
%% @param Value the value that will be used as value for all map items
%% @returns a map having all provided keys having provided value as value
%% @doc Creates a map with specified keys intialized to given value
%% @end
%%-----------------------------------------------------------------------------
-spec from_keys(list(), term()) -> map().
from_keys(List, _Value) when is_list(List) ->
erlang:nif_error(undefined).

%%-----------------------------------------------------------------------------
%% @param Fun the function to apply to every entry in the map
%% @param Map the map to which to apply the map function
Expand Down
Loading

0 comments on commit 5aef640

Please sign in to comment.