Skip to content

Commit

Permalink
Merge pull request #2139 from tweag/pkgdb-to-bzl-inexistent-dirs
Browse files Browse the repository at this point in the history
Fix error when include dirs do not exist
  • Loading branch information
mergify[bot] authored Mar 22, 2024
2 parents bf2e6cd + 1e5c097 commit e74c12b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
3 changes: 3 additions & 0 deletions haskell/private/pkgdb_to_bzl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ def pkgdb_to_bzl(repository_ctx, paths, libdir):
])
if result.return_code:
fail("Error executing pkgdb_to_bzl.py: {stderr}".format(stderr = result.stderr))
elif result.stderr:
# print any warnings from pkgdb_to_bzl.py
print(result.stderr)

result_dict = json.decode(result.stdout)

Expand Down
35 changes: 20 additions & 15 deletions haskell/private/pkgdb_to_bzl.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ def resolve(path, pkgroot):
else:
return path


def join_paths(paths):
return ["/".join(ps) for ps in paths if not None in ps]


symlinks = {}

def path_to_label(path, pkgroot, output=None):
Expand Down Expand Up @@ -218,36 +223,36 @@ def hs_library_pattern(name, mode = "static", profiling = False):
name = pkg.name,
id = pkg.id,
version = pkg.version,
hdrs = [
"/".join([path_to_label(include_dir, pkgroot, output), header])
hdrs = join_paths([
[path_to_label(include_dir, pkgroot, output), header]
for include_dir in pkg.include_dirs
for header in match_glob(resolve(include_dir, pkgroot), "**/*.h")
],
includes = [
"/".join([repo_dir, path_to_label(include_dir, pkgroot, output)])
]),
includes = join_paths([
[repo_dir, path_to_label(include_dir, pkgroot, output)]
for include_dir in pkg.include_dirs
],
static_libraries = [
"/".join([path_to_label(library_dir, pkgroot, output), library])
]),
static_libraries = join_paths([
[path_to_label(library_dir, pkgroot, output), library]
for hs_library in pkg.hs_libraries
for pattern in hs_library_pattern(hs_library, mode = "static", profiling = False)
for library_dir in pkg.library_dirs
for library in match_glob(resolve(library_dir, pkgroot), pattern)
],
static_profiling_libraries = [
"/".join([path_to_label(library_dir, pkgroot, output), library])
]),
static_profiling_libraries = join_paths([
[path_to_label(library_dir, pkgroot, output), library]
for hs_library in pkg.hs_libraries
for pattern in hs_library_pattern(hs_library, mode = "static", profiling = True)
for library_dir in pkg.library_dirs
for library in match_glob(resolve(library_dir, pkgroot), pattern)
],
shared_libraries = [
"/".join([path_to_label(dynamic_library_dir, pkgroot, output), library])
]),
shared_libraries = join_paths([
[path_to_label(dynamic_library_dir, pkgroot, output), library]
for hs_library in pkg.hs_libraries
for pattern in hs_library_pattern(hs_library, mode = "dynamic", profiling = False)
for dynamic_library_dir in set(pkg.dynamic_library_dirs + pkg.library_dirs)
for library in match_glob(resolve(dynamic_library_dir, pkgroot), pattern)
],
]),
haddock_html = repr(haddock_html),
haddock_interfaces = repr(haddock_interfaces),
deps = pkg.depends,
Expand Down

0 comments on commit e74c12b

Please sign in to comment.