Skip to content

Commit

Permalink
Support compiling without ArrayFire installed (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
lewish authored Feb 23, 2024
1 parent 9b966d2 commit 27c9dc5
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 16 deletions.
24 changes: 9 additions & 15 deletions .ijwb/.bazelproject
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
# This is a projectview file generated automatically during bazel project auto-import
# For more documentation, please visit https://ij.bazel.build/docs/project-views.html
# If your repository contains predefined .projectview files, you use 'import' directive to include them.
# Otherwise, please specify 'directories' and 'targets' you want to be imported
#
# By default we keep your 'directories' and 'targets' sections empty, so nothing is imported.
# Please uncomment them and put the correct data there, and then run 'Sync' again

directories:
# Add the directories you want added as source here
# By default, we've added your entire workspace ('.')
.

# Automatically includes all relevant targets under the 'directories' above
derive_targets_from_directories: true

targets:
# If source code isn't resolving, add additional targets that compile it here

additional_languages:
# Uncomment any additional languages you want supported
# android
# dart
# kotlin
# python
# scala
//arrayfire/...
22 changes: 22 additions & 0 deletions arrayfire/BUILD
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
package(default_visibility = ["//visibility:public"])

genrule(
name = "version_include",
outs = ["includes/af/version.h"],
cmd = """
touch $(location includes/af/version.h)
""",
)

genrule(
name = "compilers_include",
outs = ["includes/af/compilers.h"],
cmd = """
touch $(location includes/af/compilers.h)
""",
)

genrule(
name = "generate_capi",
srcs = [
"@arrayfire//:include/arrayfire.h",
":version_include",
":compilers_include",
"@arrayfire//:include_files",
"@jextract//:bin/jextract",
"@jextract//:bin/java",
Expand All @@ -14,10 +32,14 @@ genrule(
],
cmd = """
HEADER=$(location @arrayfire//:include/arrayfire.h);
VERSION_HEADER=$(location :version_include);
VERSION_PARENT=$$(dirname $$VERSION_HEADER);
$(location @jextract//:bin/jextract) \
$(location @arrayfire//:include/arrayfire.h) \
-I $$(dirname $$HEADER) \
-I $$(dirname $$VERSION_PARENT) \
--define-macro AF_API_VERSION=39 \
--define-macro __CUDACC_RTC__=1 \
-t arrayfire.capi \
; \
jar cf $(location arrayfire-capi.jar) arrayfire/capi/*;
Expand Down
2 changes: 1 addition & 1 deletion deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def arrayfire_java_fla_deps():
http_archive,
name = "jextract",
sha256 = "83626610b1b074bfe4985bd825d8ba44d906a30b24c42d971b6ac836c7eb0671",
urls = ["https://download.java.net/java/early_access/jextract/1/openjdk-21-jextract+1-2_linux-x64_bin.tar.gz"],
urls = ["https://download.java.net/java/early_access/jextract/21/1/openjdk-21-jextract+1-2_linux-x64_bin.tar.gz"],
build_file = "@arrayfire_java_fla//:jextract.BUILD",
strip_prefix = "jextract-21",
)
Expand Down

0 comments on commit 27c9dc5

Please sign in to comment.