From 68dbeca1cf8b076d5381efbee59b76fed2b5d6cb Mon Sep 17 00:00:00 2001 From: Sainan Date: Sat, 25 May 2024 01:29:46 +0200 Subject: [PATCH] Improve handling when cross-compiling DLL --- Sun/sun.cpp | 15 +++++++-------- Sun/vendor/Soup/soup/Compiler.cpp | 10 ++++++---- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Sun/sun.cpp b/Sun/sun.cpp index 1f8e935..3dd6e05 100644 --- a/Sun/sun.cpp +++ b/Sun/sun.cpp @@ -383,7 +383,7 @@ struct Project if (!opt_static) { // Tell linker to include the static library - compiler.extra_linker_args.emplace_back(soup::string::fixType(dep_proj.getOutFile(dep_name).u8string())); + compiler.extra_linker_args.emplace_back(soup::string::fixType(dep_proj.getOutFile().u8string())); } } else //if (dep_proj.opt_dynamic) @@ -505,11 +505,7 @@ struct Project [[nodiscard]] std::filesystem::path getOutFile() const { - return getOutFile(getName()); - } - - [[nodiscard]] std::filesystem::path getOutFile(std::string name) const - { + std::string name = getName(); if (opt_static) { name.append(soup::Compiler::getStaticLibraryExtension()); @@ -517,7 +513,10 @@ struct Project else if (opt_dynamic) { #if SOUP_LINUX - name.insert(0, "lib"); + if (!getCompiler().isCrossCompiler()) + { + name.insert(0, "lib"); + } #endif name.append(getCompiler().getDynamicLibraryExtension()); } @@ -713,7 +712,7 @@ int entry(std::vector&& args, bool console) { std::cout << ">>> Running...\n"; args.erase(args.cbegin(), args.cbegin() + 2); - std::cout << soup::os::execute(soup::string::fixType(proj.getOutFile(outname).u8string()), std::move(args)); + std::cout << soup::os::execute(soup::string::fixType(proj.getOutFile().u8string()), std::move(args)); } return E_OK; diff --git a/Sun/vendor/Soup/soup/Compiler.cpp b/Sun/vendor/Soup/soup/Compiler.cpp index e905748..5551581 100644 --- a/Sun/vendor/Soup/soup/Compiler.cpp +++ b/Sun/vendor/Soup/soup/Compiler.cpp @@ -158,11 +158,13 @@ NAMESPACE_SOUP { return ".js"; } -#if SOUP_WINDOWS - return ".dll"; -#else - return ".so"; +#if SOUP_LINUX + if (!isCrossCompiler()) + { + return ".so"; + } #endif + return ".dll"; } std::string Compiler::makeDynamicLibrary(const std::string& in, const std::string& out) const