This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new 368469919 testing/cxx-oot-build: Add out-of-tree build test.
368469919 is described below

commit 3684699190d785a48919e293a768c57bc722a942
Author: trns1997 <trns1...@gmail.com>
AuthorDate: Thu Sep 18 13:30:24 2025 +0200

    testing/cxx-oot-build: Add out-of-tree build test.
    
    Add the source content for the out-of-tree build test
    under `apps/testing/cxx-oot-build`. This supports the
    new CI check in NuttX to prevent regressions in the
    `make export` workflow.
    
    The test project provides:
    * Sample OOT build structure.
    * Integration with exported `nuttx-export`.
    * Verification of successful build and link.
    
    Signed-off-by: trns1997 <trns1...@gmail.com>
---
 testing/cxx-oot-build/.gitignore             |  2 +
 testing/cxx-oot-build/CMakeLists.txt         | 58 ++++++++++++++++++++++++++++
 testing/cxx-oot-build/include/HelloWorld.hpp | 35 +++++++++++++++++
 testing/cxx-oot-build/src/HelloWorld.cpp     | 52 +++++++++++++++++++++++++
 testing/cxx-oot-build/src/main.cpp           | 36 +++++++++++++++++
 5 files changed, 183 insertions(+)

diff --git a/testing/cxx-oot-build/.gitignore b/testing/cxx-oot-build/.gitignore
new file mode 100644
index 000000000..a3391e1ac
--- /dev/null
+++ b/testing/cxx-oot-build/.gitignore
@@ -0,0 +1,2 @@
+build/
+nuttx-export*
diff --git a/testing/cxx-oot-build/CMakeLists.txt 
b/testing/cxx-oot-build/CMakeLists.txt
new file mode 100644
index 000000000..d60dc3662
--- /dev/null
+++ b/testing/cxx-oot-build/CMakeLists.txt
@@ -0,0 +1,58 @@
+# 
##############################################################################
+# testing/cxx-oot-build/CMakeLists.txt
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more 
contributor
+# license agreements.  See the NOTICE file distributed with this work for
+# additional information regarding copyright ownership.  The ASF licenses this
+# file to you under the Apache License, Version 2.0 (the "License"); you may 
not
+# use this file except in compliance with the License.  You may obtain a copy 
of
+# the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations under
+# the License.
+#
+# 
##############################################################################
+
+cmake_minimum_required(VERSION 3.12...3.31)
+
+# --- 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()
diff --git a/testing/cxx-oot-build/include/HelloWorld.hpp 
b/testing/cxx-oot-build/include/HelloWorld.hpp
new file mode 100644
index 000000000..b973bdd2a
--- /dev/null
+++ b/testing/cxx-oot-build/include/HelloWorld.hpp
@@ -0,0 +1,35 @@
+/****************************************************************************
+ * testing/cxx-oot-build/include/HelloWorld.hpp
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#pragma once
+
+class CHelloWorld
+{
+public:
+    CHelloWorld();
+    ~CHelloWorld() = default;
+
+    bool HelloWorld();
+
+private:
+    int mSecret;
+};
diff --git a/testing/cxx-oot-build/src/HelloWorld.cpp 
b/testing/cxx-oot-build/src/HelloWorld.cpp
new file mode 100644
index 000000000..dcd6547da
--- /dev/null
+++ b/testing/cxx-oot-build/src/HelloWorld.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+ * testing/cxx-oot-build/src/HelloWorld.cpp
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#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;
+    }
+}
diff --git a/testing/cxx-oot-build/src/main.cpp 
b/testing/cxx-oot-build/src/main.cpp
new file mode 100644
index 000000000..c3ad2966c
--- /dev/null
+++ b/testing/cxx-oot-build/src/main.cpp
@@ -0,0 +1,36 @@
+/****************************************************************************
+ * testing/cxx-oot-build/src/main.cpp
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#include <memory>
+
+#include "HelloWorld.hpp"
+
+int main(int, char*[])
+{
+    auto pHelloWorld = std::make_shared<CHelloWorld>();
+    pHelloWorld->HelloWorld();
+
+    CHelloWorld helloWorld;
+    helloWorld.HelloWorld();
+
+    return 0;
+}

Reply via email to