Skip to content

Commit

Permalink
fork catch2, fix fs.exists, add additional_external_include_dirs and …
Browse files Browse the repository at this point in the history
…additional_include_dirs, include "include" folder as well for third party libraries
  • Loading branch information
GlynLeine committed Dec 14, 2023
1 parent 0f18a70 commit 2937220
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
url = https://github.com/Rythe-Interactive/Rythe-Standard-Library.git
[submodule "libraries/third_party/catch2"]
path = libraries/third_party/catch2
url = https://github.com/catchorg/Catch2.git
url = https://github.com/Rythe-Interactive/Catch2.git
2 changes: 1 addition & 1 deletion libraries/third_party/catch2
14 changes: 7 additions & 7 deletions premake/rythe/filesystem.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ local fs = {}

function fs.exists(file)
local ok, err, code = os.rename(file, file)
if not ok then
if code == 13 then
-- Permission denied, but it exists
return true
end
return false
if not ok then
if code == 13 or code == 32 or code == 5 then
-- Permission denied, but it exists
return true, nil, nil
end
return false, err, code
end
return true
return true, nil, nil
end

function fs.readLines(file)
Expand Down
44 changes: 37 additions & 7 deletions premake/rythe/projects.lua
Original file line number Diff line number Diff line change
Expand Up @@ -327,20 +327,38 @@ local function getDepsRecursive(project, projectType)

if fs.exists(path .. "/") then
thirdPartyProject.files = {}

if fs.exists(path .. "/src/" .. thirdPartyProject.name .. "/") then
thirdPartyProject.files[#thirdPartyProject.files + 1] = path .. "/src/" .. thirdPartyProject.name .. "/**"
thirdPartyProject.additional_include_dirs = {}
thirdPartyProject.additional_external_include_dirs = {}

local srcDir = path .. "/src/" .. thirdPartyProject.name .. "/"
if fs.exists(srcDir) then
thirdPartyProject.files[#thirdPartyProject.files + 1] = srcDir .. "**"
thirdPartyProject.additional_include_dirs[#thirdPartyProject.additional_include_dirs + 1] = srcDir
thirdPartyProject.additional_external_include_dirs[#thirdPartyProject.additional_external_include_dirs + 1] = srcDir
end

if fs.exists(path .. "/include/" .. thirdPartyProject.name .. "/") then
thirdPartyProject.files[#thirdPartyProject.files + 1] = path .. "/include/" .. thirdPartyProject.name .. "/**"

local includeDir = path .. "/include/" .. thirdPartyProject.name .. "/"
if fs.exists(includeDir) then
thirdPartyProject.files[#thirdPartyProject.files + 1] = includeDir .. "**"
thirdPartyProject.additional_include_dirs[#thirdPartyProject.additional_include_dirs + 1] = includeDir
thirdPartyProject.additional_external_include_dirs[#thirdPartyProject.additional_external_include_dirs + 1] = includeDir
end

if utils.tableIsEmpty(thirdPartyProject.files) then
thirdPartyProject.files = {
path .. "/src/**",
path .. "/include/**"
}

thirdPartyProject.additional_include_dirs = {
path .. "/src",
path .. "/include"
}

thirdPartyProject.additional_external_include_dirs = {
path .. "/src",
path .. "/include"
}
end

depProject = loadProject(depId, thirdPartyProject, project.src, path, thirdPartyProject.name, "library")
Expand Down Expand Up @@ -418,8 +436,12 @@ function projects.submit(proj)
local depProject, depId, depType = findAssembly(assemblyId)

if depProject ~= nil then
externalIncludeDirs[#externalIncludeDirs + 1] = depProject.location .. "/" .. projectTypeFilesDir(depType, "")
externalIncludeDirs[#externalIncludeDirs + 1] = depProject.location .. projectTypeFilesDir(depType, "")

if isThirdPartyProject(depId) then
externalIncludeDirs[#externalIncludeDirs + 1] = depProject.location .. "/include/"
end

depNames[#depNames + 1] = depProject.alias .. projectNameSuffix(depType)

allDefines[#allDefines + 1] = depProject.group == "" and string.upper(depProject.alias) .. "=1" or string.upper(string.gsub(depProject.group, "[/\\]", "_")) .. "_" .. string.upper(depProject.alias) .. "=1"
Expand All @@ -433,6 +455,14 @@ function projects.submit(proj)
libdirs(libDirs)
end

if not utils.tableIsEmpty(proj.additional_include_dirs) then
includedirs(proj.additional_include_dirs)
end

if not utils.tableIsEmpty(proj.additional_external_include_dirs) then
externalincludedirs(proj.additional_external_include_dirs)
end

architecture(buildSettings.platform)

if projectType ~= "util" then
Expand Down
6 changes: 6 additions & 0 deletions utils/test utils/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <catch2/catch_session.hpp>

int main(int argc, char* argv[])
{
return Catch::Session().run(argc, argv);
}

0 comments on commit 2937220

Please sign in to comment.