Skip to content

Commit

Permalink
Add --keep-dir option
Browse files Browse the repository at this point in the history
- On linux, requires an already created directory.
  • Loading branch information
theComputeKid committed Sep 9, 2024
1 parent 878270a commit bfbb680
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Compiles CUDA code using the Visual Studio CUDA Toolkit extension on Windows and
- `cudaPath` (String) -> custom CUDA install path.
- `cudaGenLineInfo` (Bool) -> generates line info.
- `cudaIntDir` (String) -> Intermediary directory for CUDA files - Windows only.
- `cudaKeepDir` (String) -> Directory to place cudaKeep files (on Linux, requires an existing directory).

The following functions are provided:
- `detectNvccVersion()` -> try to detect the default version of nvcc on the system.
Expand Down
6 changes: 6 additions & 0 deletions src/cuda-exported-variables.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,9 @@ premake.api.register {
scope = "project",
kind = "string"
}

premake.api.register {
name = "cudaKeepDir",
scope = "project",
kind = "string"
}
7 changes: 7 additions & 0 deletions src/premake5-cuda-nvcc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ function nvcc.getcxxflags(cfg)
flags = table.join(flags, { "--maxrregcount " .. cfg.cudaMaxRegCount})
end

if cfg.cudaKeepDir ~= nil then
local e = { }
e.cfg = cfg
local v = premake.detoken.expand(cfg.cudaKeepDir, e)
flags = table.join(flags, { "--keep-dir " .. v})
end

return flags
end

Expand Down
7 changes: 7 additions & 0 deletions src/premake5-cuda-vs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ local function addCompilerProps(cfg)
writeString('CompileOut', path.translate(v .. "/%%(Filename)%%(Extension).obj", "\\"))
end

if cfg.cudaKeepDir ~= nil and cfg.cudaKeepDir ~= '' then
local e = { }
e.cfg = cfg
local v = premake.detoken.expand(cfg.cudaKeepDir, e)
writeString('KeepDir', path.translate(v, "\\"))
end

-- Code Generation is useless, when you can provide it directly in the compile flags
premake.w(' <CodeGeneration></CodeGeneration>')
premake.w('</CudaCompile>')
Expand Down
1 change: 1 addition & 0 deletions test/premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ project "ExampleProjectExe"
cudaVerbosePTXAS "On"
cudaMaxRegCount "32"
cudaIntDir "out/bin/cudaobj/%{cfg.buildcfg}"
cudaKeepDir "%{cfg.objdir}"

vpaths {
["Import/*"] = "include/**.hpp",
Expand Down

0 comments on commit bfbb680

Please sign in to comment.