Skip to content
This repository was archived by the owner on Jan 11, 2026. It is now read-only.

Commit 00ba02e

Browse files
Added release mode to nobuild
1 parent 09d306a commit 00ba02e

2 files changed

Lines changed: 32 additions & 6 deletions

File tree

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,22 @@ A search engine to search for local files based on their contents and not just t
3939

4040
```console
4141
git clone --depth=1 https://github.com/Adwaith-Rajesh/calsen.git
42+
cd calsen
4243
```
4344

44-
- compiling
45-
[`Calsen`](https://github.com/Adwaith-Rajesh/calsen/) makes use of [nobuild](https://github.com/tsoding/nobuild) as it's build system. To compile run the following commands
45+
- dependencies (I've plans to make this optional [#2](https://github.com/Adwaith-Rajesh/calsen/issues/2))
46+
47+
```console
48+
apt install libmagic-dev
49+
```
50+
51+
#### Compiling
52+
53+
[`Calsen`](https://github.com/Adwaith-Rajesh/calsen/) makes use of [nobuild](https://github.com/tsoding/nobuild) as it's build system. To compile run the following commands
4654

4755
```console
4856
gcc -o nobuild ./nobuild.c
49-
./nobuild
57+
./nobuild --release
5058
ln -s ./build/bin/calsen ./calsen
5159
```
5260

nobuild.c

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
#define NOBUILD_IMPLEMENTATION
22
#include "nobuild.h"
33

4+
#include <getopt.h>
45
#include <stdio.h>
56
#include <stdlib.h>
67
#include <string.h>
78

89
#define CC "cc" // use the default compiler to compile the code
9-
#define C_FLAGS "-O3", "-Wall", "-Wextra", "-std=c11", "-I./src", "-I./src/utils"
10+
#define C_FLAGS (in_release) ? "-O3" : "-g", "-Wall", "-Wextra", "-std=c11", "-I./src", "-I./src/utils"
1011

1112
#define OUT_DIR "./build/out"
1213
#define BIN_DIR "./build/bin"
1314

15+
int in_release = 0;
16+
1417
typedef struct {
1518
char parser_file_name[20];
1619
Cmd cmd;
@@ -76,6 +79,9 @@ void build_calsen() {
7679
cmd_run_sync(cmd);
7780
}
7881

82+
#pragma GCC diagnostic push
83+
#pragma GCC diagnostic ignored "-Wstringop-overread"
84+
7985
int custom_parser_check_execute(Cstr file) {
8086
CParserCompileCommand cp_commands[] = {
8187
// sample code
@@ -94,6 +100,8 @@ int custom_parser_check_execute(Cstr file) {
94100

95101
if (!cp_commands_len) return 0;
96102

103+
// this loop will only run if there is an element in the array
104+
// so its safe to access it and also ignore the "-Wstringop-overread" warning
97105
for (size_t i = 0; i < cp_commands_len; i++) {
98106
if (strcmp(file, cp_commands[i].parser_file_name) == 0) {
99107
INFO("CMD: %s", cmd_show(cp_commands[i].cmd));
@@ -104,6 +112,8 @@ int custom_parser_check_execute(Cstr file) {
104112
return 0;
105113
}
106114

115+
#pragma GCC diagnostic pop
116+
107117
void build_parsers() {
108118
INFO("Building parsers");
109119
if (!IS_DIR("./src/parsers")) {
@@ -123,11 +133,19 @@ void build_parsers() {
123133
}
124134

125135
int main(int argc, char **argv) {
136+
GO_REBUILD_URSELF(argc, argv);
137+
138+
int option_index = 0;
139+
struct option long_options[] = {
140+
{"release", no_argument, &in_release, 1},
141+
{0, 0, 0, 0},
142+
};
143+
144+
int c = getopt_long(argc, argv, "", long_options, &option_index);
145+
126146
MKDIRS("build", "out");
127147
MKDIRS("build", "bin");
128148
MKDIRS("build", "parsers");
129-
130-
GO_REBUILD_URSELF(argc, argv);
131149
build_src();
132150
build_src_utils();
133151
build_calsen();

0 commit comments

Comments
 (0)