Skip to content

Commit

Permalink
Add support of per-file configuration buildaction "Copy" for Codeli…
Browse files Browse the repository at this point in the history
…te. (#2171)
  • Loading branch information
Jarod42 authored Dec 15, 2023
1 parent ade8edc commit 78afb22
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
9 changes: 9 additions & 0 deletions modules/codelite/codelite_project.lua
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,15 @@
local dependencies = {}
local makefilerules = {}
local function addrule(dependencies, makefilerules, config, filename)
if config.buildaction == "Copy" and filename ~= "" then
local output = project.getrelative(cfg.workspace, path.join(cfg.targetdir, config.name))
local create_directory_command = '\t@$(MakeDirCommand) $(@D)\n'
local command = '\t' .. os.translateCommands('{COPYFILE} "' .. filename .. '" "' .. output ..'"') .. '\n'

table.insert(makefilerules, output .. ": " .. filename .. '\n' .. create_directory_command .. command)
table.insert(dependencies, output)
return true
end
if #config.buildcommands == 0 or #config.buildoutputs == 0 then
return false
end
Expand Down
22 changes: 22 additions & 0 deletions modules/codelite/tests/test_codelite_additional_rules.lua
Original file line number Diff line number Diff line change
Expand Up @@ -286,3 +286,25 @@ foo.c: foo.txt foo.h extra_dependency
</AdditionalRules>]]
end

function suite.buildactionCopy()
targetdir "bin"
files {"foo.txt", "bar.txt"}
filter "files:**.txt"
buildaction "Copy"

prepare()
codelite.project.additionalRules(cfg)
test.capture( [[
<AdditionalRules>
<CustomPostBuild/>
<CustomPreBuild>bin/bar.txt bin/foo.txt
bin/bar.txt: bar.txt
@$(MakeDirCommand) $(@D)
]] .. os.translateCommands('{COPYFILE} "bar.txt" "bin/bar.txt"') .. '\n' .. [[
bin/foo.txt: foo.txt
@$(MakeDirCommand) $(@D)
]] .. os.translateCommands('{COPYFILE} "foo.txt" "bin/foo.txt"') .. '\n' .. [[
</CustomPreBuild>
</AdditionalRules>]])
end

0 comments on commit 78afb22

Please sign in to comment.