Skip to content
Snippets Groups Projects
Verified Commit d6ad9fff authored by Timm Fitschen's avatar Timm Fitschen
Browse files

Merge branch 'f-macos' into f-final-review

parents 072942a5 ddb51df6
No related branches found
No related tags found
2 merge requests!6Draft: ENH: Adapt for MacOS,!5Final review
Pipeline #18287 passed
Pipeline: caosdb-octaveinttest

#18288

    ......@@ -7,8 +7,8 @@ RUN mkdir build
    WORKDIR /libcaosdb/build
    RUN conan create .. -s "compiler.libcxx=libstdc++11"
    RUN apt-get install -y octave-common/buster-backports liboctave7/buster-backports octave/buster-backports
    RUN apt-get install -y liboctave-dev/buster-backports
    RUN apt-get install -y octave-common liboctave8 octave
    RUN apt-get install -y liboctave-dev
    RUN apt-get install -y unzip
    RUN apt-get install -y wget
    ......
    ......@@ -30,7 +30,10 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
    # dependency management with conan
    include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
    conan_basic_setup()
    conan_basic_setup(KEEP_RPATHS)
    # remove path-like elements from CONAN_LIBS, relevant on MacOS
    string(REGEX REPLACE ";/[^;]+" "" CONAN_LIBS "${CONAN_LIBS}")
    # fix grpc - remove unsecure (no-op ssl implementations)
    string(REGEX REPLACE ";grpc\\+?\\+?_unsecure" "" CONAN_LIBS_GRPC
    ......@@ -75,6 +78,7 @@ execute_process(COMMAND mkoctfile -p OCTAVE_LIBS
    OUTPUT_VARIABLE OCTLIBS
    )
    string(REGEX REPLACE "\n" "" OCTLIBS "${OCTLIBS}")
    string(REGEX REPLACE "-l" "" OCTLIBS "${OCTLIBS}")
    string(REGEX REPLACE " " ";" OCTLIBS "${OCTLIBS}")
    set(MAOXDB_DIR "${PROJECT_SOURCE_DIR}/src/lib")
    ......@@ -101,7 +105,8 @@ file(MAKE_DIRECTORY ${PKG_INST_DIR})
    string(REGEX REPLACE ";" ";-I" _MKOCTFILE_INCLUDES "-I${CONAN_INCLUDE_DIRS};${MAOXDB_DIR}")
    string(REGEX REPLACE ";" ";-L" _MKOCTFILE_LIB_DIRS "-L${CONAN_LIB_DIRS};${_MAOX_LIB_DIR}")
    string(REGEX REPLACE ";" ";-l" _MKOCTFILE_LIBS "-lmaoxdb;${CONAN_LIBS}")
    string(REGEX REPLACE ";" ":" _MKOCTFILE_RPATH "${CONAN_LIB_DIRS}")
    # Needs this in front: -Wl,-rpath,
    string(REGEX REPLACE ";" ",-rpath," _MKOCTFILE_RPATH "${CONAN_LIB_DIRS}")
    set(_MKOCTFILE_OPTIONS "-Wl,-rpath,${_MKOCTFILE_RPATH}" "--mex" "-std=gnu++17"
    "-L/usr/local/lib" ${_MKOCTFILE_INCLUDES} ${_MKOCTFILE_LIB_DIRS} ${_MKOCTFILE_LIBS})
    ......@@ -212,9 +217,8 @@ if(TEST)
    ${OCTINCLUDEDIR}
    ${MAOXDB_DIR})
    target_link_libraries(${test_case_name} PUBLIC
    maoxdb ${CONAN_LIBS_CAOSDB} ${CONAN_LIBS_GTEST} ${CONAN_LIBS_BOOST})
    maoxdb ${OCTLIBS} ${CONAN_LIBS_CAOSDB} ${CONAN_LIBS_GTEST} ${CONAN_LIBS_BOOST})
    target_link_directories(${test_case_name} PUBLIC ${OCTLIBDIR})
    target_link_options(${test_case_name} PUBLIC ${OCTLIBS})
    message(STATUS "CMAKE_CURRENT_BINARY_DIR: ${CMAKE_CURRENT_BINARY_DIR}")
    gtest_discover_tests(${test_case_name}
    WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
    ......
    ......@@ -29,6 +29,17 @@ help:
    @echo " test - run unit tests."
    @echo " doc - create the documentation."
    ###############################################################################
    # Environment dependent options #
    ###############################################################################
    TAR_OPTS := undefined
    ifeq "$(shell tar --version | head -n 1 | grep -o -i gnu | tr '[:upper:]' '[:lower:]')" 'gnu'
    TAR_OPTS := --exclude-ignore-recursive=.gitignore --transform 's,^\.,caosdb,'
    else
    TAR_OPTS := --exclude-from=.gitignore -s '/^\./caosdb/'
    endif
    .PHONY: doc
    doc:
    $(MAKE) -C doc html
    ......@@ -85,6 +96,7 @@ linting_cpp:
    test: install
    $(MAKE) -C test test
    @echo "All tests successfully passed."
    .PHONY: test
    test_octave: install
    ......@@ -108,6 +120,10 @@ install: pkg
    .PHONY: caosdb.tar.gz
    dist/caosdb.tar.gz: dist/
    # For GNU tar:
    # [...] --exclude-ignore-recursive=.gitignore --transform 's,^\.,caosdb,' [...]
    # For POSIX tar:
    # [...] --exclude-from=.gitignore -s '/^\./caosdb/' [...]
    tar -czf dist/caosdb.tar.gz \
    --exclude=.git* \
    --exclude=env* \
    ......@@ -116,8 +132,8 @@ dist/caosdb.tar.gz: dist/
    --exclude=.docker* \
    --exclude=dist* \
    --exclude=inst* \
    --exclude-ignore-recursive=.gitignore \
    --transform 's,^\.,caosdb,' .
    $(TAR_OPTS) \
    .
    .PHONY: dist/
    dist/:
    ......
    ......@@ -5,12 +5,12 @@
    This package requires the following software:
    - conan: `pip install conan`
    - Create a local conan package libcaosdb: See https://gitlab.indiscale.com/caosdb/src/caosdb-cpplib for
    further instructions.
    - Create a local *libcaosdb* conan package: See
    https://gitlab.indiscale.com/caosdb/src/caosdb-cpplib for further instructions.
    - For running this library, a valid libcaosdb configuration is needed, for example a
    `.caosdb_client.json` file in your home directory or current working directory. Please look at
    [`README_SETUP.md` in caosdb-cpplib](https://gitlab.indiscale.com/caosdb/src/caosdb-cpplib/-/blob/main/README_SETUP.md) for more information.
    * MOxUnit for unit tests, see below.
    - For unit tests, MOxUnit is required, see below.
    ## Install and Load
    ......@@ -21,6 +21,12 @@ This package requires the following software:
    * `pkg install dist/caosdb.tar.gz`
    * `pkg load caosdb;`
    ### Notes for installing on MacOS ###
    On MacOS, installation should work the same as on Linux. *libcaosdb* should be installed with conan
    as described in [its documentation](https://gitlab.indiscale.com/caosdb/src/caosdb-cpplib). Octave must of course also be installed, the developers
    tested it with the [homebrew version](https://formulae.brew.sh/formula/octave).
    ## Run Unit Tests
    * run `make test`
    ......
    attrs==21.2.0
    alabaster==0.7.12
    Babel==2.9.1
    bottle==0.12.19
    certifi==2021.10.8
    chardet==4.0.0
    charset-normalizer==2.0.7
    certifi==2021.5.30
    charset-normalizer==2.0.1
    colorama==0.4.4
    conan==1.41.0
    deprecation==2.1.0
    distro==1.6.0
    conan==1.43.0
    deprecation==2.0.7
    distro==1.5.0
    docutils==0.16
    fasteners==0.16.3
    future==0.18.2
    idna==3.2
    imagesize==1.2.0
    Jinja2==2.11.3
    jsonschema==4.1.0
    MarkupSafe==2.0.1
    miss-hit==0.9.24
    miss-hit-core==0.9.24
    node-semver==0.6.1
    packaging==21.0
    patch-ng==1.17.4
    pluginbase==1.0.1
    Pygments==2.10.0
    Pygments==2.9.0
    PyJWT==1.7.1
    pyparsing==2.4.7
    pyrsistent==0.18.0
    python-dateutil==2.8.2
    pytz==2021.1
    PyYAML==5.4.1
    requests==2.26.0
    six==1.16.0
    tqdm==4.62.3
    urllib3==1.26.7
    six==1.15.0
    snowballstemmer==2.1.0
    Sphinx==4.1.0
    sphinx-rtd-theme==0.5.2
    sphinxcontrib-applehelp==1.0.2
    sphinxcontrib-devhelp==1.0.2
    sphinxcontrib-htmlhelp==2.0.0
    sphinxcontrib-jsmath==1.0.1
    sphinxcontrib-qthelp==1.0.3
    sphinxcontrib-serializinghtml==1.1.5
    tqdm==4.61.2
    urllib3==1.26.6
    ......@@ -2,10 +2,47 @@
    set -e
    # See https://octave.org/doc/interpreter/Creating-Packages.html
    ###############################################################################
    ## Package generation script ##
    ## See https://octave.org/doc/interpreter/Creating-Packages.html ##
    ###############################################################################
    echo "Octave CaosDB SRC_DIR: $PWD"
    # Environment specific settings ###############################################
    CONAN_SETTINGS="compiler.libcxx=libstdc++11"
    # OS specific handling, with code by Ken Jackson and oHo,
    # from https://stackoverflow.com/a/52062069/232888 and
    # https://stackoverflow.com/a/14777895/232888
    if [[ $PATH == *";"* ]] ; then
    DETECTED_OS=Windows
    else
    DETECTED_OS=$(uname 2>/dev/null || echo Unknown)
    DETECTED_OS="${DETECTED_OS//CYGWIN%/Cygwin}"
    DETECTED_OS="${DETECTED_OS//MSYS%/MSYS}"
    DETECTED_OS="${DETECTED_OS//MINGW%/MSYS}"
    fi
    if [[ $DETECTED_OS == Darwin ]]; then # Test if we are on MacOS
    CONAN_SETTINGS="compiler.cppstd=17"
    fi
    # Functions for systems without coreutils (such as MacOS) #####################
    # realpath
    # Copied from https://stackoverflow.com/a/45420776/232888 by user
    # [mattes](https://stackoverflow.com/users/2142441/mattes)
    if ! which realpath > /dev/null; then
    realpath () {
    python -c 'import os, sys; print(os.path.realpath(sys.argv[1]))' "$1"
    }
    fi
    ###############################################################################
    # The real script starts here #################################################
    # clean-up
    INST_DIR="$(realpath ../inst)"
    echo "Octave CaosDB INST_DIR: $INST_DIR"
    ......@@ -30,7 +67,7 @@ fi
    # conan install .. -s "compiler.libcxx=libstdc++11"
    # cmake -G "Unix Makefiles" -D CMAKE_BUILD_TYPE=Release -D AUTOFORMATTING=OFF ..
    conan install .. -s "compiler.libcxx=libstdc++11" -s build_type="${BUILD_TYPE}"
    conan install .. -s $CONAN_SETTINGS -s build_type="${BUILD_TYPE}"
    cmake -G "Unix Makefiles" -D CMAKE_BUILD_TYPE="${BUILD_TYPE}" -D AUTOFORMATTING=OFF ..
    popd
    ......@@ -303,7 +303,7 @@ inline auto mxEmptyCell() -> mxArray * {
    * @details Valgrind complains when duplicating empty sparse arrays. This implementation works
    * around the bug, but does not care about sparse arrays inside cell arrays yet.
    */
    auto mxDuplicateArrayAlsoSparse(mxArray *array) -> mxArray*;
    auto mxDuplicateArrayAlsoSparse(mxArray *array) -> mxArray *;
    /**
    * @brief Get the value of a scalar array.
    ......
    ......@@ -23,6 +23,24 @@
    #
    # Specifically, the libraries must have be installed with Conan.
    CONAN_SETTINGS = "compiler.libcxx=libstdc++11"
    # OS specific handling, with code by Ken Jackson and oHo,
    # from https://stackoverflow.com/a/52062069/232888 and
    # https://stackoverflow.com/a/14777895/232888
    ifeq '$(findstring ;,$(PATH))' ';'
    DETECTED_OS := Windows
    else
    DETECTED_OS := $(shell uname 2>/dev/null || echo Unknown)
    DETECTED_OS := $(patsubst CYGWIN%,Cygwin,$(DETECTED_OS))
    DETECTED_OS := $(patsubst MSYS%,MSYS,$(DETECTED_OS))
    DETECTED_OS := $(patsubst MINGW%,MSYS,$(DETECTED_OS))
    endif
    ifeq ($(DETECTED_OS),Darwin) # Test if we are on MacOS
    CONAN_SETTINGS := "compiler.cppstd=17"
    endif
    .PHONY: help
    help:
    @echo "Targets:"
    ......@@ -46,9 +64,9 @@ test_octave:
    # && make test || echo "Test(s) failed."; exit 1
    test_cpp:
    $(eval BUILD_DIR ::= $(shell mktemp -d build_test_XXXXXXXX))
    $(eval BUILD_DIR := $(shell mktemp -d build_test_XXXXXXXX))
    cd $(BUILD_DIR) \
    && conan install ../.. -s "compiler.libcxx=libstdc++11" \
    && conan install ../.. -s $(CONAN_SETTINGS) \
    && cmake -D TEST=On ../.. \
    && make test_detailed \
    || (echo "Test(s) failed."; exit 1)
    ......
    % (C) Copyright 2021 IndiScale GmbH <info@indiscale.com>
    % (C) Copyright 2021 Timm FItschen <t.fitschen@indiscale.com>
    % Copyright (C) 2021 IndiScale GmbH <info@indiscale.com>
    % Copyright (C) 2021 Daniel Hornung <d.hornung@indiscale.com>
    % Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com>
    %
    % This file is a part of the CaosDB Project.
    %
    ......
    ......@@ -100,7 +100,7 @@ TEST(caosdb_conversion, value_Bool) {
    }
    TEST(caosdb_conversion, value_Integer) {
    auto value_contents = generateValues<long>();
    auto value_contents = generateValues<int64_t>();
    test_value_native(value_contents);
    }
    ......
    ......@@ -165,7 +165,7 @@ TEST(utilities, duplicateArray) {
    // Simple double array
    auto number_array = mxCreateDoubleMatrix(2, 2, mxREAL);
    double number_data[4] = {0.0, 1.0, 0.0/0.0, 3.14};
    double number_data[4] = {0.0, 1.0, 0.0 / 0.0, 3.14};
    mxSetData(number_array, number_data);
    auto number_dup = mxDuplicateArrayAlsoSparse(number_array);
    auto number_data_dup = static_cast<double *>(mxGetData(number_dup));
    ......@@ -174,7 +174,7 @@ TEST(utilities, duplicateArray) {
    EXPECT_EQ(mxGetNumberOfElements(number_array), mxGetNumberOfElements(number_dup));
    // Struct array
    auto fields = std::vector<const char*>{"role", "value", "errors"};
    auto fields = std::vector<const char *>{"role", "value", "errors"};
    auto errors_cell = mxCreateCellMatrix(1, 2);
    mxSetCell(errors_cell, 0, mxScalarINT64(23));
    mxSetCell(errors_cell, 1, mxCreateString("twenty three"));
    ......@@ -190,7 +190,6 @@ TEST(utilities, duplicateArray) {
    EXPECT_EQ(struct_data_value_dup, 23.42);
    EXPECT_EQ(mxGetScalarValue<int64_T>(mxGetCell(struct_data_errors_dup, 0)), 23);
    EXPECT_EQ(mxGetStdString(mxGetCell(struct_data_errors_dup, 1)), "twenty three");
    }
    /**
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment