Skip to content
Open
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
2 changes: 2 additions & 0 deletions testing/cxx-oot-build/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build/
nuttx-export*
36 changes: 36 additions & 0 deletions testing/cxx-oot-build/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
cmake_minimum_required(VERSION 3.12...3.31)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need add Kconfig?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no this cannot be built using using classical apporaches. The aim to to build only out of tree using the export

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about people using Make and Kconfig? Would it build for them? Please provide steps how to reproduce in Testing section. Thanks :-)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the aim was just to have add a out of tree ci test, and not necessarily expose this as a testing app, but if you guys want i can look into it, but keep in mind the build via Kconfig and make is not a representative test for what we intended to do. It's a simple oot of tree build test to prevent regressions when packaging nuttx export, the app itself doesn't do much :).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cederom where is the testing section. I'll add a link in the section orienting users to the doc in nuttx, Once i address this comment apache/nuttx#17017 (comment) from @acassis

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping @cederom


# --- Guard option ---
option(BUILD_OOTCPP "Build the Out Of Tree C++ project" OFF)

if(BUILD_OOTCPP)
project(
OOTCpp
VERSION 1.0
DESCRIPTION "Out Of Tree Build C++ NuttX")

message(STATUS "Building OOTCpp project")

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(SOURCE_FILES ${CMAKE_SOURCE_DIR}/src/HelloWorld.cpp
${CMAKE_SOURCE_DIR}/src/main.cpp)

set(EXE_NAME oot)

add_executable(${EXE_NAME} ${SOURCE_FILES})

target_include_directories(${EXE_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/include)

# Generate a .bin file from the ELF after build
add_custom_command(
TARGET ${EXE_NAME}
POST_BUILD
COMMAND ${CMAKE_OBJCOPY} -S -O binary ${CMAKE_BINARY_DIR}/${EXE_NAME}
${CMAKE_BINARY_DIR}/${EXE_NAME}.bin
COMMENT "Generating binary image ${EXE_NAME}.bin")

else()
message(STATUS "Skipping OOTCpp project")
endif()
13 changes: 13 additions & 0 deletions testing/cxx-oot-build/include/HelloWorld.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once

class CHelloWorld
{
public:
CHelloWorld();
~CHelloWorld() = default;

bool HelloWorld();

private:
int mSecret;
};
30 changes: 30 additions & 0 deletions testing/cxx-oot-build/src/HelloWorld.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <cstdio>
#include <string>

#include "HelloWorld.hpp"

CHelloWorld::CHelloWorld()
{
mSecret = 42;
std::printf("Constructor: mSecret=%d\n",mSecret);
}


bool CHelloWorld::HelloWorld()
{
std::printf("HelloWorld: mSecret=%d\n",mSecret);

std::string sentence = "Hello";
std::printf("TEST=%s\n",sentence.c_str());

if (mSecret == 42)
{
std::printf("CHelloWorld: HelloWorld: Hello, world!\n");
return true;
}
else
{
std::printf("CHelloWorld: HelloWorld: CONSTRUCTION FAILED!\n");
return false;
}
}
14 changes: 14 additions & 0 deletions testing/cxx-oot-build/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <memory>

#include "HelloWorld.hpp"

int main(int, char*[])
{
auto pHelloWorld = std::make_shared<CHelloWorld>();
pHelloWorld->HelloWorld();

CHelloWorld helloWorld;
helloWorld.HelloWorld();

return 0;
}
Loading