danlooo / dggrid-julia

Julia bindings for the DGGRID library
GNU Affero General Public License v3.0
1 stars 1 forks source link

Evaluate feasibility of bindings creation #2

Open danlooo opened 1 year ago

danlooo commented 1 year ago

Creating C++ bindings is much more complex than creating C bindings. The process was successfully demonstrated with a C++ calculator with Julia bindings in https://github.com/danlooo/CxxCalc.jl. Now we want to test whether this also works for DGGRID.

Automated approach

Just using wrapit with default parameters does not work. Julia bindings for some C++ symbols can not be created see #1. Often, wrapit produces a cxx file with duplicated lines, resulting in ambiguous definitions. This holds even with unique cxx lines, e.g. for the two constructors DgBoundedParam.

Individual approach

Test which C++ symbol fail by building the JLL package for each DGGRID header file individually.

  1. Create a git branch for each file starting from 3137ec4c5a5dd4cc624ff354359296edfd5bab85
  2. Build package using BinaryBuilder
  3. Commit the logs
  4. grep errors in all the branches
for p in $(ls src/DGGRID/src/lib/dglib/include/dglib)
do
    git checkout test_header_files
    git checkout -b "test_header_files_$p"
    sed -i s/HEADER/$p/g src/DGGRID.wit.toml 

    earthly +build-2-cpp-wrapper -a +build-2-cpp-wrapper  2>&1 | tee log
    # need to be executed locally
    julia src/build_tarballs.jl --deploy="local"  2>&1 | tee -a log

    git add -f log products
    git commit -m "Run"
done

Failure statistics

for ref in $(git show-ref | cut -f 2 -d ' ' | grep test_header_files_)
do
    msg=$(grep -oE 'error.*$' <(git show ${ref}:log))
    if [ -z "$msg" ]
    then
        echo $ref >> passed.txt
    else
        echo $ref >> failed.txt
    fi
done
wc -l (passed|failed).txt

26 failed.txt 87 passed.txt 113 total

Most frequent errors

foo() {
for ref in $(git show-ref | cut -f 2 -d ' ' | grep test_header_files_)
do
    msg=$(grep -oE 'error.*$' <(git show ${ref}:log))
    if [ -z "$msg" ]
    then
        continue
    fi
    echo $msg
done
}

foo | sort | uniq -c | sort
     24 error: dglib/dgRF.h: No such file or directory
     24 error.jl:35
     24 errors::Bool, autofix::Bool, code_dir::Union{Nothing, String}, require_license::Bool, kwargs::Base.Pairs{Symbol, V, Tuple{Vararg{Symbol, N}}, NamedTuple{names, T}} where {V, N, names, T<:Tuple{Vararg{Any, N}}})
     24 error(s::String)
      2 error: DgIDGGS4D.h: No such file or directory
      2 error: DgPhysicalRFS2D.h: No such file or directory
      4 errors=3 -MMD  -c -I /root/.julia/artifacts/32fa2e00ee8d44dabd72b80ece853bc295575d7f/include -std=c++17 -o jlDGGRID.o jlDGGRID.cxx

File DgRF.h is present, so maybe we just need to add a symlink to dglib/dgRF.h

Grep error messages

for ref in $(git show-ref | cut -f 2 -d ' ' | grep test_header_files_)
do
    msg=$(grep -oE 'error.*$' <(git show ${ref}:log))
    if [ -z "$msg" ]
    then
        continue
    fi
    echo "### $ref"
    echo "\`\`\`\n$msg\n\`\`\`"
done

refs/heads/test_header_files_DgIDGGS4D.h

errors=3 -MMD  -c -I /root/.julia/artifacts/32fa2e00ee8d44dabd72b80ece853bc295575d7f/include -std=c++17 -o jlDGGRID.o jlDGGRID.cxx
error: DgIDGGS4D.h: No such file or directory

refs/heads/test_header_files_DgIDGGS4H.h

errors=3 -MMD  -c -I /root/.julia/artifacts/32fa2e00ee8d44dabd72b80ece853bc295575d7f/include -std=c++17 -o jlDGGRID.o jlDGGRID.cxx
error: DgIDGGS4D.h: No such file or directory

refs/heads/test_header_files_DgPhysicalRFS2D.h

errors=3 -MMD  -c -I /root/.julia/artifacts/32fa2e00ee8d44dabd72b80ece853bc295575d7f/include -std=c++17 -o jlDGGRID.o jlDGGRID.cxx
error: DgPhysicalRFS2D.h: No such file or directory
error: dglib/dgRF.h: No such file or directory
error(s::String)
error.jl:35
errors::Bool, autofix::Bool, code_dir::Union{Nothing, String}, require_license::Bool, kwargs::Base.Pairs{Symbol, V, Tuple{Vararg{Symbol, N}}, NamedTuple{names, T}} where {V, N, names, T<:Tuple{Vararg{Any, N}}})

refs/heads/test_header_files_DgPolygon.h

errors=3 -MMD  -c -I /root/.julia/artifacts/32fa2e00ee8d44dabd72b80ece853bc295575d7f/include -std=c++17 -o jlDGGRID.o jlDGGRID.cxx
error: DgPhysicalRFS2D.h: No such file or directory
error: dglib/dgRF.h: No such file or directory
error(s::String)
error.jl:35
errors::Bool, autofix::Bool, code_dir::Union{Nothing, String}, require_license::Bool, kwargs::Base.Pairs{Symbol, V, Tuple{Vararg{Symbol, N}}, NamedTuple{names, T}} where {V, N, names, T<:Tuple{Vararg{Any, N}}})

refs/heads/test_header_files_DgProjFuller.h

error: dglib/dgRF.h: No such file or directory
error(s::String)
error.jl:35
errors::Bool, autofix::Bool, code_dir::Union{Nothing, String}, require_license::Bool, kwargs::Base.Pairs{Symbol, V, Tuple{Vararg{Symbol, N}}, NamedTuple{names, T}} where {V, N, names, T<:Tuple{Vararg{Any, N}}})

refs/heads/test_header_files_DgProjGnomonicRF.h

error: dglib/dgRF.h: No such file or directory
error(s::String)
error.jl:35
errors::Bool, autofix::Bool, code_dir::Union{Nothing, String}, require_license::Bool, kwargs::Base.Pairs{Symbol, V, Tuple{Vararg{Symbol, N}}, NamedTuple{names, T}} where {V, N, names, T<:Tuple{Vararg{Any, N}}})

refs/heads/test_header_files_DgProjISEA.h

error: dglib/dgRF.h: No such file or directory
error(s::String)
error.jl:35
errors::Bool, autofix::Bool, code_dir::Union{Nothing, String}, require_license::Bool, kwargs::Base.Pairs{Symbol, V, Tuple{Vararg{Symbol, N}}, NamedTuple{names, T}} where {V, N, names, T<:Tuple{Vararg{Any, N}}})

refs/heads/test_header_files_DgProjTriRF.h

error: dglib/dgRF.h: No such file or directory
error(s::String)
error.jl:35
errors::Bool, autofix::Bool, code_dir::Union{Nothing, String}, require_license::Bool, kwargs::Base.Pairs{Symbol, V, Tuple{Vararg{Symbol, N}}, NamedTuple{names, T}} where {V, N, names, T<:Tuple{Vararg{Any, N}}})

refs/heads/test_header_files_DgRF.h

error: dglib/dgRF.h: No such file or directory
error(s::String)
error.jl:35
errors::Bool, autofix::Bool, code_dir::Union{Nothing, String}, require_license::Bool, kwargs::Base.Pairs{Symbol, V, Tuple{Vararg{Symbol, N}}, NamedTuple{names, T}} where {V, N, names, T<:Tuple{Vararg{Any, N}}})

refs/heads/test_header_files_DgRFBase.h

error: dglib/dgRF.h: No such file or directory
error(s::String)
error.jl:35
errors::Bool, autofix::Bool, code_dir::Union{Nothing, String}, require_license::Bool, kwargs::Base.Pairs{Symbol, V, Tuple{Vararg{Symbol, N}}, NamedTuple{names, T}} where {V, N, names, T<:Tuple{Vararg{Any, N}}})

refs/heads/test_header_files_DgRFNetwork.h

error: dglib/dgRF.h: No such file or directory
error(s::String)
error.jl:35
errors::Bool, autofix::Bool, code_dir::Union{Nothing, String}, require_license::Bool, kwargs::Base.Pairs{Symbol, V, Tuple{Vararg{Symbol, N}}, NamedTuple{names, T}} where {V, N, names, T<:Tuple{Vararg{Any, N}}})

refs/heads/test_header_files_DgRadixString.h

error: dglib/dgRF.h: No such file or directory
error(s::String)
error.jl:35
errors::Bool, autofix::Bool, code_dir::Union{Nothing, String}, require_license::Bool, kwargs::Base.Pairs{Symbol, V, Tuple{Vararg{Symbol, N}}, NamedTuple{names, T}} where {V, N, names, T<:Tuple{Vararg{Any, N}}})

refs/heads/test_header_files_DgRandom.h

error: dglib/dgRF.h: No such file or directory
error(s::String)
error.jl:35
errors::Bool, autofix::Bool, code_dir::Union{Nothing, String}, require_license::Bool, kwargs::Base.Pairs{Symbol, V, Tuple{Vararg{Symbol, N}}, NamedTuple{names, T}} where {V, N, names, T<:Tuple{Vararg{Any, N}}})

refs/heads/test_header_files_DgRunningStats.h

error: dglib/dgRF.h: No such file or directory
error(s::String)
error.jl:35
errors::Bool, autofix::Bool, code_dir::Union{Nothing, String}, require_license::Bool, kwargs::Base.Pairs{Symbol, V, Tuple{Vararg{Symbol, N}}, NamedTuple{names, T}} where {V, N, names, T<:Tuple{Vararg{Any, N}}})

refs/heads/test_header_files_DgSeriesConverter.h

error: dglib/dgRF.h: No such file or directory
error(s::String)
error.jl:35
errors::Bool, autofix::Bool, code_dir::Union{Nothing, String}, require_license::Bool, kwargs::Base.Pairs{Symbol, V, Tuple{Vararg{Symbol, N}}, NamedTuple{names, T}} where {V, N, names, T<:Tuple{Vararg{Any, N}}})

refs/heads/test_header_files_DgSpatialDB.h

error: dglib/dgRF.h: No such file or directory
error(s::String)
error.jl:35
errors::Bool, autofix::Bool, code_dir::Union{Nothing, String}, require_license::Bool, kwargs::Base.Pairs{Symbol, V, Tuple{Vararg{Symbol, N}}, NamedTuple{names, T}} where {V, N, names, T<:Tuple{Vararg{Any, N}}})

refs/heads/test_header_files_DgSqrD4Grid2D.h

error: dglib/dgRF.h: No such file or directory
error(s::String)
error.jl:35
errors::Bool, autofix::Bool, code_dir::Union{Nothing, String}, require_license::Bool, kwargs::Base.Pairs{Symbol, V, Tuple{Vararg{Symbol, N}}, NamedTuple{names, T}} where {V, N, names, T<:Tuple{Vararg{Any, N}}})

refs/heads/test_header_files_DgSqrD4Grid2DS.h

error: dglib/dgRF.h: No such file or directory
error(s::String)
error.jl:35
errors::Bool, autofix::Bool, code_dir::Union{Nothing, String}, require_license::Bool, kwargs::Base.Pairs{Symbol, V, Tuple{Vararg{Symbol, N}}, NamedTuple{names, T}} where {V, N, names, T<:Tuple{Vararg{Any, N}}})

refs/heads/test_header_files_DgSqrD8Grid2D.h

error: dglib/dgRF.h: No such file or directory
error(s::String)
error.jl:35
errors::Bool, autofix::Bool, code_dir::Union{Nothing, String}, require_license::Bool, kwargs::Base.Pairs{Symbol, V, Tuple{Vararg{Symbol, N}}, NamedTuple{names, T}} where {V, N, names, T<:Tuple{Vararg{Any, N}}})

refs/heads/test_header_files_DgSqrD8Grid2DS.h

error: dglib/dgRF.h: No such file or directory
error(s::String)
error.jl:35
errors::Bool, autofix::Bool, code_dir::Union{Nothing, String}, require_license::Bool, kwargs::Base.Pairs{Symbol, V, Tuple{Vararg{Symbol, N}}, NamedTuple{names, T}} where {V, N, names, T<:Tuple{Vararg{Any, N}}})

refs/heads/test_header_files_DgString.h

error: dglib/dgRF.h: No such file or directory
error(s::String)
error.jl:35
errors::Bool, autofix::Bool, code_dir::Union{Nothing, String}, require_license::Bool, kwargs::Base.Pairs{Symbol, V, Tuple{Vararg{Symbol, N}}, NamedTuple{names, T}} where {V, N, names, T<:Tuple{Vararg{Any, N}}})

refs/heads/test_header_files_DgSuperfund.h

error: dglib/dgRF.h: No such file or directory
error(s::String)
error.jl:35
errors::Bool, autofix::Bool, code_dir::Union{Nothing, String}, require_license::Bool, kwargs::Base.Pairs{Symbol, V, Tuple{Vararg{Symbol, N}}, NamedTuple{names, T}} where {V, N, names, T<:Tuple{Vararg{Any, N}}})

refs/heads/test_header_files_DgTriGrid2D.h

error: dglib/dgRF.h: No such file or directory
error(s::String)
error.jl:35
errors::Bool, autofix::Bool, code_dir::Union{Nothing, String}, require_license::Bool, kwargs::Base.Pairs{Symbol, V, Tuple{Vararg{Symbol, N}}, NamedTuple{names, T}} where {V, N, names, T<:Tuple{Vararg{Any, N}}})

refs/heads/test_header_files_DgTriGrid2DS.h

error: dglib/dgRF.h: No such file or directory
error(s::String)
error.jl:35
errors::Bool, autofix::Bool, code_dir::Union{Nothing, String}, require_license::Bool, kwargs::Base.Pairs{Symbol, V, Tuple{Vararg{Symbol, N}}, NamedTuple{names, T}} where {V, N, names, T<:Tuple{Vararg{Any, N}}})

refs/heads/test_header_files_DgTriIDGG.h

error: dglib/dgRF.h: No such file or directory
error(s::String)
error.jl:35
errors::Bool, autofix::Bool, code_dir::Union{Nothing, String}, require_license::Bool, kwargs::Base.Pairs{Symbol, V, Tuple{Vararg{Symbol, N}}, NamedTuple{names, T}} where {V, N, names, T<:Tuple{Vararg{Any, N}}})

refs/heads/test_header_files_DgUtil.h

error: dglib/dgRF.h: No such file or directory
error(s::String)
error.jl:35
errors::Bool, autofix::Bool, code_dir::Union{Nothing, String}, require_license::Bool, kwargs::Base.Pairs{Symbol, V, Tuple{Vararg{Symbol, N}}, NamedTuple{names, T}} where {V, N, names, T<:Tuple{Vararg{Any, N}}})

test_header_files_dggrid.h

errors=3 -MMD  -c -I /root/.julia/artifacts/32fa2e00ee8d44dabd72b80ece853bc295575d7f/include -std=c++17 -o jlDGGRID.o jlDGGRID.cxx
error: dggrid.h: No such file or directory
error: invalid use of incomplete type ‘class DgOutShapefile’
error: invalid use of incomplete type ‘class DgOutPRCellsFile’
error: invalid use of incomplete type ‘class DgOutPRPtsFile’
error: invalid use of incomplete type ‘class DgOutNeighborsFile’
error: invalid use of incomplete type ‘class DgOutChildrenFile’
error(s::String)
error.jl:35
errors::Bool, autofix::Bool, code_dir::Union{Nothing, String}, require_license::Bool, kwargs::Base.Pairs{Symbol, V, Tuple{Vararg{Symbol, N}}, NamedTuple{names, T}} where {V, N, names, T<:Tuple{Vararg{Any, N}}})
danlooo commented 1 year ago

File dglib/dgRF.h is indeed not there but file dglib/DgRF.h is. Is this a case typo or is the header file automatically produced somewhere in the compiing process? However, file dgF2D.h is definitely not there regarding of case. DGGRID compiling works, maybe these dangling files are not being used by the cmake config of https://github.com/sahrk/DGGRID Tested on 16c00e678873edd97c945cd4310f24f5d4eea1aa