From e7be75731a4063ebc9e1008307073d7ff57dda51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Radek=20Hu=C5=A1ek?= <PitelVonSacek@gmail.com> Date: Wed, 9 Dec 2015 21:48:53 +0100 Subject: [PATCH] Clean up option definitions --- Makefile | 5 ++-- compileTimeOptions.h | 44 ++++------------------------------- fast-array.h | 1 + generateCompileTimeOptions.sh | 22 ++++++++++++++++++ group-connectivity.h | 2 +- 5 files changed, 32 insertions(+), 42 deletions(-) create mode 100755 generateCompileTimeOptions.sh diff --git a/Makefile b/Makefile index 27bc003..d1619e1 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,12 @@ default: groupConnectivity.so clean_obj -groupConnectivity.so: groupConnectivity.pyx group-connectivity.h setup.py compileTimeOptions.h rings.h fast-array.h parmap.py +groupConnectivity.so: groupConnectivity.pyx group-connectivity.h setup.py compileTimeOptions.h generateCompileTimeOptions.sh rings.h fast-array.h parmap.py + ./generateCompileTimeOptions.sh > options.h python setup.py build_ext cp build/lib*/groupConnectivity.so . clean_obj: - rm -f *.o groupConnectivity.cpp + rm -f *.o groupConnectivity.cpp options.h rm -rf build clean: clean_obj diff --git a/compileTimeOptions.h b/compileTimeOptions.h index 865d26f..5218ac0 100644 --- a/compileTimeOptions.h +++ b/compileTimeOptions.h @@ -1,50 +1,16 @@ -#ifndef __COMPILE_TIME_OPTIONS_H__ -#define __COMPILE_TIME_OPTIONS_H__ +#error "DON'T include directly" // bool; use vector<bool> instead of vector<size_t> for classes -#ifndef SAVE_MEMORY -#define SAVE_MEMORY 1 -#endif -#if SAVE_MEMORY -#pragma message "SAVE_MEMORY ON" -#else -#pragma message "SAVE_MEMORY off" -#endif +BOOL_OPTION(SAVE_MEMORY, 1) +BOOL_OPTION(OPTIMIZED_MAPPINGS, 1) -#ifndef OPTIMIZED_MAPPINGS -#define OPTIMIZED_MAPPINGS 1 -#endif -#if OPTIMIZED_MAPPINGS -#pragma message "OPTIMIZED_MAPPINGS ON" -#else -#pragma message "OPTIMIZED_MAPPINGS off" -#endif - - -#ifndef OPTIMIZE_COMBINE -#define OPTIMIZE_COMBINE 0 -#endif -#if OPTIMIZE_COMBINE -#pragma message "OPTIMIZE_COMBINE ON" -#else -#pragma message "OPTIMIZE_COMBINE off" -#endif - - -#ifndef USE_NEXT_FORB -#define USE_NEXT_FORB 1 -#endif -#if USE_NEXT_FORB -#pragma message "USE_NEXT_FORB ON" -#else -#pragma message "USE_NEXT_FORB off" -#endif +BOOL_OPTION(OPTIMIZE_COMBINE, 0) +BOOL_OPTION(USE_NEXT_FORB, 1) #ifndef MAX_EDGES #define MAX_EDGES 48 #endif -#endif diff --git a/fast-array.h b/fast-array.h index 1614691..32b45ff 100644 --- a/fast-array.h +++ b/fast-array.h @@ -2,6 +2,7 @@ #define __FAST_ARRAY_H__ #include "rings.h" +#include "options.h" template < typename Ring > struct Mapping { diff --git a/generateCompileTimeOptions.sh b/generateCompileTimeOptions.sh new file mode 100755 index 0000000..19c2de6 --- /dev/null +++ b/generateCompileTimeOptions.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +cat <<EOF +#ifndef __COMPILE_TIME_OPTIONS_H__ +#define __COMPILE_TIME_OPTIONS_H__ +EOF + +tail -n +2 compileTimeOptions.h | +sed -re 's/BOOL_OPTION\((.*), *(.*)\)/#ifndef \1\ +#define \1 \2\ +#endif\ +#if \1\ +#pragma message "\1 ON"\ +#else\ +#pragma message "\1 off"\ +#endif\ +/' + +cat <<EOF +#endif +EOF + diff --git a/group-connectivity.h b/group-connectivity.h index 1ad4100..110faf4 100644 --- a/group-connectivity.h +++ b/group-connectivity.h @@ -2,7 +2,7 @@ #define __GROUP_CONNECTIVITY_H__ #include <vector> -#include "compileTimeOptions.h" +#include "options.h" #include "rings.h" #include "fast-array.h" -- GitLab