Skip to content

Open Source alternative to Algolia + Pinecone and an Easier-to-Use alternative to ElasticSearch ⚡ 🔍 ✨ Fast, typo tolerant, in-memory fuzzy Search Engine for building delightful search experiences

Pass Typesense version from command line instead of using a brittle header file.

Kishore Nallanb0b289b43512
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 59c46dbe..91d365dc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -69,9 +69,8 @@ add_executable(typesense_test ${SRC_FILES} test/main.cpp test/array_test.cpp tes
test/topster_test.cpp test/match_score_test.cpp test/store_test.cpp test/array_utils_test.cpp
test/string_utils_test.cpp)
-target_compile_definitions(typesense-server PRIVATE ROOT_DIR="${CMAKE_SOURCE_DIR}/")
-target_compile_definitions(search PRIVATE ROOT_DIR="${CMAKE_SOURCE_DIR}/")
-target_compile_definitions(benchmark PRIVATE ROOT_DIR="${CMAKE_SOURCE_DIR}/")
+set(TYPESENSE_VERSION "nightly" CACHE STRING "") # will be overridden from command line during a release build
+target_compile_definitions(typesense-server PRIVATE TYPESENSE_VERSION="${TYPESENSE_VERSION}")
target_compile_definitions(typesense_test PRIVATE ROOT_DIR="${CMAKE_SOURCE_DIR}/")
if (APPLE)
diff --git a/include/typesense_version.h b/include/typesense_version.h
deleted file mode 100644
index 61a9740b..00000000
--- a/include/typesense_version.h
+++ /dev/null
@@ -1,2 +0,0 @@
-// This would be updated by the build script when a release is built
-#define TYPESENSE_VERSION "nightly"
\ No newline at end of file
diff --git a/src/api.cpp b/src/api.cpp
index ba531143..0be38dc8 100644
--- a/src/api.cpp
+++ b/src/api.cpp
@@ -3,7 +3,6 @@
#include <thread>
#include <sys/resource.h>
#include "api.h"
-#include "typesense_version.h"
#include "string_utils.h"
#include "collection.h"
#include "collection_manager.h"
diff --git a/src/main/typesense_server.cpp b/src/main/typesense_server.cpp
index 2dd93fbc..731e1bd1 100644
--- a/src/main/typesense_server.cpp
+++ b/src/main/typesense_server.cpp
@@ -10,7 +10,6 @@
#include "api.h"
#include "string_utils.h"
#include "replicator.h"
-#include "typesense_version.h"
#include "logger.h"
HttpServer* server;
@@ -99,6 +98,7 @@ int main(int argc, char **argv) {
}
log_worker->addDefaultLogger("typesense", log_dir, "");
+
std::cout << "Starting Typesense " << TYPESENSE_VERSION << ". Log directory is configured as: "
<< log_dir << std::endl;
}
@@ -161,10 +161,11 @@ int main(int argc, char **argv) {
replication_thread.detach();
}
- server->run();
+ int return_code = server->run();
// we are out of the event loop here
delete server;
CollectionManager::get_instance().dispose();
- return 0;
+
+ return return_code;
}
\ No newline at end of file