ohwgiles / laminar

Fast and lightweight Continuous Integration
https://laminar.ohwg.net
GNU General Public License v3.0
298 stars 54 forks source link

[PATCH] database: fix missing import #200

Closed mapperr closed 10 months ago

mapperr commented 10 months ago

Hi!

I found this project from an awesome-foss list repo ^1, and to me is a breath of fresh air.

So, I tried to build the docker image (with docker build -t laminar:latest -f docker/Dockerfile .), but I got an error (check below).

It seems there is a missing import in the database.cpp file, but, I don't know, that seems weird, so I tried to build the same thing checking out v1.2 (with no particular reason, just testing with an older version), but I got the same error.

When I added the import suggested by the compiler it worked and compiled into a docker image.
Here's the trivial patch [^2], but it really seems weird to me, there is something I am probably missing:

From 94af1b1a029c5bb52862bdcea3dd760f8eac288b Mon Sep 17 00:00:00 2001
From: mapperr <mapperr@sdf.ee>
Date: Tue, 24 Oct 2023 11:59:24 +0200
Subject: [PATCH] database: fix missing import

---
 src/database.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/database.cpp b/src/database.cpp
index 8cf77a1..318ba15 100644
--- a/src/database.cpp
+++ b/src/database.cpp
@@ -21,6 +21,7 @@
 #include <sqlite3.h>
 #include <string.h>
 #include <math.h>
+#include <cstdint>

 struct StdevCtx {
     double mean;
-- 
2.42.0

The error:

272.1 [ 69%] Building CXX object CMakeFiles/laminard.dir/src/database.cpp.o
272.5 /build/laminar/src/database.cpp:28:5: error: 'int64_t' does not name a type
272.5    28 |     int64_t count;
272.5       |     ^~~~~~~
272.5 /build/laminar/src/database.cpp:24:1: note: 'int64_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
272.5    23 | #include <math.h>
272.5   +++ |+#include <cstdint>
272.5    24 |
272.5 /build/laminar/src/database.cpp: In function 'void stdevStep(sqlite3_context*, int, sqlite3_value**)':
272.5 /build/laminar/src/database.cpp:36:12: error: 'struct StdevCtx' has no member named 'count'
272.5    36 |         p->count++;
272.5       |            ^~~~~
272.5 /build/laminar/src/database.cpp:39:31: error: 'struct StdevCtx' has no member named 'count'
272.5    39 |         p->mean += delta / p->count;
272.5       |                               ^~~~~
272.5 /build/laminar/src/database.cpp: In function 'void stdevFinalize(sqlite3_context*)':
272.5 /build/laminar/src/database.cpp:46:16: error: 'struct StdevCtx' has no member named 'count'
272.5    46 |     if(p && p->count > 1)
272.5       |                ^~~~~
272.5 /build/laminar/src/database.cpp:47:57: error: 'struct StdevCtx' has no member named 'count'
272.5    47 |         sqlite3_result_double(context, sqrt(p->M2 / (p->count-1)));
272.5       |                                                         ^~~~~
272.5 /build/laminar/src/database.cpp: In member function 'void Database::Statement::bindValue(int, uint)':
272.5 /build/laminar/src/database.cpp:85:43: error: 'int32_t' does not name a type
272.5    85 |     sqlite3_bind_int(stmt, i, static_cast<int32_t>(e));
272.5       |                                           ^~~~~~~
272.5 /build/laminar/src/database.cpp:85:43: note: 'int32_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
272.5 /build/laminar/src/database.cpp: In member function 'void Database::Statement::bindValue(int, ulong)':
272.5 /build/laminar/src/database.cpp:93:45: error: 'int64_t' does not name a type
272.5    93 |     sqlite3_bind_int64(stmt, i, static_cast<int64_t>(e));
272.5       |                                             ^~~~~~~
272.5 /build/laminar/src/database.cpp:93:45: note: 'int64_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
272.6 make[2]: *** [CMakeFiles/laminard.dir/build.make:191: CMakeFiles/laminard.dir/src/database.cpp.o] Error 1
272.6 make[2]: *** Waiting for unfinished jobs....
272.8 make[1]: *** [CMakeFiles/Makefile2:87: CMakeFiles/laminard.dir/all] Error 2
272.8 make[1]: *** Waiting for unfinished jobs....
274.4 [ 71%] Linking CXX executable laminarc
274.4 [ 71%] Built target laminarc
274.4 make: *** [Makefile:136: all] Error 2

[^2]: sorry for not using pull requests, right now I'm feeling extremely lazy

ohwgiles commented 10 months ago

Hi, thanks for your message.

It's not weird, it's just that I (and other laminar downstream packages) tend not to use the docker version, and alpine's libc has a different include chain.

The error is correct, I've applied and pushed your patch.