Skip to content

Commit

Permalink
openusd cmd: align pixar upstream target casing.
Browse files Browse the repository at this point in the history
  • Loading branch information
furby-tm committed Jun 13, 2024
1 parent 7c10d08 commit fe893d0
Showing 1 changed file with 63 additions and 3 deletions.
66 changes: 63 additions & 3 deletions Sources/OpenUSD/Commands/UpdateCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,17 @@ public enum Pxr: String, CaseIterable
// ----------- determine target and source paths -----------

let suffix = path(from: pxrPath).split(separator: "pxr/\(rawValue)/").last ?? ""
let target = (suffix.split(separator: "/").first ?? "").capitalized
let source = URL(fileURLWithPath: ".build/OpenUSD/pxr/\(rawValue)/\(path(from: pxrPath))")
var target = (suffix.split(separator: "/").first ?? "").capitalized

// ---------------- skip testenv directories ---------------
ensureCasing(for: &target)

if source.path.contains("testenv") { return nil }
// --------------------- skipped source --------------------

if source.path.contains("testenv") ||
source.path.lowercased().contains("cmakelists") ||
source.path.lowercased().contains("pch.h")
{ return nil }

// --------------- create target directories ---------------

Expand Down Expand Up @@ -276,4 +281,59 @@ public enum Pxr: String, CaseIterable
{
enumerated as? String ?? ""
}

/**
* Ensure the casing is correct for the given target.
*/
private func ensureCasing(for target: inout String)
{
for suffix in ["imaging", "app", "utils", "st", "si", "mtlx", "gp", "proc", "vol", "skel"]
{
if target.contains(suffix)
{
target = target.replacingOccurrences(of: suffix, with: suffix.capitalized)
}
}

if target.contains("Geom")
{
target = target.replacingOccurrences(of: "util", with: "Util")
}

if target.contains("Hgi")
{
target = target.replacingOccurrences(of: "metal", with: "Metal")
target = target.replacingOccurrences(of: "gl", with: "GL")
target = target.replacingOccurrences(of: "vulkan", with: "Vulkan")
target = target.replacingOccurrences(of: "interop", with: "Interop")
}

if target.contains("Hio")
{
target = target.replacingOccurrences(of: "open", with: "Open")
target = target.replacingOccurrences(of: "vdb", with: "VDB")
}

if target.contains("Px")
{
target = target.replacingOccurrences(of: "osd", with: "Osd")
}

if target.contains("Usd")
{
target = target.replacingOccurrences(of: "geom", with: "Geom")
target = target.replacingOccurrences(of: "lux", with: "Lux")
target = target.replacingOccurrences(of: "ri", with: "Ri")
target = target.replacingOccurrences(of: "pxr", with: "Pxr")
target = target.replacingOccurrences(of: "gl", with: "GL")
target = target.replacingOccurrences(of: "render", with: "Render")
target = target.replacingOccurrences(of: "hydra", with: "Hydra")
target = target.replacingOccurrences(of: "viewq", with: "ViewQ")
}

if target.contains("Hd")
{
target = target.replacingOccurrences(of: "ar", with: "Ar")
}
}
}

0 comments on commit fe893d0

Please sign in to comment.