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

Add GH Action to test on Windows and macOS #5

Merged
merged 14 commits into from
Oct 10, 2023
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
2 changes: 1 addition & 1 deletion .github/workflows/test_and_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
sudo apt-get update -y && sudo apt-get install -y build-essential
- name: Run tests
run: |
cargo test -- --nocapture
RUST_BACKTRACE=1 cargo test -- --nocapture
- name: Install cargo-llvm-cov
run: |
curl -LsSf https://github.com/taiki-e/cargo-llvm-cov/releases/latest/download/cargo-llvm-cov-x86_64-unknown-linux-gnu.tar.gz | tar xzf - -C ~/.cargo/bin
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/windows_and_macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Windows & macOS

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

env:
CARGO_TERM_COLOR: always

jobs:
build:

runs-on: ${{ matrix.os }}
strategy:
fail-fast: false

matrix:
os:
- macos-latest
- windows-latest

steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose -- --nocapture
17 changes: 17 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[cfg(any(target_os = "linux", target_os = "macos"))]
fn main() {
cc::Build::new()
.file("c_code/triangle.c")
Expand All @@ -17,3 +18,19 @@ fn main() {
.flag("-Wno-unused-but-set-variable")
.compile("c_code_interface_tetgen");
}

#[cfg(target_os = "windows")]
fn main() {
cc::Build::new()
.file("c_code/triangle.c")
.file("c_code/tricall_report.c")
.file("c_code/interface_triangle.c")
.define("NO_TIMER", None)
.compile("c_code_interface_triangle");
cc::Build::new()
.cpp(true)
.file("c_code/predicates.cxx")
.file("c_code/tetgen.cxx")
.file("c_code/interface_tetgen.cpp")
.compile("c_code_interface_tetgen");
}
2 changes: 1 addition & 1 deletion c_code/interface_triangle.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ int32_t tri_out_voronoi_npoint(struct ExtTrigen *trigen) {
return trigen->voronoi.numberofpoints;
}

int32_t tri_out_voronoi_point(struct ExtTrigen *trigen, int32_t index, int32_t dim) {
double tri_out_voronoi_point(struct ExtTrigen *trigen, int32_t index, int32_t dim) {
if (trigen == NULL) {
return 0.0;
}
Expand Down
2 changes: 1 addition & 1 deletion c_code/interface_triangle.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ int32_t tri_out_cell_attribute(struct ExtTrigen *trigen, int32_t index);

int32_t tri_out_voronoi_npoint(struct ExtTrigen *trigen);

int32_t tri_out_voronoi_point(struct ExtTrigen *trigen, int32_t index, int32_t dim);
double tri_out_voronoi_point(struct ExtTrigen *trigen, int32_t index, int32_t dim);

int32_t tri_out_voronoi_nedge(struct ExtTrigen *trigen);

Expand Down
20 changes: 10 additions & 10 deletions c_code/tetgen.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -10868,9 +10868,9 @@ void tetgenmesh::brio_multiscale_sort(point* vertexarray, int arraysize,
// //
///////////////////////////////////////////////////////////////////////////////

unsigned long tetgenmesh::randomnation(unsigned int choices)
ULONG tetgenmesh::randomnation(unsigned int choices)
{
unsigned long newrandom;
ULONG newrandom;

if (choices >= 714025l) {
newrandom = (randomseed * 1366l + 150889l) % 714025l;
Expand Down Expand Up @@ -26959,9 +26959,9 @@ void tetgenmesh::optimizemesh()
// //
///////////////////////////////////////////////////////////////////////////////

void tetgenmesh::printfcomma(unsigned long n)
void tetgenmesh::printfcomma(ULONG n)
{
unsigned long n2 = 0;
ULONG n2 = 0;
int scale = 1;
while (n >= 1000) {
n2 = n2 + scale * (n % 1000);
Expand Down Expand Up @@ -27911,10 +27911,10 @@ void tetgenmesh::qualitystatistics()
REAL tetaspect, tetradius;
REAL smalldiangle, bigdiangle;
REAL smallfaangle, bigfaangle;
unsigned long radiustable[12];
unsigned long aspecttable[16];
unsigned long dihedangletable[18];
unsigned long faceangletable[18];
ULONG radiustable[12];
ULONG aspecttable[16];
ULONG dihedangletable[18];
ULONG faceangletable[18];
int indx[4];
int radiusindex;
int aspectindex;
Expand Down Expand Up @@ -28301,7 +28301,7 @@ void tetgenmesh::memorystatistics()
}

// Calculate the total memory (in bytes) used by storing meshes.
unsigned long totalmeshmemory = 0l, totalt2shmemory = 0l;
ULONG totalmeshmemory = 0l, totalt2shmemory = 0l;
totalmeshmemory = points->maxitems * points->itembytes +
tetrahedrons->maxitems * tetrahedrons->itembytes;
if (b->plc || b->refine) {
Expand All @@ -28311,7 +28311,7 @@ void tetgenmesh::memorystatistics()
tet2segpool->maxitems * tet2segpool->itembytes);
}

unsigned long totalalgomemory = 0l;
ULONG totalalgomemory = 0l;
totalalgomemory = cavetetlist->totalmemory + cavebdrylist->totalmemory +
caveoldtetlist->totalmemory +
flippool->maxitems * flippool->itembytes;
Expand Down
38 changes: 11 additions & 27 deletions c_code/tetgen.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,28 +53,12 @@

#include <vector> // dorival

// The types 'intptr_t' and 'uintptr_t' are signed and unsigned integer types,
// respectively. They are guaranteed to be the same width as a pointer.
// They are defined in <stdint.h> by the C99 Standard. However, Microsoft
// Visual C++ 2003 -- 2008 (Visual C++ 7.1 - 9) doesn't ship with this header
// file. In such case, we can define them by ourself.
// Update (learned from Stack Overflow): Visual Studio 2010 and Visual C++ 2010
// Express both have stdint.h

// The following piece of code was provided by Steven Johnson (MIT). Define the
// symbol _MSC_VER if you are using Microsoft Visual C++. Moreover, define
// the _WIN64 symbol if you are running TetGen on Win64 systems.

#ifdef _MSC_VER // Microsoft Visual C++
# ifdef _WIN64
typedef __int64 intptr_t;
typedef unsigned __int64 uintptr_t;
# else // not _WIN64
typedef int intptr_t;
typedef unsigned int uintptr_t;
# endif
#else // not Visual C++
# include <stdint.h>
// dorival
#ifdef _MSC_VER
#define ULONG ptrdiff_t
#else
#include <stdint.h>
#define ULONG unsigned long
#endif

///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -997,7 +981,7 @@ class tetgenmesh {
int toparraylen;
char **toparray;
long objects;
unsigned long totalmemory;
ULONG totalmemory;

void restart();
void poolinit(int sizeofobject, int log2objperblk);
Expand Down Expand Up @@ -1335,7 +1319,7 @@ class tetgenmesh {
int autofliplinklevel; // The increase of link levels, default is 1.
int useinsertradius; // Save the insertion radius for Steiner points.
long samples; // Number of random samples for point location.
unsigned long randomseed; // Current random number seed.
ULONG randomseed; // Current random number seed.
REAL cosmaxdihed, cosmindihed; // The cosine values of max/min dihedral.
REAL cossmtdihed; // The cosine value of a bad dihedral to be smoothed.
REAL cosslidihed; // The cosine value of the max dihedral of a sliver.
Expand All @@ -1358,7 +1342,7 @@ class tetgenmesh {
long flip14count, flip26count, flipn2ncount;
long flip23count, flip32count, flip44count, flip41count;
long flip31count, flip22count;
unsigned long totalworkmemory; // Total memory used by working arrays.
ULONG totalworkmemory; // Total memory used by working arrays.


///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1749,7 +1733,7 @@ class tetgenmesh {
void brio_multiscale_sort(point*,int,int threshold,REAL ratio,int* depth);

// Point location.
unsigned long randomnation(unsigned int choices);
ULONG randomnation(unsigned int choices);
void randomsample(point searchpt, triface *searchtet);
enum locateresult locate(point searchpt, triface *searchtet);

Expand Down Expand Up @@ -2046,7 +2030,7 @@ class tetgenmesh {
int checkconforming(int);

// Mesh statistics.
void printfcomma(unsigned long n);
void printfcomma(ULONG n);
void qualitystatistics();
void memorystatistics();
void statistics();
Expand Down
Loading
Loading