Skip to content

Commit

Permalink
[nasa/nos3#407] CI Test 3
Browse files Browse the repository at this point in the history
  • Loading branch information
Donnie-Ice committed Nov 14, 2024
1 parent 35a2ef1 commit 142f41d
Show file tree
Hide file tree
Showing 21 changed files with 3,367 additions and 4 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/sample_unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ jobs:
# with:
# path: apps/${{ env.APP_LOWER }}

- name: Copy Files
run: |
cp ./cfe/cmake/Makefile.sample Makefile
cp -r ./cfe/cmake/sample_defs sample_defs
# - name: Copy Files
# run: |
# cp ./cfe/cmake/Makefile.sample Makefile
# cp -r ./cfe/cmake/sample_defs sample_defs

- name: Add Repo To Build
run: |
Expand Down
159 changes: 159 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
#
# Core Flight Software CMake / GNU make wrapper
#
# ABOUT THIS MAKEFILE:
# It is a GNU-make wrapper that calls the CMake tools appropriately
# so that setting up a new build is fast and easy with no need to
# learn the CMake commands. It also makes it easier to integrate
# the build with IDE tools such as Eclipse by providing a default
# makefile that has the common targets such as all/clean/etc.
#
# Use of this file is optional.
#
# This file is intended to be placed at the TOP-MOST level of the mission
# source tree, i.e. a level above "cfe". Note this is outside the cfe
# repository which is why it cannot be delivered directly in place.
# To use it, simply copy it to the top directory. As this just contains
# wrappers for the CMake targets, it is unlikely to change. Projects
# are also free to customize this file and add their own targets after
# copying it to the top of the source tree.
#
# For _ALL_ targets defined in this file the build tree location may
# be specified via the "O" variable (i.e. make O=<my-build-dir> all).
# If not specified then the "build" subdirectory will be assumed.
#
# This wrapper defines the following major targets:
# prep -- Runs CMake to create a new or re-configure an existing build tree
# Note that multiple build trees can exist from a single source
# Other control options (such as "SIMULATION") may be passed to CMake via
# make variables depending on the mission build scripts. These will be
# cached in the build tree so they do not need to be set again thereafter.
#
# all -- Build all targets in the CMake build tree
#
# install -- Copy all files to the installation tree and run packaging scripts
# The "DESTDIR" environment variable controls where the files are copied
#
# clean -- Clean all targets in the CMake build tree, but not the build tree itself.
#
# distclean -- Entirely remove the build directory specified by "O"
# Note that after this the "prep" step must be run again in order to build.
# Use caution with this as it does an rm -rf - don't set O to your home dir!
#
# doc -- Build all doxygen source documentation. The HTML documentation will be
# generated under the build tree specified by "O".
#
# usersguide -- Build all API/Cmd/Tlm doxygen documentation. The HTML documentation
# will be generated under the build tree specified by "O".
#
# osalguide -- Build OSAL API doxygen documentation. The HTML documentation will
# be generated under the build tree specified by "O".
#
# test -- Run all unit tests defined in the build. Unit tests will typically only
# be executable when building with the "SIMULATION=native" option. Otherwise
# it is up to the user to copy the executables to the target and run them.
#
# lcov -- Runs the "lcov" tool on the build tree to collect all code coverage
# analysis data and build the reports. Code coverage data may be output by
# the "make test" target above.
#

# Establish default values for critical variables. Any of these may be overridden
# on the command line or via the make environment configuration in an IDE
O ?= build
ARCH ?= native/default_cpu1
BUILDTYPE ?= debug
INSTALLPREFIX ?= /exe
DESTDIR ?= $(O)

# The "DESTDIR" variable is a bit more complicated because it should be an absolute
# path for CMake, but we want to accept either absolute or relative paths. So if
# the path does NOT start with "/", prepend it with the current directory.
ifeq ($(filter /%, $(DESTDIR)),)
DESTDIR := $(CURDIR)/$(DESTDIR)
endif

# The "LOCALTGTS" defines the top-level targets that are implemented in this makefile
# Any other target may also be given, in that case it will simply be passed through.
LOCALTGTS := doc usersguide osalguide prep all clean install distclean test lcov
OTHERTGTS := $(filter-out $(LOCALTGTS),$(MAKECMDGOALS))

# As this makefile does not build any real files, treat everything as a PHONY target
# This ensures that the rule gets executed even if a file by that name does exist
.PHONY: $(LOCALTGTS) $(OTHERTGTS)

# If the target name appears to be a directory (ends in /), do a make all in that directory
DIRTGTS := $(filter %/,$(OTHERTGTS))
ifneq ($(DIRTGTS),)
$(DIRTGTS):
$(MAKE) -C $(O)/$(patsubst $(O)/%,%,$(@)) all
endif

# For any other goal that is not one of the known local targets, pass it to the arch build
# as there might be a target by that name. For example, this is useful for rebuilding
# single unit test executable files while debugging from the IDE
FILETGTS := $(filter-out $(DIRTGTS),$(OTHERTGTS))
ifneq ($(FILETGTS),)
$(FILETGTS):
$(MAKE) -C $(O)/$(ARCH) $(@)
endif

# The "prep" step requires extra options that are specified via environment variables.
# Certain special ones should be passed via cache (-D) options to CMake.
# These are only needed for the "prep" target but they are computed globally anyway.
PREP_OPTS :=

ifneq ($(INSTALLPREFIX),)
PREP_OPTS += -DCMAKE_INSTALL_PREFIX=$(INSTALLPREFIX)
endif

ifneq ($(VERBOSE),)
PREP_OPTS += --trace
endif

ifneq ($(BUILDTYPE),)
PREP_OPTS += -DCMAKE_BUILD_TYPE=$(BUILDTYPE)
endif

all:
$(MAKE) --no-print-directory -C "$(O)" mission-all

install:
$(MAKE) --no-print-directory -C "$(O)" DESTDIR="$(DESTDIR)" mission-install

prep $(O)/.prep:
mkdir -p "$(O)"
(cd "$(O)" && cmake $(PREP_OPTS) "$(CURDIR)/cfe")
echo "$(PREP_OPTS)" > "$(O)/.prep"

clean:
$(MAKE) --no-print-directory -C "$(O)" mission-clean

distclean:
rm -rf "$(O)"

# Grab lcov baseline before running tests
test:
lcov --capture --initial --directory $(O)/$(ARCH) --output-file $(O)/$(ARCH)/coverage_base.info
(cd $(O)/$(ARCH) && ctest -O ctest.log)

lcov:
lcov --capture --rc lcov_branch_coverage=1 --directory $(O)/$(ARCH) --output-file $(O)/$(ARCH)/coverage_test.info
lcov --rc lcov_branch_coverage=1 --add-tracefile $(O)/$(ARCH)/coverage_base.info --add-tracefile $(O)/$(ARCH)/coverage_test.info --output-file $(O)/$(ARCH)/coverage_total.info
genhtml $(O)/$(ARCH)/coverage_total.info --branch-coverage --output-directory $(O)/$(ARCH)/lcov
@/bin/echo -e "\n\nCoverage Report Link: file:$(CURDIR)/$(O)/$(ARCH)/lcov/index.html\n"

doc:
$(MAKE) --no-print-directory -C "$(O)" mission-doc

usersguide:
$(MAKE) --no-print-directory -C "$(O)" cfe-usersguide

osalguide:
$(MAKE) --no-print-directory -C "$(O)" osal-apiguide

# Make all the commands that use the build tree depend on a flag file
# that is used to indicate the prep step has been done. This way
# the prep step does not need to be done explicitly by the user
# as long as the default options are sufficient.
$(filter-out prep distclean,$(LOCALTGTS)): $(O)/.prep
39 changes: 39 additions & 0 deletions sample_defs/arch_build_custom.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#
# Example arch_build_custom.cmake
# -------------------------------
#
# This file will be automatically included in the arch-specific build scope
#
# Definitions and options specified here will be used when cross-compiling
# _all_ FSW code for _all_ targets defined in targets.cmake.
#
# Avoid machine-specific code generation options in this file (e.g. -f,-m options); such
# options should be localized to the toolchain file such that they will only be
# included on the machines where they apply.
#
# CAUTION: In heterogeneous environments where different cross compilers are
# used for different CPUs, particularly if from different vendors, it is likely
# that compile options will need to be different as well.
#
# In general, options in this file can only be used in cases where all CPUs use a
# compiler from the same vendor and/or are all GCC based such that they accept similar
# command line options.
#
# This file can alternatively be named as "arch_build_custom_${TARGETSYSTEM}.cmake"
# where ${TARGETSYSTEM} represents the system type, matching the toolchain.
#
# These example options assume a GCC-style toolchain is used for cross compilation,
# and uses the same warning options that are applied at the mission level.
#
add_compile_options(
-std=c99 # Target the C99 standard (without gcc extensions)
-pedantic # Issue all the warnings demanded by strict ISO C
-Wall # Warn about most questionable operations
-Wstrict-prototypes # Warn about missing prototypes
-Wwrite-strings # Warn if not treating string literals as "const"
-Wpointer-arith # Warn about suspicious pointer operations
-Werror # Treat warnings as errors (code should be clean)
-Wno-format-truncation # Inhibit printf-style format truncation warnings
-Wno-stringop-truncation # Inhibit string operation truncation warnings
)

12 changes: 12 additions & 0 deletions sample_defs/arch_build_custom_native.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#
# Example arch_build_custom.cmake
# -------------------------------
#
# On native builds only, add strict cast alignment warnings
# This requires a newer version of gcc
#
add_compile_options(
-Wcast-align=strict # Warn about casts that increase alignment requirements
-fno-common # Do not use a common section for globals
)

33 changes: 33 additions & 0 deletions sample_defs/cpu1_cfe_es_startup.scr
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
CFE_LIB, cfe_assert, CFE_Assert_LibInit, ASSERT_LIB, 0, 0, 0x0, 0;
CFE_LIB, sample_lib, SAMPLE_LIB_Init, SAMPLE_LIB, 0, 0, 0x0, 0;
CFE_APP, sample_app, SAMPLE_APP_Main, SAMPLE_APP, 50, 16384, 0x0, 0;
CFE_APP, ci_lab, CI_Lab_AppMain, CI_LAB_APP, 60, 16384, 0x0, 0;
CFE_APP, to_lab, TO_LAB_AppMain, TO_LAB_APP, 70, 16384, 0x0, 0;
CFE_APP, sch_lab, SCH_Lab_AppMain, SCH_LAB_APP, 80, 16384, 0x0, 0;
!
! Startup script fields:
! 1. Object Type -- CFE_APP for an Application, or CFE_LIB for a library.
! 2. Path/Filename -- This is a cFE Virtual filename, not a vxWorks device/pathname
! 3. Entry Point -- This is the "main" function for Apps.
! 4. CFE Name -- The cFE name for the APP or Library
! 5. Priority -- This is the Priority of the App, not used for Library
! 6. Stack Size -- This is the Stack size for the App, not used for the Library
! 7. Load Address -- This is the Optional Load Address for the App or Library. Currently not implemented
! so keep it at 0x0.
! 8. Exception Action -- This is the Action the cFE should take if the App has an exception.
! 0 = Just restart the Application
! Non-Zero = Do a cFE Processor Reset
!
! Other Notes:
! 1. The software will not try to parse anything after the first '!' character it sees. That
! is the End of File marker.
! 2. Common Application file extensions:
! Linux = .so ( ci.so )
! OS X = .bundle ( ci.bundle )
! Cygwin = .dll ( ci.dll )
! vxWorks = .o ( ci.o )
! RTEMS with S-record Loader = .s3r ( ci.s3r )
! RTEMS with CEXP Loader = .o ( ci.o )
! 3. The filename field (2) no longer requires a fully-qualified filename; the path and extension
! may be omitted. If omitted, the standard virtual path (/cf) and a platform-specific default
! extension will be used, which is derived from the build system.
35 changes: 35 additions & 0 deletions sample_defs/default_osconfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
##########################################################################
#
# CFE-specific configuration options for OSAL
#
# This file specifies the CFE-specific values for various compile options
# supported by OSAL.
#
# OSAL has many configuration options, which may vary depending on the
# specific version of OSAL in use. The complete list of OSAL options,
# along with a description of each, can be found OSAL source in the file:
#
# osal/default_config.cmake
#
# A CFE framework build utilizes mostly the OSAL default configuration.
# This file only contains a few specific overrides that tune for a debug
# environment, rather than a deployment environment.
#
# ALSO NOTE: There is also an arch-specific addendum to this file
# to allow further tuning on a per-arch basis, in the form of:
#
# ${TOOLCHAIN_NAME}_osconfig.cmake
#
# See "native_osconfig.cmake" for options which apply only to "native" builds.
#
##########################################################################

#
# OSAL_CONFIG_DEBUG_PRINTF
# ------------------------
#
# For CFE builds this can be helpful during debugging as it will display more
# specific error messages for various OSAL error/warning events, such as if a
# module cannot be loaded or a file cannot be opened for some reason.
#
set(OSAL_CONFIG_DEBUG_PRINTF TRUE)
Loading

0 comments on commit 142f41d

Please sign in to comment.