Skip to content

Commit

Permalink
final project structure
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoczim committed Nov 7, 2020
1 parent f1b1287 commit 1688f75
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 10 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
/*.csv
/build
8 changes: 3 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,13 @@ TEST_TAGS_TABLE_OBJS = $(OBJ_DIR)/error.o \
$(OBJ_DIR)/tags.o \
$(OBJ_DIR)/test/tags_table.o

$(OBJ_DIR)/%.o: src/%.c $(HEADERS)
mkdir -p $(dir $@)
$(CC) -c $< $(CFLAGS) -o $@

moviedb: $(MOVIEDB_OBJS)
mkdir -p $(dir $(BUILD_DIR)/$@)
$(CC) $(LDFLAGS) $^ -o $(BUILD_DIR)/$@

all: moviedb test/csv test/trie test/movies_table test/users_table
$(OBJ_DIR)/%.o: src/%.c $(HEADERS)
mkdir -p $(dir $@)
$(CC) -c $< $(CFLAGS) -o $@

test/prime: $(TEST_PRIME_OBJS)
mkdir -p $(dir $(BUILD_DIR)/$@)
Expand Down
42 changes: 41 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,47 @@ Favor, descompactar arquivos na pasta "data/".

# Execução

Num shell Unix, basta executar:
Para compilar e executar o programa, basta executar em um shell Unix:
```
$ sh run.sh
```

Se já tiver compilado (veja abaixo) o programa, para executar diretamente,
em um shell Unix basta executar:
```
$ ./build/release/moviedb
```

# Compilação

Para somente compilar, num shell Unix, basta executar:
```
$ sh build.sh release
```

Ou invocar o comando `make` manualmente:
```
$ make
```

# Estrutura Do Projeto

No diretório `src/` estão códigos fonte (`.c`) e cabeçalhos (`.h`).

No diretório `src/test/` estão códigos fonte de programas testes.

No diretório `build/` estão artefatos de compilação, como arquivos objeto (`.o`)
e programas executáveis. Este diretório é gerado automaticamente pelo programa
`make`.

O shell script `build.sh` é responsável por automatizar a compilação.

O shell script `run.sh` é responsável por automatizar o processo de
compilar + executar.

O shell script `watch.sh` observa mudanças nos códigos fonte e executa um
comando (por padrão é `sh watch.sh sh build.sh release`) a cada mudança.
NÃO é NECESSÁRIO usar este script, é apenas uma facilidade de desenvolvimento.

Por fim, o arquivo `Makefile` especifica as regras de _build_, usado pelo
programa `make` para compilar o projeto.
1 change: 1 addition & 0 deletions data/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/*.csv
6 changes: 3 additions & 3 deletions src/database.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ static void load_movies(
char *file_buf,
struct error *restrict error)
{
char const *path = "movie.csv";
char const *path = "data/movie.csv";
FILE *file;
struct movie_parser parser;
struct movie_csv_row row;
Expand Down Expand Up @@ -135,7 +135,7 @@ static void load_ratings(
char *file_buf,
struct error *restrict error)
{
char const *path = "rating.csv";
char const *path = "data/rating.csv";
FILE *file;
struct rating_parser parser;
struct rating_csv_row row;
Expand Down Expand Up @@ -183,7 +183,7 @@ static void load_tags(
char *file_buf,
struct error *restrict error)
{
char const *path = "tag.csv";
char const *path = "data/tag.csv";
FILE *file;
struct tag_parser parser;
struct tag_csv_row row;
Expand Down

0 comments on commit 1688f75

Please sign in to comment.