Skip to content

Commit 43f19a7

Browse files
authored
Ignore Exampe and Test licenses (#37)
1 parent 6f048f0 commit 43f19a7

File tree

6 files changed

+37
-50
lines changed

6 files changed

+37
-50
lines changed

Example/Licenses/Alamofire/LICENSE

Lines changed: 0 additions & 19 deletions
This file was deleted.

Example/Licenses/SwiftyJSON/LICENSE

Lines changed: 0 additions & 21 deletions
This file was deleted.

Example/LicensesViewControllerExample.xcodeproj/project.pbxproj

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,10 @@
149149
isa = PBXNativeTarget;
150150
buildConfigurationList = 2B8B01B41CB12B6600F03947 /* Build configuration list for PBXNativeTarget "iOS Example" */;
151151
buildPhases = (
152+
2B5C4C7B1CB12BE0003CA077 /* Generate Licenses Plist */,
152153
65BAF183D333E2E8606F96C7 /* [CP] Check Pods Manifest.lock */,
153154
2B8B019E1CB12B6600F03947 /* Sources */,
154155
2B8B019F1CB12B6600F03947 /* Frameworks */,
155-
2B5C4C7B1CB12BE0003CA077 /* Generate Licenses Plist */,
156156
2B8B01A01CB12B6600F03947 /* Resources */,
157157
2BF95C631CB1303B00429D0B /* Embed Framework */,
158158
7B4799681485A521CA3C59A2 /* [CP] Embed Pods Frameworks */,
@@ -264,7 +264,7 @@
264264
);
265265
runOnlyForDeploymentPostprocessing = 0;
266266
shellPath = /bin/sh;
267-
shellScript = "../credits.py -s \"$SRCROOT/Licenses\" -o \"$SRCROOT/LicensesViewControllerExample/Credits.plist\"";
267+
shellScript = "../credits.py -s \"${PODS_ROOT}\" -o \"$SRCROOT/LicensesViewControllerExample/Credits.plist\"\n";
268268
};
269269
2B5C4C7B1CB12BE0003CA077 /* Generate Licenses Plist */ = {
270270
isa = PBXShellScriptBuildPhase;
@@ -278,7 +278,7 @@
278278
);
279279
runOnlyForDeploymentPostprocessing = 0;
280280
shellPath = /bin/sh;
281-
shellScript = "../credits.py -s \"$SRCROOT/Licenses\" -o \"$SRCROOT/LicensesViewControllerExample/Credits.plist\"";
281+
shellScript = "../credits.py -s \"${PODS_ROOT}\" -o \"$SRCROOT/LicensesViewControllerExample/Credits.plist\"\n";
282282
};
283283
65BAF183D333E2E8606F96C7 /* [CP] Check Pods Manifest.lock */ = {
284284
isa = PBXShellScriptBuildPhase;
@@ -305,11 +305,15 @@
305305
);
306306
inputPaths = (
307307
"${PODS_ROOT}/Target Support Files/Pods-iOS Example/Pods-iOS Example-frameworks.sh",
308+
"${BUILT_PRODUCTS_DIR}/Alamofire-iOS/Alamofire.framework",
308309
"${BUILT_PRODUCTS_DIR}/LicensesViewController-iOS/LicensesViewController.framework",
310+
"${BUILT_PRODUCTS_DIR}/SwiftyJSON-iOS/SwiftyJSON.framework",
309311
);
310312
name = "[CP] Embed Pods Frameworks";
311313
outputPaths = (
314+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Alamofire.framework",
312315
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/LicensesViewController.framework",
316+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftyJSON.framework",
313317
);
314318
runOnlyForDeploymentPostprocessing = 0;
315319
shellPath = /bin/sh;
@@ -341,11 +345,15 @@
341345
);
342346
inputPaths = (
343347
"${PODS_ROOT}/Target Support Files/Pods-tvOS Example/Pods-tvOS Example-frameworks.sh",
348+
"${BUILT_PRODUCTS_DIR}/Alamofire-tvOS/Alamofire.framework",
344349
"${BUILT_PRODUCTS_DIR}/LicensesViewController-tvOS/LicensesViewController.framework",
350+
"${BUILT_PRODUCTS_DIR}/SwiftyJSON-tvOS/SwiftyJSON.framework",
345351
);
346352
name = "[CP] Embed Pods Frameworks";
347353
outputPaths = (
354+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Alamofire.framework",
348355
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/LicensesViewController.framework",
356+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftyJSON.framework",
349357
);
350358
runOnlyForDeploymentPostprocessing = 0;
351359
shellPath = /bin/sh;

Example/Podfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@ use_frameworks!
33
target 'iOS Example' do
44
platform :ios, '8.0'
55
pod 'LicensesViewController', :path => '../'
6+
pod 'Alamofire', '~> 4.0'
7+
pod 'SwiftyJSON', '~> 4.0'
68
end
79

810
target 'tvOS Example' do
911
platform :tvos, '9.0'
1012
pod 'LicensesViewController', :path => '../'
13+
pod 'Alamofire', '~> 4.0'
14+
pod 'SwiftyJSON', '~> 4.0'
1115
end

LicensesViewController.xcodeproj/project.pbxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@
240240
);
241241
runOnlyForDeploymentPostprocessing = 0;
242242
shellPath = /bin/sh;
243-
shellScript = "./credits.py -s \"$SRCROOT/Tests/Resources\" -o \"$SRCROOT/Tests/Resources/Credits.plist\"\n";
243+
shellScript = "./credits.py --test -s \"$SRCROOT/Tests/Resources\" -o \"$SRCROOT/Tests/Resources/Credits.plist\"\n";
244244
};
245245
2BECE0F6218726BF00459C0B /* Generate Licenses Plist */ = {
246246
isa = PBXShellScriptBuildPhase;

credits.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from optparse import Option, OptionValueError
2222
from copy import deepcopy
2323

24-
VERSION = '0.3'
24+
VERSION = '0.4.0'
2525
PROG = os.path.basename(os.path.splitext(__file__)[0])
2626
DESCRIPTION = """Generate a `Settings.bundle` friendly plist file from all
2727
'LICENSE.*' files in a given directory. Inspired by JosephH and Sean's
@@ -65,6 +65,12 @@ def exclude_callback(option, _, value, option_parser):
6565
metavar='path1, ...',
6666
help='comma separated list of paths to be excluded',
6767
callback=exclude_callback)
68+
parser.add_option('-t', '--test',
69+
action="store_true",
70+
dest='include_tests',
71+
metavar='include_tests',
72+
default=False,
73+
help='include files in the `Tests` directory for unit testing')
6874
if len(sys.argv) == 1:
6975
parser.parse_args(['--help'])
7076

@@ -78,18 +84,22 @@ def exclude_callback(option, _, value, option_parser):
7884
print("Error: Outputfile must end in .plist")
7985
sys.exit(2)
8086

81-
plist = plist_from_dir(options.input_path, options.excludes)
87+
plist = plist_from_dir(
88+
options.input_path,
89+
options.excludes,
90+
options.include_tests
91+
)
8292
plistlib.writePlist(plist, options.output_file)
8393
return 0
8494

8595

86-
def plist_from_dir(directory, excludes):
96+
def plist_from_dir(directory, excludes, include_tests):
8797
"""
8898
Recursively search 'dir' to generates plist objects from LICENSE files.
8999
"""
90100
plist = {'PreferenceSpecifiers': [], 'StringsTable': 'Acknowledgements'}
91101
license_paths = license_paths_form_dir(directory)
92-
plist_paths = (plist_path for plist_path in license_paths if not exclude_path(plist_path, excludes))
102+
plist_paths = (plist_path for plist_path in license_paths if not exclude_path(plist_path, excludes, include_tests))
93103
for plist_path in plist_paths:
94104
license_dict = plist_from_file(plist_path)
95105
plist['PreferenceSpecifiers'].append(license_dict)
@@ -127,9 +137,14 @@ def plist_from_file(path):
127137
return group
128138

129139

130-
def exclude_path(path, excludes):
131-
if excludes is None:
140+
def exclude_path(path, excludes, is_testing):
141+
if "/LicenseGenerator-iOS/Example/" in path:
142+
return True
143+
elif "/LicenseGenerator-iOS/Tests/" in path:
144+
return not is_testing
145+
elif excludes is None:
132146
return False
147+
133148
for pattern in excludes:
134149
if re.search(pattern.strip(), path, re.S) is not None:
135150
return True

0 commit comments

Comments
 (0)