Skip to content

Commit ed8e51c

Browse files
committed
WIP for cocoapods
This is not yet working at all Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
1 parent adfd04c commit ed8e51c

6 files changed

Lines changed: 1523 additions & 17 deletions

File tree

apache-2.0_290.RULE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
licensed under the {{Apache License, Version 2.0}} (the “License”).
2+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

src/packagedcode/cocoapods.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
import hashlib
1111
import json
12-
import re
1312

1413
import saneyaml
1514
from packageurl import PackageURL
@@ -99,17 +98,21 @@ def assemble(cls, package_data, resource, codebase):
9998
"""
10099
Assemble pod packages and dependencies and handle the specifc cases where
101100
there are more than one podspec in the same directory.
101+
This is designed to process .podspec, Podfile and Podfile.lock
102102
"""
103103
if codebase.has_single_resource:
104104
yield from models.DatafileHandler.assemble(package_data, resource, codebase)
105105
else:
106+
# do we have more than one podspec?
106107
parent = resource.parent(codebase)
107108
sibling_podspecs = [
108109
r for r in parent.children(codebase)
109110
if r.name.endswith('.podspec')
110111
]
111112

112-
has_single_podspec = len(sibling_podspecs) == 1
113+
siblings_counts = len(sibling_podspecs)
114+
has_single_podspec = siblings_counts == 1
115+
has_multiple_podspec = siblings_counts > 1
113116

114117
if has_single_podspec:
115118
# we can treat all podfile/spec as being for one package
@@ -123,12 +126,12 @@ def assemble(cls, package_data, resource, codebase):
123126
directory=parent,
124127
codebase=codebase,
125128
)
126-
else:
129+
130+
elif has_multiple_podspec:
127131
# treat each of podspec and podfile alone without meraging
128132
# as we cannot determine easily which podfile is for which
129133
# podspec
130-
for resource in sibling_podspecs:
131-
yield from models.DatafileHandler.assemble(package_data, resource, codebase)
134+
yield from models.DatafileHandler.assemble(package_data, resource, codebase)
132135

133136
datafile_name_patterns = (
134137
'Podfile.lock',
@@ -140,6 +143,18 @@ def assemble(cls, package_data, resource, codebase):
140143
codebase=codebase,
141144
)
142145

146+
else:
147+
# has_no_podspec:
148+
datafile_name_patterns = (
149+
'Podfile.lock',
150+
'Podfile',
151+
)
152+
yield from models.DatafileHandler.assemble_from_many_datafiles(
153+
datafile_name_patterns=datafile_name_patterns,
154+
directory=parent,
155+
codebase=codebase,
156+
)
157+
143158

144159
class PodspecHandler(BasePodHandler):
145160
datasource_id = 'cocoapods_podspec'

0 commit comments

Comments
 (0)