Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
Gold856 committed Oct 22, 2024
1 parent 8436c65 commit e58cb27
Show file tree
Hide file tree
Showing 18 changed files with 704 additions and 2,996 deletions.
19 changes: 17 additions & 2 deletions upstream_utils/libdogleg.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,29 @@ def copy_upstream_src(wpilib_root):
]:
shutil.rmtree(os.path.join(wpical, d), ignore_errors=True)

walk_cwd_and_copy_if(
files = walk_cwd_and_copy_if(
lambda dp, f: f.endswith("dogleg.h"),
os.path.join(wpical, "src/main/native/thirdparty/libdogleg/include"),
)
walk_cwd_and_copy_if(
for f in files:
with open(f) as file:
content = file.read()
content = content.replace(
"#include <cholmod.h>", "#include <suitesparse/cholmod.h>"
)
with open(f, "w") as file:
file.write(content)

files = walk_cwd_and_copy_if(
lambda dp, f: f.endswith("dogleg.c"),
os.path.join(wpical, "src/main/native/thirdparty/libdogleg/src"),
)
for f in files:
with open(f) as file:
content = file.read()
content = content.replace("#warning", "// #warning")
with open(f, "w") as file:
file.write(content)


def main():
Expand Down
30 changes: 26 additions & 4 deletions upstream_utils/mrcal.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
import shutil

from upstream_utils import Lib, walk_cwd_and_copy_if
from upstream_utils import Lib, comment_out_invalid_includes, walk_cwd_and_copy_if


def copy_upstream_src(wpilib_root):
Expand All @@ -16,14 +16,28 @@ def copy_upstream_src(wpilib_root):
]:
shutil.rmtree(os.path.join(wpical, d), ignore_errors=True)

walk_cwd_and_copy_if(
files = walk_cwd_and_copy_if(
lambda dp, f: (f.endswith(".h") or f.endswith(".hh"))
and not f.endswith("stereo.h")
and not f.endswith("stereo-matching-libelas.h")
and not dp.startswith(os.path.join(".", "test")),
os.path.join(wpical, "src/main/native/thirdparty/mrcal/include"),
)
walk_cwd_and_copy_if(
for f in files:
comment_out_invalid_includes(
f,
[
os.path.join(wpical, "src/main/native/thirdparty/mrcal/include"),
os.path.join(wpical, "src/main/native/thirdparty/mrcal/generated"),
],
)
# with open(f) as file:
# content = file.read()
# content = content.replace(r"typedef struct {}", r"// typedef struct {}")
# with open(f, "w") as file:
# file.write(content)

files = walk_cwd_and_copy_if(
lambda dp, f: (f.endswith(".c") or f.endswith(".cc") or f.endswith(".pl"))
and not f.endswith("mrcal-pywrap.c")
and not f.endswith("image.c")
Expand All @@ -34,12 +48,20 @@ def copy_upstream_src(wpilib_root):
and not dp.startswith(os.path.join(".", "test")),
os.path.join(wpical, "src/main/native/thirdparty/mrcal/src"),
)
for f in files:
comment_out_invalid_includes(
f,
[
os.path.join(wpical, "src/main/native/thirdparty/mrcal/include"),
os.path.join(wpical, "src/main/native/thirdparty/mrcal/generated"),
],
)


def main():
name = "mrcal"
url = "https://github.com/dkogan/mrcal"
tag = "71c89c4e9f268a0f4fb950325e7d551986a281ec"
tag = "0d5426b5851be80dd8e51470a0784a73565a3006"

mrcal = Lib(name, url, tag, copy_upstream_src)
mrcal.main()
Expand Down
15 changes: 15 additions & 0 deletions wpical/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,21 @@ tasks.withType(CppCompile) {
dependsOn generateCppVersion
}

// Suppress sign-compare warnings
nativeUtils.platformConfigs.each {
if (it.name.contains('windows')) {
} else if (it.name.contains('osx')) {
it.cCompiler.args.add("-Wno-format-nonliteral")
it.cCompiler.args.add("-Wno-unused-function")
it.cCompiler.args.remove("-pedantic")
it.cppCompiler.args.add("-Wno-extern-c-compat")
it.cppCompiler.args.remove("-pedantic")
} else {
it.cCompiler.args.add("-Wno-format-nonliteral")
it.cppCompiler.args.add("-Wno-missing-field-initializers")
it.cppCompiler.args.remove("-pedantic")
}
}
model {
components {
// By default, a development executable will be generated. This is to help the case of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#pragma once

#include <cholmod.h>
#include <suitesparse/cholmod.h>
#include <stdbool.h>

typedef void (dogleg_callback_t)(const double* p,
Expand Down
2 changes: 1 addition & 1 deletion wpical/src/main/native/thirdparty/libdogleg/src/dogleg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1812,7 +1812,7 @@ static void accum_outlierness_factor(// output
}


#warning This is a hack. The threshold should be 1.0, and the scaling should make sure that is the case. I am leaving it for now
// #warning This is a hack. The threshold should be 1.0, and the scaling should make sure that is the case. I am leaving it for now
k /= 8.;


Expand Down
Loading

0 comments on commit e58cb27

Please sign in to comment.