add: ✨ first add files
This commit is contained in:
parent
948eade3b7
commit
3bbbb7a9b1
3
.gitignore
vendored
3
.gitignore
vendored
@ -86,3 +86,6 @@ dkms.conf
|
||||
*.out
|
||||
*.app
|
||||
|
||||
|
||||
.vscode/
|
||||
build/
|
||||
83
Makefile
Normal file
83
Makefile
Normal file
@ -0,0 +1,83 @@
|
||||
# lazy build C project Makefiles by impressionyang
|
||||
# user config values
|
||||
CC="/usr/bin/gcc"
|
||||
# CC="E:\\impressionyang\\scoop\\apps\\mingw\\12.2.0\\bin\\gcc.exe"
|
||||
PROJECT=test
|
||||
BUILD_DIR=build
|
||||
|
||||
# check operating system type
|
||||
ifeq ($(OS), Windows_NT)
|
||||
OS_TYPE := WINDOWS
|
||||
SHELL := cmd
|
||||
else
|
||||
UNAME_S := $(shell uname -s)
|
||||
ifeq ($(UNAME_S),Linux)
|
||||
OS_TYPE := LINUX
|
||||
endif
|
||||
ifeq ($(UNAME_S),Darwin)
|
||||
OS_TYPE := OSX
|
||||
endif
|
||||
endif
|
||||
|
||||
$(info OS type = $(OS_TYPE))
|
||||
|
||||
# patern config
|
||||
FILES_PATH := ./
|
||||
SRC_FILES_SUFFIX := %.c
|
||||
HDR_FILES_SUFFIX := %.h
|
||||
|
||||
# add build flags
|
||||
CFLAGS += -fdiagnostics-color=always -g
|
||||
CFLAGS += -lm
|
||||
|
||||
# define func to remove_same_str for debug: $(info get seen ${seen})
|
||||
define remove_same_str =
|
||||
$(eval seen :=)
|
||||
$(foreach _,$1,$(if $(filter $_,${seen}),,$(if $_, $(eval seen += $_))))
|
||||
${seen}
|
||||
endef
|
||||
|
||||
# find recursive all files
|
||||
rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
|
||||
|
||||
# get source file and header file
|
||||
FIND_ALL_FILES := $(foreach files_path,$(FILES_PATH), $(call rwildcard,$(files_path),*.*) )
|
||||
SOURCES := $(filter $(SRC_FILES_SUFFIX),$(FIND_ALL_FILES))
|
||||
SOURCES := $(SOURCES:$(LOCAL_PATH)/%=%)
|
||||
HEADERS := $(filter $(HDR_FILES_SUFFIX),$(FIND_ALL_FILES))
|
||||
HEADERS := $(HEADERS:$(LOCAL_PATH)/%=%)
|
||||
|
||||
# fillter out all include path
|
||||
FIND_ALL_FILES_DIR := $(dir $(foreach files_path,$(FILES_PATH), $(call rwildcard,$(files_path),*/) ) )
|
||||
GET_INC_DIRS := $(call remove_same_str,$(FIND_ALL_FILES_DIR))
|
||||
INC_DIRS :=
|
||||
INC_DIRS += $(foreach v, $(GET_INC_DIRS), $(if $(filter %/,$v) , $(eval INC_DIRS+=$v), ))
|
||||
INC_DIRS := $(subst ./, -I./, $(INC_DIRS))
|
||||
INC_DIRS := $(wordlist 1, $(words $(INC_DIRS)), $(INC_DIRS))
|
||||
|
||||
# debug print info, no need to be change
|
||||
# $(info "INC_DIRS")
|
||||
# $(info $(INC_DIRS))
|
||||
# $(info "HEADERS")
|
||||
# $(info $(HEADERS))
|
||||
# $(info "SOURCES")
|
||||
# $(info $(SOURCES))
|
||||
|
||||
# compile job
|
||||
all :
|
||||
mkdir -p $(BUILD_DIR)
|
||||
$(CC) $(CFLAGS) $(SOURCES) $(HEADERS) $(INC_DIRS) -o $(BUILD_DIR)/$(PROJECT)
|
||||
|
||||
# virtual clean job
|
||||
.PHONY : clean
|
||||
clean:
|
||||
ifeq ($(OS_TYPE), WINDOWS)
|
||||
del $(PROJECT).exe
|
||||
endif
|
||||
ifeq ($(OS_TYPE), LINUX)
|
||||
rm $(PROJECT)
|
||||
endif
|
||||
ifeq ($(OS_TYPE), OSX)
|
||||
rm $(PROJECT)
|
||||
endif
|
||||
|
||||
9
main.c
Normal file
9
main.c
Normal file
@ -0,0 +1,9 @@
|
||||
#include "test_funcs.h"
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char const *argv[])
|
||||
{
|
||||
printf("start c test\r\n");
|
||||
hello();
|
||||
return 0;
|
||||
}
|
||||
0
test_funcs/README.md
Normal file
0
test_funcs/README.md
Normal file
47
test_funcs/test_funcs.h
Normal file
47
test_funcs/test_funcs.h
Normal file
@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @file test_funcs.h
|
||||
* @author Alvin Young (impressionyang@outlook.com)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2024-08-21
|
||||
*
|
||||
* _ _
|
||||
* (_)_ _ ___ _______ ___ ___ (_)__ ___ __ _____ ____ ___ _
|
||||
* / / ' \/ _ \/ __/ -_|_-<(_-</ / _ \/ _ \/ // / _ `/ _ \/ _ `/
|
||||
* /_/_/_/_/ .__/_/ \__/___/___/_/\___/_//_/\_, /\_,_/_//_/\_, /
|
||||
* /_/ /___/ /___/
|
||||
* @copyright Copyright (c) 2024 impressionyang
|
||||
*
|
||||
* @par 修改日志:
|
||||
* <table>
|
||||
* <tr><th>Date <th>Version <th>Author <th>Description
|
||||
* <tr><td>2024-08-21 <td>v1.0 <td>Alvin Young <td>首次创建
|
||||
* </table>
|
||||
*
|
||||
*/
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
|
||||
#ifndef __TEST_FUNCS_H__
|
||||
#define __TEST_FUNCS_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/* define --------------------------------------------------------------------*/
|
||||
/* typedef -------------------------------------------------------------------*/
|
||||
/* variables -----------------------------------------------------------------*/
|
||||
/* Private function(only *.c) -----------------------------------------------*/
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
|
||||
void hello();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif //__TEST_FUNCS_H__
|
||||
|
||||
/*
|
||||
* EOF
|
||||
*/
|
||||
7
test_funcs/test_hello_word/hello.c
Normal file
7
test_funcs/test_hello_word/hello.c
Normal file
@ -0,0 +1,7 @@
|
||||
#include <stdio.h>
|
||||
#include "test_funcs.h"
|
||||
|
||||
void hello()
|
||||
{
|
||||
printf("Hello World!\r\n");
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user