Skip to content

Commit

Permalink
Add Hello_World example
Browse files Browse the repository at this point in the history
  • Loading branch information
reznikmm committed Aug 24, 2021
1 parent a8dbf20 commit 868f80a
Show file tree
Hide file tree
Showing 6 changed files with 1,324 additions and 0 deletions.
11 changes: 11 additions & 0 deletions examples/hello_world/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# For more information about build system see
# https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html
# The following five lines of boilerplate have to be in your project's
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)

set(EXTRA_COMPONENT_DIRS "/home/max/net/esp32-gnat-rts/")

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(hello_world)

20 changes: 20 additions & 0 deletions examples/hello_world/main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
idf_component_register(SRCS "hello_world.c"
INCLUDE_DIRS "."
REQUIRES esp32-gnat-rts)

# Build *.gpr into a static library
add_custom_command(OUTPUT ${BUILD_DIR}/libadamain.a
COMMAND gprbuild -b -c -p -P ${COMPONENT_DIR}/hello_world.gpr
--db ${COMPONENT_DIR}/gprconfig
--autoconf=${BUILD_DIR}/config.cgpr
--RTS=${BUILD_DIR}/rts
&& xtensa-esp32-elf-ar rcs ${BUILD_DIR}/libadamain.a
${COMPONENT_DIR}/.objs/b__hello_world.o
${COMPONENT_DIR}/.objs/hello_world.o
DEPENDS hello_world.gpr hello_world.adb
VERBATIM)

add_custom_target(adamain DEPENDS ${BUILD_DIR}/libadamain.a)
add_dependencies(${COMPONENT_LIB} adamain)
target_link_libraries(${COMPONENT_LIB} ${BUILD_DIR}/libadamain.a)

12 changes: 12 additions & 0 deletions examples/hello_world/main/hello_world.adb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
with System;

procedure Hello_World is

procedure puts
(data : System.Address)
with Import, Convention => C, External_Name => "puts";

Hello : String := "Hello from Ada!" & ASCII.NUL;
begin
puts (Hello'Address);
end;
6 changes: 6 additions & 0 deletions examples/hello_world/main/hello_world.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
extern void main();

void app_main(void)
{
main();
}
5 changes: 5 additions & 0 deletions examples/hello_world/main/hello_world.gpr
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
project Hello_World is
for Target use "xtensa-esp32-elf";
for Main use ("hello_world.adb");
for Object_Dir use ".objs";
end Hello_World;
Loading

0 comments on commit 868f80a

Please sign in to comment.