Skip to content

Commit 04fa35d

Browse files
committed
디렉토리 구조 단순화
1 parent 5fc4fce commit 04fa35d

13 files changed

Lines changed: 2562 additions & 25 deletions

File tree

Makefile

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
CC ?= cc
44
CSTD ?= c11
55
CFLAGS ?= -std=$(CSTD) -Wall -Wextra -Wpedantic -Wshadow -Wconversion -O2 -g
6-
CPPFLAGS = -Iinclude
6+
CPPFLAGS = -I.
77
LDFLAGS ?=
88
LDLIBS ?= -lz
99

1010
BIN := git-client
1111
BUILD := build
1212
TEST_BUILD := $(BUILD)/tests
13-
SRC := $(shell find src -name '*.c')
14-
OBJ := $(patsubst src/%.c,$(BUILD)/%.o,$(SRC))
13+
SRC := $(wildcard *.c)
14+
OBJ := $(patsubst %.c,$(BUILD)/%.o,$(SRC))
1515
DEP := $(OBJ:.o=.d)
1616
SHA1_TEST := $(TEST_BUILD)/test_sha1
1717
ZLIB_TEST := $(TEST_BUILD)/test_zlib
@@ -26,47 +26,47 @@ build: $(BUILD)/$(BIN) ## Compile the binary
2626
$(BUILD)/$(BIN): $(OBJ)
2727
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)
2828

29-
$(BUILD)/%.o: src/%.c
29+
$(BUILD)/%.o: %.c
3030
@mkdir -p $(dir $@)
3131
$(CC) $(CFLAGS) $(CPPFLAGS) -MMD -MP -c -o $@ $<
3232

3333
run: build ## Build and run the binary (pass ARGS="...")
3434
./$(BUILD)/$(BIN) $(ARGS)
3535

3636
test: ## Run tests
37-
@test -f include/sha1.h || { echo "missing include/sha1.h; implement the SHA-1 API from spec.md first"; exit 1; }
38-
@test -f src/sha1.c || { echo "missing src/sha1.c; implement the SHA-1 API from spec.md first"; exit 1; }
39-
@test -f include/zlib_wrap.h || { echo "missing include/zlib_wrap.h; implement the zlib API from spec.md first"; exit 1; }
40-
@test -f src/zlib_wrap.c || { echo "missing src/zlib_wrap.c; implement the zlib API from spec.md first"; exit 1; }
41-
@test -f include/object.h || { echo "missing include/object.h; implement the object API from spec.md first"; exit 1; }
42-
@test -f src/object.c || { echo "missing src/object.c; implement the Blob object store from spec.md first"; exit 1; }
37+
@test -f sha1.h || { echo "missing sha1.h; implement the SHA-1 API from spec.md first"; exit 1; }
38+
@test -f sha1.c || { echo "missing sha1.c; implement the SHA-1 API from spec.md first"; exit 1; }
39+
@test -f zlib_wrap.h || { echo "missing zlib_wrap.h; implement the zlib API from spec.md first"; exit 1; }
40+
@test -f zlib_wrap.c || { echo "missing zlib_wrap.c; implement the zlib API from spec.md first"; exit 1; }
41+
@test -f object.h || { echo "missing object.h; implement the object API from spec.md first"; exit 1; }
42+
@test -f object.c || { echo "missing object.c; implement the Blob object store from spec.md first"; exit 1; }
4343
$(MAKE) $(SHA1_TEST)
4444
$(MAKE) $(ZLIB_TEST)
4545
$(MAKE) $(OBJECT_TEST)
4646
./$(SHA1_TEST)
4747
./$(ZLIB_TEST)
4848
./$(OBJECT_TEST)
4949

50-
$(SHA1_TEST): tests/test_sha1.c src/sha1.c include/sha1.h
50+
$(SHA1_TEST): tests/test_sha1.c sha1.c sha1.h
5151
@mkdir -p $(dir $@)
52-
$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ tests/test_sha1.c src/sha1.c $(LDFLAGS) $(LDLIBS)
52+
$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ tests/test_sha1.c sha1.c $(LDFLAGS) $(LDLIBS)
5353

54-
$(ZLIB_TEST): tests/test_zlib.c src/zlib_wrap.c include/zlib_wrap.h
54+
$(ZLIB_TEST): tests/test_zlib.c zlib_wrap.c zlib_wrap.h
5555
@mkdir -p $(dir $@)
56-
$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ tests/test_zlib.c src/zlib_wrap.c $(LDFLAGS) $(LDLIBS)
56+
$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ tests/test_zlib.c zlib_wrap.c $(LDFLAGS) $(LDLIBS)
5757

58-
$(OBJECT_TEST): tests/test_object.c src/object.c src/sha1.c src/zlib_wrap.c include/object.h include/sha1.h include/zlib_wrap.h
58+
$(OBJECT_TEST): tests/test_object.c object.c sha1.c zlib_wrap.c object.h sha1.h zlib_wrap.h
5959
@mkdir -p $(dir $@)
60-
$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ tests/test_object.c src/object.c src/sha1.c src/zlib_wrap.c $(LDFLAGS) $(LDLIBS)
60+
$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ tests/test_object.c object.c sha1.c zlib_wrap.c $(LDFLAGS) $(LDLIBS)
6161

6262
fmt: ## Format sources with clang-format
63-
@find src include tests -name '*.c' -o -name '*.h' | xargs clang-format -i
63+
@clang-format -i *.c *.h tests/*.c
6464

6565
fmt-check: ## Verify formatting without writing
66-
@find src include tests -name '*.c' -o -name '*.h' | xargs clang-format --dry-run --Werror
66+
@clang-format --dry-run --Werror *.c *.h tests/*.c
6767

6868
tidy: ## Run clang-tidy over sources
69-
@find src -name '*.c' | xargs -I{} clang-tidy {} -- $(CPPFLAGS) $(CFLAGS)
69+
@clang-tidy $(wildcard *.c) -- $(CPPFLAGS) $(CFLAGS)
7070

7171
clean: ## Remove build artifacts
7272
rm -rf $(BUILD)

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,9 @@ make help # list targets
2929
## Layout
3030

3131
```
32-
src/
33-
main.c entry point
34-
cli/commands/ command implementations
35-
core/ core git logic (objects, refs, index, ...)
36-
include/git-client/ public headers
37-
tests/ tests (framework TBD)
32+
main.c entry point
33+
object.c / .h object store (blob, tree, commit)
34+
sha1.c / .h SHA-1 hashing
35+
zlib_wrap.c / .h zlib compression wrappers
36+
tests/ tests
3837
```

include/git-client/.gitkeep

Whitespace-only changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)