Skip to content

Commit 5443662

Browse files
authored
Merge pull request #168 from mpsonntag/staticlink
Windows static link build LGTM
2 parents 60e42db + e689090 commit 5443662

File tree

8 files changed

+86
-47
lines changed

8 files changed

+86
-47
lines changed

+nix/Utils.m

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,16 @@
157157
error(err);
158158
end
159159

160-
nix.Utils.validFilter(filter, val);
160+
if (maxDepth < 0)
161+
err.identifier = 'NIXMX:InvalidArgument';
162+
err.message = 'Search depth must be positive integers or logicals.';
163+
error(err);
164+
end
161165

162-
% transform matlab to c++ style index
163-
md = nix.Utils.handleIndex(maxDepth);
166+
nix.Utils.validFilter(filter, val);
164167

165168
mxMethod = strcat(obj.alias, '::', mxMethodName);
166-
list = nix_mx(mxMethod, obj.nixhandle, md, uint8(filter), val);
169+
list = nix_mx(mxMethod, obj.nixhandle, maxDepth, uint8(filter), val);
167170
r = nix.Utils.createEntityArray(list, objConstructor);
168171
end
169172

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ tests/*.h5
1212
# library files
1313
*.dll
1414
*.mex*
15+
*.exe*

CMakeLists.txt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,17 @@ if(NOT WIN32)
1818
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O2")
1919
endif()
2020

21-
#packages
21+
# packages
2222

23-
find_package(Boost 1.49.0 REQUIRED)
23+
# Provide Boost lib
24+
set(Boost_USE_STATIC_LIBS ON)
25+
find_package(Boost 1.49.0 REQUIRED date_time regex program_options system filesystem)
2426
include_directories(${Boost_INCLUDE_DIR})
2527

28+
# Provide HDF5 lib
29+
set(HDF5_USE_STATIC_LIBRARIES ON)
30+
find_package (HDF5 REQUIRED COMPONENTS C)
31+
2632
# The computing environment
2733

2834
if($ENV{CI})
@@ -56,6 +62,7 @@ if(NOT CE_PACKAGE)
5662
Install GNU Octave (or MathWorks MATLAB).")
5763
endif()
5864

65+
set(NIX_USE_STATIC_LIBS ON)
5966
find_package(NIX REQUIRED)
6067

6168
include_directories(${CE_INCDIR} ${NIX_INCLUDE_DIR} "src" "src/utils")
@@ -71,7 +78,7 @@ endif()
7178

7279
add_library(nix_mx ${LIBTYPE} nix_mx.cc ${SOURCE_FILES} ${INCLUDE_FILES})
7380

74-
target_link_libraries(nix_mx ${CE_LIBRARIES} ${NIX_LIBRARIES})
81+
target_link_libraries(nix_mx ${CE_LIBRARIES} ${NIX_LIBRARIES} ${Boost_LIBRARIES} ${HDF5_LIBRARIES})
7582
set_target_properties(nix_mx PROPERTIES
7683
VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
7784
SOVERSION ${VERSION_ABI})
@@ -105,4 +112,6 @@ MESSAGE(STATUS "Computing environment")
105112
MESSAGE(STATUS " Package: ${CE_PACKAGE}")
106113
MESSAGE(STATUS " Version: ${CE_VERSION}")
107114
MESSAGE(STATUS " Module : ${CE_EXTENSION}")
115+
MESSAGE(STATUS " BOOST : ${Boost_LIBRARIES}")
116+
MESSAGE(STATUS " NIX : ${NIX_LIBRARIES}")
108117
MESSAGE(STATUS "=====================")

src/nixblock.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ namespace nixblock {
3838
nix::DataType dtype = nix::string_to_data_type(input.str(4));
3939
nix::NDSize size = input.ndsize(5);
4040

41-
nix::DataArray dt = block.createDataArray(name, type, dtype, size);
41+
nix::DataArray dt = block.createDataArray(name, type, dtype, size, nix::Compression::None);
4242
output.set(0, dt);
4343
}
4444

tests/TestBlock.m

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,23 +1125,23 @@
11251125
end
11261126

11271127
% find all
1128-
filtered = b.findSources(5);
1129-
assert(size(filtered, 1) == 10);
1130-
1131-
% find until level 4
11321128
filtered = b.findSources(4);
11331129
assert(size(filtered, 1) == 10);
11341130

11351131
% find until level 3
11361132
filtered = b.findSources(3);
1137-
assert(size(filtered, 1) == 6);
1133+
assert(size(filtered, 1) == 10);
11381134

11391135
% find until level 2
11401136
filtered = b.findSources(2);
1141-
assert(size(filtered, 1) == 3);
1137+
assert(size(filtered, 1) == 6);
11421138

11431139
% find until level 1
11441140
filtered = b.findSources(1);
1141+
assert(size(filtered, 1) == 3);
1142+
1143+
% find until level 0
1144+
filtered = b.findSources(0);
11451145
assert(size(filtered, 1) == 1);
11461146
end
11471147

@@ -1186,9 +1186,9 @@
11861186
assert(strcmp(filtered{1}.name, sl41.name));
11871187

11881188
% test find by type
1189-
filtered = b.filterFindSources(1, nix.Filter.type, findSource);
1189+
filtered = b.filterFindSources(0, nix.Filter.type, findSource);
11901190
assert(isempty(filtered));
1191-
filtered = b.filterFindSources(4, nix.Filter.type, findSource);
1191+
filtered = b.filterFindSources(3, nix.Filter.type, findSource);
11921192
assert(size(filtered, 1) == 3);
11931193
assert(strcmp(filtered{1}.type, findSource));
11941194

tests/TestSection.m

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -753,25 +753,29 @@
753753
assert(strcmp(ME.message, err));
754754
end
755755

756-
% find all
757-
filtered = sl1.findSections(5);
758-
assert(size(filtered, 1) == 10);
756+
% Check invalid entry
757+
err = 'Search depth must be positive integers or logicals.';
758+
try
759+
sl1.findSections(-20);
760+
catch ME
761+
assert(strcmp(ME.message, err));
762+
end
759763

760-
% find until level 4
764+
% find all
761765
filtered = sl1.findSections(4);
762-
assert(size(filtered, 1) == 10);
766+
assert(size(filtered, 1) == 9);
763767

764768
% find until level 3
765769
filtered = sl1.findSections(3);
766-
assert(size(filtered, 1) == 6);
770+
assert(size(filtered, 1) == 9);
767771

768772
% find until level 2
769773
filtered = sl1.findSections(2);
770-
assert(size(filtered, 1) == 3);
774+
assert(size(filtered, 1) == 5);
771775

772776
% find until level 1
773777
filtered = sl1.findSections(1);
774-
assert(size(filtered, 1) == 1);
778+
assert(size(filtered, 1) == 2);
775779
end
776780

777781
%% Test: Find Sections with filters
@@ -805,7 +809,7 @@
805809
assert(strcmp(filtered{1}.id, sl41.id));
806810

807811
% test find by ids
808-
filterids = {sl1.id, sl41.id};
812+
filterids = {sl21.id, sl41.id};
809813
filtered = sl1.filterFindSections(1, nix.Filter.ids, filterids);
810814
assert(size(filtered, 1) == 1);
811815
filtered = sl1.filterFindSections(4, nix.Filter.ids, filterids);
@@ -821,7 +825,7 @@
821825
assert(strcmp(filtered{1}.name, sl41.name));
822826

823827
% test find by type
824-
filtered = sl1.filterFindSections(1, nix.Filter.type, findSection);
828+
filtered = main.filterFindSections(1, nix.Filter.type, findSection);
825829
assert(isempty(filtered));
826830
filtered = sl1.filterFindSections(4, nix.Filter.type, findSection);
827831
assert(size(filtered, 1) == 3);

tests/TestSource.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -401,23 +401,23 @@
401401
end
402402

403403
% find all
404-
filtered = s.findSources(5);
404+
filtered = s.findSources(4);
405405
assert(size(filtered, 1) == 11);
406406

407407
% find until level 3
408-
filtered = s.findSources(4);
408+
filtered = s.findSources(3);
409409
assert(size(filtered, 1) == 7);
410410

411411
% find until level 2
412-
filtered = s.findSources(3);
412+
filtered = s.findSources(2);
413413
assert(size(filtered, 1) == 4);
414414

415415
% find until level 1
416-
filtered = s.findSources(2);
416+
filtered = s.findSources(1);
417417
assert(size(filtered, 1) == 2);
418418

419419
% find until level 0
420-
filtered = s.findSources(1);
420+
filtered = s.findSources(0);
421421
assert(size(filtered, 1) == 1);
422422
end
423423

win_build.bat

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,34 @@
11
@ECHO off
22
SET MATLAB_BINARY=c:\work\MATLAB_R2011a\bin
3-
REM Latest dependencies at https://projects.g-node.org/nix/
3+
REM Latest Boost dependencies at https://projects.g-node.org/nix/
44
SET NIX_DEP=c:\work\nix-dep
55
REM clone nix source from https://github.com/G-Node/nix
66
SET NIX_ROOT=c:\work\nix
77
SET NIX_MX_ROOT=c:\work\nix-mx
8+
REM This build script requires HDF5 version 1.10.1
9+
REM Latest HDF5 dependencies for VS 2013 at https://www.hdfgroup.org/downloads/hdf5/
10+
REM provide them at %NIX-DEP%\x86 or %NIX-DEP%\x64
11+
SET HDF5_VERSION_DIR=hdf5-1.10.1
12+
REM Static build requires cmake version 3.9.1
13+
SET CMAKEVER=3.9.1
14+
15+
ECHO --------------------------------------------------------------------------
16+
ECHO Checking dependencies ...
17+
ECHO --------------------------------------------------------------------------
18+
19+
IF NOT EXIST cmake (
20+
ECHO Require a valid installation of cmake.\nExit...
21+
EXIT /b
22+
)
23+
24+
FOR /F "tokens=*" %%a in ('cmake /V ^| find "%CMAKEVER%" /c') DO SET HASCMAKEVER=%%a
25+
IF NOT [%HASCMAKEVER%]==[1] (
26+
ECHO Require cmake version %CMAKEVER%.
27+
EXIT /b
28+
)
829

930
IF NOT EXIST %NIX_DEP% (
10-
ECHO Please provide valid nix dependencies.
31+
ECHO Please provide the nix dependency directory.
1132
EXIT /b
1233
)
1334

@@ -40,18 +61,18 @@ SET BASE=%NIX_DEP%\%PLATFORM%\%BUILD_TYPE%
4061
SET CPPUNIT_INCLUDE_DIR=%BASE%\cppunit-1.13.2\include
4162
SET PATH=%PATH%;%CPPUNIT_INCLUDE_DIR%
4263

43-
SET HDF5_BASE=%NIX_DEP%\%PLATFORM%\hdf5-1.8.14
44-
SET HDF5_DIR=%HDF5_BASE%\cmake\hdf5
64+
SET HDF5_BASE=%NIX_DEP%\%PLATFORM%\%HDF5_VERSION_DIR%
65+
SET HDF5_DIR=%HDF5_BASE%\cmake
4566
SET PATH=%PATH%;%HDF5_BASE%\bin
4667

4768
SET BOOST_ROOT=%BASE%\boost-1.57.0
4869
SET BOOST_INCLUDEDIR=%BOOST_ROOT%\include\boost-1_57
4970

50-
ECHO CPPUNIT_INCLUDE_DIR=%CPPUNIT_INCLUDE_DIR%
71+
ECHO CPPUNIT_INCLUDE_DIR=%CPPUNIT_INCLUDE_DIR%, checking directory...
5172
IF EXIST %CPPUNIT_INCLUDE_DIR% (ECHO cppunit OK) ElSE (EXIT /b)
52-
ECHO HDF5_DIR=%HDF5_DIR%
73+
ECHO HDF5_DIR=%HDF5_DIR%, checking directory...
5374
IF EXIST %HDF5_DIR% (ECHO hdf5 OK) ELSE (EXIT /b)
54-
ECHO BOOST_INCLUDEDIR=%BOOST_INCLUDEDIR%
75+
ECHO BOOST_INCLUDEDIR=%BOOST_INCLUDEDIR%, checking directory...
5576
IF EXIST %BOOST_ROOT% (ECHO boost OK) ELSE (EXIT /b)
5677

5778
ECHO --------------------------------------------------------------------------
@@ -65,7 +86,7 @@ REM Clean up build folder to ensure clean build.
6586
DEL * /S /Q
6687
RD /S /Q "CMakeFiles" "Testing" "Debug" "Release" "nix-tool.dir" "x64" "TestRunner.dir" "nix.dir"
6788

68-
IF %PROCESSOR_ARCHITECTURE% == x86 ( cmake .. -G "Visual Studio 12") ELSE (cmake .. -G "Visual Studio 12 Win64")
89+
IF %PROCESSOR_ARCHITECTURE% == x86 ( cmake .. -DBUILD_STATIC=ON -G "Visual Studio 12") ELSE (cmake .. -DBUILD_STATIC=ON -G "Visual Studio 12 Win64")
6990

7091
ECHO --------------------------------------------------------------------------
7192
ECHO Building nix via %NIX_ROOT%\build\nix.sln ...
@@ -81,6 +102,13 @@ cmake --build . --config %BUILD_TYPE% --target testrunner
81102

82103
IF %ERRORLEVEL% == 1 (EXIT /b)
83104

105+
ECHO --------------------------------------------------------------------------
106+
ECHO Building nix-tool ...
107+
ECHO --------------------------------------------------------------------------
108+
cmake --build . --config %BUILD_TYPE% --target nix-tool
109+
110+
IF %ERRORLEVEL% == 1 (EXIT /b)
111+
84112
ECHO --------------------------------------------------------------------------
85113
ECHO Testing nix ...
86114
ECHO --------------------------------------------------------------------------
@@ -102,14 +130,6 @@ REM Clean up build folder to ensure clean build.
102130
DEL * /S /Q
103131
RD /S /Q "CMakeFiles" "Debug" "nix_mx.dir" "Release" "Win32" "x64"
104132

105-
REM Copying required libraries to nix-mx root folder
106-
COPY %NIX_BUILD_DIR%\nix.dll %NIX_MX_ROOT%\ /Y
107-
COPY %HDF5_BASE%\bin\hdf5.dll %NIX_MX_ROOT%\ /Y
108-
COPY %HDF5_BASE%\bin\msvcp120.dll %NIX_MX_ROOT%\ /Y
109-
COPY %HDF5_BASE%\bin\msvcr120.dll %NIX_MX_ROOT%\ /Y
110-
COPY %HDF5_BASE%\bin\zlib.dll %NIX_MX_ROOT%\ /Y
111-
COPY %HDF5_BASE%\bin\szip.dll %NIX_MX_ROOT%\ /Y
112-
113133
IF %PROCESSOR_ARCHITECTURE% == x86 (cmake .. -G "Visual Studio 12") ELSE (cmake .. -G "Visual Studio 12 Win64")
114134

115135
ECHO --------------------------------------------------------------------------
@@ -121,6 +141,8 @@ IF %ERRORLEVEL% == 1 (EXIT /b)
121141

122142
REM Copying required nix-mx.mex file to nix-mx root folder
123143
COPY %NIX_MX_ROOT%\build\%BUILD_TYPE%\nix_mx.mexw* %NIX_MX_ROOT%\ /Y
144+
REM Provide nix-tool as well for validation and content display
145+
COPY %NIX_ROOT%\build\%BUILD_TYPE%\nix-tool.exe %NIX_MX_ROOT%\ /Y
124146

125147
CD %NIX_MX_ROOT%
126148

0 commit comments

Comments
 (0)