Skip to content

Commit c46fc75

Browse files
committed
don't redownload duckdb for every branch
Signed-off-by: Mikhail Kot <to@myrrc.dev>
1 parent 52e26d1 commit c46fc75

3 files changed

Lines changed: 24 additions & 24 deletions

File tree

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,8 @@ use_debug = "deny"
374374

375375
[profile.release]
376376
codegen-units = 1
377-
# Turn LTO off, as it breaks when vortex-duckdb-ext is linked.
377+
# Our general performance should not be dependent on LTO since crates that use
378+
# Vortex may choose not to have LTO.
378379
lto = "off"
379380

380381
[profile.release_debug]

vortex-duckdb/build.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
use std::env;
99
use std::fs;
10-
use std::os::unix::fs::symlink;
1110
use std::path::Path;
1211
use std::path::PathBuf;
1312
use std::process::Command;
@@ -332,7 +331,7 @@ fn c2rust(crate_dir: &Path, duckdb_include_dir: &Path) {
332331
fn cpp(duckdb_include_dir: &Path) {
333332
cc::Build::new()
334333
.std("c++20")
335-
.flags(["-Wall", "-Wextra", "-Wpedantic"])
334+
.flags(["-Wall", "-Wextra", "-Wpedantic", "-Werror"])
336335
.cpp(true)
337336
.include(duckdb_include_dir)
338337
.include("cpp/include")
@@ -391,10 +390,21 @@ fn main() {
391390
DuckDBVersion::Commit(c) => println!("cargo:info=Using DuckDB commit: {c}"),
392391
}
393392

393+
let has_debug_env =
394+
env::var("VX_DUCKDB_DEBUG").is_ok_and(|v| matches!(v.as_str(), "1" | "true"));
395+
let build_type = match has_debug_env {
396+
true => "debug",
397+
false => "release",
398+
};
399+
394400
let crate_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
395-
let duckdb_dir = crate_dir.join("duckdb");
396-
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
397-
let library_dir = out_dir.join(format!("duckdb-lib-{version}"));
401+
let duckdb_dir = crate_dir.join(build_type).join("duckdb");
402+
// Cargo has changed OUT_DIR behaviour so for every branch and build we have
403+
// a different directory e.g.
404+
// ~/vortex/target/release/build/vortex-duckdb-b6bc1fb73230910e/out/duckdb-lib-v1.5.2
405+
// We don't want this since artifacts are the same.
406+
// We can't use CARGO_TARGET_DIR since it's out of tree.
407+
let library_dir = duckdb_dir.join(format!("duckdb-lib-{version}"));
398408

399409
let library_dir_str = library_dir.display();
400410
println!("cargo:rustc-link-search=native={library_dir_str}");
@@ -415,7 +425,7 @@ fn main() {
415425
// Alternatively, set LD_LIBRARY_PATH (Linux) or DYLD_LIBRARY_PATH (macOS) at runtime.
416426
println!("cargo:lib_dir={library_dir_str}");
417427

418-
let source_dir = out_dir.join(format!("duckdb-source-{version}"));
428+
let source_dir = duckdb_dir.join(format!("duckdb-source-{version}"));
419429
let source_archive_url = match &version {
420430
DuckDBVersion::Release(v) => format!("{DUCKDB_SOURCE_RELEASE_URL}/v{v}.zip"),
421431
DuckDBVersion::Commit(c) => format!("{DUCKDB_SOURCE_COMMIT_URL}/{c}.zip"),
@@ -430,16 +440,6 @@ fn main() {
430440
extract(&source_archive_path, &source_dir);
431441
}
432442

433-
drop(fs::remove_file(&duckdb_dir));
434-
drop(fs::remove_dir_all(&duckdb_dir));
435-
symlink(&source_dir, &duckdb_dir).unwrap();
436-
437-
let has_debug_env =
438-
env::var("VX_DUCKDB_DEBUG").is_ok_and(|v| matches!(v.as_str(), "1" | "true"));
439-
let build_type = match has_debug_env {
440-
true => "debug",
441-
false => "release",
442-
};
443443
println!("cargo:info=building DuckDB in {build_type} mode");
444444

445445
if has_debug_env || matches!(version, DuckDBVersion::Commit(_)) {

vortex-duckdb/cpp/CMakeLists.txt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33

44
# This CMake project is only used for IDE support (CLion, etc.).
55
# See build.rs for the actual build definition.
6-
#
76
# Prerequisites: Run `cargo build -p vortex-duckdb` first to download DuckDB
8-
# source and create the symlink at ../duckdb.
7+
# source
98
#
109
# If your editor relies on a compilation database to enable LSP functionality,
1110
# you can generate it by running `cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON` or
@@ -23,19 +22,19 @@ if (NOT CMAKE_BUILD_TYPE)
2322
endif()
2423

2524
# Enable compiler warnings (matching build.rs flags).
26-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic")
25+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Werror")
26+
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall -Wextra -Wpedantic -Werror -O3")
2727

28-
# Find DuckDB include directory via the symlink created by build.rs.
29-
# The symlink points to target/duckdb-source-vX.Y.Z which contains duckdb-X.Y.Z/
30-
file(GLOB DUCKDB_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../duckdb/duckdb-*")
28+
# Find DuckDB include directory containing duckdb-source-vX.Y.Z which contains duckdb-X.Y.Z/
29+
file(GLOB DUCKDB_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../duckdb/duckdb-source-*/duckdb-*/")
3130
if(DUCKDB_DIRS)
3231
list(GET DUCKDB_DIRS 0 DUCKDB_DIR)
3332
set(DUCKDB_INCLUDE "${DUCKDB_DIR}/src/include")
3433
message(STATUS "Found DuckDB include: ${DUCKDB_INCLUDE}")
3534
else()
3635
message(FATAL_ERROR
3736
"DuckDB source not found at ../duckdb/duckdb-*\n"
38-
"Run 'cargo build -p vortex-duckdb' first to download DuckDB and create the symlink."
37+
"Run 'cargo build -p vortex-duckdb' first to download DuckDB"
3938
)
4039
endif()
4140

0 commit comments

Comments
 (0)