Permalink
Browse files

emscripten support

  • Loading branch information...
aaalgo committed Aug 30, 2016
1 parent 77a3fc1 commit 612b5b60d480cfb049874c334ef1ef310ce28162
Showing with 43 additions and 0 deletions.
  1. +41 −0 Makefile.emscripten
  2. +2 −0 kgraph.cpp
@@ -0,0 +1,41 @@
CC=emcc
CXX=em++
OPT=-O3
VERSION=$(shell git describe --always)
BUILD_INFO=-DKGRAPH_VERSION=$(VERSION) -DKGRAPH_BUILD_ID=$(BUILD_ID) -DKGRAPH_BUILD_NUMBER=$(BUILD_NUMBER)
CXXFLAGS+=$(BUILD_INFO) -Wall -g -g4 -std=c++11 -I. $(OPENMP) $(OPT) $(ARCH)
LDFLAGS+=$(OPENMP) -static
LDLIBS+=-lboost_timer -lboost_chrono -lboost_system -lboost_program_options -lm
.SUFFIXES: .bc .js .html
.PHONY: all python clean release deps-ubuntu flann
COMMON=kgraph.o metric.o
HEADERS=kgraph.h kgraph-data.h
PROGS=resave.js index.js search.js test.js
PRELOAD=sift.data
EM_OPT=-s PRECISE_F32=1 -s ALLOW_MEMORY_GROWTH=1 -s DEMANGLE_SUPPORT=1
all: libkgraph.a $(PROGS) python $(EXTRA_PROGS)
echo $(BUILD_INFO)
%.js: %.bc
$(CXX) -O2 -o $@ $^ $(EM_OPT) #-s ALLOW_MEMORY_GROWTH=1
%.html: %.bc
$(CXX) -O2 -o $@ $^ $(EM_OPT) # --preload-file $(PRELOAD)
%.bc: %.cpp $(HEADERS) $(COMMON)
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $*.cpp $(COMMON) $(LDLIBS)
libkgraph.a: $(COMMON)
emar rvs $@ $^
%.o: %.cpp $(HEADERS)
$(CXX) $(CXXFLAGS) -c $*.cpp
clean:
rm -f $(PROGS) *.o
@@ -11,7 +11,9 @@
#define STRINGIFY_HELPER(x) #x
static char const *kgraph_version = STRINGIFY(KGRAPH_VERSION) "-" STRINGIFY(KGRAPH_BUILD_NUMBER) "," STRINGIFY(KGRAPH_BUILD_ID);
#ifdef _OPENMP
#include <omp.h>
#endif
#include <unordered_set>
#include <mutex>
#include <iostream>

0 comments on commit 612b5b6

Please sign in to comment.