Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build and commit a copy of lessc so we can do archive builds again #1184

Merged
merged 1 commit into from
Mar 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions LessStylesheet/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,23 @@ import PackageDescription
let package = Package(
name: "LessStylesheet",
products: [
.executable(name: "lessc", targets: ["lessc"]),
.plugin(name: "LessStylesheet", targets: ["LessStylesheet"]),
],
targets: [
.plugin(
name: "LessStylesheet",
capability: .buildTool(),
dependencies: [
"lessc",
]
),
.executableTarget(
name: "lessc",
resources: [
.copy("less.js"),
]
),
.plugin(
name: "LessStylesheet",
capability: .buildTool(),
dependencies: [
// No point; doesn't work in archive builds. See read me for more info.
// "lessc",
]
),
]
)
11 changes: 7 additions & 4 deletions LessStylesheet/Plugins/LessStylesheet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ struct LessStylesheet {
func createBuildCommands(
sourceFiles: FileList,
workDirectory: Path,
with tool: PluginContext.Tool
with toolPath: Path
) -> [Command] {
let importables = findImportables(sourceFiles)
let includePaths = findIncludePaths(importables)
let outputDirectory = workDirectory.appending(subpath: "LessStylesheet/")
return Array(sourceFiles
.lazy.map(\.path)
.filter { $0.isLessFile && !$0.isImportable }
.map { createBuildCommand(for: $0, in: outputDirectory, with: tool.path, include: includePaths, otherSources: importables) }
.map { createBuildCommand(for: $0, in: outputDirectory, with: toolPath, include: includePaths, otherSources: importables) }
)
}

Expand Down Expand Up @@ -74,7 +74,7 @@ extension LessStylesheet: BuildToolPlugin {
target: Target
) async throws -> [Command] {
guard let sourceFiles = target.sourceModule?.sourceFiles else { return [] }
let lessc = try context.tool(named: "lessc")
let lessc = context.package.directory.removingLastComponent().appending(subpath: prebuiltSubpath)
return createBuildCommands(sourceFiles: sourceFiles, workDirectory: context.pluginWorkDirectory, with: lessc)
}
}
Expand All @@ -87,9 +87,12 @@ extension LessStylesheet: XcodeBuildToolPlugin {
context: XcodePluginContext,
target: XcodeTarget
) throws -> [Command] {
let lessc = try context.tool(named: "lessc")
let lessc = context.xcodeProject.directory.appending(subpath: prebuiltSubpath)
return createBuildCommands(sourceFiles: target.inputFiles, workDirectory: context.pluginWorkDirectory, with: lessc)
}
}

#endif

/// See read me for an explanation.
let prebuiltSubpath = "LessStylesheet/Prebuilt/lessc"
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>23D60</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>LessStylesheet_lessc</string>
<key>CFBundleIdentifier</key>
<string>LessStylesheet.lessc.resources</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>LessStylesheet_lessc</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string></string>
<key>DTPlatformName</key>
<string>macosx</string>
<key>DTPlatformVersion</key>
<string>14.2</string>
<key>DTSDKBuild</key>
<string>23C53</string>
<key>DTSDKName</key>
<string>macosx14.2</string>
<key>DTXcode</key>
<string>1520</string>
<key>DTXcodeBuild</key>
<string>15C500b</string>
<key>LSMinimumSystemVersion</key>
<string>10.13</string>
</dict>
</plist>
Loading
Loading