From 0803ed177abd93e124a348bdaa65822a6be85cd1 Mon Sep 17 00:00:00 2001 From: Abdulaziz Ghuloum Date: Fri, 13 Sep 2024 08:37:42 +0300 Subject: [PATCH 01/10] Added docker file for portable building with no ffmpeg support --- Dockerfile | 18 ++++++++++++++++++ Makefile | 7 ++++++- runtests-mpeg.sh | 3 +++ runtests.sh | 1 - 4 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 Dockerfile create mode 100755 runtests-mpeg.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..3720157b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM ubuntu:24.04 + +RUN apt update -y +RUN apt install make bison g++ -y +RUN apt install libpng-dev -y +RUN apt install flex -y +RUN apt install libicu-dev -y + +RUN mkdir /context-free +WORKDIR /context-free +COPY Makefile . +COPY src-agg ./src-agg +COPY src-common ./src-common +COPY src-unix ./src-unix +COPY input ./input +RUN make +COPY ./runtests.sh . +RUN make test diff --git a/Makefile b/Makefile index 4d18c351..b3384178 100644 --- a/Makefile +++ b/Makefile @@ -78,6 +78,8 @@ else LIBS += stdc++ atomic icui18n icuuc icudata endif + + # # FFmpeg support # @@ -184,10 +186,13 @@ uninstall: # Tests # -.PHONY: test check +.PHONY: test test-mpeg check test: cfdg ./runtests.sh +test-mpeg: cfdg + ./runtests-mpeg.sh + check: cfdg ./runtests.sh diff --git a/runtests-mpeg.sh b/runtests-mpeg.sh new file mode 100755 index 00000000..73ba75ca --- /dev/null +++ b/runtests-mpeg.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +./cfdg -a150 -s640x480 --quicktime -vffgh input/mtree.cfdg output/mtree.mpeg diff --git a/runtests.sh b/runtests.sh index 92934b7a..2dbe90dc 100755 --- a/runtests.sh +++ b/runtests.sh @@ -12,5 +12,4 @@ do break fi done -./cfdg -a150 -s640x480 --quicktime -vffgh input/mtree.cfdg output/mtree.mpeg From 53ac04d00ba9dd143fdcaeab43e5deb57355024e Mon Sep 17 00:00:00 2001 From: Abdulaziz Ghuloum Date: Fri, 13 Sep 2024 08:48:58 +0300 Subject: [PATCH 02/10] cleaned up Dockerfile --- Dockerfile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3720157b..fa8e2b6a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,8 @@ FROM ubuntu:24.04 RUN apt update -y -RUN apt install make bison g++ -y -RUN apt install libpng-dev -y -RUN apt install flex -y -RUN apt install libicu-dev -y +RUN apt upgrade -y +RUN apt install flex bison g++ make libpng-dev libicu-dev -y RUN mkdir /context-free WORKDIR /context-free From 107c0213475908dd1996632ab7b36736ffde9416 Mon Sep 17 00:00:00 2001 From: Abdulaziz Ghuloum Date: Sun, 15 Sep 2024 00:03:40 +0300 Subject: [PATCH 03/10] WIP web assembly support, FS access not implemented --- Makefile | 25 ++++++++++++++++++++++--- Wasm.Dockerfile | 30 ++++++++++++++++++++++++++++++ src-unix/posixSystem.cpp | 31 ++++++++++++++++++++++++------- 3 files changed, 76 insertions(+), 10 deletions(-) create mode 100644 Wasm.Dockerfile diff --git a/Makefile b/Makefile index b3384178..f08fecaf 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,6 @@ all: cfdg - # # Dirs # @@ -20,6 +19,7 @@ vpath %.cfdg input INC_DIRS = $(COMMON_DIR) $(UNIX_DIR) $(DERIVED_DIR) $(COMMON_DIR)/agg-extras INC_DIRS += /usr/local/include +#INC_DIRS += /usr/local/include /emsdk/local/include # # Installation directories @@ -35,6 +35,7 @@ MAN_DIR = $(DESTDIR)$(prefix)/share/man # LIB_DIRS = /usr/local/lib +#LIB_DIRS += /emsdk/local/lib # # Sources and Objects @@ -72,12 +73,16 @@ INPUT_SRCS = ciliasun_v2.cfdg demo1_v2.cfdg demo2_v2.cfdg funky_flower_v2.cfdg \ LIBS = png m # Use the first one for clang and the second one for gcc +ifeq ($(TARGET), wasm) + LIBS += c++ + #LIBS += c++ icui18n icuuc icudata +else ifeq ($(shell uname -s), Darwin) LIBS += c++ icucore else LIBS += stdc++ atomic icui18n icuuc icudata endif - +endif # @@ -116,6 +121,10 @@ DEPS = $(patsubst %.o,%.d,$(OBJS)) LINKFLAGS += $(patsubst %,-L%,$(LIB_DIRS)) LINKFLAGS += $(patsubst %,-l%,$(LIBS)) LINKFLAGS += -fexceptions +ifeq ($(TARGET), wasm) + LINKFLAGS += -s USE_LIBPNG=1 -s USE_ICU=1 + #LINKFLAGS += -s ASSERTIONS=2 -s EXCEPTION_DEBUG=1 -s DYLINK_DEBUG=1 -s FS_DEBUG=1 -s LIBRARY_DEBUG=1 -s SYSCALL_DEBUG=1 +endif deps: $(OBJ_DIR) $(DEPS) @@ -134,9 +143,15 @@ $(OBJS): $(OBJ_DIR)/Sentry # # Under Cygwin replace strip $@ with strip $@.exe +ifeq ($(TARGET), wasm) +STRIP = echo +else +STRIP = strip +endif + cfdg: $(OBJS) $(LINK.o) $^ $(LINKFLAGS) -o $@ - strip $@ + $(STRIP) $@ # @@ -213,6 +228,10 @@ ifeq ($(shell uname -s), Darwin) # LDFLAGS += -framework CoreFoundation -framework CoreVideo -framework CoreMedia -framework VideoToolbox endif +ifeq ($(TARGET), wasm) +CXXFLAGS += -DNOSYSCTL=1 -DNONORMALIZE=1 +endif + $(OBJ_DIR)/%.o : %.cpp $(COMPILE.cpp) $(OUTPUT_OPTION) $< diff --git a/Wasm.Dockerfile b/Wasm.Dockerfile new file mode 100644 index 00000000..9ef60d0b --- /dev/null +++ b/Wasm.Dockerfile @@ -0,0 +1,30 @@ +FROM ubuntu:24.04 + +RUN apt update -y +RUN apt upgrade -y +RUN apt install git -y +RUN git clone --depth=1 https://github.com/emscripten-core/emsdk.git +WORKDIR /emsdk +RUN apt install python3 -y +RUN apt install xz-utils -y +RUN ./emsdk install latest +RUN ./emsdk activate latest +ENV EMSDK=/emsdk +ENV PATH="/emsdk:/emsdk/upstream/emscripten:/emsdk/node/18.20.3_64bit/bin:${PATH}" +RUN echo 'int main(){return 0;}' > hello.cpp && em++ -s USE_LIBPNG=1 -s USE_ICU=1 hello.cpp && rm a.out.wasm a.out.js + +RUN apt install flex bison make g++ vim -y + +RUN cp /usr/include/FlexLexer.h /usr/local/include + +RUN mkdir /context-free +WORKDIR /context-free +COPY Makefile . +COPY src-agg ./src-agg +COPY src-common ./src-common +COPY src-unix ./src-unix +COPY input ./input +RUN TARGET=wasm emmake make +RUN (echo '#!/usr/bin/env node\n' && cat cfdg) > cfdg.new && mv cfdg.new cfdg && chmod 755 cfdg +COPY ./runtests.sh . +RUN make test diff --git a/src-unix/posixSystem.cpp b/src-unix/posixSystem.cpp index bb9bf971..0b083c72 100644 --- a/src-unix/posixSystem.cpp +++ b/src-unix/posixSystem.cpp @@ -36,6 +36,9 @@ #define UCHAR_TYPE char16_t #include #include +#include +#include // ICU header for UnicodeString + #include #include @@ -45,6 +48,7 @@ #include #include +#ifndef NOSYSCTL #if defined(__GNU__) || (defined(__ILP32__) && defined(__x86_64__)) #define NOSYSCTL #else @@ -52,6 +56,7 @@ #include #endif #endif +#endif #include #include #include @@ -219,6 +224,17 @@ PosixSystem::~PosixSystem() ucnv_close(mConverter); } +#ifdef NONORMALIZE +std::wstring +PosixSystem::normalize(const std::string& u8name) { + icu::UnicodeString ustr = icu::UnicodeString::fromUTF8(icu::StringPiece(u8name.c_str())); + std::wstring wstr(ustr.length(), L' '); + for (int32_t i = 0; i < ustr.length(); ++i) { + wstr[i] = ustr.charAt(i); + } + return wstr; +} +#else std::wstring PosixSystem::normalize(const std::string& u8name) { @@ -226,13 +242,14 @@ PosixSystem::normalize(const std::string& u8name) UErrorCode status = U_ZERO_ERROR; if (!mConverter) mConverter = ucnv_open("utf-8", &status); - if (!mNormalizer && U_SUCCESS(status)) + if (U_FAILURE(status)) { + catastrophicError("No Converter"); + } + if (!mNormalizer) mNormalizer = unorm2_getNFKCInstance(&status); - if (!mConverter || !mNormalizer) { - if (!mErrorReported) - catastrophicError("String conversion initialization error"); - mErrorReported = true; - return std::wstring(); + if (U_FAILURE(status)) { + std::cerr << "Error getting NFKC normalizer: " << u_errorName(status) << std::endl; + catastrophicError("No Normalizer"); } // Convert from utf-8 to utf-16 @@ -273,4 +290,4 @@ PosixSystem::normalize(const std::string& u8name) } return ret; } - +#endif From 9a2c004eb089c5c901f53eea55c93b099075718f Mon Sep 17 00:00:00 2001 From: Abdulaziz Ghuloum Date: Sun, 15 Sep 2024 02:34:26 +0300 Subject: [PATCH 04/10] taking control of main code and module definition --- Makefile | 2 +- Wasm.Dockerfile | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index f08fecaf..71be6fdd 100644 --- a/Makefile +++ b/Makefile @@ -122,7 +122,7 @@ LINKFLAGS += $(patsubst %,-L%,$(LIB_DIRS)) LINKFLAGS += $(patsubst %,-l%,$(LIBS)) LINKFLAGS += -fexceptions ifeq ($(TARGET), wasm) - LINKFLAGS += -s USE_LIBPNG=1 -s USE_ICU=1 + LINKFLAGS += -s USE_LIBPNG=1 -s USE_ICU=1 -s INVOKE_RUN=0 -s EXPORTED_RUNTIME_METHODS=callMain #LINKFLAGS += -s ASSERTIONS=2 -s EXCEPTION_DEBUG=1 -s DYLINK_DEBUG=1 -s FS_DEBUG=1 -s LIBRARY_DEBUG=1 -s SYSCALL_DEBUG=1 endif diff --git a/Wasm.Dockerfile b/Wasm.Dockerfile index 9ef60d0b..4d1bfc4a 100644 --- a/Wasm.Dockerfile +++ b/Wasm.Dockerfile @@ -25,6 +25,8 @@ COPY src-common ./src-common COPY src-unix ./src-unix COPY input ./input RUN TARGET=wasm emmake make -RUN (echo '#!/usr/bin/env node\n' && cat cfdg) > cfdg.new && mv cfdg.new cfdg && chmod 755 cfdg +RUN mv cfdg cfdg.js +COPY src-js/cfdg cfdg +RUN touch cfdg # avoid make recompiling stuff COPY ./runtests.sh . RUN make test From f3ffa6c3bc5bbbb0ec50accfdabb75f2f28a1ce9 Mon Sep 17 00:00:00 2001 From: Abdulaziz Ghuloum Date: Sun, 15 Sep 2024 02:40:29 +0300 Subject: [PATCH 05/10] renamed/added missing main.js file --- Wasm.Dockerfile | 2 +- src-js/main.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100755 src-js/main.js diff --git a/Wasm.Dockerfile b/Wasm.Dockerfile index 4d1bfc4a..fc306cbd 100644 --- a/Wasm.Dockerfile +++ b/Wasm.Dockerfile @@ -26,7 +26,7 @@ COPY src-unix ./src-unix COPY input ./input RUN TARGET=wasm emmake make RUN mv cfdg cfdg.js -COPY src-js/cfdg cfdg +COPY src-js/main.js cfdg RUN touch cfdg # avoid make recompiling stuff COPY ./runtests.sh . RUN make test diff --git a/src-js/main.js b/src-js/main.js new file mode 100755 index 00000000..776bfa52 --- /dev/null +++ b/src-js/main.js @@ -0,0 +1,8 @@ +#!/usr/bin/env node + +var cfdg = require('./cfdg.js'); +cfdg.onRuntimeInitialized = () => { + var [_node, _script, ...args] = [...process.argv]; + cfdg.callMain(args); +}; + From db52bd354b60650853bc0063848d5ce92abdd73f Mon Sep 17 00:00:00 2001 From: Abdulaziz Ghuloum Date: Sun, 15 Sep 2024 07:34:45 +0300 Subject: [PATCH 06/10] most tests running, 3 failing --- Makefile | 8 ++++---- Wasm.Dockerfile | 5 ++++- runtests.sh | 3 +-- src-js/main.js | 7 +++++++ 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 71be6fdd..4c11ed6d 100644 --- a/Makefile +++ b/Makefile @@ -122,7 +122,7 @@ LINKFLAGS += $(patsubst %,-L%,$(LIB_DIRS)) LINKFLAGS += $(patsubst %,-l%,$(LIBS)) LINKFLAGS += -fexceptions ifeq ($(TARGET), wasm) - LINKFLAGS += -s USE_LIBPNG=1 -s USE_ICU=1 -s INVOKE_RUN=0 -s EXPORTED_RUNTIME_METHODS=callMain + LINKFLAGS += -s ASSERTIONS=2 -s EXCEPTION_DEBUG=1 -s USE_LIBPNG=1 -s USE_ICU=1 -s INVOKE_RUN=0 -s EXPORTED_RUNTIME_METHODS=callMain,FS -lnodefs.js -lnoderawfs.js -g -gsource-map -s ALLOW_MEMORY_GROWTH=1 -s STACK_SIZE=104857600 #LINKFLAGS += -s ASSERTIONS=2 -s EXCEPTION_DEBUG=1 -s DYLINK_DEBUG=1 -s FS_DEBUG=1 -s LIBRARY_DEBUG=1 -s SYSCALL_DEBUG=1 endif @@ -216,9 +216,9 @@ check: cfdg # CXXFLAGS += $(patsubst %,-I%,$(INC_DIRS)) -CXXFLAGS += -O2 -Wall -Wextra -Wno-parentheses -std=c++17 -CXXFLAGS += -g -D_GLIBCXX_USE_C99_MATH=1 -CPPFLAGS += -DNDEBUG +CXXFLAGS += -Wall -Wextra -Wno-parentheses -std=c++17 +CXXFLAGS += -g -gsource-map -D_GLIBCXX_USE_C99_MATH=1 +#CPPFLAGS += -DNDEBUG # Add this for clang ifeq ($(shell uname -s), Darwin) diff --git a/Wasm.Dockerfile b/Wasm.Dockerfile index fc306cbd..b2978091 100644 --- a/Wasm.Dockerfile +++ b/Wasm.Dockerfile @@ -23,10 +23,13 @@ COPY Makefile . COPY src-agg ./src-agg COPY src-common ./src-common COPY src-unix ./src-unix -COPY input ./input +RUN mkdir ./input +COPY ./input/*.cfdg ./input RUN TARGET=wasm emmake make RUN mv cfdg cfdg.js COPY src-js/main.js cfdg RUN touch cfdg # avoid make recompiling stuff +COPY ./input/*.SKIP ./input +COPY ./input/tests ./input/tests COPY ./runtests.sh . RUN make test diff --git a/runtests.sh b/runtests.sh index 2dbe90dc..a42b431d 100755 --- a/runtests.sh +++ b/runtests.sh @@ -1,9 +1,8 @@ #!/bin/sh - mkdir output for file in input/tests/*.cfdg input/*.cfdg do - ./cfdg -qP "$file" output/test.png + ./cfdg -P "$file" output/test.png if [ $? -eq 0 ] then echo "$file pass" diff --git a/src-js/main.js b/src-js/main.js index 776bfa52..2611a7fc 100755 --- a/src-js/main.js +++ b/src-js/main.js @@ -1,7 +1,14 @@ #!/usr/bin/env node var cfdg = require('./cfdg.js'); +var fs = require('fs'); + cfdg.onRuntimeInitialized = () => { + // console.log(cfdg); + // console.log(cfdg.FS); + // console.log(process.cwd()); + // console.log(cfdg.FS.cwd()); + // console.log(cfdg.FS.readdir(cfdg.FS.cwd())); var [_node, _script, ...args] = [...process.argv]; cfdg.callMain(args); }; From 0e87521e8ec2fe57111b0540538014847961dead Mon Sep 17 00:00:00 2001 From: Abdulaziz Ghuloum Date: Mon, 16 Sep 2024 07:54:51 +0300 Subject: [PATCH 07/10] made a web-suitable compiled file --- Makefile | 2 +- Wasm.Dockerfile | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 4c11ed6d..30fbbbdc 100644 --- a/Makefile +++ b/Makefile @@ -122,7 +122,7 @@ LINKFLAGS += $(patsubst %,-L%,$(LIB_DIRS)) LINKFLAGS += $(patsubst %,-l%,$(LIBS)) LINKFLAGS += -fexceptions ifeq ($(TARGET), wasm) - LINKFLAGS += -s ASSERTIONS=2 -s EXCEPTION_DEBUG=1 -s USE_LIBPNG=1 -s USE_ICU=1 -s INVOKE_RUN=0 -s EXPORTED_RUNTIME_METHODS=callMain,FS -lnodefs.js -lnoderawfs.js -g -gsource-map -s ALLOW_MEMORY_GROWTH=1 -s STACK_SIZE=104857600 + LINKFLAGS += -s ASSERTIONS=2 -s EXCEPTION_DEBUG=1 -s USE_LIBPNG=1 -s USE_ICU=1 -s INVOKE_RUN=0 -s EXPORTED_RUNTIME_METHODS=callMain,FS -g -gsource-map -s ALLOW_MEMORY_GROWTH=1 -s STACK_SIZE=104857600 #LINKFLAGS += -s ASSERTIONS=2 -s EXCEPTION_DEBUG=1 -s DYLINK_DEBUG=1 -s FS_DEBUG=1 -s LIBRARY_DEBUG=1 -s SYSCALL_DEBUG=1 endif diff --git a/Wasm.Dockerfile b/Wasm.Dockerfile index b2978091..1fbb9ba7 100644 --- a/Wasm.Dockerfile +++ b/Wasm.Dockerfile @@ -25,7 +25,11 @@ COPY src-common ./src-common COPY src-unix ./src-unix RUN mkdir ./input COPY ./input/*.cfdg ./input -RUN TARGET=wasm emmake make + +RUN TARGET=wasm LINKFLAGS='-s ENVIRONMENT=web,worker -s WASM=1 -s SINGLE_FILE=1' emmake make +RUN mkdir web && mv cfdg cfdg.js && mv cfdg.* web + +RUN TARGET=wasm LINKFLAGS='-lnodefs.js -lnoderawfs.js' emmake make RUN mv cfdg cfdg.js COPY src-js/main.js cfdg RUN touch cfdg # avoid make recompiling stuff From 807e522c9e61d34afcc980b7cdf663a51aa61750 Mon Sep 17 00:00:00 2001 From: Abdulaziz Ghuloum Date: Thu, 19 Sep 2024 06:15:53 +0300 Subject: [PATCH 08/10] compiled code did not catch exceptions, fixed --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 30fbbbdc..31078969 100644 --- a/Makefile +++ b/Makefile @@ -122,7 +122,7 @@ LINKFLAGS += $(patsubst %,-L%,$(LIB_DIRS)) LINKFLAGS += $(patsubst %,-l%,$(LIBS)) LINKFLAGS += -fexceptions ifeq ($(TARGET), wasm) - LINKFLAGS += -s ASSERTIONS=2 -s EXCEPTION_DEBUG=1 -s USE_LIBPNG=1 -s USE_ICU=1 -s INVOKE_RUN=0 -s EXPORTED_RUNTIME_METHODS=callMain,FS -g -gsource-map -s ALLOW_MEMORY_GROWTH=1 -s STACK_SIZE=104857600 + LINKFLAGS += -fexceptions -s SUPPORT_LONGJMP=emscripten -s ASSERTIONS=2 -s USE_LIBPNG=1 -s USE_ICU=1 -s INVOKE_RUN=0 -s EXPORTED_RUNTIME_METHODS=callMain,FS -g -gsource-map -s ALLOW_MEMORY_GROWTH=1 -s STACK_SIZE=104857600 #LINKFLAGS += -s ASSERTIONS=2 -s EXCEPTION_DEBUG=1 -s DYLINK_DEBUG=1 -s FS_DEBUG=1 -s LIBRARY_DEBUG=1 -s SYSCALL_DEBUG=1 endif @@ -229,7 +229,7 @@ ifeq ($(shell uname -s), Darwin) endif ifeq ($(TARGET), wasm) -CXXFLAGS += -DNOSYSCTL=1 -DNONORMALIZE=1 +CXXFLAGS += -DNOSYSCTL=1 -DNONORMALIZE=1 -fexceptions -s SUPPORT_LONGJMP=emscripten endif $(OBJ_DIR)/%.o : %.cpp From d6acf4317ba6ee48eadade7b552561108474d6d8 Mon Sep 17 00:00:00 2001 From: Abdulaziz Ghuloum Date: Fri, 20 Sep 2024 10:43:49 +0300 Subject: [PATCH 09/10] debug build is now optional, with optimized build being the default --- Makefile | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 31078969..6ba82d34 100644 --- a/Makefile +++ b/Makefile @@ -122,8 +122,10 @@ LINKFLAGS += $(patsubst %,-L%,$(LIB_DIRS)) LINKFLAGS += $(patsubst %,-l%,$(LIBS)) LINKFLAGS += -fexceptions ifeq ($(TARGET), wasm) - LINKFLAGS += -fexceptions -s SUPPORT_LONGJMP=emscripten -s ASSERTIONS=2 -s USE_LIBPNG=1 -s USE_ICU=1 -s INVOKE_RUN=0 -s EXPORTED_RUNTIME_METHODS=callMain,FS -g -gsource-map -s ALLOW_MEMORY_GROWTH=1 -s STACK_SIZE=104857600 - #LINKFLAGS += -s ASSERTIONS=2 -s EXCEPTION_DEBUG=1 -s DYLINK_DEBUG=1 -s FS_DEBUG=1 -s LIBRARY_DEBUG=1 -s SYSCALL_DEBUG=1 +ifeq ($(WASM_DEBUG), 1) + LINKFLAGS += -s EXCEPTION_DEBUG=1 -s SYSCALL_DEBUG=1 -s FS_DEBUG=1 -s ASSERTIONS=2 -g -gsource-map +endif + LINKFLAGS += -fexceptions -s SUPPORT_LONGJMP=emscripten -s USE_LIBPNG=1 -s USE_ICU=1 -s INVOKE_RUN=0 -s EXPORTED_RUNTIME_METHODS=callMain,FS -s ALLOW_MEMORY_GROWTH=1 -s STACK_SIZE=104857600 endif deps: $(OBJ_DIR) $(DEPS) @@ -216,8 +218,8 @@ check: cfdg # CXXFLAGS += $(patsubst %,-I%,$(INC_DIRS)) -CXXFLAGS += -Wall -Wextra -Wno-parentheses -std=c++17 -CXXFLAGS += -g -gsource-map -D_GLIBCXX_USE_C99_MATH=1 +CXXFLAGS += -O2 -Wall -Wextra -Wno-parentheses -std=c++17 +CXXFLAGS += -D_GLIBCXX_USE_C99_MATH=1 #CPPFLAGS += -DNDEBUG # Add this for clang @@ -230,6 +232,9 @@ endif ifeq ($(TARGET), wasm) CXXFLAGS += -DNOSYSCTL=1 -DNONORMALIZE=1 -fexceptions -s SUPPORT_LONGJMP=emscripten +ifeq ($(WASM_DEBUG), 1) +CXXFLAGS += -g -gsource-map +endif endif $(OBJ_DIR)/%.o : %.cpp From 50f109ea749a87407bff97ab8b41d2755a3be635 Mon Sep 17 00:00:00 2001 From: Abdulaziz Ghuloum Date: Thu, 26 Sep 2024 23:18:22 +0300 Subject: [PATCH 10/10] added new sections to README --- README | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/README b/README index c613aaaa..bba64284 100644 --- a/README +++ b/README @@ -127,3 +127,38 @@ will install cfdg and the cfdg.1 man page in /usr/local. FFmpeg BUILD NOTES Check out README.ffmpeg for building ffmpeg and enabling ffmpeg support + +~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ +DOCKER BUILD NOTES + +You can build and run the Linux/Posix version of cfdg inside a docker container +by running the command: + + $ docker build . -f Dockerfile + +This will install the operating system and all the build tools (GCC, Make, etc) +inside an image, copy the cfdg files needed for the build, compile it, then run +the tests. Note that to use cfdg inside a container, you need to mount your +files/folders into the container then execute the cfdg command on the mounted +files. + +~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ +WEBASSEMBLY + +You can compile cfdg to wasm by running the command: + + $ docker build . -f Wasm.Dockerfile + +This will install the operating system and all the build tools (Emscripten and +friends), then build and test cfdg wasm scripts/libraries. + +At the end, the docker file will produce two artifacts: + +(1) The browser-suitable library: + /context-free/web/cfdg.js + +(2) NodeJS executable script: + /context-free/cfdg + +The executable script is used for running the tests. The web library is not +tested here.