Compare commits
7 Commits
Author | SHA1 | Date |
---|---|---|
|
c9dc6e9948 | |
|
34778b7e04 | |
|
5da6bd3219 | |
|
32169dddb9 | |
|
29babf6c47 | |
|
cc60aa9f30 | |
|
8bbde5260e |
|
@ -1,12 +1,6 @@
|
|||
main.o
|
||||
main.map
|
||||
main.elf
|
||||
build/CMakeFiles
|
||||
build/src
|
||||
build/tests
|
||||
build/CMakeCache.txt
|
||||
build/CTestTestfile.cmake
|
||||
build/Makefile
|
||||
build/cmake_install.cmake
|
||||
build/compile_commands.json
|
||||
.cache/clangd/index
|
||||
pre_built/attiny13_9-6Mhz.hex
|
||||
test_blink/waveform
|
||||
test_blink/main.hex
|
||||
|
|
|
@ -1,69 +0,0 @@
|
|||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
# Use the fancy version substitution
|
||||
project(cmake-cpputest-template
|
||||
VERSION 1.0
|
||||
DESCRIPTION "template for cmake + cpputest"
|
||||
LANGUAGES C CXX
|
||||
)
|
||||
enable_testing()
|
||||
|
||||
set(TARGET_GROUP production CACHE STRING "Group to build")
|
||||
|
||||
if(MSVC OR MSYS OR MINGW)
|
||||
message("### SETUP FOR WINDOWS ###")
|
||||
add_definitions(-DWINDOWS)
|
||||
else()
|
||||
message("### SETUP FOR UNIX ###")
|
||||
add_definitions(-DUNIX)
|
||||
endif()
|
||||
|
||||
# For being able to used LSP
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
# Request C 17 standard features
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
set(CMAKE_C_STANDARD_REQUIRED True)
|
||||
set(CMAKE_C_FLAGS "-Wall -Werror -Wpedantic")
|
||||
|
||||
# SETUP THE CXX flags for .cpp
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
set(CMAKE_CXX_FLAGS "-Wall -Werror -Wpedantic")
|
||||
|
||||
#Define the device type
|
||||
add_definitions(-D__AVR_ATtiny13A__)
|
||||
|
||||
# #######################################
|
||||
# TESTING STUFF
|
||||
# #######################################
|
||||
|
||||
|
||||
if (UNIT_TESTING)
|
||||
|
||||
if(DEFINED ENV{CPPUTEST_HOME})
|
||||
message(STATUS "Using CppUTest home: $ENV{CPPUTEST_HOME}")
|
||||
set(CPPUTEST_INCLUDE_DIRS $ENV{CPPUTEST_HOME}/include)
|
||||
set(CPPUTEST_LIBRARIES $ENV{CPPUTEST_HOME}/lib)
|
||||
set(CPPUTEST_LDFLAGS CppUTest CppUTestExt)
|
||||
else()
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_search_module(CPPUTEST REQUIRED cpputest>=3.8)
|
||||
message(STATUS "Found CppUTest version ${CPPUTEST_VERSION}")
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
${CPPUTEST_INCLUDE_DIRS}
|
||||
/usr/include/c++/11/
|
||||
)
|
||||
link_directories(${CPPUTEST_LIBRARIES})
|
||||
|
||||
add_subdirectory(tests)
|
||||
|
||||
endif()
|
||||
|
||||
# #######################################
|
||||
# PROJECT SPECIFIC
|
||||
# #######################################
|
||||
|
||||
add_subdirectory(src)
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
425
avrgcc_tc.cmake
425
avrgcc_tc.cmake
|
@ -1,425 +0,0 @@
|
|||
##########################################################################
|
||||
# "THE ANY BEVERAGE-WARE LICENSE" (Revision 42 - based on beer-ware
|
||||
# license):
|
||||
# <dev@layer128.net> wrote this file. As long as you retain this notice
|
||||
# you can do whatever you want with this stuff. If we meet some day, and
|
||||
# you think this stuff is worth it, you can buy me a be(ve)er(age) in
|
||||
# return. (I don't like beer much.)
|
||||
#
|
||||
# Matthias Kleemann
|
||||
##########################################################################
|
||||
|
||||
set(AVR_MCU attiny13a)
|
||||
set(AVR_PROGAMMER usbasp)
|
||||
|
||||
##########################################################################
|
||||
# The toolchain requires some variables set.
|
||||
#
|
||||
# AVR_MCU (default: atmega8)
|
||||
# the type of AVR the application is built for
|
||||
# AVR_L_FUSE (NO DEFAULT)
|
||||
# the LOW fuse value for the MCU used
|
||||
# AVR_H_FUSE (NO DEFAULT)
|
||||
# the HIGH fuse value for the MCU used
|
||||
# AVR_UPLOADTOOL (default: avrdude)
|
||||
# the application used to upload to the MCU
|
||||
# NOTE: The toolchain is currently quite specific about
|
||||
# the commands used, so it needs tweaking.
|
||||
# AVR_UPLOADTOOL_PORT (default: usb)
|
||||
# the port used for the upload tool, e.g. usb
|
||||
# AVR_PROGRAMMER (default: avrispmkII)
|
||||
# the programmer hardware used, e.g. avrispmkII
|
||||
##########################################################################
|
||||
|
||||
##########################################################################
|
||||
# options
|
||||
##########################################################################
|
||||
option(WITH_MCU "Add the mCU type to the target file name." ON)
|
||||
|
||||
##########################################################################
|
||||
# executables in use
|
||||
##########################################################################
|
||||
find_program(AVR_CC avr-gcc REQUIRED)
|
||||
find_program(AVR_CXX avr-g++ REQUIRED)
|
||||
find_program(AVR_OBJCOPY avr-objcopy REQUIRED)
|
||||
find_program(AVR_SIZE_TOOL avr-size REQUIRED)
|
||||
find_program(AVR_OBJDUMP avr-objdump REQUIRED)
|
||||
|
||||
##########################################################################
|
||||
# toolchain starts with defining mandatory variables
|
||||
##########################################################################
|
||||
set(CMAKE_SYSTEM_NAME Generic)
|
||||
set(CMAKE_SYSTEM_PROCESSOR avr)
|
||||
set(CMAKE_C_COMPILER ${AVR_CC})
|
||||
set(CMAKE_CXX_COMPILER ${AVR_CXX})
|
||||
|
||||
##########################################################################
|
||||
# Identification
|
||||
##########################################################################
|
||||
set(AVR 1)
|
||||
|
||||
##########################################################################
|
||||
# some necessary tools and variables for AVR builds, which may not
|
||||
# defined yet
|
||||
# - AVR_UPLOADTOOL
|
||||
# - AVR_UPLOADTOOL_PORT
|
||||
# - AVR_PROGRAMMER
|
||||
# - AVR_MCU
|
||||
# - AVR_SIZE_ARGS
|
||||
##########################################################################
|
||||
|
||||
# default upload tool
|
||||
if(NOT AVR_UPLOADTOOL)
|
||||
set(
|
||||
AVR_UPLOADTOOL avrdude
|
||||
CACHE STRING "Set default upload tool: avrdude"
|
||||
)
|
||||
find_program(AVR_UPLOADTOOL avrdude)
|
||||
endif(NOT AVR_UPLOADTOOL)
|
||||
|
||||
# default upload tool port
|
||||
if(NOT AVR_UPLOADTOOL_PORT)
|
||||
set(
|
||||
AVR_UPLOADTOOL_PORT usb
|
||||
CACHE STRING "Set default upload tool port: usb"
|
||||
)
|
||||
endif(NOT AVR_UPLOADTOOL_PORT)
|
||||
|
||||
# default programmer (hardware)
|
||||
if(NOT AVR_PROGRAMMER)
|
||||
set(
|
||||
AVR_PROGRAMMER avrispmkII
|
||||
CACHE STRING "Set default programmer hardware model: avrispmkII"
|
||||
)
|
||||
endif(NOT AVR_PROGRAMMER)
|
||||
|
||||
# default MCU (chip)
|
||||
if(NOT AVR_MCU)
|
||||
set(
|
||||
AVR_MCU atmega8
|
||||
CACHE STRING "Set default MCU: atmega8 (see 'avr-gcc --target-help' for valid values)"
|
||||
)
|
||||
endif(NOT AVR_MCU)
|
||||
|
||||
#default avr-size args
|
||||
if(NOT AVR_SIZE_ARGS)
|
||||
if(APPLE)
|
||||
set(AVR_SIZE_ARGS -B)
|
||||
else(APPLE)
|
||||
set(AVR_SIZE_ARGS -C;--mcu=${AVR_MCU})
|
||||
endif(APPLE)
|
||||
endif(NOT AVR_SIZE_ARGS)
|
||||
|
||||
# prepare base flags for upload tool
|
||||
set(AVR_UPLOADTOOL_BASE_OPTIONS -p ${AVR_MCU} -c ${AVR_PROGRAMMER})
|
||||
|
||||
# use AVR_UPLOADTOOL_BAUDRATE as baudrate for upload tool (if defined)
|
||||
if(AVR_UPLOADTOOL_BAUDRATE)
|
||||
set(AVR_UPLOADTOOL_BASE_OPTIONS ${AVR_UPLOADTOOL_BASE_OPTIONS} -b ${AVR_UPLOADTOOL_BAUDRATE})
|
||||
endif()
|
||||
|
||||
##########################################################################
|
||||
# check build types:
|
||||
# - Debug
|
||||
# - Release
|
||||
# - RelWithDebInfo
|
||||
#
|
||||
# Release is chosen, because of some optimized functions in the
|
||||
# AVR toolchain, e.g. _delay_ms().
|
||||
##########################################################################
|
||||
if(NOT ((CMAKE_BUILD_TYPE MATCHES Release) OR
|
||||
(CMAKE_BUILD_TYPE MATCHES RelWithDebInfo) OR
|
||||
(CMAKE_BUILD_TYPE MATCHES Debug) OR
|
||||
(CMAKE_BUILD_TYPE MATCHES MinSizeRel)))
|
||||
set(
|
||||
CMAKE_BUILD_TYPE Release
|
||||
CACHE STRING "Choose cmake build type: Debug Release RelWithDebInfo MinSizeRel"
|
||||
FORCE
|
||||
)
|
||||
endif(NOT ((CMAKE_BUILD_TYPE MATCHES Release) OR
|
||||
(CMAKE_BUILD_TYPE MATCHES RelWithDebInfo) OR
|
||||
(CMAKE_BUILD_TYPE MATCHES Debug) OR
|
||||
(CMAKE_BUILD_TYPE MATCHES MinSizeRel)))
|
||||
|
||||
|
||||
|
||||
##########################################################################
|
||||
|
||||
##########################################################################
|
||||
# target file name add-on
|
||||
##########################################################################
|
||||
if(WITH_MCU)
|
||||
set(MCU_TYPE_FOR_FILENAME "-${AVR_MCU}")
|
||||
else(WITH_MCU)
|
||||
set(MCU_TYPE_FOR_FILENAME "")
|
||||
endif(WITH_MCU)
|
||||
|
||||
##########################################################################
|
||||
# add_avr_executable
|
||||
# - IN_VAR: EXECUTABLE_NAME
|
||||
#
|
||||
# Creates targets and dependencies for AVR toolchain, building an
|
||||
# executable. Calls add_executable with ELF file as target name, so
|
||||
# any link dependencies need to be using that target, e.g. for
|
||||
# target_link_libraries(<EXECUTABLE_NAME>-${AVR_MCU}.elf ...).
|
||||
##########################################################################
|
||||
function(add_avr_executable EXECUTABLE_NAME)
|
||||
|
||||
if(NOT ARGN)
|
||||
message(FATAL_ERROR "No source files given for ${EXECUTABLE_NAME}.")
|
||||
endif(NOT ARGN)
|
||||
|
||||
# set file names
|
||||
set(elf_file ${EXECUTABLE_NAME}${MCU_TYPE_FOR_FILENAME}.elf)
|
||||
set(hex_file ${EXECUTABLE_NAME}${MCU_TYPE_FOR_FILENAME}.hex)
|
||||
set(lst_file ${EXECUTABLE_NAME}${MCU_TYPE_FOR_FILENAME}.lst)
|
||||
set(map_file ${EXECUTABLE_NAME}${MCU_TYPE_FOR_FILENAME}.map)
|
||||
set(eeprom_image ${EXECUTABLE_NAME}${MCU_TYPE_FOR_FILENAME}-eeprom.hex)
|
||||
|
||||
set (${EXECUTABLE_NAME}_ELF_TARGET ${elf_file} PARENT_SCOPE)
|
||||
set (${EXECUTABLE_NAME}_HEX_TARGET ${hex_file} PARENT_SCOPE)
|
||||
set (${EXECUTABLE_NAME}_LST_TARGET ${lst_file} PARENT_SCOPE)
|
||||
set (${EXECUTABLE_NAME}_MAP_TARGET ${map_file} PARENT_SCOPE)
|
||||
set (${EXECUTABLE_NAME}_EEPROM_TARGET ${eeprom_file} PARENT_SCOPE)
|
||||
# elf file
|
||||
add_executable(${elf_file} EXCLUDE_FROM_ALL ${ARGN})
|
||||
|
||||
set_target_properties(
|
||||
${elf_file}
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "-mmcu=${AVR_MCU}"
|
||||
LINK_FLAGS "-mmcu=${AVR_MCU} -Wl,--gc-sections -mrelax -Wl,-Map,${map_file}"
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${hex_file}
|
||||
COMMAND
|
||||
${AVR_OBJCOPY} -j .text -j .data -O ihex ${elf_file} ${hex_file}
|
||||
COMMAND
|
||||
${AVR_SIZE_TOOL} ${AVR_SIZE_ARGS} ${elf_file}
|
||||
DEPENDS ${elf_file}
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${lst_file}
|
||||
COMMAND
|
||||
${AVR_OBJDUMP} -d ${elf_file} > ${lst_file}
|
||||
DEPENDS ${elf_file}
|
||||
)
|
||||
|
||||
# eeprom
|
||||
add_custom_command(
|
||||
OUTPUT ${eeprom_image}
|
||||
COMMAND
|
||||
${AVR_OBJCOPY} -j .eeprom --set-section-flags=.eeprom=alloc,load
|
||||
--change-section-lma .eeprom=0 --no-change-warnings
|
||||
-O ihex ${elf_file} ${eeprom_image}
|
||||
DEPENDS ${elf_file}
|
||||
)
|
||||
|
||||
add_custom_target(
|
||||
${EXECUTABLE_NAME}
|
||||
ALL
|
||||
DEPENDS ${hex_file} ${lst_file} ${eeprom_image}
|
||||
)
|
||||
|
||||
set_target_properties(
|
||||
${EXECUTABLE_NAME}
|
||||
PROPERTIES
|
||||
OUTPUT_NAME "${elf_file}"
|
||||
)
|
||||
|
||||
# clean
|
||||
get_directory_property(clean_files ADDITIONAL_MAKE_CLEAN_FILES)
|
||||
set_directory_properties(
|
||||
PROPERTIES
|
||||
ADDITIONAL_MAKE_CLEAN_FILES "${map_file}"
|
||||
)
|
||||
|
||||
# upload - with avrdude
|
||||
add_custom_target(
|
||||
upload_${EXECUTABLE_NAME}
|
||||
${AVR_UPLOADTOOL} ${AVR_UPLOADTOOL_BASE_OPTIONS} ${AVR_UPLOADTOOL_OPTIONS}
|
||||
-U flash:w:${hex_file}
|
||||
-P ${AVR_UPLOADTOOL_PORT}
|
||||
DEPENDS ${hex_file}
|
||||
COMMENT "Uploading ${hex_file} to ${AVR_MCU} using ${AVR_PROGRAMMER}"
|
||||
)
|
||||
|
||||
# upload eeprom only - with avrdude
|
||||
# see also bug http://savannah.nongnu.org/bugs/?40142
|
||||
add_custom_target(
|
||||
upload_${EXECUTABLE_NAME}_eeprom
|
||||
${AVR_UPLOADTOOL} ${AVR_UPLOADTOOL_BASE_OPTIONS} ${AVR_UPLOADTOOL_OPTIONS}
|
||||
-U eeprom:w:${eeprom_image}
|
||||
-P ${AVR_UPLOADTOOL_PORT}
|
||||
DEPENDS ${eeprom_image}
|
||||
COMMENT "Uploading ${eeprom_image} to ${AVR_MCU} using ${AVR_PROGRAMMER}"
|
||||
)
|
||||
|
||||
# disassemble
|
||||
add_custom_target(
|
||||
disassemble_${EXECUTABLE_NAME}
|
||||
${AVR_OBJDUMP} -h -S ${elf_file} > ${EXECUTABLE_NAME}.lst
|
||||
DEPENDS ${elf_file}
|
||||
)
|
||||
endfunction(add_avr_executable)
|
||||
|
||||
|
||||
##########################################################################
|
||||
# add_avr_library
|
||||
# - IN_VAR: LIBRARY_NAME
|
||||
#
|
||||
# Calls add_library with an optionally concatenated name
|
||||
# <LIBRARY_NAME>${MCU_TYPE_FOR_FILENAME}.
|
||||
# This needs to be used for linking against the library, e.g. calling
|
||||
# target_link_libraries(...).
|
||||
##########################################################################
|
||||
function(add_avr_library LIBRARY_NAME)
|
||||
if(NOT ARGN)
|
||||
message(FATAL_ERROR "No source files given for ${LIBRARY_NAME}.")
|
||||
endif(NOT ARGN)
|
||||
|
||||
set(lib_file ${LIBRARY_NAME}${MCU_TYPE_FOR_FILENAME})
|
||||
set (${LIBRARY_NAME}_LIB_TARGET ${elf_file} PARENT_SCOPE)
|
||||
|
||||
add_library(${lib_file} STATIC ${ARGN})
|
||||
|
||||
set_target_properties(
|
||||
${lib_file}
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "-mmcu=${AVR_MCU}"
|
||||
OUTPUT_NAME "${lib_file}"
|
||||
)
|
||||
|
||||
if(NOT TARGET ${LIBRARY_NAME})
|
||||
add_custom_target(
|
||||
${LIBRARY_NAME}
|
||||
ALL
|
||||
DEPENDS ${lib_file}
|
||||
)
|
||||
|
||||
set_target_properties(
|
||||
${LIBRARY_NAME}
|
||||
PROPERTIES
|
||||
OUTPUT_NAME "${lib_file}"
|
||||
)
|
||||
endif(NOT TARGET ${LIBRARY_NAME})
|
||||
|
||||
endfunction(add_avr_library)
|
||||
|
||||
##########################################################################
|
||||
# avr_target_link_libraries
|
||||
# - IN_VAR: EXECUTABLE_TARGET
|
||||
# - ARGN : targets and files to link to
|
||||
#
|
||||
# Calls target_link_libraries with AVR target names (concatenation,
|
||||
# extensions and so on.
|
||||
##########################################################################
|
||||
function(avr_target_link_libraries EXECUTABLE_TARGET)
|
||||
if(NOT ARGN)
|
||||
message(FATAL_ERROR "Nothing to link to ${EXECUTABLE_TARGET}.")
|
||||
endif(NOT ARGN)
|
||||
|
||||
get_target_property(TARGET_LIST ${EXECUTABLE_TARGET} OUTPUT_NAME)
|
||||
|
||||
foreach(TGT ${ARGN})
|
||||
if(TARGET ${TGT})
|
||||
get_target_property(ARG_NAME ${TGT} OUTPUT_NAME)
|
||||
list(APPEND NON_TARGET_LIST ${ARG_NAME})
|
||||
else(TARGET ${TGT})
|
||||
list(APPEND NON_TARGET_LIST ${TGT})
|
||||
endif(TARGET ${TGT})
|
||||
endforeach(TGT ${ARGN})
|
||||
|
||||
target_link_libraries(${TARGET_LIST} ${NON_TARGET_LIST})
|
||||
endfunction(avr_target_link_libraries EXECUTABLE_TARGET)
|
||||
|
||||
##########################################################################
|
||||
# avr_target_include_directories
|
||||
#
|
||||
# Calls target_include_directories with AVR target names
|
||||
##########################################################################
|
||||
|
||||
function(avr_target_include_directories EXECUTABLE_TARGET)
|
||||
if(NOT ARGN)
|
||||
message(FATAL_ERROR "No include directories to add to ${EXECUTABLE_TARGET}.")
|
||||
endif()
|
||||
|
||||
get_target_property(TARGET_LIST ${EXECUTABLE_TARGET} OUTPUT_NAME)
|
||||
set(extra_args ${ARGN})
|
||||
|
||||
target_include_directories(${TARGET_LIST} ${extra_args})
|
||||
endfunction()
|
||||
|
||||
##########################################################################
|
||||
# avr_target_compile_definitions
|
||||
#
|
||||
# Calls target_compile_definitions with AVR target names
|
||||
##########################################################################
|
||||
|
||||
function(avr_target_compile_definitions EXECUTABLE_TARGET)
|
||||
if(NOT ARGN)
|
||||
message(FATAL_ERROR "No compile definitions to add to ${EXECUTABLE_TARGET}.")
|
||||
endif()
|
||||
|
||||
get_target_property(TARGET_LIST ${EXECUTABLE_TARGET} OUTPUT_NAME)
|
||||
set(extra_args ${ARGN})
|
||||
|
||||
target_compile_definitions(${TARGET_LIST} ${extra_args})
|
||||
endfunction()
|
||||
|
||||
function(avr_generate_fixed_targets)
|
||||
# get status
|
||||
add_custom_target(
|
||||
get_status
|
||||
${AVR_UPLOADTOOL} ${AVR_UPLOADTOOL_BASE_OPTIONS} -P ${AVR_UPLOADTOOL_PORT} -n -v
|
||||
COMMENT "Get status from ${AVR_MCU}"
|
||||
)
|
||||
|
||||
# get fuses
|
||||
add_custom_target(
|
||||
get_fuses
|
||||
${AVR_UPLOADTOOL} ${AVR_UPLOADTOOL_BASE_OPTIONS} -P ${AVR_UPLOADTOOL_PORT} -n
|
||||
-U lfuse:r:-:b
|
||||
-U hfuse:r:-:b
|
||||
COMMENT "Get fuses from ${AVR_MCU}"
|
||||
)
|
||||
|
||||
# set fuses
|
||||
add_custom_target(
|
||||
set_fuses
|
||||
${AVR_UPLOADTOOL} ${AVR_UPLOADTOOL_BASE_OPTIONS} -P ${AVR_UPLOADTOOL_PORT}
|
||||
-U lfuse:w:${AVR_L_FUSE}:m
|
||||
-U hfuse:w:${AVR_H_FUSE}:m
|
||||
COMMENT "Setup: High Fuse: ${AVR_H_FUSE} Low Fuse: ${AVR_L_FUSE}"
|
||||
)
|
||||
|
||||
# get oscillator calibration
|
||||
add_custom_target(
|
||||
get_calibration
|
||||
${AVR_UPLOADTOOL} ${AVR_UPLOADTOOL_BASE_OPTIONS} -P ${AVR_UPLOADTOOL_PORT}
|
||||
-U calibration:r:${AVR_MCU}_calib.tmp:r
|
||||
COMMENT "Write calibration status of internal oscillator to ${AVR_MCU}_calib.tmp."
|
||||
)
|
||||
|
||||
# set oscillator calibration
|
||||
add_custom_target(
|
||||
set_calibration
|
||||
${AVR_UPLOADTOOL} ${AVR_UPLOADTOOL_BASE_OPTIONS} -P ${AVR_UPLOADTOOL_PORT}
|
||||
-U calibration:w:${AVR_MCU}_calib.hex
|
||||
COMMENT "Program calibration status of internal oscillator from ${AVR_MCU}_calib.hex."
|
||||
)
|
||||
endfunction()
|
||||
|
||||
##########################################################################
|
||||
# Bypass the link step in CMake's "compiler sanity test" check
|
||||
#
|
||||
# CMake throws in a try_compile() target test in some generators, but does
|
||||
# not know that this is a cross compiler so the executable can't link.
|
||||
# Change the target type:
|
||||
#
|
||||
# https://stackoverflow.com/q/53633705
|
||||
##########################################################################
|
||||
|
||||
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
|
|
@ -1 +0,0 @@
|
|||
./build/compile_commands.json
|
|
@ -1,16 +1,18 @@
|
|||
/*
|
||||
* FileName: *.c
|
||||
* Date: 2023
|
||||
* Date: 2024
|
||||
* Descripton: Program for Atiny13A controllers, controls DPDT relays and
|
||||
* has options to save settings in EEPROM.
|
||||
*/
|
||||
|
||||
//#define __AVR_ATtiny13A__
|
||||
|
||||
#ifndef MCU
|
||||
#define MCU atiny13a
|
||||
#endif
|
||||
|
||||
#ifndef F_CPU
|
||||
#define F_CPU 4800000UL
|
||||
#define F_CPU 9600000UL
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -29,7 +31,7 @@
|
|||
#endif
|
||||
|
||||
#ifndef UINT8_MAX
|
||||
#define UINT8_MAX 256
|
||||
#define UINT8_MAX 256
|
||||
#endif
|
||||
|
||||
//This is the bitpattern that should be at address 0x00
|
||||
|
@ -43,11 +45,7 @@
|
|||
#define ROM_EP_ADR 0x3
|
||||
|
||||
//Debounce check number.
|
||||
#define MAX_CHECKS 10
|
||||
|
||||
// Define DISABLE_TEMPORARY_SWITCH to turn off the ability to hold
|
||||
// the switch to temporarily engage/bypass.
|
||||
//#define DISABLE_TEMPORARY_SWITCH
|
||||
#define MAX_CHECKS 5
|
||||
|
||||
#define PIN_SW2 PINB3
|
||||
#define PIN_BYPASS2 PB4
|
||||
|
@ -58,25 +56,18 @@
|
|||
//The BLINK_QTY can be edited from 0-255 blinks
|
||||
#define BLINK_QTY 2
|
||||
#define BLINK_CNT 2 * BLINK_QTY
|
||||
#define BLINK_DELAY 200
|
||||
#define BLINK_DELAY 20
|
||||
|
||||
|
||||
|
||||
/*The timing of "ticks" is dependent on the AVR timer's counter register
|
||||
* so for an 8bit register the maximum value is 256. Given we stick with
|
||||
* a 1Mhz cpu frequency can use this formula to calculate the number of
|
||||
* interrupts(timer overflows) per second:
|
||||
*
|
||||
* OVF_S = (F_CPU / DIV)/ (2^8)
|
||||
* 61 = (1000000 / 64) / 256
|
||||
/*Assuming default fuses are used then it's approximatly 33.4375ms per tick.
|
||||
*
|
||||
* This is important because the ATiny13/A only have a single timer built into
|
||||
* them.
|
||||
*
|
||||
* Ticks are used as our way of keep track of long button presses.
|
||||
* */
|
||||
//original sent had 60
|
||||
#define LONG_PRESS_TICKS 66
|
||||
#define LONG_PRESS_TICKS 32 /*Approximatly 510ms*/
|
||||
|
||||
|
||||
/*A structure to hold the button info*/
|
||||
|
@ -107,8 +98,6 @@ volatile uint8_t debounced_state;
|
|||
volatile uint8_t db_state[MAX_CHECKS];
|
||||
volatile uint8_t idx;
|
||||
|
||||
volatile uint16_t tick_count;
|
||||
|
||||
/*
|
||||
* ###############################
|
||||
* FUNCTION PROTOTYPES
|
||||
|
@ -206,15 +195,6 @@ int main()
|
|||
* ###############################
|
||||
*/
|
||||
|
||||
void inf_blink_test(){
|
||||
DDRB |= (1<<PB3);
|
||||
while(1){
|
||||
PORTB ^= (1<<PB3);
|
||||
_delay_ms(250);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Made heavy use of static inline functions to improve readability.
|
||||
|
||||
static inline void blink_bypass1(void)
|
||||
|
@ -374,8 +354,6 @@ static inline void debounce_switch() {
|
|||
|
||||
/*Setup the timer0 on the AVR*/
|
||||
static inline void init_timer0() {
|
||||
/*Zero out the tick_count var*/
|
||||
tick_count = 0;
|
||||
|
||||
/*config to normal mode.*/
|
||||
TCCR0A = 0x00; //stop timer
|
||||
|
@ -395,18 +373,14 @@ static inline void init_timer0() {
|
|||
}
|
||||
|
||||
|
||||
//ISR(TIMER0_OVF_vect)
|
||||
|
||||
/*The interrupt service routine for the timer0*/
|
||||
ISR(TIM0_OVF_vect)
|
||||
ISR(TIM0_OVF_vect, ISR_BLOCK)
|
||||
{
|
||||
/*Disable global interrupts*/
|
||||
cli();
|
||||
|
||||
/*Check the state of the switches*/
|
||||
debounce_switch();
|
||||
|
||||
/*Update the tick_count*/
|
||||
if(btn1.timer_enabled && btn1.pressed_ticks <= UINT8_MAX){
|
||||
btn1.pressed_ticks += 1;
|
||||
}
|
||||
|
@ -415,7 +389,6 @@ ISR(TIM0_OVF_vect)
|
|||
btn2.pressed_ticks += 1;
|
||||
}
|
||||
|
||||
|
||||
/*Re-Enable global interrupts*/
|
||||
sei();
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
# Author: Jake Goodwin
|
||||
# DATE: 2023-12-07
|
||||
# Descripion: A simple makefile for building and flashing hex files
|
||||
|
||||
# Makefile for ATtiny13A
|
||||
|
||||
# Compiler
|
||||
CC = avr-gcc
|
||||
|
||||
#Default cpu frequency is 9.6Mhz, 4.8 gives us less power consumption
|
||||
#F_CPU = 1000000UL
|
||||
#F_CPU = 4800000UL
|
||||
F_CPU = 9600000UL
|
||||
MCU = attiny13a
|
||||
|
||||
# Flags
|
||||
CFLAGS = -g -Os -mmcu=$(MCU) -DF_CPU=$(F_CPU)
|
||||
LDFLAGS = -Wl,-Map,$(TARGET).map
|
||||
|
||||
# Source files
|
||||
SRC = main.c
|
||||
|
||||
# Object files
|
||||
OBJ = $(SRC:.c=.o)
|
||||
|
||||
# Target HEX file
|
||||
TARGET = main
|
||||
|
||||
# Flashing options
|
||||
AVRDUDE = avrdude
|
||||
AVRDUDE_PROGRAMMER = -c usbasp
|
||||
BUADRATE = -B 125kHz
|
||||
AVRDUDE_PORT = -P /dev/ttyUSB0
|
||||
AVRDUDE_MCU = -p $(MCU)
|
||||
|
||||
|
||||
# Compile and generate HEX file
|
||||
all: $(TARGET).hex
|
||||
|
||||
$(TARGET).hex: $(TARGET).elf
|
||||
avr-objcopy -j .text -j .data -O ihex $< $@
|
||||
|
||||
$(TARGET).elf: $(OBJ)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
size: $(TARGET).o
|
||||
avr-size --mcu=$(MCU) -t ./$(TARGET).o
|
||||
# Default for the attiny13a is going to be 9.6Mhz
|
||||
flash_defualt_fuses:
|
||||
$(AVRDUDE) $(AVRDUDE_PROGRAMMER) $(AVRDUDE_PORT) $(AVRDUDE_MCU) $(BUADRATE) -U lfuse:w:0x6A:m -U hfuse:w:0xFF:m -U lock:w:0xFF:m
|
||||
# This is for 4.8Mhz
|
||||
flash_slow_fuse:
|
||||
$(AVRDUDE) $(AVRDUDE_PROGRAMMER) $(AVRDUDE_PORT) $(AVRDUDE_MCU) $(BUADRATE) -U lfuse:w:0x69:m -U hfuse:w:0xFF:m -U lock:w:0xFF:m
|
||||
flash_slow_nodiv8:
|
||||
$(AVRDUDE) $(AVRDUDE_PROGRAMMER) $(AVRDUDE_PORT) $(AVRDUDE_MCU) $(BUADRATE) -U lfuse:w:0x79:m -U hfuse:w:0xFF:m -U lock:w:0xFF:m
|
||||
flash: $(TARGET).hex
|
||||
$(AVRDUDE) $(AVRDUDE_PROGRAMMER) $(AVRDUDE_PORT) $(AVRDUDE_MCU) $(BUADRATE) -U flash:w:$(TARGET).hex:i
|
||||
|
||||
clean:
|
||||
rm -f $(OBJ) $(TARGET).elf $(TARGET).hex $(TARGET).map
|
||||
|
||||
.PHONY: all clean
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
|
||||
|
||||
|
||||
|
244
otto.sh
244
otto.sh
|
@ -1,244 +0,0 @@
|
|||
#!/bin/sh
|
||||
# Author: Jake Goodwin
|
||||
# Date: 2024
|
||||
# Filename: otto.sh
|
||||
|
||||
TC=avrgcc_tc.cmake
|
||||
CMAKE_VERBOSE="ON"
|
||||
CROSS_COMPILE=1
|
||||
TEMPLATE_FILES=".template_files"
|
||||
MODULE_DIR="${TEMPLATE_FILES}/modules"
|
||||
|
||||
|
||||
add_compile_commands () {
|
||||
if [ -f ./compile_commands.json ]; then
|
||||
echo "compile_commands.json already exists!\n"
|
||||
else
|
||||
echo "Creating new symlink for compile commands!\n"
|
||||
ln -s ./build/compile_commands.json ./compile_commands.json
|
||||
fi
|
||||
}
|
||||
|
||||
clear_cmake_cache () {
|
||||
cd ./build
|
||||
rm -rf CMakeCache.txt CMakeFiles/
|
||||
}
|
||||
|
||||
|
||||
does_module_exist () {
|
||||
local basename="$1"
|
||||
|
||||
if [ -d "src/${basename}" ]; then
|
||||
echo "1"
|
||||
else
|
||||
echo "0"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
add_module_to_cmakes () {
|
||||
local basename="$1"
|
||||
|
||||
echo "add_subdirectory(${basename})" >> ./src/CMakeLists.txt
|
||||
|
||||
# Tests cmake file needs to be edited in place.
|
||||
sed -i'' "s/# TEST_DIRS.*$/# TEST_DIRS\r\nadd_subdirectory(${basename})/g" ./tests/CMakeLists.txt
|
||||
sed -i'' "s/# TEST_LINKS.*$/# TEST_LINKS\r\n\t${basename}/g" ./tests/CMakeLists.txt
|
||||
}
|
||||
|
||||
remove_module_from_cmakes () {
|
||||
local basename="$1"
|
||||
|
||||
sed -i'' "s/^.*add_subdirectory(${basename}).*$//g" ./src/CMakeLists.txt
|
||||
sed -i'' "s/^.*add_subdirectory(${basename}).*$//g" ./tests/CMakeLists.txt
|
||||
sed -i'' "s/^.*${basename}.*$//g" ./tests/CMakeLists.txt
|
||||
}
|
||||
|
||||
git_add_module () {
|
||||
|
||||
local basename="$1"
|
||||
|
||||
read -p "Auto add to git?(y/n):" CHOICE
|
||||
if [ "${CHOICE}" = "n" ]; then
|
||||
echo "not being added!"
|
||||
return 0
|
||||
fi
|
||||
|
||||
modsrc_dir="./src/${basename}"
|
||||
modtest_dir="./tests/${basename}"
|
||||
|
||||
# Now we add the new files to the git tracked files
|
||||
git add ${modsrc_dir}/*
|
||||
git add ${modsrc_dir}
|
||||
git add ${modtest_dir}/*
|
||||
git add ${modtest_dir}
|
||||
git add ./src/CMakeLists.txt
|
||||
git add ./tests/CMakeLists.txt
|
||||
}
|
||||
|
||||
|
||||
git_remove_module () {
|
||||
local basename="$1"
|
||||
|
||||
read -p "Auto del from git?(y/n):" CHOICE
|
||||
if [ "${CHOICE}" -eq "n" ]; then
|
||||
echo "not being removed!"
|
||||
return 0
|
||||
fi
|
||||
|
||||
modsrc_dir="./src/${basename}"
|
||||
modtest_dir="./tests/${basename}"
|
||||
|
||||
# Now we add the new files to the git tracked files
|
||||
git rm -r ${modsrc_dir}/*
|
||||
git rm -r ${modsrc_dir}
|
||||
git rm -r ${modtest_dir}/*
|
||||
git rm -r ${modtest_dir}
|
||||
git rm -r ./src/CMakeLists.txt
|
||||
git rm -r ./tests/CMakeLists.txt
|
||||
}
|
||||
|
||||
|
||||
add_new_module () {
|
||||
read -p "Enter the name of the module:" modname
|
||||
|
||||
result=$(does_module_exist "$modname")
|
||||
|
||||
if [ "${result}" -eq "1" ]; then
|
||||
echo "Module already exists!"
|
||||
echo "Exiting without changing anything"
|
||||
exit
|
||||
fi
|
||||
|
||||
modname_cap=$(echo $modname | sed 's/[a-z]/\U&/g')
|
||||
modsrc_dir="./src/${modname}"
|
||||
modtest_dir="./tests/${modname}"
|
||||
|
||||
echo "creating: ${modsrc_dir}, ${modtest_dir}"
|
||||
mkdir $modsrc_dir
|
||||
mkdir $modtest_dir
|
||||
|
||||
#copy the template files.
|
||||
echo "copying & customizing template files..."
|
||||
|
||||
sed "s/module_name/${modname}/" $MODULE_DIR/module_name.c > $modsrc_dir/${modname}.c
|
||||
sed -i'' "3s/todays_date/$(date +%Y)/" $modsrc_dir/${modname}.c
|
||||
|
||||
sed "s/module_name/${modname_cap}/" $MODULE_DIR/module_name.h > $modsrc_dir/${modname}.h
|
||||
sed -i'' "3s/todays_date/$(date +%Y)/" $modsrc_dir/${modname}.h
|
||||
|
||||
sed "s/module_name/${modname}/" $MODULE_DIR/CMakeLists.txt > $modsrc_dir/CMakeLists.txt
|
||||
|
||||
sed "s/module_name/${modname}/" $MODULE_DIR/test_module_name.cpp > $modtest_dir/test_${modname}.cpp
|
||||
sed "s/module_name/${modname}/" $MODULE_DIR/TestCMakeLists.txt > $modtest_dir/CMakeLists.txt
|
||||
|
||||
# Add the module to the cmake lists files.
|
||||
add_module_to_cmakes "${modname}"
|
||||
|
||||
echo "Resulting files/dirs:"
|
||||
tree -L 2 $modsrc_dir
|
||||
tree -L 2 $modtest_dir
|
||||
|
||||
# Now we add the new files to the git tracked files
|
||||
git_add_module "${modname}"
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
del_module () {
|
||||
read -p "Enter the name of the module:" modname
|
||||
|
||||
rm -r ./tests/${modname}
|
||||
rm -r ./src/${modname}
|
||||
remove_module_from_cmakes "${modname}"
|
||||
}
|
||||
|
||||
cross_compile () {
|
||||
clear_cmake_cache
|
||||
cmake -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE} -DCMAKE_TOOLCHAIN_FILE=../${TC} ../
|
||||
make
|
||||
}
|
||||
|
||||
build_release() {
|
||||
clear_cmake_cache
|
||||
cmake -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE} -DCMAKE_TOOLCHAIN_FILE=../${TC} ../
|
||||
make
|
||||
}
|
||||
|
||||
build_main () {
|
||||
clear_cmake_cache
|
||||
|
||||
cmake -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE} ../
|
||||
make main
|
||||
}
|
||||
|
||||
run_c_tests () {
|
||||
clear_cmake_cache
|
||||
cmake -DUNIT_TESTING=ON -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE} ../
|
||||
make AllTests && ./tests/AllTests
|
||||
}
|
||||
|
||||
print_menu () {
|
||||
echo "BUILD MENU:"
|
||||
echo "1. Run Tests"
|
||||
echo "2. Build Project"
|
||||
echo "3. Build for release"
|
||||
echo "4. cross compile for XXXXXX"
|
||||
echo "5. Add new module to project"
|
||||
echo "6. Delete module from project"
|
||||
echo "7. Exit"
|
||||
}
|
||||
|
||||
|
||||
main() {
|
||||
add_compile_commands
|
||||
valid_choice=false
|
||||
|
||||
while [ "$valid_choice" != true ]; do
|
||||
print_menu
|
||||
read -p "Enter your choice: " choice
|
||||
|
||||
case $choice in
|
||||
1)
|
||||
echo "You selected Option 1"
|
||||
valid_choice=true
|
||||
run_c_tests
|
||||
;;
|
||||
2)
|
||||
echo "You selected Option 2"
|
||||
valid_choice=true
|
||||
build_main
|
||||
;;
|
||||
3)
|
||||
echo "You selected Option 3"
|
||||
valid_choice=true
|
||||
build_release
|
||||
;;
|
||||
4)
|
||||
echo "You selected Option 4"
|
||||
valid_choice=true
|
||||
cross_compile
|
||||
;;
|
||||
5)
|
||||
echo "You selected Option 5"
|
||||
valid_choice=true
|
||||
add_new_module
|
||||
;;
|
||||
6)
|
||||
echo "You selected Option 6"
|
||||
valid_choice=true
|
||||
del_module
|
||||
;;
|
||||
7)
|
||||
echo "Exiting..."
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Invalid choice. Please select a valid option."
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
main
|
|
@ -0,0 +1,65 @@
|
|||
:1000000009C016C015C067C113C012C011C010C00E
|
||||
:100010000FC00EC011241FBECFE9CDBF20E0A0E667
|
||||
:10002000B0E001C01D92A637B207E1F79ED1DFC153
|
||||
:10003000E7CFFC0180811182887F877F8083628384
|
||||
:10004000438397B321E030E0A90101C0440F6A95D2
|
||||
:10005000EAF7842F8095892387BB48B3C9010280C2
|
||||
:1000600002C0880F991F0A94E2F7842B88BB47B31C
|
||||
:10007000C901038002C0880F991F0A94E2F7842BFC
|
||||
:1000800087BB88B3038002C0220F331F0A94E2F7B4
|
||||
:100090002095282328BB0895FC019081338191FD90
|
||||
:1000A0000BC09260908328B381E090E001C0880F7C
|
||||
:1000B0003A95EAF7822B0BC09D7F908328B381E0AD
|
||||
:1000C00090E001C0880F3A95EAF78095822388BBBB
|
||||
:1000D0000895CF93DF93EC01888180FF13C0982FA0
|
||||
:1000E0009C7039F4CE01D8DF888119828B7F8860BB
|
||||
:1000F00007C083FF10C09981923468F08460877FC5
|
||||
:10010000888309C082FF02C0CE01C6DF8881877F55
|
||||
:100110008B7F88831982DF91CF9108958FEF809331
|
||||
:10012000750041E062E081E790E083DF44E063E056
|
||||
:100130008AE690E07EDF8FE697E10197F1F700C055
|
||||
:100140000000E199FECF80E090E03DD18A3A99F439
|
||||
:1001500081E090E038D19091710080FB91F990930B
|
||||
:10016000710082E090E02FD190916A0080FB91F9BC
|
||||
:1001700090936A000CC06AEA80E090E02BD160E0C6
|
||||
:1001800081E090E027D160E082E090E023D186B367
|
||||
:1001900090E00090730002C0959587950A94E2F76D
|
||||
:1001A0008170992721E082272091710080FB20F93E
|
||||
:1001B0002093710086B390E000906C0002C095958A
|
||||
:1001C00087950A94E2F78170992731E0832790910F
|
||||
:1001D0006A0080FB90F990936A0020FD05C0809131
|
||||
:1001E0006A0080FF3AC01DC021FB662760F981E0EC
|
||||
:1001F000682760FB21F92093710081E090E0EAD04C
|
||||
:1002000084E022E098B3922798BB4FEF9DEE32E056
|
||||
:10021000415090403040E1F700C00000815091F71C
|
||||
:10022000DECF81FB662760F991E0692760FB81F9E9
|
||||
:1002300080936A0082E090E0CDD084E020E198B322
|
||||
:10024000922798BB4FEF9DEE32E0415090403040F6
|
||||
:10025000E1F700C00000815091F78091710081FFAB
|
||||
:100260000CC028B381E090E00090740002C0880FB9
|
||||
:10027000991F0A94E2F7822B88BB80916A0081FF64
|
||||
:100280000CC028B381E090E000906D0002C0880FA0
|
||||
:10029000991F0A94E2F7822B88BB10926F0010928C
|
||||
:1002A0006E001FBC13BE83B7836083BF789412BEF9
|
||||
:1002B00089B7826089BF0895BB9A98E088B389277F
|
||||
:1002C00088BB2FE739EA83E0215030408040E1F7D6
|
||||
:1002D00000C00000F3CF1F920F920FB60F921124AF
|
||||
:1002E0002F933F938F939F93EF93FF93F894E09115
|
||||
:1002F0007000F0E086B3E05AFF4F80838091700079
|
||||
:100300008F5F8093700080E090E02FEFFC01E05A57
|
||||
:10031000FF4F3081232301968A309105B9F720934E
|
||||
:100320007500809170008A3010F0109270008091FA
|
||||
:10033000710083FF05C0809172008F5F809372000F
|
||||
:1003400080916A0083FF05C080916B008F5F80936E
|
||||
:100350006B007894FF91EF919F918F913F912F9136
|
||||
:100360000F900FBE0F901F901895D8DE81E790E098
|
||||
:10037000B0DE8AE690E0ADDE2091750030E00090BE
|
||||
:10038000730002C0359527950A94E2F780917100B9
|
||||
:1003900020FF02C08E7F01C0816080937100209198
|
||||
:1003A000750030E000906C0002C0359527950A94E6
|
||||
:1003B000E2F780916A0020FF02C08E7F01C0816059
|
||||
:1003C00080936A00D3CFE199FECF8EBBE09A992744
|
||||
:1003D0008DB30895262FE199FECF1CBA8EBB2DBB9D
|
||||
:1003E0000FB6F894E29AE19A0FBE01960895F89438
|
||||
:0203F000FFCF3D
|
||||
:00000001FF
|
86
setup.sh
86
setup.sh
|
@ -1,86 +0,0 @@
|
|||
#!/bin/sh
|
||||
#Author: Jake G
|
||||
#Date: 2024
|
||||
#Filename: setup.sh
|
||||
|
||||
PKG_MNGR=""
|
||||
DEBIAN=0
|
||||
FBSD=0
|
||||
SYSINSTALL=0
|
||||
DEV_UTILS="vim tmux fzf"
|
||||
|
||||
|
||||
install_dev_utils () {
|
||||
ICMD=""
|
||||
if [ $DEBIAN -eq 1 ]; then
|
||||
ICMD="sudo apt install"
|
||||
elif [ $FBSD -eq 1 ]; then
|
||||
ICMD="sudo pkg install"
|
||||
fi
|
||||
|
||||
for util in $DEV_UTILS
|
||||
do
|
||||
${ICMD} ${util}
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
check_os () {
|
||||
if [ -f /etc/debian_version ]; then
|
||||
DEBIAN=1
|
||||
elif [ -f /etc/freebsd-update.conf ]; then
|
||||
FBSD=1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
remove_template_examples () {
|
||||
echo "does nothing right now"
|
||||
}
|
||||
|
||||
|
||||
install_needed_dependencies () {
|
||||
# Check the OS
|
||||
echo "checking the OS..."
|
||||
# If it's debian based then apt install
|
||||
|
||||
# If it's freeBSD then pkg
|
||||
|
||||
# If it's windows....you're SOL
|
||||
}
|
||||
|
||||
|
||||
create_project_symlinks () {
|
||||
# Allows the clangd LSP to find it.
|
||||
ln -s ./build/compile_commands.json ./compile_commands.json
|
||||
}
|
||||
|
||||
|
||||
build_cpputest () {
|
||||
git submodule add https://github.com/cpputest/cpputest.git
|
||||
git sumodule status
|
||||
cd ./cpputest/build
|
||||
cmake ../
|
||||
|
||||
if [ SYSINSTALL -eq 1]; then
|
||||
make install
|
||||
else
|
||||
make
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# The default setup stuff.
|
||||
default () {
|
||||
remove_template_examples
|
||||
install_needed_dependencies
|
||||
create_project_symlinks
|
||||
}
|
||||
|
||||
setup() {
|
||||
echo "Setting up env"
|
||||
check_os
|
||||
install_dev_utils
|
||||
}
|
||||
|
||||
setup
|
|
@ -1,3 +0,0 @@
|
|||
add_executable(main
|
||||
main.c
|
||||
)
|
|
@ -1,12 +0,0 @@
|
|||
#include "CppUTest/CommandLineTestRunner.h"
|
||||
|
||||
|
||||
//ImportTestGroups
|
||||
IMPORT_TEST_GROUP(simple_test);
|
||||
|
||||
//START: main
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
return RUN_ALL_TESTS(argc, argv);
|
||||
}
|
||||
//END: main
|
|
@ -1,16 +0,0 @@
|
|||
project(Tests)
|
||||
|
||||
# TEST_DIRS
|
||||
add_subdirectory(simple_test)
|
||||
|
||||
# TEST_RUNNER
|
||||
add_executable(AllTests
|
||||
AllTests.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(AllTests
|
||||
${CPPUTEST_LIBRARIES}/libCppUTest.a
|
||||
${CPPUTEST_LIBRARIES}/libCppUTestExt.a
|
||||
# TEST_LINKS
|
||||
simple_test
|
||||
)
|
|
@ -1,11 +0,0 @@
|
|||
|
||||
# TEST_RUNNER
|
||||
add_library(simple_test
|
||||
simple_test.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(simple_test
|
||||
${CPPUTEST_LIBRARIES}/libCppUTest.a
|
||||
${CPPUTEST_LIBRARIES}/libCppUTestExt.a
|
||||
)
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
#include "CppUTest/TestHarness.h"
|
||||
|
||||
/*
|
||||
extern C
|
||||
{
|
||||
#include "simple.h"
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
TEST_GROUP(simple_test)
|
||||
{
|
||||
void setup()
|
||||
{
|
||||
|
||||
}
|
||||
void teardown()
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
TEST(simple_test, passing_test)
|
||||
{
|
||||
CHECK_TRUE(1);
|
||||
}
|
Binary file not shown.
Loading…
Reference in New Issue