Skip to content
Merged

ok #160

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,25 @@
CXX = /opt/homebrew/opt/llvm/bin/clang++
EMCC = emcc

# Extract version from package.json
VERSION := $(shell node -p "require('./js/package.json').version" 2>/dev/null || echo "3.8.0")

# Flags
CXXFLAGS = -std=c++20 -Wall -Wextra -pedantic -O3 -march=native -mtune=native
CXXFLAGS = -std=c++20 -Wall -Wextra -pedantic -O3 -march=native -mtune=native -DVERSION=\"$(VERSION)\"
#CXXFLAGS = -std=c++20 -Wall -Wextra -pedantic -O0 -fsanitize=address,undefined -march=native
#CXXFLAGS = -std=c++20 -Wall -Wextra -pedantic -O0 -g
CXXFLAGS += -isysroot $(shell xcrun --show-sdk-path)
CXXFLAGS += -fopenmp -I/opt/homebrew/opt/llvm/include
DEPFLAGS = -MMD -MF $(@:.o=.d)

LDFLAGS = -fopenmp -L/opt/homebrew/opt/llvm/lib -lz -lc++
LDFLAGS = -fopenmp -L/opt/homebrew/opt/llvm/lib -L/opt/homebrew/opt/llvm/lib/c++ -Wl,-rpath,/opt/homebrew/opt/llvm/lib/c++ -lz -lc++

# Emscripten Flags for WASM
# Include your new bridging funcs in EXPORTED_FUNCTIONS:
EMCCFLAGS = -O2 -s WASM=1 \
-DVERSION=\"$(VERSION)\" \
-s EXPORTED_FUNCTIONS="['_rainbowHash64','_rainbowHash128','_rainbowHash256','_rainstormHash64', '_rainstormHash128', '_rainstormHash256', '_rainstormHash512', 'stringToUTF8','UTF8ToString', 'lengthBytesUTF8','_malloc','_free','_wasmGetFileHeaderInfo','_wasmFree', '_wasmStreamEncryptBuffer', '_wasmStreamDecryptBuffer', '_wasmFreeBuffer', '_wasmCreateHMAC', '_wasmVerifyHMAC']" \
-s EXPORTED_RUNTIME_METHODS="['wasmExports','ccall','cwrap', 'getValue']" \
-s EXPORTED_RUNTIME_METHODS="['wasmExports','ccall','cwrap', 'getValue', 'HEAPU8', 'HEAPU32', 'HEAP32', 'UTF8ToString', 'stringToUTF8', 'lengthBytesUTF8']" \
-s WASM_BIGINT=1 \
-s ALLOW_MEMORY_GROWTH=1 \
-s USE_ZLIB=1 \
Expand Down Expand Up @@ -97,5 +101,7 @@ install: rainsum
clean:
rm -rf $(OBJDIR) $(BUILDDIR) rainsum \
$(WASMDIR) js/node_modules scripts/node_modules \
$(WASM_OUTPUT) $(JS_OUTPUT)
$(WASM_OUTPUT) $(JS_OUTPUT) \
test.log test-file.* *.rc *.rc.* \
docs/rain.html

2 changes: 1 addition & 1 deletion docs/rain.cjs

Large diffs are not rendered by default.

Binary file modified docs/rain.wasm
Binary file not shown.
3 changes: 3 additions & 0 deletions js/lib/api.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,9 @@ async function loadRain() {
rain = x.default;
rain.loaded = true;

// Note: HEAPU8, getValue, etc. should already be properties of the Module object
// after WASM initialization. The Emscripten-generated code makes them available.

const { cwrap } = rain;

// Wrap rainstormHash functions
Expand Down
4 changes: 2 additions & 2 deletions js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dosyago/rainsum",
"version": "3.7.2",
"version": "3.8.0",
"module": true,
"type": "module",
"description": "The fastest 128-bit and 256-bit hash, passes all tests, and under 140 source lines of code. API library and CLI tool in C++ and NodeJS/Wasm",
Expand Down
2 changes: 1 addition & 1 deletion js/wasm/rain.cjs

Large diffs are not rendered by default.

Binary file modified js/wasm/rain.wasm
Binary file not shown.
4 changes: 4 additions & 0 deletions scripts/testjs.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#!/usr/bin/env bash

wd="$(pwd)"
cd ../emsdk
source ./emsdk_env.sh
cd "$wd"
make clean && make && ./js/test.mjs
4 changes: 3 additions & 1 deletion src/tool.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once
#define VERSION "3.7.1"
#ifndef VERSION
#define VERSION "3.8.0"
#endif
#include <atomic> // for std::atomic
#include <iostream>
#include <array>
Expand Down