diff --git a/.gitignore b/.gitignore index 293edcd..4d3c2a1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ build/ docs/ -tests/testing_tmp/ -tests/testing_bak/ +test/testing_tmp/ +test/testing_bak/ include/migrations/*.sql.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e2d682..d242e6f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,26 +1,25 @@ cmake_minimum_required (VERSION 3.7) project(core) -add_executable(core main.c) +add_executable(core src/main.c) -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wpedantic -Werror -Wall -Wextra -luuid -lsqlite3 -ffile-prefix-map=${CMAKE_SOURCE_DIR}/=/") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wpedantic -Werror -Wall -Wextra -luuid -lsqlite3 -ffile-prefix-map=${CMAKE_SOURCE_DIR}/src/=") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -fprofile-arcs -ftest-coverage") add_definitions("-DMG_ENABLE_EXTRA_ERRORS_DESC") -aux_source_directory(vendor VENDOR_SRC) # vendor first to put their warnings on top -aux_source_directory(. SRC_DIR) -aux_source_directory(models MODELS_SRC) -aux_source_directory(helpers HELPERS_SRC) -aux_source_directory(handlers HANDLERS_SRC) -aux_source_directory(endpoints ENDPOINTS_SRC) +aux_source_directory(src/ SRC_DIR) +aux_source_directory(src/models MODELS_SRC) +aux_source_directory(src/helpers HELPERS_SRC) +aux_source_directory(src/handlers HANDLERS_SRC) +aux_source_directory(src/endpoints ENDPOINTS_SRC) configure_file("core.ini" "core.ini" COPYONLY) add_dependencies(core migrations) -target_sources(core PRIVATE ${VENDOR_SRC} ${SRC_DIR} ${HANDLERS_SRC} ${HELPERS_SRC} ${MODELS_SRC} ${ENDPOINTS_SRC}) +target_sources(core PRIVATE ${SRC_DIR} ${HANDLERS_SRC} ${HELPERS_SRC} ${MODELS_SRC} ${ENDPOINTS_SRC}) target_include_directories(core PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) target_include_directories(core PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/vendor) @@ -53,7 +52,7 @@ add_custom_target(docs add_custom_target(test COMMAND ./run_tests.sh ${CMAKE_BINARY_DIR}/core "dev" DEPENDS core - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/test ) add_custom_target(coverage COMMAND gcovr -s --root ${CMAKE_SOURCE_DIR} -e ${CMAKE_SOURCE_DIR}/vendor --html-details ${CMAKE_BINARY_DIR}/coverage.html --html-title "Emgauwa Core Coverage" ${CMAKE_BINARY_DIR}/CMakeFiles/core.dir diff --git a/enums.h b/enums.h deleted file mode 100644 index d773c08..0000000 --- a/enums.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef CORE_ENUM_H -#define CORE_ENUM_H - -enum control_mapping -{ - COMMAND_MAPPING_CODE = 0, - COMMAND_MAPPING_NAME = 1, - COMMAND_MAPPING_RELAY_NUM = 2, - COMMAND_MAPPING_SCHEDULES_ARRAY = 3, - COMMAND_MAPPING_SCHEDULE_ID = 4, - COMMAND_MAPPING_PERIODS_COUNT = 5, - COMMAND_MAPPING_PERIODS_BLOB = 6, -}; - -#endif /* CORE_ENUM_H */ diff --git a/vendor/argparse.h b/include/argparse.h similarity index 100% rename from vendor/argparse.h rename to include/argparse.h diff --git a/vendor/cJSON.h b/include/cJSON.h similarity index 100% rename from vendor/cJSON.h rename to include/cJSON.h diff --git a/vendor/confini.h b/include/confini.h similarity index 100% rename from vendor/confini.h rename to include/confini.h diff --git a/vendor/mongoose.h b/include/mongoose.h similarity index 100% rename from vendor/mongoose.h rename to include/mongoose.h diff --git a/vendor/mpack.h b/include/mpack.h similarity index 100% rename from vendor/mpack.h rename to include/mpack.h diff --git a/vendor/argparse.c b/src/argparse.c similarity index 100% rename from vendor/argparse.c rename to src/argparse.c diff --git a/vendor/cJSON.c b/src/cJSON.c similarity index 100% rename from vendor/cJSON.c rename to src/cJSON.c diff --git a/command.c b/src/command.c similarity index 100% rename from command.c rename to src/command.c diff --git a/config.c b/src/config.c similarity index 100% rename from config.c rename to src/config.c diff --git a/vendor/confini.c b/src/confini.c similarity index 100% rename from vendor/confini.c rename to src/confini.c diff --git a/database.c b/src/database.c similarity index 100% rename from database.c rename to src/database.c diff --git a/endpoint.c b/src/endpoint.c similarity index 100% rename from endpoint.c rename to src/endpoint.c diff --git a/endpoints/api_v1_controllers.c b/src/endpoints/api_v1_controllers.c similarity index 100% rename from endpoints/api_v1_controllers.c rename to src/endpoints/api_v1_controllers.c diff --git a/endpoints/api_v1_controllers_STR.c b/src/endpoints/api_v1_controllers_STR.c similarity index 100% rename from endpoints/api_v1_controllers_STR.c rename to src/endpoints/api_v1_controllers_STR.c diff --git a/endpoints/api_v1_controllers_STR_relays.c b/src/endpoints/api_v1_controllers_STR_relays.c similarity index 100% rename from endpoints/api_v1_controllers_STR_relays.c rename to src/endpoints/api_v1_controllers_STR_relays.c diff --git a/endpoints/api_v1_controllers_STR_relays_INT.c b/src/endpoints/api_v1_controllers_STR_relays_INT.c similarity index 100% rename from endpoints/api_v1_controllers_STR_relays_INT.c rename to src/endpoints/api_v1_controllers_STR_relays_INT.c diff --git a/endpoints/api_v1_controllers_discover.c b/src/endpoints/api_v1_controllers_discover.c similarity index 100% rename from endpoints/api_v1_controllers_discover.c rename to src/endpoints/api_v1_controllers_discover.c diff --git a/endpoints/api_v1_relays.c b/src/endpoints/api_v1_relays.c similarity index 100% rename from endpoints/api_v1_relays.c rename to src/endpoints/api_v1_relays.c diff --git a/endpoints/api_v1_relays_tag_STR.c b/src/endpoints/api_v1_relays_tag_STR.c similarity index 100% rename from endpoints/api_v1_relays_tag_STR.c rename to src/endpoints/api_v1_relays_tag_STR.c diff --git a/endpoints/api_v1_schedules.c b/src/endpoints/api_v1_schedules.c similarity index 100% rename from endpoints/api_v1_schedules.c rename to src/endpoints/api_v1_schedules.c diff --git a/endpoints/api_v1_schedules_STR.c b/src/endpoints/api_v1_schedules_STR.c similarity index 100% rename from endpoints/api_v1_schedules_STR.c rename to src/endpoints/api_v1_schedules_STR.c diff --git a/endpoints/api_v1_schedules_list.c b/src/endpoints/api_v1_schedules_list.c similarity index 100% rename from endpoints/api_v1_schedules_list.c rename to src/endpoints/api_v1_schedules_list.c diff --git a/endpoints/api_v1_schedules_tag_STR.c b/src/endpoints/api_v1_schedules_tag_STR.c similarity index 100% rename from endpoints/api_v1_schedules_tag_STR.c rename to src/endpoints/api_v1_schedules_tag_STR.c diff --git a/endpoints/api_v1_tags.c b/src/endpoints/api_v1_tags.c similarity index 100% rename from endpoints/api_v1_tags.c rename to src/endpoints/api_v1_tags.c diff --git a/handlers/connection.c b/src/handlers/connection.c similarity index 100% rename from handlers/connection.c rename to src/handlers/connection.c diff --git a/helpers/connect_server.c b/src/helpers/connect_server.c similarity index 100% rename from helpers/connect_server.c rename to src/helpers/connect_server.c diff --git a/helpers/get_weekday.c b/src/helpers/get_weekday.c similarity index 100% rename from helpers/get_weekday.c rename to src/helpers/get_weekday.c diff --git a/helpers/parse_cli.c b/src/helpers/parse_cli.c similarity index 100% rename from helpers/parse_cli.c rename to src/helpers/parse_cli.c diff --git a/logger.c b/src/logger.c similarity index 100% rename from logger.c rename to src/logger.c diff --git a/main.c b/src/main.c similarity index 100% rename from main.c rename to src/main.c diff --git a/models/controller.c b/src/models/controller.c similarity index 100% rename from models/controller.c rename to src/models/controller.c diff --git a/models/junction_relay_schedule.c b/src/models/junction_relay_schedule.c similarity index 100% rename from models/junction_relay_schedule.c rename to src/models/junction_relay_schedule.c diff --git a/models/junction_tag.c b/src/models/junction_tag.c similarity index 100% rename from models/junction_tag.c rename to src/models/junction_tag.c diff --git a/models/period.c b/src/models/period.c similarity index 100% rename from models/period.c rename to src/models/period.c diff --git a/models/relay.c b/src/models/relay.c similarity index 100% rename from models/relay.c rename to src/models/relay.c diff --git a/models/schedule.c b/src/models/schedule.c similarity index 100% rename from models/schedule.c rename to src/models/schedule.c diff --git a/models/tag.c b/src/models/tag.c similarity index 100% rename from models/tag.c rename to src/models/tag.c diff --git a/vendor/mongoose.c b/src/mongoose.c similarity index 100% rename from vendor/mongoose.c rename to src/mongoose.c diff --git a/vendor/mpack.c b/src/mpack.c similarity index 100% rename from vendor/mpack.c rename to src/mpack.c diff --git a/router.c b/src/router.c similarity index 100% rename from router.c rename to src/router.c diff --git a/tests/controller.testing.ini b/test/controller.testing.ini similarity index 100% rename from tests/controller.testing.ini rename to test/controller.testing.ini diff --git a/tests/core.testing.ini b/test/core.testing.ini similarity index 100% rename from tests/core.testing.ini rename to test/core.testing.ini diff --git a/tests/run_tests.sh b/test/run_tests.sh similarity index 100% rename from tests/run_tests.sh rename to test/run_tests.sh diff --git a/tests/tavern_tests/0.0.get_all.tavern.yaml b/test/tavern_tests/0.0.get_all.tavern.yaml similarity index 100% rename from tests/tavern_tests/0.0.get_all.tavern.yaml rename to test/tavern_tests/0.0.get_all.tavern.yaml diff --git a/tests/tavern_tests/1.0.controllers_basic.tavern.yaml b/test/tavern_tests/1.0.controllers_basic.tavern.yaml similarity index 100% rename from tests/tavern_tests/1.0.controllers_basic.tavern.yaml rename to test/tavern_tests/1.0.controllers_basic.tavern.yaml diff --git a/tests/tavern_tests/1.1.controller_relays_basic.tavern.yaml b/test/tavern_tests/1.1.controller_relays_basic.tavern.yaml similarity index 100% rename from tests/tavern_tests/1.1.controller_relays_basic.tavern.yaml rename to test/tavern_tests/1.1.controller_relays_basic.tavern.yaml diff --git a/tests/tavern_tests/1.2.controllers_bad.tavern.yaml b/test/tavern_tests/1.2.controllers_bad.tavern.yaml similarity index 100% rename from tests/tavern_tests/1.2.controllers_bad.tavern.yaml rename to test/tavern_tests/1.2.controllers_bad.tavern.yaml diff --git a/tests/tavern_tests/2.0.schedules_basic.tavern.yaml b/test/tavern_tests/2.0.schedules_basic.tavern.yaml similarity index 100% rename from tests/tavern_tests/2.0.schedules_basic.tavern.yaml rename to test/tavern_tests/2.0.schedules_basic.tavern.yaml diff --git a/tests/tavern_tests/2.1.schedules_protected.tavern.yaml b/test/tavern_tests/2.1.schedules_protected.tavern.yaml similarity index 100% rename from tests/tavern_tests/2.1.schedules_protected.tavern.yaml rename to test/tavern_tests/2.1.schedules_protected.tavern.yaml diff --git a/tests/tavern_tests/2.2.schedules_bad.tavern.yaml b/test/tavern_tests/2.2.schedules_bad.tavern.yaml similarity index 100% rename from tests/tavern_tests/2.2.schedules_bad.tavern.yaml rename to test/tavern_tests/2.2.schedules_bad.tavern.yaml diff --git a/tests/tavern_tests/3.0.tags.tavern.yaml b/test/tavern_tests/3.0.tags.tavern.yaml similarity index 100% rename from tests/tavern_tests/3.0.tags.tavern.yaml rename to test/tavern_tests/3.0.tags.tavern.yaml diff --git a/tests/tavern_utils/validate_controller.py b/test/tavern_utils/validate_controller.py similarity index 100% rename from tests/tavern_utils/validate_controller.py rename to test/tavern_utils/validate_controller.py diff --git a/tests/tavern_utils/validate_relay.py b/test/tavern_utils/validate_relay.py similarity index 100% rename from tests/tavern_utils/validate_relay.py rename to test/tavern_utils/validate_relay.py diff --git a/tests/tavern_utils/validate_schedule.py b/test/tavern_utils/validate_schedule.py similarity index 100% rename from tests/tavern_utils/validate_schedule.py rename to test/tavern_utils/validate_schedule.py diff --git a/tests/tavern_utils/validate_tag.py b/test/tavern_utils/validate_tag.py similarity index 100% rename from tests/tavern_utils/validate_tag.py rename to test/tavern_utils/validate_tag.py diff --git a/toolchain-rpi.cmake b/toolchain-rpi.cmake deleted file mode 100644 index 21fe457..0000000 --- a/toolchain-rpi.cmake +++ /dev/null @@ -1,18 +0,0 @@ -set(CMAKE_C_COMPILER /usr/bin/arm-none-eabi-gcc) -set(CMAKE_C_COMPILER_WORKS 1) - -set(ARM-SYSROOT /usr/arm-none-eabi) - -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -marm") -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=vfp") -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv6zk+fp") -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mcpu=arm1176jzf-s") -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mtune=arm1176jzf-s") -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --sysroot=${ARM-SYSROOT}" CACHE INTERNAL "" FORCE) - -set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} --sysroot=${ARM-SYSROOT}" CACHE INTERNAL "" FORCE) - -set(CMAKE_FIND_ROOT_PATH ${ARM-SYSROOT}) -set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) -set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)