From ee58af73f09020aaa8a65e4a660484ff9826dabc Mon Sep 17 00:00:00 2001 From: Alinson S Xavier Date: Fri, 15 Oct 2021 08:14:04 -0500 Subject: [PATCH] Update sysimage and build scripts --- Makefile | 11 ++++------- src/sysimage.jl | 37 ++++++++++++++++++++++++++----------- test/model/resolve_test.jl | 4 +++- test/reports_test.jl | 4 +++- 4 files changed, 36 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index e86d416..5d6bfcc 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,11 @@ -JULIA := julia --color=yes --project=@. +JULIA := julia --project=. SRC_FILES := $(wildcard src/*.jl test/*.jl) VERSION := 0.5 all: docs test build/sysimage.so: src/sysimage.jl Project.toml Manifest.toml - mkdir -p build - $(JULIA) src/sysimage.jl - -build/test.log: $(SRC_FILES) build/sysimage.so - cd test; $(JULIA) --sysimage ../build/sysimage.so runtests.jl + @$(JULIA) src/sysimage.jl clean: rm -rf build/* @@ -20,7 +16,8 @@ docs: format: julia -e 'using JuliaFormatter; format(["src", "test"], verbose=true);' -test: build/test.log +test: + @$(JULIA) --sysimage build/sysimage.so test/runtests.jl test-watch: bash -c "while true; do make test --quiet; sleep 1; done" diff --git a/src/sysimage.jl b/src/sysimage.jl index 162a2fc..8cdeecf 100644 --- a/src/sysimage.jl +++ b/src/sysimage.jl @@ -1,15 +1,30 @@ using PackageCompiler +using TOML +using Logging -using Cbc -using Clp -using Geodesy -using JSON -using JSONSchema -using JuMP -using MathOptInterface -using ProgressBars +Logging.disable_logging(Logging.Info) -pkg = [:Cbc, :Clp, :Geodesy, :JSON, :JSONSchema, :JuMP, :MathOptInterface, :ProgressBars] +mkpath("build") -@info "Building system image..." -create_sysimage(pkg, sysimage_path = "build/sysimage.so") +printstyled("Generating precompilation statements...\n", color=:light_green) +run(`julia --project=. --trace-compile=build/precompile.jl $ARGS`) + +printstyled("Finding dependencies...\n", color=:light_green) +project = TOML.parsefile("Project.toml") +manifest = TOML.parsefile("Manifest.toml") +deps = Symbol[] +for dep in keys(project["deps"]) + if "path" in keys(manifest[dep][1]) + printstyled(" skip $(dep)\n", color=:light_black) + else + println(" add $(dep)") + push!(deps, Symbol(dep)) + end +end + +printstyled("Building system image...\n", color=:light_green) +create_sysimage( + deps, + precompile_statements_file = "build/precompile.jl", + sysimage_path = "build/sysimage.so", +) diff --git a/test/model/resolve_test.jl b/test/model/resolve_test.jl index f4d4e60..9021000 100644 --- a/test/model/resolve_test.jl +++ b/test/model/resolve_test.jl @@ -3,9 +3,11 @@ using RELOG +basedir = @__DIR__ + @testset "Resolve" begin # Shoud not crash - filename = "$(pwd())/../instances/s1.json" + filename = "$basedir/../../instances/s1.json" solution_old, model_old = RELOG.solve(filename, return_model = true) solution_new = RELOG.resolve(model_old, filename) end diff --git a/test/reports_test.jl b/test/reports_test.jl index 684a4cf..9193977 100644 --- a/test/reports_test.jl +++ b/test/reports_test.jl @@ -4,9 +4,11 @@ using RELOG, JSON, GZip +basedir = @__DIR__ + @testset "Reports" begin @testset "from solve" begin - solution = RELOG.solve("$(pwd())/../instances/s1.json") + solution = RELOG.solve("$basedir/../instances/s1.json") tmp_filename = tempname() # The following should not crash RELOG.write_plant_emissions_report(solution, tmp_filename)