mirror of
https://github.com/ANL-CEEESA/UnitCommitment.jl.git
synced 2025-12-06 08:18:51 -06:00
Replace sysimage.jl by juliaw; add deps/formatter
This commit is contained in:
18
Makefile
18
Makefile
@@ -2,14 +2,8 @@
|
|||||||
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
||||||
# Released under the modified BSD license. See COPYING.md for more details.
|
# Released under the modified BSD license. See COPYING.md for more details.
|
||||||
|
|
||||||
JULIA := julia --color=yes --project=@.
|
|
||||||
VERSION := 0.2
|
VERSION := 0.2
|
||||||
|
|
||||||
build/sysimage.so: src/utils/sysimage.jl Project.toml
|
|
||||||
julia --project=. -e "using Pkg; Pkg.instantiate()"
|
|
||||||
julia --project=test -e "using Pkg; Pkg.instantiate()"
|
|
||||||
$(JULIA) src/utils/sysimage.jl test/runtests.jl
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rfv build
|
rm -rfv build
|
||||||
|
|
||||||
@@ -17,13 +11,13 @@ docs:
|
|||||||
cd docs; make clean; make dirhtml
|
cd docs; make clean; make dirhtml
|
||||||
rsync -avP --delete-after docs/_build/dirhtml/ ../docs/$(VERSION)/
|
rsync -avP --delete-after docs/_build/dirhtml/ ../docs/$(VERSION)/
|
||||||
|
|
||||||
test: build/sysimage.so
|
|
||||||
$(JULIA) --sysimage build/sysimage.so test/runtests.jl
|
|
||||||
|
|
||||||
format:
|
format:
|
||||||
julia -e 'using JuliaFormatter; format(["src", "test", "benchmark"], verbose=true);'
|
cd deps/formatter; ../../juliaw format.jl
|
||||||
|
|
||||||
install-deps:
|
test: test/Manifest.toml
|
||||||
julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter", version="0.14.4"))'
|
./juliaw test/runtests.jl
|
||||||
|
|
||||||
|
test/Manifest.toml: test/Project.toml
|
||||||
|
julia --project=test -e "using Pkg; Pkg.instantiate()"
|
||||||
|
|
||||||
.PHONY: docs test format install-deps
|
.PHONY: docs test format install-deps
|
||||||
|
|||||||
5
deps/formatter/Project.toml
vendored
Normal file
5
deps/formatter/Project.toml
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
[deps]
|
||||||
|
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
|
||||||
|
|
||||||
|
[compat]
|
||||||
|
JuliaFormatter = "0.14.4"
|
||||||
9
deps/formatter/format.jl
vendored
Normal file
9
deps/formatter/format.jl
vendored
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
using JuliaFormatter
|
||||||
|
format(
|
||||||
|
[
|
||||||
|
"../../src",
|
||||||
|
"../../test",
|
||||||
|
"../../benchmark/run.jl",
|
||||||
|
],
|
||||||
|
verbose=true,
|
||||||
|
)
|
||||||
68
juliaw
Normal file
68
juliaw
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
|
||||||
|
# Copyright (C) 2020-2021, UChicago Argonne, LLC. All rights reserved.
|
||||||
|
# Released under the modified BSD license. See COPYING.md for more details.
|
||||||
|
|
||||||
|
if [ ! -e Project.toml ]; then
|
||||||
|
echo "juliaw: Project.toml not found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -e Manifest.toml ]; then
|
||||||
|
julia --project=. -e 'using Pkg; Pkg.instantiate()' || exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -e build/sysimage.so -o Project.toml -nt build/sysimage.so ]; then
|
||||||
|
echo "juliaw: rebuilding system image..."
|
||||||
|
|
||||||
|
# Generate temporary project folder
|
||||||
|
rm -rf $HOME/.juliaw
|
||||||
|
mkdir -p $HOME/.juliaw/src
|
||||||
|
cp Project.toml Manifest.toml $HOME/.juliaw
|
||||||
|
NAME=$(julia -e 'using TOML; toml = TOML.parsefile("Project.toml"); "name" in keys(toml) && print(toml["name"])')
|
||||||
|
if [ ! -z $NAME ]; then
|
||||||
|
cat > $HOME/.juliaw/src/$NAME.jl << EOF
|
||||||
|
module $NAME
|
||||||
|
end
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Add PackageCompiler dependencies to temporary project
|
||||||
|
julia --project=$HOME/.juliaw -e 'using Pkg; Pkg.add(["PackageCompiler", "TOML", "Logging"])'
|
||||||
|
|
||||||
|
# Generate system image scripts
|
||||||
|
cat > $HOME/.juliaw/sysimage.jl << EOF
|
||||||
|
using PackageCompiler
|
||||||
|
using TOML
|
||||||
|
using Logging
|
||||||
|
|
||||||
|
Logging.disable_logging(Logging.Info)
|
||||||
|
mkpath("$PWD/build")
|
||||||
|
|
||||||
|
println("juliaw: generating precompilation statements...")
|
||||||
|
run(\`julia --project="$PWD" --trace-compile="$PWD"/build/precompile.jl \$(ARGS)\`)
|
||||||
|
|
||||||
|
println("juliaw: finding dependencies...")
|
||||||
|
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])
|
||||||
|
println(" - \$(dep) [skip]")
|
||||||
|
else
|
||||||
|
println(" - \$(dep)")
|
||||||
|
push!(deps, Symbol(dep))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
println("juliaw: building system image...")
|
||||||
|
create_sysimage(
|
||||||
|
deps,
|
||||||
|
precompile_statements_file = "$PWD/build/precompile.jl",
|
||||||
|
sysimage_path = "$PWD/build/sysimage.so",
|
||||||
|
)
|
||||||
|
EOF
|
||||||
|
julia --project=$HOME/.juliaw $HOME/.juliaw/sysimage.jl $*
|
||||||
|
else
|
||||||
|
julia --project=. --sysimage build/sysimage.so $*
|
||||||
|
fi
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
# UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
|
|
||||||
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
|
||||||
# Released under the modified BSD license. See COPYING.md for more details.
|
|
||||||
|
|
||||||
using PackageCompiler
|
|
||||||
using TOML
|
|
||||||
using Logging
|
|
||||||
|
|
||||||
Logging.disable_logging(Logging.Info)
|
|
||||||
mkpath("build")
|
|
||||||
|
|
||||||
println("Generating precompilation statements...")
|
|
||||||
run(`julia --project=. --trace-compile=build/precompile.jl $(ARGS)`)
|
|
||||||
|
|
||||||
println("Finding dependencies...")
|
|
||||||
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])
|
|
||||||
println(" - $(dep) [skip]")
|
|
||||||
else
|
|
||||||
println(" - $(dep)")
|
|
||||||
push!(deps, Symbol(dep))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
println("Building system image...")
|
|
||||||
create_sysimage(
|
|
||||||
deps,
|
|
||||||
precompile_statements_file = "build/precompile.jl",
|
|
||||||
sysimage_path = "build/sysimage.so",
|
|
||||||
)
|
|
||||||
Reference in New Issue
Block a user