Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [0.7.0-alpha.1] - Unreleased

### Added
- Added `json` module to estdlib, compatible with Erlang/OTP `json` API
- Added `Keyword.put_new/3` to exavmlib
- Added `JSON` module to exavmlib (Elixir wrapper for estdlib `json`)
- Added `erlang:node/1` BIF
- Added `erts_internal:cmp_term/2`
- Added `short` option to `erlang:float_to_binary/2` and `erlang:float_to_list/2`
Expand All @@ -32,6 +35,9 @@ strict format validation
- Fixed `erlang:binary_to_float/1` and `erlang:list_to_float/1` returning `inf` for overflow instead
of raising `badarg`

### Removed
- Removed old `json_encoder` module (now standard Erlang/OTP `json` module is available)

## [0.7.0-alpha.0] - 2026-03-20

### Added
Expand Down
69 changes: 68 additions & 1 deletion CMakeModules/BuildElixir.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,75 @@
# SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
#

# Compile a single .ex source that defines multiple modules.
# All module names must be listed, and OUTPUT names the variable
# that receives the beam paths (for passing to pack_archive).
#
# Usage:
# compile_multi(json.ex
# JSON
# JSON.Encoder
# JSON.Encoder.Atom
# OUTPUT JSON_BEAMS
# )
# pack_archive(mylib ${MODULES} EXTRA_BEAMS ${JSON_BEAMS})
#
macro(compile_multi source_file)
find_package(Elixir REQUIRED)
set(_cm_modules "")
set(_cm_outputs "")
set(_cm_outvar "")
set(_cm_in_output FALSE)
foreach(_arg ${ARGN})
if(_arg STREQUAL "OUTPUT")
set(_cm_in_output TRUE)
elseif(_cm_in_output)
set(_cm_outvar "${_arg}")
else()
list(APPEND _cm_modules "${_arg}")
list(APPEND _cm_outputs
"${CMAKE_CURRENT_BINARY_DIR}/beams/Elixir.${_arg}.beam"
)
endif()
endforeach()
add_custom_command(
OUTPUT ${_cm_outputs}
COMMAND mkdir -p
${CMAKE_CURRENT_BINARY_DIR}/beams
${CMAKE_CURRENT_BINARY_DIR}/beams.tmp.multi.${_cm_outvar}
COMMAND elixirc --no-docs --no-debug-info
--ignore-module-conflict
-o ${CMAKE_CURRENT_BINARY_DIR}/beams.tmp.multi.${_cm_outvar}/
${CMAKE_CURRENT_SOURCE_DIR}/${source_file}
COMMAND sh -c
"mv ${CMAKE_CURRENT_BINARY_DIR}/beams.tmp.multi.${_cm_outvar}/Elixir.*.beam ${CMAKE_CURRENT_BINARY_DIR}/beams/"
COMMAND rmdir
${CMAKE_CURRENT_BINARY_DIR}/beams.tmp.multi.${_cm_outvar}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${source_file}
COMMENT "Compiling ${source_file}"
VERBATIM
)
set(${_cm_outvar} ${_cm_outputs})
endmacro()

macro(pack_archive avm_name)
find_package(Elixir REQUIRED)

foreach(module_name ${ARGN})
# Parse EXTRA_BEAMS keyword from arguments
set(_pa_modules "")
set(_pa_extra "")
set(_pa_in_extra FALSE)
foreach(_arg ${ARGN})
if(_arg STREQUAL "EXTRA_BEAMS")
set(_pa_in_extra TRUE)
elseif(_pa_in_extra)
list(APPEND _pa_extra "${_arg}")
else()
list(APPEND _pa_modules "${_arg}")
endif()
endforeach()

foreach(module_name ${_pa_modules})
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/beams/Elixir.${module_name}.beam
COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/beams ${CMAKE_CURRENT_BINARY_DIR}/beams.tmp.${module_name}
Expand All @@ -35,6 +100,8 @@ macro(pack_archive avm_name)
set(BEAMS ${BEAMS} ${CMAKE_CURRENT_BINARY_DIR}/beams/Elixir.${module_name}.beam)
endforeach()

set(BEAMS ${BEAMS} ${_pa_extra})

add_custom_target(
${avm_name}_beams ALL
DEPENDS ${BEAMS}
Expand Down
2 changes: 2 additions & 0 deletions UPDATING.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ rather than copy sdkconfig.release-defaults.in to sdkconfig.defaults.in (which s
`reconfigure` or `set-target` to be run to pick up the changes), this may also be combined with the
`ATOMVM_ELIXIR_SUPPORT` option. For example, an Elixir-supported release build is configured using:
`idf.py -DATOMVM_ELIXIR_SUPPORT=on -DATOMVM_RELEASE=on set-target ${CHIP}`
- `json_encoder` module has been removed, use new (and standard) `json` module. New module uses
standard Erlang/OTP API, that takes maps instead of proplists.

## v0.6.4 -> v0.6.5

Expand Down
20 changes: 10 additions & 10 deletions examples/erlang/system_info_server.erl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%
% This file is part of AtomVM.
%
% Copyright 2019-2020 Davide Bettio <davide@uninstall.it>
% Copyright 2019-2026 Davide Bettio <davide@uninstall.it>
%
% Licensed under the Apache License, Version 2.0 (the "License");
% you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -62,18 +62,18 @@ handle_req("GET", [], Conn) ->
Body = [<<"<html><body><h1>">>, TimeString, <<"</h1></body></html>">>],
http_server:reply(200, Body, Conn);
handle_req("GET", ["system", "info"], Conn) ->
SysInfo = [
{atom_count, erlang:system_info(atom_count)},
{process_count, erlang:system_info(process_count)},
{port_count, erlang:system_info(port_count)},
{word_size, erlang:system_info(wordsize)},
{system_architecture, erlang:system_info(system_architecture)}
],
Body = json_encoder:encode(SysInfo),
SysInfo = #{
atom_count => erlang:system_info(atom_count),
process_count => erlang:system_info(process_count),
port_count => erlang:system_info(port_count),
word_size => erlang:system_info(wordsize),
system_architecture => erlang:system_info(system_architecture)
},
Body = json:encode(SysInfo),
http_server:reply(200, Body, Conn);
handle_req("GET", ["processes", PidString, "info"], Conn) ->
{Code, ProcInfo} = try_proc_info_list(PidString),
Body = json_encoder:encode(ProcInfo),
Body = json:encode(ProcInfo),
http_server:reply(Code, Body, Conn);
handle_req(Method, Path, Conn) ->
io:format("Method: ~p Path: ~p~n", [Method, Path]),
Expand Down
1 change: 0 additions & 1 deletion libs/eavmlib/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ set(ERLANG_MODULES
console
gpio_hal
i2c_hal
json_encoder
logger_manager
port
spi_hal
Expand Down
78 changes: 0 additions & 78 deletions libs/eavmlib/src/json_encoder.erl

This file was deleted.

1 change: 1 addition & 0 deletions libs/estdlib/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ set(ERLANG_MODULES
init
io_lib
io
json
lists
maps
math
Expand Down
Loading
Loading