mirror of
https://github.com/yonaskolb/XcodeGen.git
synced 2024-09-20 17:17:33 +03:00
Merge pull request #238 from yonaskolb/ts-exclude-dsstore-bug
sources.excludes wasn't applied for localisedDirectory such as Base.lproj
This commit is contained in:
commit
cc76e37d35
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,4 +1,7 @@
|
|||||||
.DS_Store
|
# NOTE: Do not ignore .DS_Store for test fixtures.
|
||||||
|
# .DS_Store
|
||||||
|
./.DS_Store
|
||||||
|
|
||||||
/.build
|
/.build
|
||||||
/Packages
|
/Packages
|
||||||
xcuserdata
|
xcuserdata
|
||||||
|
BIN
Fixtures/TestProject/.DS_Store
vendored
Normal file
BIN
Fixtures/TestProject/.DS_Store
vendored
Normal file
Binary file not shown.
@ -220,26 +220,24 @@ class SourceGenerator {
|
|||||||
return variantGroup
|
return variantGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
private func getSourceChildren(targetSource: TargetSource, dirPath: Path) throws -> [Path] {
|
private func getSourceExcludes(targetSource: TargetSource) -> [Path] {
|
||||||
|
let rootSourcePath = spec.basePath + targetSource.path
|
||||||
|
|
||||||
func getSourceExcludes(dirPath: Path) -> [Path] {
|
return targetSource.excludes.map {
|
||||||
return targetSource.excludes.map {
|
Path.glob("\(rootSourcePath)/\($0)")
|
||||||
Path.glob("\(dirPath)/\($0)")
|
.map {
|
||||||
.map {
|
guard $0.isDirectory else {
|
||||||
guard $0.isDirectory else {
|
return [$0]
|
||||||
return [$0]
|
|
||||||
}
|
|
||||||
|
|
||||||
return (try? $0.recursiveChildren().filter { $0.isFile }) ?? []
|
|
||||||
}
|
}
|
||||||
.reduce([], +)
|
|
||||||
|
return (try? $0.recursiveChildren().filter { $0.isFile }) ?? []
|
||||||
|
}
|
||||||
|
.reduce([], +)
|
||||||
}
|
}
|
||||||
.reduce([], +)
|
.reduce([], +)
|
||||||
}
|
}
|
||||||
|
|
||||||
let defaultExcludedFiles = [".DS_Store"].map { dirPath + Path($0) }
|
private func getSourceChildren(targetSource: TargetSource, dirPath: Path) throws -> [Path] {
|
||||||
|
|
||||||
let rootSourcePath = spec.basePath + targetSource.path
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Exclude following if mentioned in TargetSource.excludes.
|
Exclude following if mentioned in TargetSource.excludes.
|
||||||
@ -248,21 +246,23 @@ class SourceGenerator {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
let sourceExcludeFilePaths: Set<Path> = Set(
|
let sourceExcludeFilePaths: Set<Path> = Set(
|
||||||
getSourceExcludes(dirPath: rootSourcePath)
|
getSourceExcludes(targetSource: targetSource)
|
||||||
+ defaultExcludedFiles
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func isNotExcludeFilePath(_ path: Path) -> Bool {
|
||||||
|
return !path.lastComponent.contains(".DS_Store")
|
||||||
|
&& !sourceExcludeFilePaths.contains(path)
|
||||||
|
}
|
||||||
|
|
||||||
return try dirPath.children()
|
return try dirPath.children()
|
||||||
.filter {
|
.filter {
|
||||||
if $0.isDirectory {
|
if $0.isDirectory {
|
||||||
let pathChildren = try $0.children()
|
let pathChildren = try $0.children()
|
||||||
.filter {
|
.filter(isNotExcludeFilePath(_:))
|
||||||
return !sourceExcludeFilePaths.contains($0)
|
|
||||||
}
|
|
||||||
|
|
||||||
return !pathChildren.isEmpty
|
return !pathChildren.isEmpty
|
||||||
} else if $0.isFile {
|
} else if $0.isFile {
|
||||||
return !sourceExcludeFilePaths.contains($0)
|
return isNotExcludeFilePath($0)
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -270,7 +270,8 @@ class SourceGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func getGroupSources(targetSource: TargetSource, path: Path, isBaseGroup: Bool)
|
private func getGroupSources(targetSource: TargetSource, path: Path, isBaseGroup: Bool)
|
||||||
throws -> (sourceFiles: [SourceFile], groups: [ObjectReference<PBXGroup>]) {
|
throws -> (sourceFiles: [SourceFile], groups: [ObjectReference<PBXGroup>])
|
||||||
|
{
|
||||||
|
|
||||||
let children = try getSourceChildren(targetSource: targetSource, dirPath: path)
|
let children = try getSourceChildren(targetSource: targetSource, dirPath: path)
|
||||||
|
|
||||||
@ -323,8 +324,19 @@ class SourceGenerator {
|
|||||||
// create variant groups of the base localisation first
|
// create variant groups of the base localisation first
|
||||||
var baseLocalisationVariantGroups: [PBXVariantGroup] = []
|
var baseLocalisationVariantGroups: [PBXVariantGroup] = []
|
||||||
|
|
||||||
|
let sourceExcludeFilePaths: Set<Path> = Set(
|
||||||
|
getSourceExcludes(targetSource: targetSource)
|
||||||
|
)
|
||||||
|
|
||||||
|
func isNotExcludeFilePath(_ path: Path) -> Bool {
|
||||||
|
return !path.lastComponent.contains(".DS_Store")
|
||||||
|
&& !sourceExcludeFilePaths.contains(path)
|
||||||
|
}
|
||||||
|
|
||||||
if let baseLocalisedDirectory = baseLocalisedDirectory {
|
if let baseLocalisedDirectory = baseLocalisedDirectory {
|
||||||
for filePath in try baseLocalisedDirectory.children().sorted() {
|
for filePath in try baseLocalisedDirectory.children()
|
||||||
|
.filter(isNotExcludeFilePath(_:))
|
||||||
|
.sorted() {
|
||||||
let variantGroup = getVariantGroup(path: filePath, inPath: path)
|
let variantGroup = getVariantGroup(path: filePath, inPath: path)
|
||||||
groupChildren.append(variantGroup.reference)
|
groupChildren.append(variantGroup.reference)
|
||||||
baseLocalisationVariantGroups.append(variantGroup.object)
|
baseLocalisationVariantGroups.append(variantGroup.object)
|
||||||
@ -342,7 +354,9 @@ class SourceGenerator {
|
|||||||
// add references to localised resources into base localisation variant groups
|
// add references to localised resources into base localisation variant groups
|
||||||
for localisedDirectory in localisedDirectories {
|
for localisedDirectory in localisedDirectories {
|
||||||
let localisationName = localisedDirectory.lastComponentWithoutExtension
|
let localisationName = localisedDirectory.lastComponentWithoutExtension
|
||||||
for filePath in try localisedDirectory.children().sorted { $0.lastComponent < $1.lastComponent } {
|
for filePath in try localisedDirectory.children()
|
||||||
|
.filter(isNotExcludeFilePath(_:))
|
||||||
|
.sorted { $0.lastComponent < $1.lastComponent } {
|
||||||
// find base localisation variant group
|
// find base localisation variant group
|
||||||
// ex: Foo.strings will be added to Foo.strings or Foo.storyboard variant group
|
// ex: Foo.strings will be added to Foo.strings or Foo.storyboard variant group
|
||||||
let variantGroup = baseLocalisationVariantGroups
|
let variantGroup = baseLocalisationVariantGroups
|
||||||
|
0
Tests/Fixtures/TestProject/.DS_Store
vendored
Normal file
0
Tests/Fixtures/TestProject/.DS_Store
vendored
Normal file
0
Tests/Fixtures/TestProject/App_iOS/.DS_Store
vendored
Normal file
0
Tests/Fixtures/TestProject/App_iOS/.DS_Store
vendored
Normal file
0
Tests/Fixtures/TestProject/App_iOS/Base.lproj/.DS_Store
vendored
Normal file
0
Tests/Fixtures/TestProject/App_iOS/Base.lproj/.DS_Store
vendored
Normal file
0
Tests/Fixtures/TestProject/App_iOS/excluded-file
Normal file
0
Tests/Fixtures/TestProject/App_iOS/excluded-file
Normal file
0
Tests/Fixtures/TestProject/excluded-file
Normal file
0
Tests/Fixtures/TestProject/excluded-file
Normal file
@ -29,6 +29,9 @@ targets:
|
|||||||
name: App
|
name: App
|
||||||
compilerFlags:
|
compilerFlags:
|
||||||
- "-Werror"
|
- "-Werror"
|
||||||
|
excludes:
|
||||||
|
- "**/excluded-file"
|
||||||
|
- "excluded-file"
|
||||||
- path: StandaloneFiles/Standalone.swift
|
- path: StandaloneFiles/Standalone.swift
|
||||||
- FileGroup/UnderFileGroup
|
- FileGroup/UnderFileGroup
|
||||||
- Resources/MyBundle.bundle
|
- Resources/MyBundle.bundle
|
||||||
|
Loading…
Reference in New Issue
Block a user