Skip to content

Commit

Permalink
Merge pull request #17 from jserv/sourcetree-reorg
Browse files Browse the repository at this point in the history
Source tree re-organization
  • Loading branch information
WEI, CHEN committed Mar 19, 2018
2 parents bec1a28 + f60e638 commit 8c0a832
Show file tree
Hide file tree
Showing 19 changed files with 33 additions and 34 deletions.
37 changes: 18 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@ endif
TESTS = \
trinary \
curl \
pow_sse
pow_sse \
multi_pow

ifneq ("$(DISABLE_GPU)","1")
TESTS += \
pow_cl
endif

TESTS := $(addprefix $(OUT)/test_, $(TESTS))
TESTS := $(addprefix $(OUT)/test-, $(TESTS))

LIBS = libdcurl.so
LIBS := $(addprefix $(OUT)/, $(LIBS))
Expand All @@ -45,9 +46,9 @@ all: $(TESTS) $(LIBS)
.DEFAULT_GOAL := all

OBJS = \
hash/curl.o \
curl.o \
constants.o \
trinary/trinary.o \
trinary.o \
dcurl.o \
pow_sse.o

Expand All @@ -65,39 +66,37 @@ endif
OBJS := $(addprefix $(OUT)/, $(OBJS))
deps := $(OBJS:%.o=%.o.d)

SUBDIRS = \
hash \
trinary \
jni
SHELL_HACK := $(shell mkdir -p $(OUT))
SHELL_HACK := $(shell mkdir -p $(addprefix $(OUT)/,$(SUBDIRS)))
SHELL_HACK := $(shell mkdir -p $(addprefix $(OUT)/,jni))

$(OUT)/test_%.o: test/test_%.c
$(OUT)/test-%.o: tests/test-%.c
$(VECHO) " CC\t$@\n"
$(Q)$(CC) -o $@ $(CFLAGS) -c -MMD -MF $@.d $<
$(Q)$(CC) -o $@ $(CFLAGS) -I src -c -MMD -MF $@.d $<

$(OUT)/trinary/%.o: $(SRC)/trinary/%.c
$(OUT)/hash/%.o: $(SRC)/hash/%.c
$(OUT)/%.o: $(SRC)/%.c
$(VECHO) " CC\t$@\n"
$(Q)$(CC) -o $@ $(CFLAGS) -c -MMD -MF $@.d $<

$(OUT)/test_%: $(OUT)/test_%.o $(OBJS)
$(OUT)/test-%: $(OUT)/test-%.o $(OBJS)
$(VECHO) " LD\t$@\n"
$(Q)$(CC) -o $@ $^ $(LDFLAGS)

$(OUT)/libdcurl.so: $(OBJS)
$(VECHO) " LD\t$@\n"
$(Q)$(CC) -shared -o $@ $^ $(LDFLAGS)

test_multi_pow: test/test_multi_pow.py $(OUT)/libdcurl.so
$(Q)$(PRINTF) "*** Validating $< ***\n"
$(Q)python3 $< $(PYFLAGS) && $(PRINTF) "\t$(PASS_COLOR)[ Verified ]$(NO_COLOR)\n"
# FIXME: script "tests/test-multi_pow.py" depends on PyIOTA package, and we
# have to check in advance, otherwise python3 would complain as following:
# ModuleNotFoundError: No module named 'iota'
$(OUT)/test-multi_pow: tests/test-multi_pow.py $(OUT)/libdcurl.so
@echo "#!/usr/bin/env python3" > $@
@cat $< >> $@
@chmod +x $@

$(OUT)/test_%.done: $(OUT)/test_%
$(OUT)/test-%.done: $(OUT)/test-%
$(Q)$(PRINTF) "*** Validating $< ***\n"
$(Q)./$< && $(PRINTF) "\t$(PASS_COLOR)[ Verified ]$(NO_COLOR)\n"
check: $(addsuffix .done, $(TESTS)) test_multi_pow
check: $(addsuffix .done, $(TESTS))

clean:
$(RM) -r $(OUT)
Expand Down
2 changes: 1 addition & 1 deletion jni/iri-pearldiver-exlib.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "iri-pearldiver-exlib.h"
#include <jni.h>
#include "../src/dcurl.h"
#include "../src/trinary/trinary.h"
#include "../src/trinary.h"
#include <stdint.h>

static int8_t *int_to_char_array(jint *arr, int size)
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/hash/curl.h → src/curl.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef CURL_H_
#define CURL_H_

#include "../trinary/trinary.h"
#include "trinary.h"

#define HASH_LENGTH 243
#define STATE_LENGTH 3 * HASH_LENGTH
Expand Down
2 changes: 1 addition & 1 deletion src/dcurl.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <unistd.h>
#include "pow_cl.h"
#include "pow_sse.h"
#include "trinary/trinary.h"
#include "trinary.h"

/* number of task that CPU can execute concurrently */
static int MAX_CPU_THREAD = -1;
Expand Down
2 changes: 1 addition & 1 deletion src/dcurl.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef DCURL_H_
#define DCURL_H_

#include "trinary/trinary.h"
#include "trinary.h"

int dcurl_init(int max_cpu_thread, int max_gpu_thread);
void dcurl_destroy();
Expand Down
2 changes: 1 addition & 1 deletion src/pow_cl.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "./hash/curl.h"
#include "curl.h"
#include "clcontext.h"
#include "constants.h"

Expand Down
2 changes: 1 addition & 1 deletion src/pow_cl.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef POW_CL_H_
#define POW_CL_H_

#include "./trinary/trinary.h"
#include "trinary.h"

int8_t *PowCL(int8_t *trytes, int mwm, int index);
int pwork_ctx_init(int context_size);
Expand Down
2 changes: 1 addition & 1 deletion src/pow_sse.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <pthread.h>
#include <stdio.h>
#include <string.h>
#include "./hash/curl.h"
#include "curl.h"
#include "constants.h"
#include <stdint.h>

Expand Down
2 changes: 1 addition & 1 deletion src/pow_sse.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef POW_SSE_H_
#define POW_SSE_H_

#include "./trinary/trinary.h"
#include "trinary.h"
#include <stdint.h>

typedef struct _pwork_struct Pwork_struct;
Expand Down
4 changes: 2 additions & 2 deletions src/trinary/trinary.c → src/trinary.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

#include <stdint.h>
#include "trinary.h"
#include "../constants.h"
#include "../hash/curl.h"
#include "constants.h"
#include "curl.h"

static int8_t TrytesToTritsMappings[][3] = {
{0, 0, 0}, {1, 0, 0}, {-1, 1, 0}, {0, 1, 0}, {1, 1, 0}, {-1, -1, 1},
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions test/common.h → tests/common.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#ifndef TEST_COMMON_H
#define TEST_COMMON_H

#include "../src/hash/curl.h"
#include "../src/trinary/trinary.h"
#include "curl.h"
#include "trinary.h"

/* FIXME: conditional inclusion of architecture-specific headers */
#include "../src/pow_sse.h"
#include "pow_sse.h"

#if defined(ENABLE_OPENCL)
#include "../src/pow_cl.h"
#include "pow_cl.h"
#endif

#include <stdlib.h>
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion test/test_multi_pow.py → tests/test-multi_pow.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from iota import TryteString
from iota.crypto import Curl

TRYTES_LIST_PATH = "./test/trytes.txt"
TRYTES_LIST_PATH = "./tests/trytes.txt"
DCURL_PATH = "./build/libdcurl.so"
NUM_TRYTES = 10

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 8c0a832

Please sign in to comment.