mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Co-authored-by: Gold856 <117957790+Gold856@users.noreply.github.com> Co-authored-by: Jade <spacey-sooty@proton.me> Co-authored-by: Matthew Morley <matthew.morley.ca@gmail.com>
59 lines
1.6 KiB
Python
Executable File
59 lines
1.6 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import os
|
|
import shutil
|
|
|
|
from upstream_utils import Lib, walk_cwd_and_copy_if
|
|
|
|
|
|
def copy_upstream_src(wpilib_root):
|
|
wpical = os.path.join(wpilib_root, "wpical")
|
|
|
|
# Delete old install
|
|
for d in [
|
|
"src/main/native/thirdparty/libdogleg/src",
|
|
"src/main/native/thirdparty/libdogleg/include",
|
|
]:
|
|
shutil.rmtree(os.path.join(wpical, d), ignore_errors=True)
|
|
|
|
files = walk_cwd_and_copy_if(
|
|
lambda dp, f: f.endswith("dogleg.h"),
|
|
os.path.join(wpical, "src/main/native/thirdparty/libdogleg/include"),
|
|
)
|
|
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.cpp"),
|
|
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")
|
|
content = content.replace("__attribute__((unused))", "")
|
|
content = content.replace(
|
|
"#include <cholmod_function.h>", "#include <suitesparse/cholmod_function.h>"
|
|
)
|
|
with open(f, "w") as file:
|
|
file.write(content)
|
|
|
|
|
|
def main():
|
|
name = "libdogleg"
|
|
url = "https://github.com/dkogan/libdogleg"
|
|
tag = "c971ea43088d286a3683c1039b9a85f761f7df15"
|
|
|
|
libdogleg = Lib(name, url, tag, copy_upstream_src)
|
|
libdogleg.main()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|