Skip to content

Commit e3a15ae

Browse files
committed
APL-CORE: July 2023 Release of APL 2023.2 compilant core engine (2023.2.0)
For more details on this release refer to CHANGELOG.md To learn about APL see: https://developer.amazon.com/docs/alexa-presentation-language/understand-apl.html
1 parent 0442a24 commit e3a15ae

File tree

569 files changed

+26519
-10188
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

569 files changed

+26519
-10188
lines changed

CHANGELOG.md

+17
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
# Changelog
22

3+
## [2023.2]
4+
5+
This release adds support for version 2023.2 of the APL specification.
6+
7+
### Added
8+
9+
- Deferred evaluation
10+
- SeekTo command for video
11+
- Alpha feature: Host component
12+
- Alpha feature: Support for viewport autosize
13+
- Alpha feature: InsertItem and RemoveItem command
14+
15+
### Changed
16+
17+
- Bug fixes
18+
- Performance improvements.
19+
320
## [2023.1]
421

522
### Added

CMakeLists.txt

+15
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ cmake_minimum_required(VERSION 3.11)
1919
set(CMAKE_CXX_STANDARD 11)
2020
set(CMAKE_CXX_STANDARD_REQUIRED ON)
2121

22+
if(POLICY CMP0135)
23+
# If available, use the new timestamp policy for FetchContent
24+
cmake_policy(SET CMP0135 NEW)
25+
endif()
26+
2227
project(APLCoreEngine
2328
VERSION 1.0.0
2429
LANGUAGES CXX)
@@ -32,3 +37,13 @@ include(options.cmake)
3237
set(APL_PATCH_DIR "${CMAKE_CURRENT_SOURCE_DIR}/patches")
3338

3439
include(components.cmake)
40+
41+
if (BUILD_UNIT_TESTS)
42+
include(CTest)
43+
44+
set(MEMCHECK_OPTIONS "--tool=memcheck --leak-check=full --show-reachable=no --error-exitcode=1 --errors-for-leak-kinds=definite,possible")
45+
add_custom_target(unittest_memcheck
46+
COMMAND ${CMAKE_CTEST_COMMAND} -VV
47+
--overwrite MemoryCheckCommandOptions=${MEMCHECK_OPTIONS}
48+
-T memcheck)
49+
endif()

README.md

-6
Original file line numberDiff line numberDiff line change
@@ -263,12 +263,6 @@ To build lib with memory debugging support use:
263263
$ cmake -DDEBUG_MEMORY_USE=ON
264264
```
265265

266-
## Tools
267-
In order to build the tools use:
268-
```
269-
$ cmake -DTOOLS=ON
270-
```
271-
272266
## Paranoid build
273267
In order to build library with -Werror use:
274268
```

apl-dev-env.sh

+6-2
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ function apl-test-core { # Run unit tests in the core build
130130
apl-switch-to-build-directory build $@ && \
131131
$CMAKE -DBUILD_TESTS=ON -DCOVERAGE=OFF .. && \
132132
make -j$APL_BUILD_PROCS && \
133-
unit/unittest
133+
aplcore/unit/unittest && \
134+
tools/unit/tools-unittest && \
135+
extensions/unit/alexaext-unittest
134136
)
135137
}
136138

@@ -139,7 +141,9 @@ function apl-memcheck-core { # Run unit tests in the core build
139141
apl-switch-to-build-directory build $@ && \
140142
$CMAKE -DBUILD_TESTS=ON -DCOVERAGE=OFF .. && \
141143
make -j$APL_BUILD_PROCS && \
142-
valgrind --tool=memcheck --gen-suppressions=all --track-origins=yes --leak-check=full --num-callers=50 ./unit/unittest
144+
valgrind --tool=memcheck --gen-suppressions=all --track-origins=yes --leak-check=full --num-callers=50 ./aplcore/unit/unittest && \
145+
valgrind --tool=memcheck --gen-suppressions=all --track-origins=yes --leak-check=full --num-callers=50 ./tools/unit/tools-unittest && \
146+
valgrind --tool=memcheck --gen-suppressions=all --track-origins=yes --leak-check=full --num-callers=50 ./extensions/unit/alexaext-unittest
143147
)
144148
}
145149

aplcore/CMakeLists.txt

+17-28
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,12 @@ if (TARGET yoga)
5757
add_dependencies(apl yoga)
5858
endif()
5959

60-
if (NOT HAS_FETCH_CONTENT)
61-
add_dependencies(apl pegtl-build)
60+
if (NOT USE_PROVIDED_YOGA_INLINE)
61+
target_link_libraries(apl PUBLIC $<BUILD_INTERFACE:libyoga>)
6262
endif()
6363

64-
# When not using the system rapidjson build the library, add a dependency on the build step
65-
if (NOT USE_SYSTEM_RAPIDJSON AND NOT HAS_FETCH_CONTENT)
66-
add_dependencies(apl rapidjson-build)
64+
if (NOT HAS_FETCH_CONTENT)
65+
add_dependencies(apl pegtl-build)
6766
endif()
6867

6968
add_subdirectory(src/action)
@@ -75,6 +74,7 @@ add_subdirectory(src/content)
7574
add_subdirectory(src/datagrammar)
7675
add_subdirectory(src/datasource)
7776
add_subdirectory(src/document)
77+
add_subdirectory(src/embed)
7878
add_subdirectory(src/engine)
7979
add_subdirectory(src/extension)
8080
add_subdirectory(src/focus)
@@ -100,7 +100,9 @@ set_target_properties(apl
100100
PROPERTIES
101101
VERSION "${PROJECT_VERSION}"
102102
SOVERSION 1
103-
PUBLIC_HEADER "${PUBLIC_HEADER_LIST}")
103+
PUBLIC_HEADER "${PUBLIC_HEADER_LIST}"
104+
EXPORT_NAME "core"
105+
)
104106

105107
if (ENABLE_PIC)
106108
set_target_properties(apl
@@ -116,19 +118,16 @@ target_include_directories(apl
116118
PUBLIC
117119
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
118120
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/aplcore/include>
119-
$<BUILD_INTERFACE:${RAPIDJSON_INCLUDE}>
120121
$<INSTALL_INTERFACE:include>
121122
PRIVATE
122123
$<BUILD_INTERFACE:${PEGTL_INCLUDE}>
123124
$<BUILD_INTERFACE:${YOGA_INCLUDE}>
124125
)
125126

127+
target_link_libraries(apl PUBLIC rapidjson-apl)
128+
126129
if (USE_PROVIDED_YOGA_INLINE)
127130
target_sources(apl PRIVATE ${YOGA_SRC})
128-
else()
129-
target_link_libraries(apl
130-
PRIVATE
131-
libyoga)
132131
endif()
133132

134133
# include the alexa extensions library
@@ -159,6 +158,12 @@ target_link_libraries(apl PRIVATE ${log-lib})
159158

160159
endif(ANDROID)
161160

161+
# Test cases are built conditionally. Only affect core do not build them for everything else.
162+
if (BUILD_UNIT_TESTS)
163+
include_directories(${GTEST_INCLUDE})
164+
add_subdirectory(unit)
165+
endif (BUILD_UNIT_TESTS)
166+
162167
install(TARGETS apl
163168
EXPORT apl-targets
164169
ARCHIVE DESTINATION lib
@@ -173,12 +178,6 @@ install(DIRECTORY ${PROJECT_SOURCE_DIR}/aplcore/include/apl
173178
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/apl.pc
174179
DESTINATION lib/pkgconfig)
175180

176-
if (NOT USE_SYSTEM_RAPIDJSON)
177-
install(DIRECTORY ${RAPIDJSON_INCLUDE}/rapidjson
178-
DESTINATION include
179-
FILES_MATCHING PATTERN "*.h")
180-
endif()
181-
182181
if (USE_PROVIDED_YOGA_AS_LIB)
183182
# We built the bundled yoga lib, install it
184183
install(FILES ${YOGA_LIB}
@@ -189,16 +188,6 @@ if (USE_PROVIDED_YOGA_AS_LIB)
189188
set(YOGA_EXTERNAL_LIB ${YOGA_LIB}) # used by aplcoreConfig.cmake.in
190189
endif()
191190

192-
if (NOT USE_PROVIDED_YOGA_INLINE)
193-
set_target_properties(apl PROPERTIES
194-
EXPORT_NAME
195-
core
196-
INTERFACE_LINK_LIBRARIES
197-
# Only set this for builds, the find module will handle the other cases
198-
$<BUILD_INTERFACE:${YOGA_LIB}>
199-
)
200-
endif()
201-
202191
export(
203192
EXPORT
204193
apl-targets
@@ -227,4 +216,4 @@ install(
227216
${CMAKE_CURRENT_BINARY_DIR}/aplcoreConfig.cmake
228217
DESTINATION
229218
lib/cmake/aplcore
230-
)
219+
)

aplcore/aplcoreConfig.cmake.in

+40-19
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,51 @@
11
@PACKAGE_INIT@
22

3+
set(USE_PROVIDED_YOGA_INLINE @USE_PROVIDED_YOGA_INLINE@)
34
set(YOGA_EXTERNAL_LIB @YOGA_EXTERNAL_LIB@)
4-
5-
if(YOGA_EXTERNAL_LIB)
6-
set_and_check(aplcore_yoga_LIBRARY "${YOGA_EXTERNAL_LIB}")
7-
else()
8-
# This file gets installed at ${APL_CORE_INSTALL_DIR}/lib/cmake/aplcore/aplcoreConfig.cmake, so go up 3 directories
9-
# to find the root
10-
get_filename_component(APL_CORE_INSTALL_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)
11-
12-
set_and_check(aplcore_yoga_LIBRARY "${APL_CORE_INSTALL_DIR}/lib/@YOGA_LIB_NAME@")
13-
14-
endif()
5+
set(USE_SYSTEM_RAPIDJSON @USE_SYSTEM_RAPIDJSON@)
156

167
set(ENABLE_ALEXAEXTENSIONS @ENABLE_ALEXAEXTENSIONS@)
17-
set(USE_INTERNAL_ALEXAEXT @BUILD_ALEXAEXTENSIONS@)
188

199
if(ENABLE_ALEXAEXTENSIONS)
20-
if(NOT USE_INTERNAL_ALEXAEXT)
21-
find_package(alexaext REQUIRED)
22-
endif()
10+
find_package(alexaext REQUIRED)
2311
endif(ENABLE_ALEXAEXTENSIONS)
2412

13+
# For backwards-compatibility with the old build logic, try to locate RapidJSON on the system if the
14+
# new CMake package is not found
15+
if (NOT TARGET rapidjson-apl)
16+
if (USE_SYSTEM_RAPIDJSON)
17+
find_package(aplrapidjson QUIET)
18+
if (NOT aplrapidjson_FOUND)
19+
# Try to locate RapidJSON on the system
20+
find_package(RapidJSON QUIET)
21+
22+
if (NOT RapidJSON_FOUND)
23+
# Try to find the headers directly on the system
24+
find_path(RAPIDJSON_INCLUDE_DIRS
25+
NAMES rapidjson/document.h
26+
REQUIRED)
27+
endif()
28+
29+
add_library(rapidjson-apl INTERFACE IMPORTED)
30+
target_include_directories(rapidjson-apl INTERFACE ${RAPIDJSON_INCLUDE_DIRS})
31+
endif()
32+
else()
33+
find_package(aplrapidjson REQUIRED)
34+
endif()
35+
endif()
36+
2537
include("${CMAKE_CURRENT_LIST_DIR}/aplcoreTargets.cmake")
2638

27-
set_target_properties(apl::core
28-
PROPERTIES
29-
INTERFACE_LINK_LIBRARIES "${aplcore_yoga_LIBRARY}"
30-
)
39+
if (NOT USE_PROVIDED_YOGA_INLINE)
40+
# Yoga is not built into core, so add the dependency here
41+
if(YOGA_EXTERNAL_LIB)
42+
set_and_check(aplcore_yoga_LIBRARY "${YOGA_EXTERNAL_LIB}")
43+
else()
44+
# This file gets installed at ${APL_CORE_INSTALL_DIR}/lib/cmake/aplcore/aplcoreConfig.cmake, so go up 3 directories
45+
# to find the root
46+
get_filename_component(APL_CORE_INSTALL_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)
47+
48+
set_and_check(aplcore_yoga_LIBRARY "${APL_CORE_INSTALL_DIR}/lib/@YOGA_LIB_NAME@")
49+
endif()
50+
target_link_libraries(apl::core INTERFACE "${aplcore_yoga_LIBRARY}")
51+
endif()

aplcore/buildTimeConstants.cpp.in

+2
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,6 @@ namespace apl {
1717

1818
const char *sCoreRepositoryVersion = "@CORE_REPOSITORY_VERSION@";
1919

20+
int kEvaluationDepthLimit = @EVALUATION_DEPTH_LIMIT@;
21+
2022
} // namespace apl

aplcore/include/apl/action/action.h

+3-8
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,13 @@
1616
#ifndef _APL_ACTION_H
1717
#define _APL_ACTION_H
1818

19-
#include <cassert>
20-
#include <functional>
21-
#include <memory>
22-
#include <vector>
23-
2419
#include "apl/common.h"
20+
#include "apl/primitives/rect.h"
2521
#include "apl/time/timers.h"
2622
#include "apl/utils/counter.h"
2723
#include "apl/utils/noncopyable.h"
2824
#include "apl/utils/streamer.h"
2925
#include "apl/utils/userdata.h"
30-
#include "apl/primitives/rect.h"
3126

3227
namespace apl {
3328

@@ -200,10 +195,10 @@ class Action : public std::enable_shared_from_this<Action>,
200195

201196
/**
202197
* Revive an action in the new context.
203-
* @param context new RootContext.
198+
* @param context new DocumentContext.
204199
* @return true if successful, false otherwise.
205200
*/
206-
virtual bool rehydrate(const RootContext& context);
201+
virtual bool rehydrate(const CoreDocumentContext& context);
207202

208203
protected:
209204
virtual void onFinish() {}

aplcore/include/apl/action/animatedscrollaction.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class AnimatedScrollAction : public ResourceHoldingAction {
3030

3131

3232
void freeze() override;
33-
bool rehydrate(const RootContext& context) override;
33+
bool rehydrate(const CoreDocumentContext& context) override;
3434

3535
protected:
3636
AnimatedScrollAction(const TimersPtr& timers,

aplcore/include/apl/action/animateitemaction.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class AnimateItemAction : public ResourceHoldingAction {
3838
bool fastMode);
3939

4040
void freeze() override;
41-
bool rehydrate(const RootContext& context) override;
41+
bool rehydrate(const CoreDocumentContext& context) override;
4242

4343
private:
4444
void start();

aplcore/include/apl/action/arrayaction.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ namespace apl {
2525
class ArrayAction : public Action {
2626
public:
2727
static std::shared_ptr<ArrayAction> make(const TimersPtr& timers,
28-
std::shared_ptr<const ArrayCommand> command,
28+
std::shared_ptr<const ArrayCommand>&& command,
2929
bool fastMode) {
30-
auto ptr = std::make_shared<ArrayAction>(timers, command, fastMode);
30+
auto ptr = std::make_shared<ArrayAction>(timers, std::move(command), fastMode);
3131
ptr->advance();
3232
return ptr;
3333
}
3434

35-
ArrayAction(const TimersPtr& timers, std::shared_ptr<const ArrayCommand> command, bool fastMode);
35+
ArrayAction(const TimersPtr& timers, std::shared_ptr<const ArrayCommand>&& command, bool fastMode);
3636

3737
private:
3838
void advance();

aplcore/include/apl/action/autopageaction.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
#ifndef _APL_AUTO_PAGE_ACTION_H
1717
#define _APL_AUTO_PAGE_ACTION_H
1818

19-
#include "apl/action/resourceholdingaction.h"
2019
#include "apl/common.h"
20+
#include "apl/action/resourceholdingaction.h"
2121

2222
namespace apl {
2323

@@ -40,7 +40,7 @@ class AutoPageAction : public ResourceHoldingAction {
4040
apl_time_t duration);
4141

4242
void freeze() override;
43-
bool rehydrate(const RootContext& context) override;
43+
bool rehydrate(const CoreDocumentContext& context) override;
4444

4545
private:
4646
void advance();

aplcore/include/apl/action/delayaction.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class DelayAction : public Action {
3636
DelayAction(const TimersPtr& timers, const CommandPtr& command, bool fastMode);
3737

3838
void freeze() override;
39-
bool rehydrate(const RootContext& context) override;
39+
bool rehydrate(const CoreDocumentContext& context) override;
4040

4141
private:
4242
/**

aplcore/include/apl/action/playmediaaction.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class PlayMediaAction : public ResourceHoldingAction {
4040
const ComponentPtr& target);
4141

4242
void freeze() override;
43-
bool rehydrate(const RootContext& context) override;
43+
bool rehydrate(const CoreDocumentContext& context) override;
4444

4545
private:
4646
void start();

aplcore/include/apl/action/resourceholdingaction.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class ResourceHoldingAction : public Action {
2929
const ContextPtr& context);
3030

3131
void freeze() override;
32-
bool rehydrate(const RootContext& context) override;
32+
bool rehydrate(const CoreDocumentContext& context) override;
3333

3434
protected:
3535
void onFinish() override;

aplcore/include/apl/action/scrollaction.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class ScrollAction : public AnimatedScrollAction {
5858
apl_duration_t duration);
5959

6060
void freeze() override;
61-
bool rehydrate(const RootContext& context) override;
61+
bool rehydrate(const CoreDocumentContext& context) override;
6262

6363
private:
6464
void start();

0 commit comments

Comments
 (0)