openscd / xmlvalidate.js

Validate XML Schema in the browser using libxml2
Apache License 2.0
4 stars 6 forks source link

Updated version #3

Open vegarringdal opened 2 years ago

vegarringdal commented 2 years ago

I tried to make new version of a updated version of libxml2 Did not go well, making old version was ok. but looks like libxml2 have changed.

I just tried to manually add the xmlvalidate.c to libxml2_la_SOURCES in the makefile.am. But no xmlvalidate.o gets generated.

Figured I could ask if you see what is needed, so I get a better start.

vegarringdal commented 2 years ago

Think i actually go it working...

Hint to myself for later, if validation works and I need to clean this up..

post.js -> rename addOnPreMain to addOnInit

emmake.sh (commented the path and updated exported functions

#! /bin/sh

cp xmlvalidate.c libxml2

cd libxml2

#patch -N < ../Makefile.am.patch
[ -f ./Makefile ] || emconfigure ./autogen.sh --with-minimum --with-schemas --disable-shared
emmake make

OBJECTS="SAX.o entities.o encoding.o error.o parserInternals.o  \
        parser.o tree.o hash.o list.o xmlIO.o xmlmemory.o uri.o  \
        valid.o xlink.o HTMLparser.o HTMLtree.o debugXML.o xpath.o  \
        xpointer.o xinclude.o nanohttp.o nanoftp.o \
        catalog.o globals.o threads.o c14n.o xmlstring.o buf.o \
        xmlregexp.o xmlschemas.o xmlschemastypes.o xmlunicode.o \
        xmlreader.o relaxng.o dict.o SAX2.o \
        xmlwriter.o legacy.o chvalid.o pattern.o xmlsave.o \
        xmlmodule.o schematron.o xzlib.o"

emcc -Os xmlvalidate.o $OBJECTS -o xmlvalidate.js -s ALLOW_MEMORY_GROWTH=1 -s EXPORTED_FUNCTIONS='["_validate", "_init", "_malloc", "_free"]' -s EXPORTED_RUNTIME_METHODS='["cwrap"]' -s 'ENVIRONMENT=worker' --pre-js ../pre.js --post-js ../post.js

mv xmlvalidate.wasm xmlvalidate.js ../dist
cd ..

int the makefile.am of newest libxml2 I added this to xmlCatalog?sources

xmlcatalog_SOURCES=xmlcatalog.c buf.c chvalid.c dict.c entities.c encoding.c error.c xmlmodule.c \
             globals.c hash.c list.c parser.c parserInternals.c relaxng.c xmlwriter.c legacy.c pattern.c xmlsave.c schematron.c xzlib.c \
             SAX2.c threads.c tree.c uri.c valid.c xmlIO.c xmlschemas.c xmlschemastypes.c xmlunicode.c xmlreader.c \
             xmlmemory.c xmlstring.c xmlvalidate.c SAX.c xlink.c HTMLparser.c HTMLtree.c debugXML.c xpath.c xpointer.c xinclude.c nanohttp.c nanoftp.c catalog.c c14n.c xmlregexp.c

feel free to tell me what I could do better :smile: