diff options
author | Vyacheslav Yurkov <uvv.mail@gmail.com> | 2024-01-16 09:23:20 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-01-19 12:21:22 +0000 |
commit | d5e2279d21410cc4684a5fc903fa079e7efb1c54 (patch) | |
tree | 776f17d56faed0e31cde4f8a7d59b048cfdc61e0 /meta/classes | |
parent | 0161d08ac93a286f09c4e757d817a40f1a2a1602 (diff) | |
download | poky-d5e2279d21410cc4684a5fc903fa079e7efb1c54.tar.gz |
classes: go-vendor: Reference local modules
Create symlinks for local modules, which are usually not referenced in
the SRC_URI, but still expected to be found in the vendor directory
during the build.
(From OE-Core rev: 16da5d9ad448aafd8b5fd63480727bd1b09ec9f1)
Signed-off-by: Vyacheslav Yurkov <uvv.mail@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
-rw-r--r-- | meta/classes/go-vendor.bbclass | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/meta/classes/go-vendor.bbclass b/meta/classes/go-vendor.bbclass index 2426bddfba..b965428dd1 100644 --- a/meta/classes/go-vendor.bbclass +++ b/meta/classes/go-vendor.bbclass | |||
@@ -169,6 +169,7 @@ python do_go_vendor() { | |||
169 | fetched_paths.remove('.') | 169 | fetched_paths.remove('.') |
170 | 170 | ||
171 | vendored_paths = set() | 171 | vendored_paths = set() |
172 | replaced_paths = dict() | ||
172 | with open(modules_txt_src) as f: | 173 | with open(modules_txt_src) as f: |
173 | for line in f: | 174 | for line in f: |
174 | if not line.startswith("#"): | 175 | if not line.startswith("#"): |
@@ -182,6 +183,15 @@ python do_go_vendor() { | |||
182 | vendored_paths.add(topdir) | 183 | vendored_paths.add(topdir) |
183 | 184 | ||
184 | topdir = os.path.dirname(topdir) | 185 | topdir = os.path.dirname(topdir) |
186 | else: | ||
187 | replaced_module = line.split("=>") | ||
188 | if len(replaced_module) > 1: | ||
189 | # This module has been replaced, use a local path | ||
190 | # we parse the line that has a pattern "# module-name [module-version] => local-path | ||
191 | actual_path = replaced_module[1].strip() | ||
192 | vendored_name = replaced_module[0].split()[1] | ||
193 | bb.debug(1, "added vendored name %s for actual path %s" % (vendored_name, actual_path)) | ||
194 | replaced_paths[vendored_name] = actual_path | ||
185 | 195 | ||
186 | for path in fetched_paths: | 196 | for path in fetched_paths: |
187 | if path not in vendored_paths: | 197 | if path not in vendored_paths: |
@@ -189,7 +199,13 @@ python do_go_vendor() { | |||
189 | if os.path.exists(realpath): | 199 | if os.path.exists(realpath): |
190 | shutil.rmtree(realpath) | 200 | shutil.rmtree(realpath) |
191 | 201 | ||
192 | # Create a symlink the the actual directory | 202 | for vendored_name, replaced_path in replaced_paths.items(): |
203 | symlink_target = os.path.join(source_dir, *['src', go_import, replaced_path]) | ||
204 | symlink_name = os.path.join(vendor_dir, vendored_name) | ||
205 | bb.debug(1, "vendored name %s, symlink name %s" % (vendored_name, symlink_name)) | ||
206 | os.symlink(symlink_target, symlink_name) | ||
207 | |||
208 | # Create a symlink to the actual directory | ||
193 | os.symlink(vendor_dir, linkname) | 209 | os.symlink(vendor_dir, linkname) |
194 | } | 210 | } |
195 | 211 | ||