Skip to content

Commit

Permalink
move build files to build/_ACTION, rename configure to refresh, auto …
Browse files Browse the repository at this point in the history
…clean refresh project to fix "project up to date", update premake
  • Loading branch information
GlynLeine committed Dec 24, 2023
1 parent ce9399f commit ed0694c
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 43 deletions.
72 changes: 45 additions & 27 deletions premake/rythe/projects.lua
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ local function isProjectTypeMainType(projectType)
return true
end

local function loadProject(projectId, project, projectFile, projectPath, name, projectType)
local function loadProject(projectId, project, projectPath, name, projectType)
if project.alias == nil then
project.alias = name
end
Expand All @@ -199,7 +199,6 @@ local function loadProject(projectId, project, projectFile, projectPath, name, p
project.defines[#project.defines +1 ] = "PROJECT_NAMESPACE=" .. project.namespace
end

project.src = projectFile
project.location = projectPath

if project.files == nil then -- files can be an empty table if no files need to be loaded
Expand Down Expand Up @@ -231,9 +230,16 @@ function projects.load(projectPath)
local thirdParties = dofile(thirdPartyFile)

for i, thirdParty in ipairs(thirdParties) do
thirdParty.src = thirdPartyFile

if thirdParty.init ~= nil then
thirdParty = thirdParty:init(ctx)
end

if thirdParty == nil then
print("Could not initialize a third party dependency of project \"" .. group .. "/" .. name .. "\"")
return nil
end

local thirdPartyId = getProjectId(thirdParty.group, thirdParty.name)

Expand All @@ -246,12 +252,15 @@ function projects.load(projectPath)
thirdParty.location = projectPath .. "/third_party/" .. thirdParty.name
end

loadProject(thirdPartyId, thirdParty, thirdPartyFile, thirdParty.location, thirdParty.name, "library")
thirdParty = loadProject(thirdPartyId, thirdParty, thirdParty.location, thirdParty.name, "library")
end
end

project = dofile(projectFile)

project.group = group
project.name = name
project.src = projectFile
if project.init ~= nil then
project = project:init(ctx)
end
Expand All @@ -261,10 +270,8 @@ function projects.load(projectPath)
return nil
end

project.group = group
project.name = name

return loadProject(projectId, project, projectFile, projectPath, name, projectType)
return loadProject(projectId, project, projectPath, name, projectType)
end

local function setupRelease(projectType)
Expand Down Expand Up @@ -355,7 +362,8 @@ local function getDepsRecursive(project, projectType)
}
end

depProject = loadProject(depId, thirdPartyProject, project.src, path, thirdPartyProject.name, "library")
thirdPartyProject.src = project.src
depProject = loadProject(depId, thirdPartyProject, path, thirdPartyProject.name, "library")
depType = "library"
end
end
Expand Down Expand Up @@ -393,13 +401,13 @@ function projects.submit(proj)

for i, projectType in ipairs(proj.types) do
local fullGroupPath = projectTypeGroupPrefix(projectType) .. proj.group
local binDir = _ACTION .. "/bin/"
local binDir = "build/" .. _ACTION .. "/bin/"
print("Building " .. proj.name .. ": " .. projectType)

group(fullGroupPath)
project(proj.alias .. projectNameSuffix(projectType))
filename(proj.alias .. projectNameSuffix(projectType))
location(_ACTION .. "/" .. proj.group)
location("build/" .. _ACTION .. "/" .. proj.group)

if proj.pre_build ~= nil then
prebuildcommands(proj.pre_build)
Expand All @@ -419,12 +427,12 @@ function projects.submit(proj)
if allDefines == nil then
allDefines = {}
end


local libDirs = {}
local externalIncludeDirs = {}

if not utils.tableIsEmpty(allDeps) then
local libDirs = {}
local externalIncludeDirs = {}
local depNames = {}

for i, dep in ipairs(allDeps) do
local assemblyId, scope = getDepAssemblyAndScope(dep)
local depProject, depId, depType = findAssembly(assemblyId)
Expand All @@ -443,25 +451,33 @@ function projects.submit(proj)
print("\tDependency \"" .. depId .. "\" was not found")
end
end

dependson(depNames)
externalincludedirs(externalIncludeDirs)
libdirs(libDirs)
end

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

local targetDir = binDir .. proj.group .. "/" .. proj.name .. projectNameSuffix(projectType)
targetdir(targetDir)
objdir(binDir .. "obj")

if projectType ~= "util" then
if not utils.tableIsEmpty(externalIncludeDirs) then
externalincludedirs(externalIncludeDirs)
end

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

architecture(buildSettings.platform)
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

if projectType ~= "util" then
targetdir(binDir .. proj.group .. "/" .. proj.name .. projectNameSuffix(projectType))
objdir(binDir .. "obj")
defines(allDefines)

toolset(buildSettings.toolset)
Expand All @@ -484,7 +500,9 @@ function projects.submit(proj)
vpaths({ ["test utils"] = _WORKING_DIR .. "/utils/test utils/**" })
end

vpaths({ ["*"] = proj.location .. projectTypeFilesDir(projectType, proj.namespace) })
filePatterns[#filePatterns + 1] = proj.src

vpaths({ ["*"] = { proj.location .. projectTypeFilesDir(projectType, proj.namespace), fs.parentPath(proj.src) }})
files(filePatterns)

if not utils.tableIsEmpty(proj.exclude_files) then
Expand Down
4 changes: 2 additions & 2 deletions premake5.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
-- root workspace, all sub-project should be included
workspace "rythe"
location(_ACTION)
location("build/" .. _ACTION)
configurations { "Debug", "Development", "Release" }

os.chdir(_WORKING_DIR)
os.chdir(_MAIN_SCRIPT_DIR)

local r = require("premake/rythe")

Expand Down
Binary file modified tools/premake5.exe
Binary file not shown.
14 changes: 0 additions & 14 deletions utils/configure/.rythe_project

This file was deleted.

19 changes: 19 additions & 0 deletions utils/refresh/.rythe_project
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
local project = {
post_build = {}
}

function project.init(proj, ctx)
proj.post_build = {
"cd " .. _WORKING_DIR,
ctx.getCommand()
}
local targetPattern = "build/" .. _ACTION .. "/bin/**/" .. proj.name
for i, dir in ipairs(os.matchdirs(targetPattern)) do
print(dir)
os.rmdir(dir)
end

return proj
end

return project

0 comments on commit ed0694c

Please sign in to comment.