Skip to content

Commit b98bd7f

Browse files
committed
More stuff
1 parent 84ac04b commit b98bd7f

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

examples/MyLib/Makefile

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,34 @@ all: build-library build-executable
77

88
JULIA ?= julia
99
GCC ?= gcc
10+
1011
DLEXT := $(shell $(JULIA) --startup-file=no -e 'import Libdl; print(Libdl.dlext)')
1112

1213
TARGET="MyLibCompiled"
1314

1415
MYLIB_INCLUDES = $(TARGET)/include/julia_init.h $(TARGET)/include/mylib.h
1516
MYLIB_PATH := $(TARGET)/lib/libmylib.$(DLEXT)
1617

18+
DEPS_build_library := src/MyLib.jl
19+
DEPS_build_library += build/build.jl
20+
DEPS_build_library += build/generate_precompile.jl build/additional_precompile.jl
21+
DEPS_build_library += build/mylib.h
22+
DEPS_build_library += build/Project.toml build/Manifest.toml
23+
1724
.PHONY: build-library
18-
build-library: build/build.jl src/MyLib.jl
25+
build-library: MyLibCompiled/lib/libmylib.dylib
26+
27+
MyLibCompiled/lib/libmylib.dylib: $(DEPS_build_library)
1928
$(JULIA) --startup-file=no --project=. -e 'import Pkg; Pkg.instantiate(); Pkg.precompile()'
2029
$(JULIA) --startup-file=no --project=build -e 'import Pkg; Pkg.instantiate(); Pkg.precompile()'
2130
$(JULIA) --startup-file=no --project=build -e 'include("build/build.jl")'
2231

2332
INCLUDE_DIR = $(TARGET)/include
2433

2534
.PHONY: build-executable
26-
build-executable:
35+
build-executable: my_application.out
36+
37+
my_application.out: MyLibCompiled/lib/libmylib.dylib
2738
$(GCC) my_application.c -o my_application.out -I$(INCLUDE_DIR) -L$(TARGET)/lib -ljulia -lmylib
2839

2940
.PHONY: clean

examples/MyLib/runme.bash

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
3+
set -euf -o pipefail
4+
5+
if [[ "$OSTYPE" == "darwin"* ]]; then
6+
export DYLD_FALLBACK_LIBRARY_PATH="./MyLibCompiled/lib/:./MyLibCompiled/lib/julia"
7+
else
8+
export LD_LIBRARY_PATH="./MyLibCompiled/lib/"
9+
fi
10+
11+
./my_application.out "$@"

test/runtests.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ end
277277
cmd = `$(Base.julia_cmd()[1]) --project="./build" -e "$(code)"`
278278
run(cmd)
279279

280-
280+
281281
# We don't want to assume that the machine running the tests has `make` installed
282282
# and available in the PATH. Therefore, we use the `GNUMake_jll.jl`` package.
283283
my_run(`$(GNUMake_jll.make())`)
@@ -295,6 +295,11 @@ end
295295
expected_str = "Incremented count: 4 (Cint)\nIncremented value: 4"
296296
@test observed_str == expected_str
297297

298+
# Yes, we do have a convenience wrapper script at `examples/MyLib/runme.bash`
299+
# However, for the PackageCompiler test suite, we don't want to make any assumptions
300+
# about Bash being available on the machine that's running the tests.
301+
# So instead, we manaully run the `./my_application.out` executable ourselves.
302+
298303
# Finally, exercise a few more `Makefile` targets, to make sure that they
299304
# don't bitrot.
300305
my_run(`$(GNUMake_jll.make()) all`)

0 commit comments

Comments
 (0)