summaryrefslogtreecommitdiff
path: root/mech
diff options
context:
space:
mode:
Diffstat (limited to 'mech')
-rw-r--r--mech/CMakeLists.txt19
-rw-r--r--mech/mech.cmake62
-rw-r--r--mech/pcb_case/CMakeLists.txt9
3 files changed, 90 insertions, 0 deletions
diff --git a/mech/CMakeLists.txt b/mech/CMakeLists.txt
new file mode 100644
index 0000000..9b045ba
--- /dev/null
+++ b/mech/CMakeLists.txt
@@ -0,0 +1,19 @@
+include(mech.cmake)
+
+set(
+ printer_config
+ "${CMAKE_CURRENT_SOURCE_DIR}/prusa-slicer/anycubic_i3_mega_s.ini"
+)
+
+set(
+ prints
+ "${CMAKE_CURRENT_SOURCE_DIR}/assembly.scad"
+ "${CMAKE_CURRENT_SOURCE_DIR}/production.scad"
+)
+
+foreach(print ${prints})
+ openscad(${print})
+ prusa_slicer(${print} ${printer_config})
+endforeach()
+
+add_subdirectory(pcb_case)
diff --git a/mech/mech.cmake b/mech/mech.cmake
new file mode 100644
index 0000000..2d2b979
--- /dev/null
+++ b/mech/mech.cmake
@@ -0,0 +1,62 @@
+function(openscad source_file)
+ if (NOT source_file)
+ message(FATAL_ERROR "Missing source_file argument in openscad function.")
+ endif()
+
+ get_filename_component(name "${source_file}" NAME_WE)
+
+ set(sink_file "${CMAKE_CURRENT_BINARY_DIR}/${name}.stl")
+
+ add_custom_command(
+ OUTPUT
+ ${sink_file}
+ COMMAND
+ openscad
+ --hardwarnings
+ --export-format binstl
+ -o ${sink_file}
+ ${source_file}
+ DEPENDS
+ ${source_file}
+ )
+
+ add_custom_target(
+ "stl-${name}"
+ ALL
+ DEPENDS
+ ${sink_file}
+ )
+endfunction()
+
+function(prusa_slicer source_file printer_config)
+ if (NOT source_file)
+ message(FATAL_ERROR "Missing source_file argument in prusa-slicer function.")
+ endif()
+
+ if (NOT printer_config)
+ message(FATAL_ERROR "Missing printer_config argument in prusa-slicer function.")
+ endif()
+
+ get_filename_component(name "${source_file}" NAME_WE)
+
+ set(stl_file "${CMAKE_CURRENT_BINARY_DIR}/${name}.stl")
+ set(sink_file "${CMAKE_CURRENT_BINARY_DIR}/${name}.gcode")
+
+ add_custom_command(
+ OUTPUT
+ ${sink_file}
+ COMMAND
+ prusa-slicer
+ --load ${printer_config}
+ --output ${sink_file}
+ --export-gcode ${stl_file}
+ DEPENDS
+ ${stl_file}
+ )
+ add_custom_target(
+ "gcode-${name}"
+ ALL
+ DEPENDS
+ ${sink_file}
+ )
+endfunction()
diff --git a/mech/pcb_case/CMakeLists.txt b/mech/pcb_case/CMakeLists.txt
new file mode 100644
index 0000000..40c9edf
--- /dev/null
+++ b/mech/pcb_case/CMakeLists.txt
@@ -0,0 +1,9 @@
+set(
+ prints
+ "${CMAKE_CURRENT_SOURCE_DIR}/tolerance_tests.scad"
+)
+
+foreach(print ${prints})
+ openscad(${print})
+ prusa_slicer(${print} ${printer_config})
+endforeach()