diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 743b4eb..9d9e428 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,15 +11,27 @@ jobs: node-version-file: '.node-version' cache: 'npm' cache-dependency-path: 'package-lock.json' + - uses: mymindstorm/setup-emsdk@6ab9eb1bda2574c4ddb79809fc9247783eaf9021 # v14 + with: + version: 3.1.60 + actions-cache-folder: 'emsdk-cache' + - name: Poop out node info + run: which node && node --version && npm --version - name: Install apt deps run: sudo apt-get install clang-format ninja-build - name: Install npm deps run: npm ci + - name: pre-lib node info + run: which node && node --version && npm --version - name: Build library run: make lib + - name: post-lib node info + run: which node && node --version && npm --version - name: Typecheck run: make typecheck - name: Check formatting run: make checkformat + - name: Mode node info + run: which node && node --version && npm --version - name: Run tests run: make test diff --git a/Makefile b/Makefile index 3e2a81e..9fc0436 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,5 @@ include third_party_versions.mk -EMSDK_DIR=$(PWD)/third_party/emsdk/upstream/emscripten INSTALL_DIR=$(PWD)/install FALLBACK_INSTALL_DIR=$(INSTALL_DIR)/fallback @@ -40,6 +39,13 @@ typecheck: .PHONY: test test: third_party/tessdata_fast + SHELL=/bin/bash + echo "Current Shell: $$SHELL" + echo "PATH: $$PATH" + echo "Checking user permissions:" + id + which node + node --version node --test test/ocr-engine-test.js .PHONY: release @@ -47,17 +53,6 @@ release: clean lib typecheck test @which np || (echo "Install np from https://github.com/sindresorhus/np" && false) np minor -third_party/emsdk: third_party_versions.mk - mkdir -p third_party/emsdk - test -d $@/.git || git clone --depth 1 https://github.com/emscripten-core/emsdk.git $@ - cd $@ && git fetch origin $(EMSDK_COMMIT) && git checkout $(EMSDK_COMMIT) - touch $@ - -build/emsdk.uptodate: third_party/emsdk | build - third_party/emsdk/emsdk install latest - third_party/emsdk/emsdk activate latest - touch build/emsdk.uptodate - # Compile flags for Leptonica. These turn off support for various image formats to # reduce size. We don't need this since the browser includes this functionality. LEPTONICA_FLAGS=\ @@ -71,11 +66,11 @@ third_party/leptonica: third_party_versions.mk cd $@ && git fetch origin $(LEPTONICA_COMMIT) && git checkout $(LEPTONICA_COMMIT) touch $@ -build/leptonica.uptodate: third_party/leptonica build/emsdk.uptodate +build/leptonica.uptodate: third_party/leptonica mkdir -p build/leptonica - cd build/leptonica && $(EMSDK_DIR)/emcmake cmake -G Ninja ../../third_party/leptonica $(LEPTONICA_FLAGS) - cd build/leptonica && $(EMSDK_DIR)/emmake ninja - cd build/leptonica && $(EMSDK_DIR)/emmake ninja install + cd build/leptonica && emcmake cmake -G Ninja ../../third_party/leptonica $(LEPTONICA_FLAGS) + cd build/leptonica && emmake ninja + cd build/leptonica && emmake ninja install touch build/leptonica.uptodate # Additional preprocessor defines for Tesseract. @@ -126,16 +121,16 @@ third_party/tessdata_fast: build/tesseract.uptodate: build/leptonica.uptodate third_party/tesseract mkdir -p build/tesseract - (cd build/tesseract && $(EMSDK_DIR)/emcmake cmake -G Ninja ../../third_party/tesseract $(TESSERACT_FLAGS)) - (cd build/tesseract && $(EMSDK_DIR)/emmake ninja) - (cd build/tesseract && $(EMSDK_DIR)/emmake ninja install) + (cd build/tesseract && emcmake cmake -G Ninja ../../third_party/tesseract $(TESSERACT_FLAGS)) + (cd build/tesseract && emmake ninja) + (cd build/tesseract && emmake ninja install) touch build/tesseract.uptodate build/tesseract-fallback.uptodate: build/leptonica.uptodate third_party/tesseract mkdir -p build/tesseract-fallback - (cd build/tesseract-fallback && $(EMSDK_DIR)/emcmake cmake -G Ninja ../../third_party/tesseract $(TESSERACT_FALLBACK_FLAGS)) - (cd build/tesseract-fallback && $(EMSDK_DIR)/emmake ninja) - (cd build/tesseract-fallback && $(EMSDK_DIR)/emmake ninja install) + (cd build/tesseract-fallback && emcmake cmake -G Ninja ../../third_party/tesseract $(TESSERACT_FALLBACK_FLAGS)) + (cd build/tesseract-fallback && emmake ninja) + (cd build/tesseract-fallback && emmake ninja install) touch build/tesseract-fallback.uptodate # emcc flags. `-Os` minifies the JS wrapper and optimises WASM code size. @@ -161,7 +156,7 @@ EMCC_FLAGS =\ # Build main WASM binary for browsers that support WASM SIMD. build/tesseract-core.js build/tesseract-core.wasm: src/lib.cpp src/tesseract-init.js build/tesseract.uptodate - $(EMSDK_DIR)/emcc src/lib.cpp $(EMCC_FLAGS) \ + emcc src/lib.cpp $(EMCC_FLAGS) \ -I$(INSTALL_DIR)/include/ -L$(INSTALL_DIR)/lib/ -ltesseract -lleptonica -lembind \ -o build/tesseract-core.js cp src/tesseract-core.d.ts build/ @@ -169,7 +164,7 @@ build/tesseract-core.js build/tesseract-core.wasm: src/lib.cpp src/tesseract-ini # Build fallback WASM binary for browsers that don't support WASM SIMD. The JS # output from this build is not used. build/tesseract-core-fallback.js build/tesseract-core-fallback.wasm: src/lib.cpp src/tesseract-init.js build/tesseract-fallback.uptodate - $(EMSDK_DIR)/emcc src/lib.cpp $(EMCC_FLAGS) \ + emcc src/lib.cpp $(EMCC_FLAGS) \ -I$(INSTALL_DIR)/include/ -L$(FALLBACK_INSTALL_DIR)/lib/ -L$(INSTALL_DIR)/lib -ltesseract -lleptonica -lembind \ -o build/tesseract-core-fallback.js diff --git a/third_party_versions.mk b/third_party_versions.mk index 2615930..03cd942 100644 --- a/third_party_versions.mk +++ b/third_party_versions.mk @@ -1,6 +1,3 @@ -# v3.1.60 -EMSDK_COMMIT=ce74ca2b1c968f897150bdc55daa9e3c12a3fefc - # v1.84.1 LEPTONICA_COMMIT=7e803e73511fbd320f01314c141d35d2b8491dde