Skip to content

Commit

Permalink
Np 5 wasupppp (#2025)
Browse files Browse the repository at this point in the history
  • Loading branch information
casperlamboo authored Feb 20, 2024
2 parents f2ab613 + de12ba8 commit 996fce7
Show file tree
Hide file tree
Showing 21 changed files with 287 additions and 138 deletions.
1 change: 1 addition & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ on:
- main
- 'CURA-*'
- 'PP-*'
- 'NP-*'
- '[0-9]+.[0-9]+'

permissions:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/conan-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ on:
- main
- 'CURA-*'
- 'PP-*'
- 'NP-*'
- '[0-9].[0-9]*'
- '[0-9].[0-9][0-9]*'
tags:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/gcodeanalyzer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ on:
- main
- 'CURA-*'
- 'PP-*'
- 'NP-*'
- '[0-9]+.[0-9]+'

permissions:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/stress_benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ on:
- main
- 'CURA-*'
- 'PP-*'
- 'NP-*'
- '[0-9]+.[0-9]+'

permissions:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ on:
- main
- 'CURA-*'
- 'PP-*'
- 'NP-*'
- '[0-9]+.[0-9]+'

pull_request:
Expand Down
71 changes: 41 additions & 30 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,23 @@ option(ENABLE_SENTRY "Send crash data via Sentry" OFF)
option(ENABLE_MORE_COMPILER_OPTIMIZATION_FLAGS "Enable more optimization flags" ON)
option(USE_SYSTEM_LIBS "Use the system libraries if available" OFF)
option(OLDER_APPLE_CLANG "Apple Clang <= 13 used" OFF)
option(ENABLE_THREADING "Enable threading support" ON)

# Generate the plugin types
find_package(protobuf REQUIRED)
find_package(asio-grpc REQUIRED)
find_package(gRPC REQUIRED)
find_package(curaengine_grpc_definitions REQUIRED)
option(OLDER_APPLE_CLANG "Apple Clang <= 13 used" OFF)
if (${ENABLE_ARCUS} OR ${ENABLE_PLUGINS})
find_package(protobuf REQUIRED)
endif ()

MESSAGE(STATUS "Compiling with plugins support: ${ENABLE_PLUGINS}")
MESSAGE(STATUS "Building with plugins support: ${ENABLE_PLUGINS}")
if (${ENABLE_PLUGINS})
find_package(asio-grpc REQUIRED)
find_package(gRPC REQUIRED)
find_package(curaengine_grpc_definitions REQUIRED)
find_package(semver REQUIRED)
MESSAGE(STATUS "Plugin secure remotes allowed: ${ENABLE_REMOTE_PLUGINS}")
endif ()

if (ENABLE_ARCUS)
message(STATUS "Building with Arcus")
message(STATUS "Building with Arcus: ${ENABLE_ARCUS}")
if (${ENABLE_ARCUS})
find_package(arcus REQUIRED)
protobuf_generate_cpp(engine_PB_SRCS engine_PB_HEADERS Cura.proto)
endif ()
Expand Down Expand Up @@ -151,18 +153,20 @@ set(engine_SRCS # Except main.cpp.
src/utils/ToolpathVisualizer.cpp
src/utils/VoronoiUtils.cpp
src/utils/VoxelUtils.cpp
)
)

add_library(_CuraEngine STATIC ${engine_SRCS} ${engine_PB_SRCS})
use_threads(_CuraEngine)
if (ENABLE_THREADING)
use_threads(_CuraEngine)
endif ()

target_include_directories(_CuraEngine
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}> # Include Cura.pb.h
)
)

target_compile_definitions(_CuraEngine
PUBLIC
Expand All @@ -180,7 +184,7 @@ target_compile_definitions(_CuraEngine
$<$<CONFIG:RelWithDebInfo>:ASSERT_INSANE_OUTPUT>
$<$<CONFIG:RelWithDebInfo>:USE_CPU_TIME>
$<$<CONFIG:RelWithDebInfo>:DEBUG>
)
)

enable_sanitizers(_CuraEngine)

Expand All @@ -189,7 +193,7 @@ if (${EXTENSIVE_WARNINGS})
endif ()

if (ENABLE_ARCUS)
target_link_libraries(_CuraEngine PUBLIC arcus::arcus )
target_link_libraries(_CuraEngine PUBLIC arcus::arcus)
endif ()

find_package(clipper REQUIRED)
Expand All @@ -200,7 +204,6 @@ find_package(spdlog REQUIRED)
find_package(fmt REQUIRED)
find_package(range-v3 REQUIRED)
find_package(scripta REQUIRED)
find_package(semver REQUIRED)

if (ENABLE_SENTRY)
find_package(sentry REQUIRED)
Expand All @@ -220,13 +223,13 @@ target_link_libraries(_CuraEngine
stb::stb
boost::boost
scripta::scripta
semver::semver
curaengine_grpc_definitions::curaengine_grpc_definitions
asio-grpc::asio-grpc
grpc::grpc
protobuf::libprotobuf
$<$<BOOL:${ENABLE_SENTRY}>:sentry::sentry>
$<$<BOOL:${ENABLE_TESTING}>:GTest::gtest>)
$<$<TARGET_EXISTS:semver::semver>:semver::semver>
$<$<TARGET_EXISTS:curaengine_grpc_definitions::curaengine_grpc_definitions>:curaengine_grpc_definitions::curaengine_grpc_definitions>
$<$<TARGET_EXISTS:asio-grpc::asio-grpc>:asio-grpc::asio-grpc>
$<$<TARGET_EXISTS:grpc::grpc>:grpc::grpc>
$<$<TARGET_EXISTS:protobuf::libprotobuf>:protobuf::libprotobuf>
$<$<TARGET_EXISTS:sentry::sentry>:sentry::sentry>
$<$<TARGET_EXISTS:GTest::gtest>:GTest::gtest>)

target_compile_definitions(_CuraEngine PRIVATE
$<$<BOOL:${ENABLE_SENTRY}>:SENTRY_URL=\"${SENTRY_URL}\">
Expand All @@ -242,18 +245,26 @@ else ()
SET(CMAKE_RC_COMPILER_INIT windres)
SET(CMAKE_RC_COMPILE_OBJECT
"<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>"
)
)
endif ()
add_executable(CuraEngine src/main.cpp ${RES_FILES}) # ..., but don't forget the glitter!
if (ENABLE_SENTRY)
set_target_properties(CuraEngine PROPERTIES LINK_FLAGS "/DEBUG:FULL")
endif ()
endif (NOT WIN32)

use_threads(CuraEngine)
if (ENABLE_THREADING)
use_threads(CuraEngine)
endif ()

if (CMAKE_CXX_PLATFORM_ID STREQUAL "emscripten")
message(STATUS "Building for Emscripten")
target_link_options(_CuraEngine PUBLIC -Wno-unused-command-line-argument -sINVOKE_RUN=0 -sEXPORT_NAME=CuraEngine -sEXPORTED_RUNTIME_METHODS=[callMain,FS] -sFORCE_FILESYSTEM=1 -sALLOW_MEMORY_GROWTH=1 -sEXPORT_ES6=1 -sMODULARIZE=1 -sSINGLE_FILE=1 -sENVIRONMENT=worker -sERROR_ON_UNDEFINED_SYMBOLS=0 -lembind --embind-emit-tsd CuraEngine.d.ts)
endif ()

target_link_libraries(CuraEngine PRIVATE
_CuraEngine
$<$<BOOL:${ENABLE_SENTRY}>:sentry::sentry>
$<$<TARGET_EXISTS:sentry::sentry>:sentry::sentry>
)
target_compile_definitions(CuraEngine PRIVATE
$<$<BOOL:${ENABLE_SENTRY}>:SENTRY_URL=\"${SENTRY_URL}\">
Expand All @@ -280,10 +291,10 @@ if (ENABLE_TESTING OR ENABLE_BENCHMARKS)
GTest::gtest
GTest::gmock
clipper::clipper
curaengine_grpc_definitions::curaengine_grpc_definitions
asio-grpc::asio-grpc
grpc::grpc
protobuf::libprotobuf)
$<$<TARGET_EXISTS:curaengine_grpc_definitions::curaengine_grpc_definitions>:curaengine_grpc_definitions::curaengine_grpc_definitions>
$<$<TARGET_EXISTS:asio-grpc::asio-grpc>:asio-grpc::asio-grpc>
$<$<TARGET_EXISTS:grpc::grpc>:grpc::grpc>
$<$<TARGET_EXISTS:protobuf::libprotobuf>:protobuf::libprotobuf>)
if (ENABLE_ARCUS)
target_link_libraries(test_helpers PUBLIC arcus::arcus)
endif ()
Expand All @@ -293,7 +304,7 @@ if (ENABLE_BENCHMARKS)
add_subdirectory(benchmark)
if (NOT WIN32)
add_subdirectory(stress_benchmark)
endif()
endif ()
endif ()

if (ENABLE_TESTING)
Expand Down
1 change: 1 addition & 0 deletions Cura.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ message ObjectList
// 0 ... 99: Broadcasts
// 100 ... 199: Modify
// 200 ... 299: Generate
// IMPORTANT: If you add a slot ID also update the SlotID enum in include/plugins/slots.h
enum SlotID {
SETTINGS_BROADCAST = 0;
SIMPLIFY_MODIFY = 100;
Expand Down
9 changes: 7 additions & 2 deletions benchmark/simplify_benchmark.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
// Copyright (c) 2023 UltiMaker
// Copyright (c) 2024 UltiMaker
// CuraEngine is released under the terms of the AGPLv3 or higher

#ifndef CURAENGINE_BENCHMARK_SIMPLIFY_BENCHMARK_H
#define CURAENGINE_BENCHMARK_SIMPLIFY_BENCHMARK_H

#include "../tests/ReadTestPolygons.h"
#include "plugins/slots.h"
#include "utils/Simplify.h"
#include "utils/channel.h"

#include <fmt/format.h>

#include <benchmark/benchmark.h>
#include <filesystem>

#ifdef ENABLE_PLUGINS
#include "plugins/slots.h"
#include <grpcpp/create_channel.h>
#endif

namespace cura
{
Expand Down Expand Up @@ -58,6 +61,7 @@ BENCHMARK_DEFINE_F(SimplifyTestFixture, simplify_local)(benchmark::State& st)

BENCHMARK_REGISTER_F(SimplifyTestFixture, simplify_local);

#ifdef ENABLE_PLUGINS
BENCHMARK_DEFINE_F(SimplifyTestFixture, simplify_slot_noplugin)(benchmark::State& st)
{
for (auto _ : st)
Expand All @@ -71,6 +75,7 @@ BENCHMARK_DEFINE_F(SimplifyTestFixture, simplify_slot_noplugin)(benchmark::State
}

BENCHMARK_REGISTER_F(SimplifyTestFixture, simplify_slot_noplugin);
#endif

} // namespace cura
#endif // CURAENGINE_BENCHMARK_SIMPLIFY_BENCHMARK_H
4 changes: 3 additions & 1 deletion conandata.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
version: "5.7.0-alpha.1"
requirements:
- "scripta/0.1.0@ultimaker/testing"
requirements_arcus:
- "arcus/5.3.1"
requirements_plugins:
- "curaengine_grpc_definitions/(latest)@ultimaker/testing"
- "scripta/0.1.0@ultimaker/testing"
29 changes: 21 additions & 8 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ def config_options(self):
def configure(self):
self.options["boost"].header_only = True
self.options["clipper"].shared = True
self.options["protobuf"].shared = False
if self.options.enable_arcus or self.options.enable_plugins:
self.options["protobuf"].shared = False
if self.options.enable_arcus:
self.options["arcus"].shared = True
if self.settings.os == "Linux":
Expand Down Expand Up @@ -103,23 +104,27 @@ def build_requirements(self):

def requirements(self):
for req in self.conan_data["requirements"]:
if "arcus" in req and not self.options.enable_arcus:
continue
self.requires(req)
if self.options.enable_arcus:
for req in self.conan_data["requirements_arcus"]:
self.requires(req)
if self.options.get_safe("enable_sentry", False):
self.requires("sentry-native/0.6.5")
if self.options.enable_plugins:
self.requires("neargye-semver/0.3.0")
self.requires("asio-grpc/2.6.0")
self.requires("grpc/1.50.1")
for req in self.conan_data["requirements_plugins"]:
self.requires(req)
if self.options.enable_arcus or self.options.enable_plugins:
self.requires("protobuf/3.21.9")
self.requires("asio-grpc/2.6.0")
self.requires("grpc/1.50.1")
self.requires("protobuf/3.21.12")
self.requires("clipper/6.4.2@ultimaker/stable")
self.requires("boost/1.82.0")
self.requires("rapidjson/1.1.0")
self.requires("stb/20200203")
self.requires("spdlog/1.12.0")
self.requires("fmt/10.1.1")
self.requires("range-v3/0.12.0")
self.requires("neargye-semver/0.3.0")
self.requires("zlib/1.2.12")
self.requires("openssl/3.2.0")

Expand All @@ -134,6 +139,7 @@ def generate(self):
tc.variables["ENABLE_BENCHMARKS"] = self.options.enable_benchmarks
tc.variables["EXTENSIVE_WARNINGS"] = self.options.enable_extensive_warnings
tc.variables["OLDER_APPLE_CLANG"] = self.settings.compiler == "apple-clang" and Version(self.settings.compiler.version) < "14"
tc.variables["ENABLE_THREADING"] = not (self.settings.arch == "wasm" and self.settings.os == "Emscripten")
if self.options.get_safe("enable_sentry", False):
tc.variables["ENABLE_SENTRY"] = True
tc.variables["SENTRY_URL"] = self.conf.get("user.curaengine:sentry_url", "", check_type=str)
Expand Down Expand Up @@ -206,8 +212,15 @@ def build(self):
self.run(f"sentry-cli --auth-token {os.environ['SENTRY_TOKEN']} releases finalize -o {sentry_org} -p {sentry_project} {self.version}")

def package(self):
ext = ".exe" if self.settings.os == "Windows" else ""
match self.setting.os:
case "Windows":
ext = ".exe"
case "Emscripten":
ext = ".js"
case other:
ext = ""
copy(self, f"CuraEngine{ext}", src=self.build_folder, dst=path.join(self.package_folder, "bin"))
copy(self, f"*.d.ts", src=self.build_folder, dst=path.join(self.package_folder, "bin"))
copy(self, f"_CuraEngine.*", src=self.build_folder, dst=path.join(self.package_folder, "lib"))
copy(self, "LICENSE*", src=self.source_folder, dst=path.join(self.package_folder, "license"))

Expand Down
23 changes: 12 additions & 11 deletions include/communication/CommandLine.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Copyright (c) 2018-2022 Ultimaker B.V.
// CuraEngine is released under the terms of the AGPLv3 or higher.
// Copyright (c) 2024 UltiMaker
// CuraEngine is released under the terms of the AGPLv3 or higher

#ifndef COMMANDLINE_H
#define COMMANDLINE_H

#include <filesystem>
#include <rapidjson/document.h> //Loading JSON documents to get settings from them.
#include <string> //To store the command line arguments.
#include <unordered_set>
Expand Down Expand Up @@ -151,6 +152,12 @@ class CommandLine : public Communication
void sliceNext() override;

private:
#ifdef __EMSCRIPTEN__
std::string progressHandler;
#endif

std::unordered_set<std::filesystem::path> search_directories_;

/*
* \brief The command line arguments that the application was called with.
*/
Expand All @@ -161,12 +168,6 @@ class CommandLine : public Communication
*/
unsigned int last_shown_progress_;

/*
* \brief Get the default search directories to search for definition files.
* \return The default search directories to search for definition files.
*/
std::unordered_set<std::string> defaultSearchDirectories();

/*
* \brief Load a JSON file and store the settings inside it.
* \param json_filename The location of the JSON file to load settings from.
Expand All @@ -177,7 +178,7 @@ class CommandLine : public Communication
* 1, the file could not be opened. If it's 2, there was a syntax error in
* the file.
*/
int loadJSON(const std::string& json_filename, Settings& settings, bool force_read_parent = false, bool force_read_nondefault = false);
int loadJSON(const std::filesystem::path& json_filename, Settings& settings, bool force_read_parent = false, bool force_read_nondefault = false);

/*
* \brief Load a JSON document and store the settings inside it.
Expand All @@ -190,7 +191,7 @@ class CommandLine : public Communication
*/
int loadJSON(
const rapidjson::Document& document,
const std::unordered_set<std::string>& search_directories,
const std::unordered_set<std::filesystem::path>& search_directories,
Settings& settings,
bool force_read_parent = false,
bool force_read_nondefault = false);
Expand All @@ -211,7 +212,7 @@ class CommandLine : public Communication
* \param search_directories The directories to search in.
* \return The first definition file that matches the definition ID.
*/
const std::string findDefinitionFile(const std::string& definition_id, const std::unordered_set<std::string>& search_directories);
static std::string findDefinitionFile(const std::string& definition_id, const std::unordered_set<std::filesystem::path>& search_directories);
};

} // namespace cura
Expand Down
Loading

0 comments on commit 996fce7

Please sign in to comment.