Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into CURA-11622_conan_v2
Browse files Browse the repository at this point in the history
  • Loading branch information
wawanbreton committed Sep 25, 2024
2 parents 9b7fd40 + 7672fb4 commit 228c4dd
Show file tree
Hide file tree
Showing 17 changed files with 3,690 additions and 20 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/conan-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ on:
- 'conanfile.py'
- 'CMakeLists.txt'
- 'pyDulcificum/**'
- 'DulcificumJS/**'
- '.github/workflows/conan-package.yml'
- '.github/worflows/requirements-conan-package.txt'
branches:
- main
- 'CURA-*'
- 'NP-*'
- 'PP-*'
- 'SS-*'
- '[0-9].[0-9]*'
Expand Down
84 changes: 84 additions & 0 deletions .github/workflows/npm-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: NPM package

on:
release:
types: [ created ]

jobs:
build:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Sync pip requirements
run: curl -O https://raw.githubusercontent.com/Ultimaker/cura-workflows/main/.github/workflows/requirements-runner.txt
working-directory: .github/workflows

- name: Setup Python and pip
uses: actions/setup-python@v4
with:
python-version: 3.11.x
cache: pip
cache-dependency-path: .github/workflows/requirements-runner.txt

- name: Install Python requirements and Create default Conan profile
run: pip install -r .github/workflows/requirements-runner.txt

- name: Install Linux system requirements for building
run: |
mkdir runner_scripts
cd runner_scripts
curl -O https://raw.githubusercontent.com/Ultimaker/cura-workflows/main/runner_scripts/ubuntu_setup.sh
chmod +x ubuntu_setup.sh
sudo ./ubuntu_setup.sh
- name: Setup pipeline caches
run: |
mkdir -p /home/runner/.conan/downloads
mkdir -p /home/runner/.conan/data
- name: Create default Conan profile
run: conan profile new default --detect

- name: Get Conan configuration
run: |
conan config install https://github.com/Ultimaker/conan-config.git
conan config install https://github.com/Ultimaker/conan-config.git -a "-b runner/${{ runner.os }}/${{ runner.arch }}"
- name: Cache Conan packages
uses: actions/cache@v3
with:
path: /home/runner/.conan/data
key: ${{ runner.os }}-conan-data-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-conan-data-
- name: Cache Conan downloads
uses: actions/cache@v3
with:
path: /home/runner/.conan/downloads
key: ${{ runner.os }}-conan-downloads-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-conan-downloads-
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version-file: ./DulcificumJS/.nvmrc
registry-url: 'https://npm.pkg.github.com'
scope: '@ultimaker'

- name: NPM install and publish
run: |
npm run install_dulcificum
npm ci
npm publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
working-directory: DulcificumJS
18 changes: 13 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ find_package(standardprojectsettings REQUIRED)
option(EXTENSIVE_WARNINGS "Build with all warnings" ON)
option(ENABLE_TESTS "Build with unit test" ON)
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" )
message(STATUS "Configuring translator app version: ${APP_VERSION}")
Expand All @@ -29,16 +31,14 @@ set(DULCIFICUM_SRC
src/gcode/ast/ast.cpp
src/gcode/ast/entries.cpp
src/gcode/parse.cpp

src/miracle_jtp/mgjtp_command_to_json.cpp
src/miracle_jtp/mgjtp_json_to_command.cpp

src/gcode/gcode_to_command.cpp

src/utils/io.cpp
src/command_types.cpp
)
add_library(dulcificum ${DULCIFICUM_SRC})
add_library(dulcificum STATIC ${DULCIFICUM_SRC})

target_link_libraries(dulcificum
PUBLIC
nlohmann_json::nlohmann_json
Expand All @@ -54,12 +54,20 @@ target_include_directories(dulcificum

target_compile_definitions(dulcificum PRIVATE DULCIFICUM_VERSION="${DULCIFICUM_VERSION}")

use_threads(dulcificum)
if (NOT WITH_JS_BINDINGS)
use_threads(dulcificum)
endif ()

enable_sanitizers(dulcificum)
if (${EXTENSIVE_WARNINGS})
set_project_warnings(dulcificum)
endif ()

# --- Setup JavaScript bindings ---
if (WITH_JS_BINDINGS)
add_subdirectory(DulcificumJS/cpp)
endif ()

# --- Setup Python bindings ---
if (WITH_PYTHON_BINDINGS)
add_subdirectory(pyDulcificum)
Expand Down
1 change: 1 addition & 0 deletions DulcificumJS/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.github/**
3 changes: 3 additions & 0 deletions DulcificumJS/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}
@ultimaker:registry=https://npm.pkg.github.com
always-auth=true
1 change: 1 addition & 0 deletions DulcificumJS/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lts/*
52 changes: 52 additions & 0 deletions DulcificumJS/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Dulcificum JS

A worker that runs Dulcificum in a browser using the Emscripten to compile for wasm

## System Requirements

### Windows
- Python 3.11 or higher
- Ninja 1.10 or higher
- VS2022 or higher
- CMake 3.23 or higher
- nmake

### MacOs
- Python 3.11 or higher
- Ninja 1.10 or higher
- apply clang 11 or higher
- CMake 3.23 or higher
- make
-
### Linux
- Python 3.11 or higher
- Ninja 1.10 or higher
- gcc 13 or higher
- CMake 3.23 or higher
- make

# Installation
We are using conan to manage our C++ dependencies and build configuration. If you have never used Conan read their documentation which is quite extensive and well maintained.

1. Configure Conan

2. Before you start, if you use conan for other (big) projects as well, it's a good idea to either switch conan-home and/or backup your existing conan configuration(s).

That said, installing our config goes as follows:

```
pip install conan==1.64
conan config install https://github.com/ultimaker/conan-config.git
conan profile new default --detect --force
```

2. Installing NodeJS deps

Using Dulcificum in this project follows normal NodeJS package conventions. During an explicit user instigated pre-install step,
we use Conan (installed and setup above), to build or download the wasm binaries from the JFrog Artifactory.
and installing these in `src/Dulcificum/`

```
npm run install_dulcificum
npm install
```
16 changes: 16 additions & 0 deletions DulcificumJS/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
add_executable(dulcificum_js DulcificumJS.cpp)
target_link_options(dulcificum_js
PUBLIC
"SHELL:-s USE_ES6_IMPORT_META=1"
"SHELL:-s FORCE_FILESYSTEM=1"
"SHELL:-s EXPORT_NAME=dulcificum"
"SHELL:-s MODULARIZE=1"
"SHELL:-s EXPORT_ES6=1"
"SHELL:-s SINGLE_FILE=1"
"SHELL:-s ALLOW_MEMORY_GROWTH=1"
"SHELL:-s ERROR_ON_UNDEFINED_SYMBOLS=0"
"SHELL:--bind"
"SHELL:-l embind"
"SHELL: --embind-emit-tsd dulcificum_js.d.ts"
)
target_link_libraries(dulcificum_js PUBLIC dulcificum)
7 changes: 7 additions & 0 deletions DulcificumJS/cpp/DulcificumJS.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <dulcificum.h>
#include <emscripten/bind.h>

EMSCRIPTEN_BINDINGS(dulcificum)
{
emscripten::function("gcode_2_miracle_jtp", &dulcificum::GCode2Miracle_JTP);
}
Loading

0 comments on commit 228c4dd

Please sign in to comment.