Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WASM module and NPM library (javascript bindings) #892

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

fr-an-k
Copy link
Contributor

@fr-an-k fr-an-k commented Dec 9, 2023

I made a simple LibreDWG file conversion library for easier interoperability.
I was hoping a WASM build of this could be released by default.
WASM (with 3 exports) is easy to fit onto any machine or language without manual compilation.
I will also make an NPM library wrapper around it.

I'm not finished, but I'm stuck on why autotools is seeing my new flag (in help and log) after running autogen.sh, but not picking it up when I set it, I tried many things but it seems I'm missing something trivial.

I was hoping someone could help out.
My commands with emscripten:

./autogen.sh
mkdir .build-wasm
(cd .build-wasm && emconfigure ../configure --enable-libconvert-only --disable-bindings --disable-shared)
(cd .build-wasm && emmake make -j)

In stdout it doesn't mention my flag, in .build-wasm/config.log it mentions it but says it's not detected, defaulting to "no".

My addition to configure.ac:

dnl --enable-libconvert-only
AC_MSG_CHECKING([for --enable-libconvert-only])
AC_ARG_ENABLE([libconvert-only],AS_HELP_STRING([--enable-libconvert-only],[
    Build only the library for pure file format conversion (default: no).]),
  [libconvert_only=yes
  AC_MSG_RESULT([yes])],
  AC_MSG_RESULT([no (default)]))
AM_CONDITIONAL([LIBCONVERTONLY], [test x$libconvert_only = xyes])

(The cmake route does not seem to work in any way, so I'll have to use autotools)

I was also wondering if it would be acceptable to put the NPM library under the usual ISC/MIT license within this repository. Bundled GPLv3 javascript does not require one to open up their source code, but it's scary for those who don't understand this, since Javascript only exists as source code. The actual LibreDWG library is in compiled form (WASM).

Copy link

codecov bot commented Dec 9, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (10c79fd) 73.77% compared to head (16e8294) 73.77%.
Report is 7 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #892   +/-   ##
=======================================
  Coverage   73.77%   73.77%           
=======================================
  Files           2        2           
  Lines         122      122           
=======================================
  Hits           90       90           
  Misses         32       32           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

"version": "0.0.0-dev.0",
"description": "GNU LibreDWG is a free library to handle DWG/DXF files",
"main": "index.js",
"repository": "git://fr-an-k/libredwg.git",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's just a test through my fork and reservation of the library name, of course I will transfer ownership if desired. I just need auto updates in my production environment.

Copy link
Contributor

@rurban rurban Dec 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a valid Url mostly. The domain is missing

@rurban rurban self-assigned this Dec 10, 2023
@rurban rurban added enhancement New feature or request cla_needed Waiting for the Copyright assignment labels Dec 10, 2023
@rurban
Copy link
Contributor

rurban commented Dec 10, 2023

I don't like the libconvert-only flag, convert.c is wasm-only. Therefore it should be moved to bindings/js

@fr-an-k
Copy link
Contributor Author

fr-an-k commented Dec 10, 2023

I'll try to make it a separate target instead of a flag, but I'm not sure if that can work.

It's not wasm only, it's very useful for anyone who just needs file conversion.
It does one single thing well, with common parameter types, the structs don't need to be ported, the binding itself doesn't need to change as formats are added.
It's the functionality that LibreDWG offers through CLI, so it makes sense to have it as a readymade module.

Later it could for instance be extended to add/remove/update individual JSON/DXF features quickly, as a string based version of LibreDWG. The normal LibreDWG API is not portable to higher languages by itself. The majority of programmers are currently not able to utilize LibreDWG at all.

It doesn't need maintenance and I believe it shouldn't be put in a separate repository.

WASM is also useful separate from javascript, for instance because it's sandboxed and therefore easy to accept in a strictly regulated enterprise.

I'm just combining it all in one PR to make them work together.

@rurban
Copy link
Contributor

rurban commented Dec 11, 2023

The size_t printf probe needs to be spezialized for emscripten also

@rurban
Copy link
Contributor

rurban commented Dec 11, 2023

I'll try to make it a separate target instead of a flag, but I'm not sure if that can work.

You just need to make the src/libredwg.lo, and the bindings/convert.lo and link them together. No need for a configure/cmake flag.

It's an abstraction of our programs binaries, useful for modules. But we cannot violate the namespaces this way (read/write without dwg_ prefixes), only with bindings.

It doesn't need maintenance and I believe it shouldn't be put in a separate repository.

Sure.

I'm just combining it all in one PR to make them work together.

Yes, please squash it.

@fr-an-k fr-an-k closed this Dec 16, 2023
@rurban
Copy link
Contributor

rurban commented Dec 16, 2023

No need to close. Just force push please

@rurban rurban reopened this Dec 16, 2023
@qwuip789
Copy link

qwuip789 commented Jan 3, 2025

emconfigure: error: './configure --disable-bindings --disable-shared' failed (returned 1)
make: make
make: *** No targets specified and no makefile found. Stop.
emmake: error: 'make' failed (returned 2)

@qwuip789
Copy link

qwuip789 commented Jan 3, 2025

configure: error: cannot find a suitable modifier
emconfigure: error: './configure --enable-libconvert-only --disable-bindings --disable-shared' failed (returned 1)
make: make
make: *** No targets specified and no makefile found. Stop.
emmake: error: 'make' failed (returned 2)

@qwuip789
Copy link

qwuip789 commented Jan 3, 2025

./common.h:367:5: error: 'HAVE_FUNC_ATTRIBUTE_ALIGNED' is not defined, evaluates to 0 [-Werror,-Wundef]
367 | #if HAVE_FUNC_ATTRIBUTE_ALIGNED
| ^
dwg.c:120:18: error: format specifies type 'unsigned int' but the argument has type 'size_t' (aka 'unsigned long') [-Werror,-Wformat]
118 | LOG_ERROR ("Could not read file (%" PRIuSIZE " out of %" PRIuSIZE
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
119 | "): %s\n",
| ~~~~~~~~~~
120 | size, dat->size, filename)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~

@qwuip789
Copy link

qwuip789 commented Jan 3, 2025

libtool: error: '../src/libredwg.la' is not a valid libtool archive
make[2]: *** [Makefile:706: dwg2dxf] Error 1
make[2]: *** Waiting for unfinished jobs....
libtool: error: '../src/libredwg.la' is not a valid libtool archive
make[2]: *** [Makefile:726: dwgread] Error 1
libtool: error: '../src/libredwg.la' is not a valid libtool archive
make[2]: *** [Makefile:714: dwgbmp] Error 1
libtool: error: '../src/libredwg.la' is not a valid libtool archive
make[2]: *** [Makefile:722: dwglayers] Error 1
libtool: error: '../src/libredwg.la' is not a valid libtool archive
make[2]: *** [Makefile:702: dwg2SVG] Error 1
libtool: error: '../src/libredwg.la' is not a valid libtool archive
make[2]: *** [Makefile:730: dwgrewrite] Error 1
libtool: error: '../src/libredwg.la' is not a valid libtool archive
make[2]: *** [Makefile:734: dwgwrite] Error 1
libtool: error: '../src/libredwg.la' is not a valid libtool archive
make[2]: *** [Makefile:742: dxfwrite] Error 1
libtool: error: '../src/libredwg.la' is not a valid libtool archive
make[2]: *** [Makefile:738: dxf2dwg] Error 1
make[1]: *** [Makefile:709: all-recursive] Error 1
make: *** [Makefile:588: all] Error 2
emmake: error: 'make -j -s WARN_CFLAGS=-Wno-error' failed (returned 2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla_needed Waiting for the Copyright assignment enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants