-
Notifications
You must be signed in to change notification settings - Fork 2
feat(poly2tri): add LLAR formula #157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
1666cc4
dec5317
1978534
ea545a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| cmake_minimum_required(VERSION 3.15) | ||
| project(poly2tri LANGUAGES CXX) | ||
|
|
||
| include(GNUInstallDirs) | ||
|
|
||
| add_library(poly2tri | ||
| ${POLY2TRI_SRC_DIR}/common/shapes.cc | ||
| ${POLY2TRI_SRC_DIR}/sweep/advancing_front.cc | ||
| ${POLY2TRI_SRC_DIR}/sweep/cdt.cc | ||
| ${POLY2TRI_SRC_DIR}/sweep/sweep.cc | ||
| ${POLY2TRI_SRC_DIR}/sweep/sweep_context.cc | ||
| ) | ||
|
|
||
| target_compile_definitions(poly2tri PRIVATE _USE_MATH_DEFINES) | ||
|
|
||
| if(MSVC AND BUILD_SHARED_LIBS) | ||
| set_property(TARGET poly2tri PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS ON) | ||
| endif() | ||
|
|
||
| install( | ||
| TARGETS poly2tri | ||
| RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
| LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
| ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
| ) | ||
|
|
||
| install( | ||
| DIRECTORY ${POLY2TRI_SRC_DIR} | ||
| DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} | ||
| FILES_MATCHING PATTERN "*.h" | ||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| import ( | ||
| "os" | ||
| "path/filepath" | ||
| "slices" | ||
| ) | ||
|
|
||
| const consumerSource = `#include <poly2tri/poly2tri.h> | ||
|
|
||
| int main() { | ||
| p2t::Point p1(0.0, 0.0); | ||
| p2t::Point p2(1.0, 0.0); | ||
| p2t::Point p3(0.0, 1.0); | ||
| p2t::Triangle triangle(p1, p2, p3); | ||
| return 0; | ||
| } | ||
| ` | ||
|
|
||
| // Conan Center cci.20130502 pins greenm01/poly2tri to this untagged commit. | ||
| id "greenm01/poly2tri" | ||
|
|
||
| fromVer "88de49021b6d9bef6faa1bc94ceb3fbd85c3c204" | ||
|
|
||
| defaults { | ||
| "shared": "OFF", | ||
| "fPIC": "ON", | ||
| } | ||
|
|
||
| filter => { | ||
| for name, values in target.options { | ||
| if name != "shared" && name != "fPIC" { | ||
| return false | ||
| } | ||
| for value in values { | ||
| if value != "ON" && value != "OFF" { | ||
| return false | ||
| } | ||
| } | ||
| } | ||
| return true | ||
| } | ||
|
|
||
| onBuild ctx => { | ||
| installDir := ctx.outputDir | ||
|
|
||
| cmakeLists := ctx.Proj.readFile("88de49021b6d9bef6faa1bc94ceb3fbd85c3c204/CMakeLists.txt")! | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor: the commit SHA |
||
| os.writeFile(filepath.join(ctx.SourceDir, "CMakeLists.txt"), cmakeLists, 0o644)! | ||
|
|
||
| shared := slices.contains(target.options["shared"], "ON") | ||
| fPIC := slices.contains(target.options["fPIC"], "ON") | ||
| c := cmake.new(ctx.SourceDir, filepath.join(ctx.SourceDir, "_build"), installDir) | ||
| c.define "POLY2TRI_SRC_DIR", filepath.join(ctx.SourceDir, "poly2tri") | ||
| c.define "CMAKE_INSTALL_LIBDIR", "lib" | ||
| c.defineBool "BUILD_SHARED_LIBS", shared | ||
| c.defineBool "CMAKE_POSITION_INDEPENDENT_CODE", fPIC | ||
| c.configure | ||
| c.build | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cmake |
||
| c.install | ||
|
|
||
| licenseDir := filepath.join(installDir, "licenses") | ||
| os.mkdirAll(licenseDir, 0o755)! | ||
| os.writeFile(filepath.join(licenseDir, "LICENSE"), os.readFile(filepath.join(ctx.SourceDir, "LICENSE"))!, 0o644)! | ||
|
|
||
| pcDir := filepath.join(installDir, "lib", "pkgconfig") | ||
| os.mkdirAll(pcDir, 0o755)! | ||
| pc := `prefix=$${pcfiledir}/../.. | ||
| exec_prefix=$${prefix} | ||
| libdir=$${prefix}/lib | ||
| includedir=$${prefix}/include | ||
|
|
||
| Name: poly2tri | ||
| Description: 2D constrained Delaunay triangulation library | ||
| Version: 88de49021b6d9bef6faa1bc94ceb3fbd85c3c204 | ||
| Libs: -L$${libdir} -lpoly2tri` | ||
| if slices.contains(target.require["os"], "linux") || slices.contains(target.require["os"], "freebsd") { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor: the |
||
| pc += " -lm" | ||
| } | ||
| pc += ` | ||
| Cflags: -I$${includedir} | ||
| ` | ||
| os.writeFile(filepath.join(pcDir, "poly2tri.pc"), []byte(pc), 0o644)! | ||
|
|
||
| pkgconfig.use installDir | ||
| ctx.setMetadata pkgconfig.lookup("poly2tri")! | ||
| } | ||
|
|
||
| onTest ctx => { | ||
| installDir := ctx.outputDir | ||
| testDir := filepath.join(ctx.SourceDir, "_llar_consumer") | ||
| testBuild := filepath.join(testDir, "_build") | ||
| sourcePath := filepath.join(testDir, "consumer.cpp") | ||
| binary := filepath.join(testBuild, "consumer") | ||
| os.mkdirAll(testDir, 0o755)! | ||
| os.mkdirAll(testBuild, 0o755)! | ||
| os.writeFile(sourcePath, []byte(consumerSource), 0o644)! | ||
|
|
||
| pkgconfig.use installDir | ||
| args := []string{"-std=c++11", sourcePath} | ||
| // pkg-config escapes the `|` in LLAR option-cache paths; restore it before | ||
| // passing each complete lookup token to the compiler. | ||
| flags := pkgconfig.lookup("poly2tri")! | ||
| args <- flags.replaceAll(`\|`, `|`).fields... | ||
| args <- "-o", binary | ||
| exec! "c++", args... | ||
|
|
||
| if slices.contains(target.options["shared"], "ON") { | ||
| os.setenv("LD_LIBRARY_PATH", filepath.join(installDir, "lib"))! | ||
| os.setenv("DYLD_LIBRARY_PATH", filepath.join(installDir, "lib"))! | ||
| } | ||
| exec! binary | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "path": "greenm01/poly2tri", | ||
| "deps": {} | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verify the source/header paths against upstream's layout. At this pinned commit, greenm01/poly2tri keeps all sources and headers under a top-level
poly2tri/subdirectory (poly2tri/common/shapes.cc,poly2tri/sweep/cdt.cc,poly2tri/poly2tri.h, ...).POLY2TRI_SRC_DIRis set toctx.SourceDir(the checkout root) in the formula, so${POLY2TRI_SRC_DIR}/common/shapes.ccresolves to<root>/common/shapes.cc, which doesn't exist — the paths look like they're missing thepoly2tri/prefix (e.g.${POLY2TRI_SRC_DIR}/poly2tri/common/shapes.cc).Same concern for the header install below:
install(DIRECTORY ${POLY2TRI_SRC_DIR} ...)(no trailing slash) installs the checkout-root directory itself underinclude/, producing something likeinclude/<checkout-name>/poly2tri/poly2tri.h, whereas the consumer test does#include <poly2tri/poly2tri.h>with only-Iinclude. Please confirmonTestactually passes; if it does,ctx.SourceDirmust already point at thepoly2tri/subdir — otherwise both the source list and the include layout need thepoly2tri/prefix.