Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions test/trimming/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
$(error "Please pass BIN=[path of build directory], or set as environment variable!")
endif

# When made in cygwin, paths generated herein will start with /cygdrive/c/,
# but when passed as arguments into julia, they must start with C:/. This function
# shoulde be used on all paths that are passed to and are to be used within a julia session.

Check warning on line 17 in test/trimming/Makefile

View workflow job for this annotation

GitHub Actions / Check for new typos

perhaps "shoulde" should be "should or shoulder".

Check warning on line 17 in test/trimming/Makefile

View workflow job for this annotation

GitHub Actions / Check whitespace

Whitespace check

trailing whitespace
define maybe_windows_path
$(if $(filter CYGWIN%,$(shell uname -s)),$(shell cygpath -m $(1)),$(1))
endef

#=============================================================================
# location of test source
SRCDIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
Expand All @@ -37,19 +44,19 @@

# Complete any needed Pkg operations before trimming (some Pkg code may not be trimmable)
Manifest.toml: $(SRCDIR)/Project.toml
$(JULIA) --startup-file=no --history-file=no -e 'using Pkg; Pkg.activate("$(SRCDIR)"); Pkg.instantiate()'
$(JULIA) --startup-file=no --history-file=no -e 'using Pkg; Pkg.activate("$(call maybe_windows_path,$(SRCDIR))"); Pkg.instantiate()'

$(BIN)/hello-o.a: $(SRCDIR)/hello.jl $(JULIAC_BUILDSCRIPT) Manifest.toml
$(JULIA) -t 1 -J $(JULIA_LIBDIR)/julia/sys.$(SHLIB_EXT) --startup-file=no --history-file=no --output-o $@ --output-incremental=no --strip-ir --strip-metadata --experimental --trim $(JULIAC_BUILDSCRIPT) $< --output-exe true
$(JULIA) -t 1 -J $(JULIA_LIBDIR)/julia/sys.$(SHLIB_EXT) --startup-file=no --history-file=no --output-o $(call maybe_windows_path,$@) --output-incremental=no --strip-ir --strip-metadata --experimental --trim $(JULIAC_BUILDSCRIPT) $(call maybe_windows_path,$<) --output-exe true

$(BIN)/trimmability-o.a: $(SRCDIR)/trimmability.jl $(JULIAC_BUILDSCRIPT) Manifest.toml
$(JULIA) -t 1 -J $(JULIA_LIBDIR)/julia/sys.$(SHLIB_EXT) --startup-file=no --history-file=no --output-o $@ --output-incremental=no --strip-ir --strip-metadata --experimental --trim $(JULIAC_BUILDSCRIPT) $< --output-exe true
$(JULIA) -t 1 -J $(JULIA_LIBDIR)/julia/sys.$(SHLIB_EXT) --startup-file=no --history-file=no --output-o $(call maybe_windows_path,$@) --output-incremental=no --strip-ir --strip-metadata --experimental --trim $(JULIAC_BUILDSCRIPT) $(call maybe_windows_path,$<) --output-exe true

$(BIN)/basic_jll-o.a: $(SRCDIR)/basic_jll.jl $(JULIAC_BUILDSCRIPT) Manifest.toml
$(JULIA) -t 1 -J $(JULIA_LIBDIR)/julia/sys.$(SHLIB_EXT) --startup-file=no --history-file=no --project=$(SRCDIR) --output-o $@ --output-incremental=no --strip-ir --strip-metadata --experimental --trim $(JULIAC_BUILDSCRIPT) $< --output-exe true
$(JULIA) -t 1 -J $(JULIA_LIBDIR)/julia/sys.$(SHLIB_EXT) --startup-file=no --history-file=no --project=$(SRCDIR) --output-o $(call maybe_windows_path,$@) --output-incremental=no --strip-ir --strip-metadata --experimental --trim $(JULIAC_BUILDSCRIPT) $(call maybe_windows_path,$<) --output-exe true

$(BIN)/libsimple-o.a: $(SRCDIR)/libsimple.jl $(JULIAC_BUILDSCRIPT)
$(JULIA) -t 1 -J $(JULIA_LIBDIR)/julia/sys.$(SHLIB_EXT) --startup-file=no --history-file=no --output-o $@ --output-incremental=no --strip-ir --strip-metadata --experimental --trim $(JULIAC_BUILDSCRIPT) $< --output-lib true $(BIN)/bindinginfo_libsimple.json
$(JULIA) -t 1 -J $(JULIA_LIBDIR)/julia/sys.$(SHLIB_EXT) --startup-file=no --history-file=no --output-o $(call maybe_windows_path,$@) --output-incremental=no --strip-ir --strip-metadata --experimental --trim $(JULIAC_BUILDSCRIPT) $(call maybe_windows_path,$<) --output-lib true $(call maybe_windows_path,$(BIN)/bindinginfo_libsimple.json)

$(BIN)/hello$(EXE): $(BIN)/hello-o.a
$(CC) -o $@ $(call whole_archive,$<) $(CPPFLAGS_ADD) $(CPPFLAGS) $(CFLAGS_ADD) $(CFLAGS) $(LDFLAGS_ADD) $(LDFLAGS)
Expand All @@ -64,7 +71,7 @@
$(CC) -I$(BIN) -I$(SRCDIR) -I$(JULIA_LIBDIR) -o $@ $< -Wl,--whole-archive $(BIN)/libsimple-o.a -Wl,--no-whole-archive $(LDFLAGS_ADD) $(LDFLAGS) $(CPPFLAGS_ADD) $(CPPFLAGS) $(CFLAGS_ADD) $(CFLAGS)

check: $(BIN)/hello$(EXE) $(BIN)/trimmability$(EXE) $(BIN)/basic_jll$(EXE) $(BIN)/capplication$(EXE)
$(JULIA) --startup-file=no --history-file=no --depwarn=error $(SRCDIR)/trimming.jl $<
$(JULIA) --startup-file=no --history-file=no --depwarn=error $(call maybe_windows_path,$(SRCDIR))/trimming.jl $(call maybe_windows_path,$<)

clean:
-rm -f $(BIN)/hello$(EXE) $(BIN)/trimmability$(EXE) $(BIN)/basic_jll$(EXE) $(BIN)/hello-o.a $(BIN)/trimmability-o.a $(BIN)/basic_jll-o.a $(BIN)/libsimple-o.a $(BIN)/libsimple.$(SHLIB_EXT) $(BIN)/capplication$(EXE) $(BIN)/bindinginfo_libsimple.json $(BIN)/Manifest.toml
Expand Down
8 changes: 6 additions & 2 deletions test/trimming/trimming.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ let exe_suffix = splitext(Base.julia_exename())[2]

hello_exe = joinpath(bindir, "hello" * exe_suffix)
@test readchomp(`$hello_exe arg1 arg2`) == "Hello, world!"
@test filesize(hello_exe) < 1_900_000
if Sys.iswindows()
@test filesize(hello_exe) < 2_000_000
else
@test filesize(hello_exe) < 1_900_000
end

trimmability_exe = joinpath(bindir, "trimmability" * exe_suffix)
@test readchomp(`$trimmability_exe arg1 arg2`) == "Hello, world!\n$trimmability_exe\narg1\narg2\n$(4.0+pi)"
Expand All @@ -26,7 +30,7 @@ let exe_suffix = splitext(Base.julia_exename())[2]

# Test that the shared library can be used in a C application
capplication_exe = joinpath(bindir, "capplication" * exe_suffix)
lines = split(readchomp(`$capplication_exe`), "\n")
lines = readlines(`$capplication_exe`)
@test length(lines) == 2
@test lines[1] == "Sum of copied values: 6.000000"
@test lines[2] == "Count of same vectors: 1"
Expand Down
Loading