Skip to content

Commit

Permalink
removed unity build
Browse files Browse the repository at this point in the history
  • Loading branch information
hannes committed Jul 15, 2020
1 parent ebd9140 commit 4996145
Show file tree
Hide file tree
Showing 130 changed files with 140 additions and 212 deletions.
72 changes: 0 additions & 72 deletions CMakeLists.txt
Expand Up @@ -172,78 +172,6 @@ include_directories(third_party/utf8proc/include)
include_directories(third_party/miniparquet)
include_directories(third_party/concurrentqueue)

# todo only regenerate ub file if one of the input files changed hack alert
function(enable_unity_build UB_SUFFIX SOURCE_VARIABLE_NAME)
set(files ${${SOURCE_VARIABLE_NAME}})

# Generate a unique filename for the unity build translation unit
set(unit_build_file ${CMAKE_CURRENT_BINARY_DIR}/ub_${UB_SUFFIX}.cpp)
set(temp_unit_build_file ${CMAKE_CURRENT_BINARY_DIR}/ub_${UB_SUFFIX}.cpp.tmp)
# Exclude all translation units from compilation
set_source_files_properties(${files}
PROPERTIES
HEADER_FILE_ONLY
true)

set(rebuild FALSE)
# check if any of the source files have changed
foreach(source_file ${files})
if(${CMAKE_CURRENT_SOURCE_DIR}/${source_file} IS_NEWER_THAN
${unit_build_file})
set(rebuild TRUE)
endif()
endforeach(source_file)
# write a temporary file
file(WRITE ${temp_unit_build_file} "// Unity Build generated by CMake\n")
foreach(source_file ${files})
file(
APPEND ${temp_unit_build_file}
"#line 0 \"${source_file}\"\n#include <${CMAKE_CURRENT_SOURCE_DIR}/${source_file}>\n"
)
endforeach(source_file)

execute_process(COMMAND ${CMAKE_COMMAND}
-E
compare_files
${unit_build_file}
${temp_unit_build_file}
RESULT_VARIABLE compare_result
OUTPUT_VARIABLE bla
ERROR_VARIABLE bla)
if(compare_result EQUAL 0)
# files are identical: do nothing
elseif(compare_result EQUAL 1)
# files are different: rebuild
set(rebuild TRUE)
else()
# error while compiling: rebuild
set(rebuild TRUE)
endif()

if(${rebuild})
file(WRITE ${unit_build_file} "// Unity Build generated by CMake\n")
foreach(source_file ${files})
file(
APPEND ${unit_build_file}
"#line 0 \"${source_file}\"\n#include <${CMAKE_CURRENT_SOURCE_DIR}/${source_file}>\n"
)
endforeach(source_file)
endif()

# Complement list of translation units with the name of ub
set(${SOURCE_VARIABLE_NAME}
${${SOURCE_VARIABLE_NAME}} ${unit_build_file}
PARENT_SCOPE)
endfunction(enable_unity_build)

function(add_library_unity NAME MODE)
set(SRCS ${ARGN})
if(NOT DISABLE_UNITY)
enable_unity_build(${NAME} SRCS)
endif()
add_library(${NAME} OBJECT ${SRCS})
endfunction()

function(disable_target_warnings NAME)
if(MSVC)
target_compile_options(${NAME} PRIVATE "/W0")
Expand Down
21 changes: 10 additions & 11 deletions Makefile
Expand Up @@ -8,31 +8,30 @@ imdb: third_party/imdb/data
GENERATOR=
FORCE_COLOR=
WARNINGS_AS_ERRORS=
DISABLE_UNITY_FLAG=
ifeq ($(GEN),ninja)
GENERATOR=-G "Ninja"
FORCE_COLOR=-DFORCE_COLORED_OUTPUT=1
endif
ifeq (${TREAT_WARNINGS_AS_ERRORS}, 1)
WARNINGS_AS_ERRORS=-DTREAT_WARNINGS_AS_ERRORS=1
endif
ifeq (${DISABLE_UNITY}, 1)
DISABLE_UNITY_FLAG=-DDISABLE_UNITY=1
endif

EXTENSIONS="-DBUILD_PARQUET_EXTENSION=TRUE -DBUILD_ICU_EXTENSION=TRUE"


clean:
rm -rf build

debug:
mkdir -p build/debug && \
cd build/debug && \
cmake $(GENERATOR) $(FORCE_COLOR) ${WARNINGS_AS_ERRORS} ${DISABLE_UNITY_FLAG} -DCMAKE_BUILD_TYPE=Debug ../.. && \
cmake $(GENERATOR) $(FORCE_COLOR) ${WARNINGS_AS_ERRORS} ${EXTENSIONS} -DCMAKE_BUILD_TYPE=Debug ../.. && \
cmake --build .

release_expanded:
mkdir -p build/release_expanded && \
cd build/release_expanded && \
cmake $(GENERATOR) $(FORCE_COLOR) ${WARNINGS_AS_ERRORS} ${DISABLE_UNITY_FLAG} -DCMAKE_BUILD_TYPE=Release ../.. && \
cmake $(GENERATOR) $(FORCE_COLOR) ${WARNINGS_AS_ERRORS} ${EXTENSIONS} -DCMAKE_BUILD_TYPE=Release ../.. && \
cmake --build .

unittest: debug
Expand All @@ -53,34 +52,34 @@ release:
mkdir -p build/release && \
python scripts/amalgamation.py && \
cd build/release && \
cmake $(GENERATOR) $(FORCE_COLOR) ${WARNINGS_AS_ERRORS} ${DISABLE_UNITY_FLAG} -DCMAKE_BUILD_TYPE=Release -DAMALGAMATION_BUILD=1 ../.. && \
cmake $(GENERATOR) $(FORCE_COLOR) ${WARNINGS_AS_ERRORS} ${EXTENSIONS} -DCMAKE_BUILD_TYPE=Release -DAMALGAMATION_BUILD=1 ../.. && \
cmake --build .

reldebug:
mkdir -p build/reldebug && \
cd build/reldebug && \
cmake $(GENERATOR) $(FORCE_COLOR) ${WARNINGS_AS_ERRORS} ${DISABLE_UNITY_FLAG} -DCMAKE_BUILD_TYPE=RelWithDebInfo ../.. && \
cmake $(GENERATOR) $(FORCE_COLOR) ${WARNINGS_AS_ERRORS} ${EXTENSIONS} -DCMAKE_BUILD_TYPE=RelWithDebInfo ../.. && \
cmake --build .

amaldebug:
mkdir -p build/amaldebug && \
python scripts/amalgamation.py && \
cd build/amaldebug && \
cmake $(GENERATOR) $(FORCE_COLOR) -DAMALGAMATION_BUILD=1 -DCMAKE_BUILD_TYPE=Debug ../.. && \
cmake $(GENERATOR) $(FORCE_COLOR) -DAMALGAMATION_BUILD=1 ${EXTENSIONS} -DCMAKE_BUILD_TYPE=Debug ../.. && \
cmake --build .

jdbc:
mkdir -p build/release && \
python scripts/amalgamation.py && \
cd build/release && \
cmake $(GENERATOR) $(FORCE_COLOR) ${WARNINGS_AS_ERRORS} ${DISABLE_UNITY_FLAG} -DCMAKE_BUILD_TYPE=Release -DAMALGAMATION_BUILD=1 -DJDBC_DRIVER=1 ../.. && \
cmake $(GENERATOR) $(FORCE_COLOR) ${WARNINGS_AS_ERRORS} ${EXTENSIONS} -DCMAKE_BUILD_TYPE=Release -DAMALGAMATION_BUILD=1 -DJDBC_DRIVER=1 ../.. && \
cmake --build .


jdbcdebug:
mkdir -p build/jdbcdebug && \
cd build/jdbcdebug && \
cmake $(GENERATOR) $(FORCE_COLOR) -DJDBC_DRIVER=1 -DENABLE_SANITIZER=FALSE -DCMAKE_BUILD_TYPE=Debug ../.. && \
cmake $(GENERATOR) $(FORCE_COLOR) -DJDBC_DRIVER=1 -DENABLE_SANITIZER=FALSE ${EXTENSIONS} -DCMAKE_BUILD_TYPE=Debug ../.. && \
cmake --build .

test_compile: # test compilation of individual cpp files
Expand Down
2 changes: 1 addition & 1 deletion src/catalog/CMakeLists.txt
@@ -1,6 +1,6 @@
add_subdirectory(catalog_entry)

add_library_unity(duckdb_catalog
add_library(duckdb_catalog
OBJECT
catalog_entry.cpp
catalog.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/catalog/catalog_entry/CMakeLists.txt
@@ -1,4 +1,4 @@
add_library_unity(duckdb_catalog_entries
add_library(duckdb_catalog_entries
OBJECT
index_catalog_entry.cpp
schema_catalog_entry.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/common/CMakeLists.txt
Expand Up @@ -5,7 +5,7 @@ add_subdirectory(types)
add_subdirectory(value_operations)
add_subdirectory(vector_operations)

add_library_unity(duckdb_common
add_library(duckdb_common
OBJECT
constants.cpp
checksum.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/common/enums/CMakeLists.txt
@@ -1,4 +1,4 @@
add_library_unity(duckdb_common_enums
add_library(duckdb_common_enums
OBJECT
catalog_type.cpp
expression_type.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/common/operator/CMakeLists.txt
@@ -1,3 +1,3 @@
add_library_unity(duckdb_common_operators OBJECT cast_operators.cpp)
add_library(duckdb_common_operators OBJECT cast_operators.cpp)
set(ALL_OBJECT_FILES ${ALL_OBJECT_FILES}
$<TARGET_OBJECTS:duckdb_common_operators> PARENT_SCOPE)
2 changes: 1 addition & 1 deletion src/common/serializer/CMakeLists.txt
@@ -1,4 +1,4 @@
add_library_unity(duckdb_common_serializer
add_library(duckdb_common_serializer
OBJECT
buffered_deserializer.cpp
buffered_file_reader.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/common/types/CMakeLists.txt
@@ -1,4 +1,4 @@
add_library_unity(duckdb_common_types
add_library(duckdb_common_types
OBJECT
chunk_collection.cpp
data_chunk.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/common/value_operations/CMakeLists.txt
@@ -1,4 +1,4 @@
add_library_unity(duckdb_value_operations
add_library(duckdb_value_operations
OBJECT
comparison_operations.cpp
hash.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/common/vector_operations/CMakeLists.txt
@@ -1,4 +1,4 @@
add_library_unity(duckdb_vector_operations
add_library(duckdb_vector_operations
OBJECT
boolean_operators.cpp
vector_cast.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/execution/CMakeLists.txt
Expand Up @@ -5,7 +5,7 @@ add_subdirectory(operator)
add_subdirectory(physical_plan)
add_subdirectory(index/art)

add_library_unity(duckdb_execution
add_library(duckdb_execution
OBJECT
adaptive_filter.cpp
aggregate_hashtable.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/execution/expression_executor/CMakeLists.txt
@@ -1,4 +1,4 @@
add_library_unity(duckdb_expression_executor
add_library(duckdb_expression_executor
OBJECT
execute_between.cpp
execute_case.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/execution/index/art/CMakeLists.txt
@@ -1,4 +1,4 @@
add_library_unity(duckdb_art_index_execution
add_library(duckdb_art_index_execution
OBJECT
art_key.cpp
leaf.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/execution/merge_join/CMakeLists.txt
@@ -1,4 +1,4 @@
add_library_unity(duckdb_merge_join
add_library(duckdb_merge_join
OBJECT
merge_join.cpp
merge_join_complex.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/execution/nested_loop_join/CMakeLists.txt
@@ -1,4 +1,4 @@
add_library_unity(duckdb_nested_loop_join
add_library(duckdb_nested_loop_join
OBJECT
nested_loop_join_inner.cpp
nested_loop_join_mark.cpp)
Expand Down
2 changes: 1 addition & 1 deletion src/execution/operator/aggregate/CMakeLists.txt
@@ -1,4 +1,4 @@
add_library_unity(duckdb_operator_aggregate
add_library(duckdb_operator_aggregate
OBJECT
physical_hash_aggregate.cpp
physical_simple_aggregate.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/execution/operator/filter/CMakeLists.txt
@@ -1,3 +1,3 @@
add_library_unity(duckdb_operator_filter OBJECT physical_filter.cpp)
add_library(duckdb_operator_filter OBJECT physical_filter.cpp)
set(ALL_OBJECT_FILES ${ALL_OBJECT_FILES}
$<TARGET_OBJECTS:duckdb_operator_filter> PARENT_SCOPE)
2 changes: 1 addition & 1 deletion src/execution/operator/helper/CMakeLists.txt
@@ -1,4 +1,4 @@
add_library_unity(duckdb_operator_helper
add_library(duckdb_operator_helper
OBJECT
physical_execute.cpp
physical_limit.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/execution/operator/join/CMakeLists.txt
@@ -1,4 +1,4 @@
add_library_unity(duckdb_operator_join
add_library(duckdb_operator_join
OBJECT
physical_blockwise_nl_join.cpp
physical_comparison_join.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/execution/operator/order/CMakeLists.txt
@@ -1,4 +1,4 @@
add_library_unity(duckdb_operator_order
add_library(duckdb_operator_order
OBJECT
physical_order.cpp
physical_top_n.cpp)
Expand Down
2 changes: 1 addition & 1 deletion src/execution/operator/persistent/CMakeLists.txt
@@ -1,4 +1,4 @@
add_library_unity(duckdb_operator_persistent
add_library(duckdb_operator_persistent
OBJECT
buffered_csv_reader.cpp
physical_copy_from_file.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/execution/operator/projection/CMakeLists.txt
@@ -1,4 +1,4 @@
add_library_unity(duckdb_operator_projection
add_library(duckdb_operator_projection
OBJECT
physical_projection.cpp
physical_unnest.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/execution/operator/scan/CMakeLists.txt
@@ -1,4 +1,4 @@
add_library_unity(duckdb_operator_scan
add_library(duckdb_operator_scan
OBJECT
physical_chunk_scan.cpp
physical_dummy_scan.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/execution/operator/schema/CMakeLists.txt
@@ -1,4 +1,4 @@
add_library_unity(duckdb_operator_schema
add_library(duckdb_operator_schema
OBJECT
physical_alter.cpp
physical_create_index.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/execution/operator/set/CMakeLists.txt
@@ -1,4 +1,4 @@
add_library_unity(duckdb_operator_set OBJECT physical_union.cpp physical_recursive_cte.cpp)
add_library(duckdb_operator_set OBJECT physical_union.cpp physical_recursive_cte.cpp)
set(ALL_OBJECT_FILES
${ALL_OBJECT_FILES} $<TARGET_OBJECTS:duckdb_operator_set>
PARENT_SCOPE)
2 changes: 1 addition & 1 deletion src/execution/physical_plan/CMakeLists.txt
@@ -1,4 +1,4 @@
add_library_unity(duckdb_physical_plan
add_library(duckdb_physical_plan
OBJECT
plan_aggregate.cpp
plan_any_join.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/function/CMakeLists.txt
Expand Up @@ -2,7 +2,7 @@ add_subdirectory(aggregate)
add_subdirectory(scalar)
add_subdirectory(table)

add_library_unity(duckdb_function
add_library(duckdb_function
OBJECT
cast_rules.cpp
function.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/function/aggregate/CMakeLists.txt
Expand Up @@ -2,7 +2,7 @@ add_subdirectory(algebraic)
add_subdirectory(distributive)
add_subdirectory(nested)

add_library_unity(duckdb_func_aggr
add_library(duckdb_func_aggr
OBJECT
algebraic_functions.cpp
distributive_functions.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/function/aggregate/algebraic/CMakeLists.txt
@@ -1,4 +1,4 @@
add_library_unity(duckdb_aggr_algebraic
add_library(duckdb_aggr_algebraic
OBJECT
avg.cpp
covar.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/function/aggregate/distributive/CMakeLists.txt
@@ -1,4 +1,4 @@
add_library_unity(duckdb_aggr_distr
add_library(duckdb_aggr_distr
OBJECT
bitagg.cpp
count.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/function/aggregate/nested/CMakeLists.txt
@@ -1,4 +1,4 @@
add_library_unity(duckdb_aggr_nested
add_library(duckdb_aggr_nested
OBJECT
list.cpp)
set(ALL_OBJECT_FILES
Expand Down
2 changes: 1 addition & 1 deletion src/function/scalar/CMakeLists.txt
Expand Up @@ -6,7 +6,7 @@ add_subdirectory(sequence)
add_subdirectory(string)
add_subdirectory(nested)

add_library_unity(duckdb_func_scalar
add_library(duckdb_func_scalar
OBJECT
date_functions.cpp
generic_functions.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/function/scalar/date/CMakeLists.txt
@@ -1,4 +1,4 @@
add_library_unity(
add_library(
duckdb_func_date
OBJECT
age.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/function/scalar/generic/CMakeLists.txt
@@ -1,4 +1,4 @@
add_library_unity(duckdb_func_generic
add_library(duckdb_func_generic
OBJECT
least.cpp)
set(ALL_OBJECT_FILES
Expand Down
2 changes: 1 addition & 1 deletion src/function/scalar/math/CMakeLists.txt
@@ -1,4 +1,4 @@
add_library_unity(duckdb_func_math
add_library(duckdb_func_math
OBJECT
numeric.cpp
random.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/function/scalar/nested/CMakeLists.txt
@@ -1,4 +1,4 @@
add_library_unity(duckdb_func_nested
add_library(duckdb_func_nested
OBJECT
list_value.cpp
struct_extract.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/function/scalar/operators/CMakeLists.txt
@@ -1,4 +1,4 @@
add_library_unity(duckdb_func_ops
add_library(duckdb_func_ops
OBJECT
arithmetic.cpp
bitwise.cpp)
Expand Down
2 changes: 1 addition & 1 deletion src/function/scalar/sequence/CMakeLists.txt
@@ -1,4 +1,4 @@
add_library_unity(duckdb_func_seq OBJECT nextval.cpp)
add_library(duckdb_func_seq OBJECT nextval.cpp)
set(ALL_OBJECT_FILES
${ALL_OBJECT_FILES} $<TARGET_OBJECTS:duckdb_func_seq>
PARENT_SCOPE)
2 changes: 1 addition & 1 deletion src/function/scalar/string/CMakeLists.txt
@@ -1,4 +1,4 @@
add_library_unity(
add_library(
duckdb_func_string
OBJECT
reverse.cpp
Expand Down

0 comments on commit 4996145

Please sign in to comment.