Skip to content
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

Windows dll exports patch #10

Merged
merged 2 commits into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
246 changes: 246 additions & 0 deletions recipe/dllexport.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f080b4b..b324094 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -209,6 +209,10 @@ add_library(s2
src/s2/util/math/mathutil.cc
src/s2/util/units/length-units.cc)

+if (WIN32)
+ target_compile_definitions(s2 PRIVATE S2GEOMETRY_BUILDING_S2GEOMETRY)
+endif()
+
if (GTEST_ROOT)
add_library(s2testing STATIC
src/s2/s2builderutil_testing.cc
diff --git a/src/s2/base/port.h b/src/s2/base/port.h
index 0efaba8..e810617 100644
--- a/src/s2/base/port.h
+++ b/src/s2/base/port.h
@@ -46,6 +46,17 @@
// MSVC Specific Requirements
// -----------------------------------------------------------------------------

+#ifdef _WIN32
+ #ifdef S2GEOMETRY_BUILDING_S2GEOMETRY
+ #define S2GEOMETRY_DLL __declspec(dllexport)
+ #else
+ #define S2GEOMETRY_DLL __declspec(dllimport)
+ #endif
+#else
+ #define S2GEOMETRY_DLL
+#endif
+
+
#ifdef _MSC_VER /* if Visual C++ */

#include <intrin.h>
diff --git a/src/s2/s2coords_internal.h b/src/s2/s2coords_internal.h
index df2f606..69d3878 100644
--- a/src/s2/s2coords_internal.h
+++ b/src/s2/s2coords_internal.h
@@ -18,6 +18,8 @@
#ifndef S2_S2COORDS_INTERNAL_H_
#define S2_S2COORDS_INTERNAL_H_

+#include "s2/base/port.h"
+
namespace S2 {
namespace internal {

@@ -41,7 +43,7 @@ int constexpr kInvertMask = 0x02;
// Given a cell orientation and the (i,j)-index of a subcell (0=(0,0),
// 1=(0,1), 2=(1,0), 3=(1,1)), return the order in which this subcell is
// visited by the Hilbert curve (a position in the range [0..3]).
-extern const int kIJtoPos[4][4];
+S2GEOMETRY_DLL extern const int kIJtoPos[4][4];

// kPosToIJ[orientation][pos] -> ij
//
@@ -50,7 +52,7 @@ extern const int kIJtoPos[4][4];
// inverse of the previous table:
//
// kPosToIJ[r][kIJtoPos[r][ij]] == ij
-extern const int kPosToIJ[4][4];
+S2GEOMETRY_DLL extern const int kPosToIJ[4][4];

// kPosToOrientation[pos] -> orientation_modifier
//
@@ -58,13 +60,13 @@ extern const int kPosToIJ[4][4];
// with the given traversal position [0..3] is related to the orientation
// of the parent cell. The modifier should be XOR-ed with the parent
// orientation to obtain the curve orientation in the child.
-extern const int kPosToOrientation[4];
+S2GEOMETRY_DLL extern const int kPosToOrientation[4];

// The U,V,W axes for each face.
-extern const double kFaceUVWAxes[6][3][3];
+S2GEOMETRY_DLL extern const double kFaceUVWAxes[6][3][3];

// The precomputed neighbors of each face (see GetUVWFace).
-extern const int kFaceUVWFaces[6][3][2];
+S2GEOMETRY_DLL extern const int kFaceUVWFaces[6][3][2];

} // namespace internal
} // namespace S2
diff --git a/src/s2/s2edge_clipping.h b/src/s2/s2edge_clipping.h
index dfab202..043dc77 100644
--- a/src/s2/s2edge_clipping.h
+++ b/src/s2/s2edge_clipping.h
@@ -31,6 +31,7 @@
#include <cmath>

#include "s2/base/logging.h"
+#include "s2/base/port.h"
#include "absl/container/inlined_vector.h"
#include "s2/_fp_contract_off.h"
#include "s2/r2.h"
@@ -91,9 +92,9 @@ bool ClipToPaddedFace(const S2Point& a, const S2Point& b, int face,
// returned vertex there is a point on the exact edge AB whose u- and
// v-coordinates differ from the vertex by at most this amount.

-extern const double kFaceClipErrorRadians;
-extern const double kFaceClipErrorUVDist;
-extern const double kFaceClipErrorUVCoord;
+S2GEOMETRY_DLL extern const double kFaceClipErrorRadians;
+S2GEOMETRY_DLL extern const double kFaceClipErrorUVDist;
+S2GEOMETRY_DLL extern const double kFaceClipErrorUVCoord;

// Returns true if the edge AB intersects the given (closed) rectangle to
// within the error bound below.
@@ -105,7 +106,7 @@ bool IntersectsRect(const R2Point& a, const R2Point& b, const R2Rect& rect);
// the result is guaranteed to be false. This bound assumes that "rect" is
// a subset of the rectangle [-1,1]x[-1,1] or extends slightly outside it
// (e.g., by 1e-10 or less).
-extern const double kIntersectsRectErrorUVDist;
+S2GEOMETRY_DLL extern const double kIntersectsRectErrorUVDist;

// Given an edge AB, returns the portion of AB that is contained by the given
// rectangle "clip". Returns false if there is no intersection.
@@ -144,8 +145,8 @@ bool ClipEdgeBound(const R2Point& a, const R2Point& b,
// the corresponding exact result. It is equal to the error in a single
// coordinate because at most one coordinate is subject to error.

-extern const double kEdgeClipErrorUVCoord;
-extern const double kEdgeClipErrorUVDist;
+S2GEOMETRY_DLL extern const double kEdgeClipErrorUVCoord;
+S2GEOMETRY_DLL extern const double kEdgeClipErrorUVDist;

// Given a value x that is some linear combination of a and b, returns the
// value x1 that is the same linear combination of a1 and b1. This function
diff --git a/src/s2/s2edge_crossings_internal.h b/src/s2/s2edge_crossings_internal.h
index 2487754..f1a48a4 100644
--- a/src/s2/s2edge_crossings_internal.h
+++ b/src/s2/s2edge_crossings_internal.h
@@ -21,6 +21,7 @@
#ifndef S2_S2EDGE_CROSSINGS_INTERNAL_H_
#define S2_S2EDGE_CROSSINGS_INTERNAL_H_

+#include "s2/base/port.h"
#include "s2/s1angle.h"
#include "s2/s2point.h"

@@ -43,7 +44,7 @@ bool GetStableCrossProd(const Vector3<T>& a, const Vector3<T>& b,
Vector3_d ExactCrossProd(const S2Point& a, const S2Point& b);

// The maximum error in the method above.
-extern const S1Angle kExactCrossProdError;
+S2GEOMETRY_DLL extern const S1Angle kExactCrossProdError;

// Returns the cross product of two points using symbolic perturbations, rounded
// to double-precision and scaled so that the result can be normalized to an
@@ -59,7 +60,7 @@ S2Point GetIntersectionExact(const S2Point& a0, const S2Point& a1,
const S2Point& b0, const S2Point& b1);

// The maximum error in the method above.
-extern const S1Angle kIntersectionExactError;
+S2GEOMETRY_DLL extern const S1Angle kIntersectionExactError;

// The following field is used exclusively by s2edge_crossings_test.cc to
// measure how often each intersection method is used by GetIntersection().
diff --git a/src/s2/s2metrics.h b/src/s2/s2metrics.h
index b236515..0772567 100644
--- a/src/s2/s2metrics.h
+++ b/src/s2/s2metrics.h
@@ -31,6 +31,7 @@
#include <algorithm>
#include <cmath>

+#include "s2/base/port.h"
#include "s2/s2coords.h"
#include "s2/util/math/mathutil.h"

@@ -86,9 +87,9 @@ using AreaMetric = Metric<2>;
// example, the maximum angle between opposite bounding planes for a cell at
// level k is kMaxAngleSpan.GetValue(k), and the average angle span for all
// cells at level k is approximately kAvgAngleSpan.GetValue(k).
-extern const LengthMetric kMinAngleSpan;
-extern const LengthMetric kMaxAngleSpan;
-extern const LengthMetric kAvgAngleSpan;
+S2GEOMETRY_DLL extern const LengthMetric kMinAngleSpan;
+S2GEOMETRY_DLL extern const LengthMetric kMaxAngleSpan;
+S2GEOMETRY_DLL extern const LengthMetric kAvgAngleSpan;

// The width of geometric figure is defined as the distance between two
// parallel bounding lines in a given direction. For cells, the minimum
@@ -112,9 +113,9 @@ extern const LengthMetric kAvgAngleSpan;
// Note that because S2Cells are not usually rectangles, the minimum width of
// a cell is generally smaller than its minimum edge length. (The interior
// angles of an S2Cell range from 60 to 120 degrees.)
-extern const LengthMetric kMinWidth;
-extern const LengthMetric kMaxWidth;
-extern const LengthMetric kAvgWidth;
+S2GEOMETRY_DLL extern const LengthMetric kMinWidth;
+S2GEOMETRY_DLL extern const LengthMetric kMaxWidth;
+S2GEOMETRY_DLL extern const LengthMetric kAvgWidth;

// The minimum edge length of any cell at level k is at least
// kMinEdge.GetValue(k), and the maximum is at most kMaxEdge.GetValue(k).
@@ -125,9 +126,9 @@ extern const LengthMetric kAvgWidth;
// its edge neighbors. In particular, it can be used to bound the distance
// between adjacent cell centers along the space-filling Hilbert curve for
// cells at any given level.
-extern const LengthMetric kMinEdge;
-extern const LengthMetric kMaxEdge;
-extern const LengthMetric kAvgEdge;
+S2GEOMETRY_DLL extern const LengthMetric kMinEdge;
+S2GEOMETRY_DLL extern const LengthMetric kMaxEdge;
+S2GEOMETRY_DLL extern const LengthMetric kAvgEdge;

// The minimum diagonal length of any cell at level k is at least
// kMinDiag.GetValue(k), and the maximum is at most kMaxDiag.GetValue(k).
@@ -137,26 +138,26 @@ extern const LengthMetric kAvgEdge;
// and also the maximum geometric width (see the discussion above). So for
// example, the distance from an arbitrary point to the closest cell center
// at a given level is at most half the maximum diagonal length.
-extern const LengthMetric kMinDiag;
-extern const LengthMetric kMaxDiag;
-extern const LengthMetric kAvgDiag;
+S2GEOMETRY_DLL extern const LengthMetric kMinDiag;
+S2GEOMETRY_DLL extern const LengthMetric kMaxDiag;
+S2GEOMETRY_DLL extern const LengthMetric kAvgDiag;

// The minimum area of any cell at level k is at least kMinArea.GetValue(k),
// and the maximum is at most kMaxArea.GetValue(k). The average area of all
// cells at level k is exactly kAvgArea.GetValue(k).
-extern const AreaMetric kMinArea;
-extern const AreaMetric kMaxArea;
-extern const AreaMetric kAvgArea;
+S2GEOMETRY_DLL extern const AreaMetric kMinArea;
+S2GEOMETRY_DLL extern const AreaMetric kMaxArea;
+S2GEOMETRY_DLL extern const AreaMetric kAvgArea;

// This is the maximum edge aspect ratio over all cells at any level, where
// the edge aspect ratio of a cell is defined as the ratio of its longest
// edge length to its shortest edge length.
-extern const double kMaxEdgeAspect;
+S2GEOMETRY_DLL extern const double kMaxEdgeAspect;

// This is the maximum diagonal aspect ratio over all cells at any level,
// where the diagonal aspect ratio of a cell is defined as the ratio of its
// longest diagonal length to its shortest diagonal length.
-extern const double kMaxDiagAspect;
+S2GEOMETRY_DLL extern const double kMaxDiagAspect;


////////////////// Implementation details follow ////////////////////
4 changes: 3 additions & 1 deletion recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ source:
- allow_override_cpp_standard.patch
# old gcc version used for linux builds?
- fix_gcc_prid64.patch # [linux]
# missing DLL exports on windows (data)
- dllexport.patch

build:
number: 0
number: 1

requirements:
build:
Expand Down