Skip to content

Commit

Permalink
Merge pull request openscad#5399 from openscad/fs_uncomplete
Browse files Browse the repository at this point in the history
Use filesystem::relative for boostfs_uncomplete.
  • Loading branch information
thehans authored Oct 31, 2024
2 parents 7f05c62 + 7068366 commit 3971745
Show file tree
Hide file tree
Showing 49 changed files with 136 additions and 246 deletions.
13 changes: 2 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,8 @@ cmake_dependent_option(APPLE_UNIX "Build OpenSCAD in Unix mode in MacOS X instea
cmake_dependent_option(ENABLE_QTDBUS "Enable DBus input driver for Qt." ON "NOT HEADLESS" OFF)
cmake_dependent_option(ENABLE_GAMEPAD "Enable Qt5Gamepad input driver." ON "NOT HEADLESS;NOT USE_QT6" OFF)

if(USE_QT6)
set(DEPLOYMENT_TARGET "10.15")
elseif(EXPERIMENTAL AND ENABLE_TBB)
# TBB 2021.8.0 uses aligned memory deallocation.
# While this is technically supported in macOS 10.13, an LLVM bug used to limit this to macOS 10.14+.
# The bug was fixed in LLVM 15.0.0 (https://reviews.llvm.org/D129198), but was still present in Xcode 14.3.1a.
set(DEPLOYMENT_TARGET "10.14")
else()
set(DEPLOYMENT_TARGET "10.13")
endif()
# Minimum version required for std::filesystem
set(DEPLOYMENT_TARGET "10.15")

# Note: CMAKE_OSX_DEPLOYMENT_TARGET must be set before the project() invocation
set(CMAKE_OSX_DEPLOYMENT_TARGET ${DEPLOYMENT_TARGET} CACHE STRING "Minimum OS X deployment version")
Expand Down Expand Up @@ -861,7 +853,6 @@ set(CORE_SOURCES
src/libsvg/util.cc
src/platform/PlatformUtils.cc
src/utils/StackCheck.h
src/utils/boost-utils.cc
src/utils/calc.cc
src/utils/degree_trig.cc
src/utils/hash.cc
Expand Down
2 changes: 1 addition & 1 deletion scripts/macosx-build-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ BASEDIR=$PWD/../libraries
OPENSCADDIR=$PWD
SRCDIR=$BASEDIR/src
DEPLOYDIR=$BASEDIR/install
MAC_OSX_VERSION_MIN=10.13
MAC_OSX_VERSION_MIN=10.15
OPTION_DEPLOY=false
OPTION_FORCE=0
OPTION_ARM64=false
Expand Down
2 changes: 1 addition & 1 deletion scripts/macosx-sanity-check.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

cxxlib = None

macos_version_min = '10.14'
macos_version_min = '10.15'

def usage():
print("Usage: " + sys.argv[0] + " <executable>", sys.stderr)
Expand Down
4 changes: 2 additions & 2 deletions src/FontCache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <iostream>
#include <vector>

#include <boost/filesystem.hpp>
#include <filesystem>
#include <boost/algorithm/string.hpp>
#include <string>
#include <utility>
Expand All @@ -43,7 +43,7 @@ extern std::vector<std::string> librarypath;

std::vector<std::string> fontpath;

namespace fs = boost::filesystem;
namespace fs = std::filesystem;

const std::string get_fontconfig_version()
{
Expand Down
4 changes: 2 additions & 2 deletions src/core/AST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <memory>
#include <sstream>
#include <string>
#include "utils/boost-utils.h"
#include "io/fileutils.h"

const Location Location::NONE(0, 0, 0, 0, std::make_shared<fs::path>(fs::path{}));

Expand All @@ -27,7 +27,7 @@ bool Location::isNone() const {

std::string Location::toRelativeString(const std::string& docPath) const {
if (this->isNone()) return "location unknown";
return "in file " + boostfs_uncomplete((*path), docPath).generic_string() + ", " + "line " + std::to_string(this->firstLine());
return "in file " + fs_uncomplete((*path), docPath).generic_string() + ", " + "line " + std::to_string(this->firstLine());
}

std::ostream& operator<<(std::ostream& stream, const ASTNode& ast)
Expand Down
4 changes: 2 additions & 2 deletions src/core/AST.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#include <ostream>
#include <string>
#include <memory>
#include <boost/filesystem.hpp>
#include <filesystem>
#include <utility>
namespace fs = boost::filesystem;
namespace fs = std::filesystem;

#include <string>

Expand Down
9 changes: 4 additions & 5 deletions src/core/ImportNode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,15 @@
#include "io/fileutils.h"
#include "Feature.h"
#include "handle_dep.h"
#include "utils/boost-utils.h"
#include <cmath>
#include <ios>
#include <utility>
#include <memory>
#include <sys/types.h>
#include <sstream>
#include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp>
namespace fs = boost::filesystem;
#include <filesystem>
namespace fs = std::filesystem;
#include <boost/assign/std/vector.hpp>
using namespace boost::assign; // bring 'operator+=()' into scope

Expand Down Expand Up @@ -139,7 +138,7 @@ static std::shared_ptr<AbstractNode> do_import(const ModuleInstantiation *inst,
if (dpi.type() == Value::Type::NUMBER) {
double val = dpi.toDouble();
if (val < 0.001) {
std::string filePath = boostfs_uncomplete(inst->location().filePath(), parameters.documentRoot()).generic_string();
std::string filePath = fs_uncomplete(inst->location().filePath(), parameters.documentRoot()).generic_string();
LOG(message_group::Warning,
"Invalid dpi value giving, using default of %1$f dpi. Value must be positive and >= 0.001, file %2$s, import() at line %3$d",
origin.toEchoStringNoThrow(), filePath, filePath, inst->location().firstLine()
Expand Down Expand Up @@ -243,7 +242,7 @@ std::string ImportNode::toString() const
stream << ", scale = " << this->scale
<< ", convexity = " << this->convexity
<< ", $fn = " << this->fn << ", $fa = " << this->fa << ", $fs = " << this->fs
<< ", timestamp = " << (fs::exists(path) ? fs::last_write_time(path) : 0)
<< ", timestamp = " << fs_timestamp(path)
<< ")";

return stream.str();
Expand Down
6 changes: 3 additions & 3 deletions src/core/LinearExtrudeNode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
#include <boost/assign/std/vector.hpp>
using namespace boost::assign; // bring 'operator+=()' into scope

#include <boost/filesystem.hpp>
namespace fs = boost::filesystem;
#include <filesystem>
namespace fs = std::filesystem;

/*
* Historic linear_extrude argument parsing is quirky. To remain bug-compatible,
Expand Down Expand Up @@ -168,7 +168,7 @@ std::string LinearExtrudeNode::toString() const
"file = " << this->filename << ", "
"layer = " << QuotedString(this->layername) << ", "
"origin = [" << this->origin_x << ", " << this->origin_y << "], "
<< "timestamp = " << (fs::exists(path) ? fs::last_write_time(path) : 0) << ", "
<< "timestamp = " << fs_timestamp(path) << ", "
;
}
double height=this->height.norm();
Expand Down
6 changes: 3 additions & 3 deletions src/core/RotateExtrudeNode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
#include <boost/assign/std/vector.hpp>
using namespace boost::assign; // bring 'operator+=()' into scope

#include <boost/filesystem.hpp>
namespace fs = boost::filesystem;
#include <filesystem>
namespace fs = std::filesystem;

static std::shared_ptr<AbstractNode> builtin_rotate_extrude(const ModuleInstantiation *inst, Arguments arguments, const Children& children)
{
Expand Down Expand Up @@ -104,7 +104,7 @@ std::string RotateExtrudeNode::toString() const
"layer = " << QuotedString(this->layername) << ", "
"origin = [" << std::dec << this->origin_x << ", " << this->origin_y << "], "
"scale = " << this->scale << ", "
<< "timestamp = " << (fs::exists(path) ? fs::last_write_time(path) : 0) << ", "
<< "timestamp = " << fs_timestamp(path) << ", "
;
}
stream <<
Expand Down
5 changes: 3 additions & 2 deletions src/core/SourceFile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,16 @@
#include "core/parsersettings.h"
#include "core/StatCache.h"
#include <algorithm>
#include <ctime>
#include <ostream>
#include <memory>
#include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp>
#include <filesystem>
#include <string>
#include <utility>
#include <vector>

namespace fs = boost::filesystem;
namespace fs = std::filesystem;
#include "FontCache.h"
#include <sys/stat.h>

Expand Down
6 changes: 3 additions & 3 deletions src/core/SurfaceNode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
#include <boost/assign/std/vector.hpp>
using namespace boost::assign; // bring 'operator+=()' into scope

#include <boost/filesystem.hpp>
namespace fs = boost::filesystem;
#include <filesystem>
namespace fs = std::filesystem;


static std::shared_ptr<AbstractNode> builtin_surface(const ModuleInstantiation *inst, Arguments arguments, const Children& children)
Expand Down Expand Up @@ -339,7 +339,7 @@ std::string SurfaceNode::toString() const
stream << this->name() << "(file = " << this->filename
<< ", center = " << (this->center ? "true" : "false")
<< ", invert = " << (this->invert ? "true" : "false")
<< ", " "timestamp = " << (fs::exists(path) ? fs::last_write_time(path) : 0)
<< ", " "timestamp = " << fs_timestamp(path)
<< ")";

return stream.str();
Expand Down
5 changes: 3 additions & 2 deletions src/core/Value.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,15 @@
#include <boost/lexical_cast.hpp>

#include "core/EvaluationSession.h"
#include "io/fileutils.h"
#include "utils/printutils.h"
#include "utils/StackCheck.h"
#include "utils/boost-utils.h"
#include <double-conversion/double-conversion.h>
#include <double-conversion/utils.h>
#include <double-conversion/ieee.h>

namespace fs = boost::filesystem;
namespace fs = std::filesystem;

const Value Value::undefined;
const VectorType VectorType::EMPTY(nullptr);
Expand Down Expand Up @@ -180,7 +181,7 @@ static uint32_t convert_to_uint32(const double d)
std::ostream& operator<<(std::ostream& stream, const Filename& filename)
{
fs::path fnpath{static_cast<std::string>(filename)}; // gcc-4.6
auto fpath = boostfs_uncomplete(fnpath, fs::current_path());
auto fpath = fs_uncomplete(fnpath, fs::current_path());
stream << QuotedString(fpath.generic_string());
return stream;
}
Expand Down
5 changes: 2 additions & 3 deletions src/core/lexer.l
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@
#include "core/SourceFile.h"
#include <assert.h>
#include <boost/lexical_cast.hpp>
#include <boost/filesystem.hpp>
//#include "utils/boost-utils.h"
namespace fs = boost::filesystem;
#include <filesystem>
namespace fs = std::filesystem;

//isatty for visual c++ and mingw-cross-env
#if defined __WIN32__ && ! defined _MSC_VER
Expand Down
10 changes: 5 additions & 5 deletions src/core/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@
#include "core/Assignment.h"
#include "core/Expression.h"
#include "core/function.h"
#include "io/fileutils.h"
#include "utils/printutils.h"
#include <memory>
#include <sstream>
#include <stack>
#include <boost/filesystem.hpp>
#include "utils/boost-utils.h"
#include <filesystem>

namespace fs = boost::filesystem;
namespace fs = std::filesystem;

#define YYMAXDEPTH 20000
#define LOC(loc) Location(loc.first_line, loc.first_column, loc.last_line, loc.last_column, sourcefile())
Expand Down Expand Up @@ -728,8 +728,8 @@ void handle_assignment(const std::string token, Expression *expr, const Location
auto prevFile = assignment->location().fileName();
auto currFile = loc.fileName();

const auto uncPathCurr = boostfs_uncomplete(currFile, mainFilePath.parent_path());
const auto uncPathPrev = boostfs_uncomplete(prevFile, mainFilePath.parent_path());
const auto uncPathCurr = fs_uncomplete(currFile, mainFilePath.parent_path());
const auto uncPathPrev = fs_uncomplete(prevFile, mainFilePath.parent_path());
if (fileEnded) {
//assignments via commandline
} else if (prevFile == mainFile && currFile == mainFile) {
Expand Down
4 changes: 2 additions & 2 deletions src/core/parsersettings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
#include <string>
#include <vector>

#include <boost/filesystem.hpp>
#include <filesystem>
#include <boost/algorithm/string.hpp>
#include "platform/PlatformUtils.h"

namespace fs = boost::filesystem;
namespace fs = std::filesystem;

std::vector<std::string> librarypath;

Expand Down
4 changes: 2 additions & 2 deletions src/core/parsersettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

#include <string>
#include <vector>
#include <boost/filesystem.hpp>
#include <filesystem>

namespace fs = boost::filesystem;
namespace fs = std::filesystem;

extern int parser_error_pos;

Expand Down
4 changes: 2 additions & 2 deletions src/glview/ColorMap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
#include <exception>
#include <memory>
#include <boost/property_tree/json_parser.hpp>
#include <boost/filesystem.hpp>
#include <filesystem>
#include <cmath>

namespace fs = boost::filesystem;
namespace fs = std::filesystem;

static const char *DEFAULT_COLOR_SCHEME_NAME = "Cornfield";

Expand Down
4 changes: 2 additions & 2 deletions src/glview/ColorMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

#include "geometry/linalg.h"

#include <boost/filesystem.hpp>
#include <filesystem>
#include <boost/property_tree/ptree.hpp>

namespace fs = boost::filesystem;
namespace fs = std::filesystem;

enum class RenderColor {
BACKGROUND_COLOR,
Expand Down
2 changes: 1 addition & 1 deletion src/gui/Animate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <QTimer>
#include <QWidget>
#include <iostream>
#include <boost/filesystem.hpp>
#include <filesystem>
#include <QFormLayout>

Animate::Animate(QWidget *parent) : QWidget(parent)
Expand Down
2 changes: 1 addition & 1 deletion src/gui/ErrorLog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <QStandardItemModel>
#include <QString>
#include <QWidget>
#include <boost/filesystem.hpp>
#include <filesystem>

ErrorLog::ErrorLog(QWidget *parent) : QWidget(parent)
{
Expand Down
6 changes: 3 additions & 3 deletions src/gui/MainWindow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
#ifdef ENABLE_MANIFOLD
#include "geometry/manifold/manifoldutils.h"
#endif
#include "utils/boost-utils.h"
#include "core/Builtins.h"
#include "core/BuiltinContext.h"
#include "core/customizer/CommentParser.h"
Expand All @@ -74,6 +73,7 @@
#include "core/ScopeContext.h"
#include "core/progress.h"
#include "io/dxfdim.h"
#include "io/fileutils.h"
#include "gui/Settings.h"
#include "gui/AboutDialog.h"
#include "gui/FontListDialog.h"
Expand Down Expand Up @@ -1292,7 +1292,7 @@ void MainWindow::instantiateRoot()
this->root_node.reset();
this->tree.setRoot(nullptr);

boost::filesystem::path doc(activeEditor->filepath.toStdString());
std::filesystem::path doc(activeEditor->filepath.toStdString());
this->tree.setDocumentPath(doc.parent_path().string());

if (this->root_file) {
Expand Down Expand Up @@ -2489,7 +2489,7 @@ void MainWindow::rightClick(QPoint mouse)
ss << name << " (" << location.filePath().filename().string() << ":"
<< location.firstLine() << ")";
} else {
auto relative_filename = boostfs_uncomplete(location.filePath(), fs::path(activeEditor->filepath.toStdString()).parent_path())
auto relative_filename = fs_uncomplete(location.filePath(), fs::path(activeEditor->filepath.toStdString()).parent_path())
.generic_string();
// Set the displayed name relative to the active editor window
ss << name << " (" << relative_filename << ":" << location.firstLine() << ")";
Expand Down
1 change: 1 addition & 0 deletions src/gui/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <QTimer>
#include <QUrl>
#include <QWidget>
#include <ctime>
#include <unordered_map>
#include <memory>
#include <string>
Expand Down
Loading

0 comments on commit 3971745

Please sign in to comment.