Closed PiKa20 closed 8 months ago
hi, I refer to example/make_example and try to test my .c files
example/make_example
Firstly, I put all the source files in the SRC directory and set SRC_DIR in the makefile: export SRC_DIR ?= ../src. It compiles and runs correctly. My file structure is as follows.
SRC_DIR
export SRC_DIR ?= ../src
../src/foo1.c ../src/foo1.h ../src/foo2.c ../src/foo2.h
But, when I put my source files in the different directory as below, and set SRC_DIR in the makefile:
export SRC_DIR ?= ../src export SRC_DIR += ../foo
My file structure is as follows:
../src/foo1.c ../src/foo1.h ../foo/foo2.c ../foo/foo2.h
It tells me I can't find the relevant file:
My Makefile and MakefileTestSupport files as follows:
Makefile
CC = gcc export BUILD_DIR ?= ./build export SRC_DIR ?= ../src export SRC_DIR += ../foo export TEST_DIR ?= ./test export TEST_BUILD_DIR ?= ${BUILD_DIR}/test export CMOCK_DIR ?= ../../cmock export UNITY_DIR ?= ../../cmock/vendor/unity TEST_MAKEFILE = ${TEST_BUILD_DIR}/MakefileTestSupport OBJ ?= ${BUILD_DIR}/obj OBJ_DIR = ${OBJ} default: all all: setup test setup: mkdir -p ${BUILD_DIR} mkdir -p ${OBJ} ruby ../../cmock/scripts/create_makefile.rb --silent clean: rm -rf ${BUILD_DIR} test: setup -include ${TEST_MAKEFILE}
MakefileTestSupport
CC ?= gcc BUILD_DIR = ./build SRC_DIR = ../src ../foo TEST_DIR = ./test TEST_CFLAGS ?= -DTEST CMOCK_DIR ?= E:/git/mt-x/cmock UNITY_DIR ?= E:/git/mt-x/cmock/vendor/unity TEST_BUILD_DIR ?= ${BUILD_DIR}/test TEST_MAKEFILE = ${TEST_BUILD_DIR}/MakefileTestSupport OBJ ?= ${BUILD_DIR}/obj OBJ_DIR = ${OBJ} ./build/test/obj/unity.o: E:/git/mt-x/cmock/vendor/unity/src/unity.c ${CC} -o $@ -c $< -I E:/git/mt-x/cmock/vendor/unity/src ./build/test/obj/cmock.o: E:/git/mt-x/cmock/src/cmock.c ${CC} -o $@ -c $< -I E:/git/mt-x/cmock/vendor/unity/src -I E:/git/mt-x/cmock/src ./build/test/obj/foo1.o: ../src ../foo/foo1.c ${CC} -o $@ -c $< ${TEST_CFLAGS} -I ${SRC_DIR} ${INCLUDE_PATH} ./build/test/runners/runner_test_foo1.c: ./test/test_foo1.c @UNITY_DIR=${UNITY_DIR} ruby ${CMOCK_DIR}/scripts/create_runner.rb ./test/test_foo1.c ./build/test/runners/runner_test_foo1.c ./build/test/obj/runner_test_foo1.o: ./build/test/runners/runner_test_foo1.c ${CC} -o $@ -c $< ${TEST_CFLAGS} -I ../src ../foo -I ./build/test/mocks -I E:/git/mt-x/cmock/vendor/unity/src -I E:/git/mt-x/cmock/src ${INCLUDE_PATH} ./build/test/obj/test_foo1.o: ./test/test_foo1.c ./build/test/obj/foo1.o ${CC} -o $@ -c $< ${TEST_CFLAGS} -I ../src ../foo -I E:/git/mt-x/cmock/vendor/unity/src -I E:/git/mt-x/cmock/src -I ./build/test/mocks ${INCLUDE_PATH} ./build/test/test_foo1: ./build/test/obj/test_foo1.o ./build/test/obj/runner_test_foo1.o ./build/test/obj/foo1.o ./build/test/obj/unity.o ./build/test/obj/cmock.o ${CC} -o $@ ${LDFLAGS} ./build/test/obj/test_foo1.o ./build/test/obj/runner_test_foo1.o ./build/test/obj/foo1.o ./build/test/obj/unity.o ./build/test/obj/cmock.o ./build/test/test_foo1.testresult: ./build/test/test_foo1 -./build/test/test_foo1 > ./build/test/test_foo1.testresult 2>&1 ./build/test/obj/foo2.o: ../src ../foo/foo2.c ${CC} -o $@ -c $< ${TEST_CFLAGS} -I ${SRC_DIR} ${INCLUDE_PATH} ./build/test/runners/runner_test_foo2.c: ./test/test_foo2.c @UNITY_DIR=${UNITY_DIR} ruby ${CMOCK_DIR}/scripts/create_runner.rb ./test/test_foo2.c ./build/test/runners/runner_test_foo2.c ./build/test/obj/runner_test_foo2.o: ./build/test/runners/runner_test_foo2.c ${CC} -o $@ -c $< ${TEST_CFLAGS} -I ../src ../foo -I ./build/test/mocks -I E:/git/mt-x/cmock/vendor/unity/src -I E:/git/mt-x/cmock/src ${INCLUDE_PATH} ./build/test/obj/test_foo2.o: ./test/test_foo2.c ./build/test/obj/foo2.o ${CC} -o $@ -c $< ${TEST_CFLAGS} -I ../src ../foo -I E:/git/mt-x/cmock/vendor/unity/src -I E:/git/mt-x/cmock/src -I ./build/test/mocks ${INCLUDE_PATH} ./build/test/test_foo2: ./build/test/obj/test_foo2.o ./build/test/obj/runner_test_foo2.o ./build/test/obj/foo2.o ./build/test/obj/unity.o ./build/test/obj/cmock.o ${CC} -o $@ ${LDFLAGS} ./build/test/obj/test_foo2.o ./build/test/obj/runner_test_foo2.o ./build/test/obj/foo2.o ./build/test/obj/unity.o ./build/test/obj/cmock.o ./build/test/test_foo2.testresult: ./build/test/test_foo2 -./build/test/test_foo2 > ./build/test/test_foo2.testresult 2>&1 test_summary: @UNITY_DIR=${UNITY_DIR} ruby ${CMOCK_DIR}/scripts/test_summary.rb --silent .PHONY: test_summary test: ./build/test/test_foo1.testresult ./build/test/test_foo2.testresult test_summary
I don't know if I can set SRC_DIR like this.
hi, I refer to
example/make_example
and try to test my .c filesFirstly, I put all the source files in the SRC directory and set
SRC_DIR
in the makefile:export SRC_DIR ?= ../src
. It compiles and runs correctly. My file structure is as follows.But, when I put my source files in the different directory as below, and set
SRC_DIR
in the makefile:My file structure is as follows:
It tells me I can't find the relevant file:
My Makefile and MakefileTestSupport files as follows:
Makefile
MakefileTestSupport
I don't know if I can set
SRC_DIR
like this.