Skip to content

Commit

Permalink
Update version numbers and add commit hash support
Browse files Browse the repository at this point in the history
Updated version numbers across various files to "0.2.1". Added commit hash retrieval and binding for better tracking of builds.

NP-349
  • Loading branch information
saumyaj3 committed Oct 9, 2024
1 parent 7672fb4 commit aabf086
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 11 deletions.
15 changes: 11 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,21 @@ option(WITH_APPS "Build with apps" ON)
option(WITH_JS_BINDINGS "Build with JavaScript Emscripten bindings" OFF)

if(WITH_APPS)
set(APP_VERSION "0.1.0" CACHE STRING "Version of the translator app" )
set(APP_VERSION "0.2.1" CACHE STRING "Version of the translator app" )
message(STATUS "Configuring translator app version: ${APP_VERSION}")
endif ()

option(WITH_PYTHON_BINDINGS "Build with Python bindings: `pyDulcificum`" ON)
if(WITH_PYTHON_BINDINGS)
set(PYDULCIFICUM_VERSION "0.1.0" CACHE STRING "Version of the pyDulcificum python bindings" )
set(PYDULCIFICUM_VERSION "0.2.1" CACHE STRING "Version of the pyDulcificum python bindings" )
message(STATUS "Configuring pyDulcificum version: ${PYDULCIFICUM_VERSION}")
endif ()

set(DULCIFICUM_VERSION "0.1.0" CACHE STRING "Version of the dulcificum library" )
if(NOT DEFINED DULCIFICUM_VERSION)
message(FATAL_ERROR "DULCIFICUM_VERSION is not defined!")
endif()
message(STATUS "Configuring Dulcificum version: ${DULCIFICUM_VERSION}")
message(STATUS "Configuring Dulcificum hash: ${GIT_COMMIT_HASH}")

find_package(nlohmann_json REQUIRED)
find_package(spdlog REQUIRED)
Expand Down Expand Up @@ -52,7 +55,11 @@ target_include_directories(dulcificum
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

target_compile_definitions(dulcificum PRIVATE DULCIFICUM_VERSION="${DULCIFICUM_VERSION}")
target_compile_definitions(dulcificum
PUBLIC
DULCIFICUM_VERSION="${DULCIFICUM_VERSION}"
DULCIFICUM_HASH="${GIT_COMMIT_HASH}"
)

if (NOT WITH_JS_BINDINGS)
use_threads(dulcificum)
Expand Down
20 changes: 19 additions & 1 deletion DulcificumJS/cpp/DulcificumJS.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
#include <dulcificum.h>
#include <emscripten/bind.h>

struct info_t
{
std::string dulcificum_version;
std::string dulcificum_hash;
};

info_t get_info()
{
return { DULCIFICUM_VERSION, DULCIFICUM_HASH };
}

EMSCRIPTEN_BINDINGS(dulcificum)
{
emscripten::function("gcode_2_miracle_jtp", &dulcificum::GCode2Miracle_JTP);
}
// Binding for info_t structure
emscripten::value_object<info_t>("info_t")
.field("dulcificum_version", &info_t::dulcificum_version)
.field("dulcificum_hash", &info_t::dulcificum_hash);

// Binding for get_info function
emscripten::function("dulcificum_info", &get_info);
}
4 changes: 2 additions & 2 deletions DulcificumJS/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion DulcificumJS/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ultimaker/dulcificumjs",
"version": "0.1.0-alpha.7",
"version": "0.1.0-alpha.8",
"description": "DulcificumJS is a TS component to run Dulcificum in a browser",
"main": "dist/index.js",
"scripts": {
Expand Down
7 changes: 7 additions & 0 deletions DulcificumJS/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,10 @@ export function gcode_2_miracle_jtp(input: string): string {
}
return <string> mod.gcode_2_miracle_jtp(input);
}

export function dulcificum_info(): dulcificum.info_t {
if (mod == null) {
return { dulcificum_version: "", dulcificum_hash: "" };
}
return mod.dulcificum_info();
}
10 changes: 10 additions & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import subprocess

from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
Expand Down Expand Up @@ -129,6 +130,7 @@ def generate(self):
tc.variables["ENABLE_TESTS"] = self._run_tests
tc.variables["EXTENSIVE_WARNINGS"] = self.options.enable_extensive_warnings
tc.variables["DULCIFICUM_VERSION"] = self.version
tc.variables["GIT_COMMIT_HASH"] = self._get_git_commit_hash()

tc.variables["WITH_APPS"] = self.options.with_apps
if self.options.with_apps:
Expand Down Expand Up @@ -176,6 +178,14 @@ def generate(self):
if len(dep.cpp_info.bindirs) > 0:
copy(self, "*.dll", dep.cpp_info.bindirs[0], os.path.join(self.build_folder, "tests"))

def _get_git_commit_hash(self):
try:
result = subprocess.run(["git", "rev-parse", "HEAD"], cwd=self.recipe_folder, capture_output=True,
check=True, text=True)
return result.stdout.strip()
except subprocess.CalledProcessError:
return "unknown"

def build(self):
cmake = CMake(self)
cmake.configure()
Expand Down
2 changes: 1 addition & 1 deletion include/dulcificum.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <nlohmann/json_fwd.hpp>
#ifndef DULCIFICUM_VERSION
#define DULCIFICUM_VERSION "0.1.0"
#define DULCIFICUM_VERSION "0.2.1"
#endif

#include "dulcificum/gcode/gcode_to_command.h"
Expand Down
4 changes: 2 additions & 2 deletions pyDulcificum/pyDulcificum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <string>

#ifndef PYDULCIFICUM_VERSION
#define PYDULCIFICUM_VERSION "0.1.0"
#define PYDULCIFICUM_VERSION "0.2.1"
#endif

namespace py = pybind11;
Expand Down Expand Up @@ -44,4 +44,4 @@ PYBIND11_MODULE(pyDulcificum, module)
"Writes a given string to a file.");

module.def("gcode_2_miracle_jtp", &dulcificum::GCode2Miracle_JTP, "Converts GGode to Miracle JSON Toolpaths", py::arg("content"));
}
}

0 comments on commit aabf086

Please sign in to comment.