Skip to content
This repository has been archived by the owner on May 25, 2021. It is now read-only.

Add Windows binaries #22

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
13 changes: 12 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,23 @@ SSE2 := yes
TARGET ?= $(shell uname -s 2>/dev/null || echo unknown)
override TARGET := $(shell echo $(TARGET) | tr A-Z a-z)

JAVA_HOME ?= $(realpath $(dir $(realpath $(shell which java)))../)
JAVA_HOME ?= $(realpath $(dir $(realpath $(shell which javac)))../)

ifeq ($(TARGET), darwin)
DYLIB := dylib
LDFLAGS := -dynamiclib -Wl,-undefined -Wl,dynamic_lookup -Wl,-single_module
CFLAGS += -I $(JAVA_HOME)/Headers/
else ifeq ($(TARGET), win32)
DYLIB := dll
LDFLAGS := -shared
CC := i586-mingw32msvc-cc
SSE2 :=
CFLAGS += -I $(JAVA_HOME)/include -I $(JAVA_HOME)/include/$(TARGET) -DNO_HAVE_POSIX_MEMALIGN
else ifeq ($(TARGET), win64)
DYLIB := dll
LDFLAGS := -shared
CC := x86_64-w64-mingw32-gcc
CFLAGS += -I $(JAVA_HOME)/include -I $(JAVA_HOME)/include/$(TARGET) -DNO_HAVE_POSIX_MEMALIGN
else
DYLIB := so
LDFLAGS := -shared
Expand Down
7 changes: 7 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,10 @@ Building Native Implementation
A precompiled native library for Android 2.3 running on ARM is located in
src/android/resources/lib/arm5/libscrypt.so. If placed in an .apk file's
lib/armeabi directory it will be automatically loaded.

To build the Windows shared library, you need MinGW. On Ubuntu, this is:
* mingw32
* mingw32-binutils
* mingw32-runtime
* mingw-w64
* mingw-w64-tools
3 changes: 3 additions & 0 deletions src/main/c/crypto_scrypt-nosse.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@
#include "scrypt_platform.h"

#include <sys/types.h>

#ifdef HAVE_POSIX_MEMALIGN
#include <sys/mman.h>
#endif

#include <errno.h>
#include <stdint.h>
Expand Down
2 changes: 2 additions & 0 deletions src/main/c/crypto_scrypt-sse.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
#include "scrypt_platform.h"

#include <sys/types.h>
#ifdef HAVE_POSIX_MEMALIGN
#include <sys/mman.h>
#endif

#include <emmintrin.h>
#include <errno.h>
Expand Down
2 changes: 2 additions & 0 deletions src/main/include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
#define HAVE_MMAP 1

#ifndef __ANDROID__
#ifndef NO_HAVE_POSIX_MEMALIGN
#define HAVE_POSIX_MEMALIGN 1
#endif
#endif

#ifdef __ANDROID__
#include <sys/limits.h>
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/lambdaworks/jni/JarLibraryLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ private List<String> libCandidates(Platform platform, String name) {
candidates.add(sb + ".dylib");
candidates.add(sb + ".jnilib");
break;
case windows:
candidates.add(sb + ".dll");
break;
case linux:
case freebsd:
candidates.add(sb + ".so");
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/lambdaworks/jni/Platform.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public enum Arch {
}

public enum OS {
windows ("windows .*"),
darwin ("darwin|mac os x"),
freebsd("freebsd"),
linux ("linux");
Expand Down
Binary file added src/main/resources/lib/x86/windows/libscrypt.dll
Binary file not shown.
Binary file not shown.