Skip to content

Commit

Permalink
Merge pull request #109 from niklasdewally/issue/108
Browse files Browse the repository at this point in the history
Add tools/update-submodules.sh + a few other changes to how we build things
  • Loading branch information
ozgurakgun authored Nov 25, 2023
2 parents b27d0bc + 6c18e46 commit 5dda8e7
Show file tree
Hide file tree
Showing 17 changed files with 108 additions and 50 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/code-coverage-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ jobs:
- name: "Generate indexes"
run: |
./etc/ci/genindex.py pages/coverage/${{ steps.sha.outputs.result }}
./etc/ci/genindex.py pages/coverage/main
./etc/ci/genindex.py pages/coverage/
./tools/ci/genindex.py pages/coverage/${{ steps.sha.outputs.result }}
./tools/ci/genindex.py pages/coverage/main
./tools/ci/genindex.py pages/coverage/
- uses: JamesIves/github-pages-deploy-action@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
- name: Generate coverage reports
working-directory: .
run: |
./etc/scripts/gen_coverage_all.sh
./tools/gen_coverage_all.sh
- name: Move all html to correct folders for deployment
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
- name: Generate documentation
working-directory: .
run: |
./etc/scripts/gen_docs.sh
./tools/gen_docs.sh
- name: Move all html to correct folders for deployment
run: |
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "minion-bindings/vendor"]
[submodule "solvers/minion/vendor"]
path = solvers/minion/vendor
url = https://github.com/minion/minion
ignore = dirty
Expand Down
21 changes: 20 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1 +1,20 @@
Stay tuned!
# Conjure-Oxide

This repository contains the in progress Conjure Oxide constraints modelling
tool, and it's dependencies.

This repository hosts the following projects:

* [Conjure Oxide](https://github.com/conjure-cp/conjure-oxide/tree/main/conjure_oxide)
* [`minion_rs` - Rust bindings to Minion](https://github.com/conjure-cp/conjure-oxide/tree/main/solvers/minion)
* [`chuffed_rs` - Rust bindings to Chuffed](https://github.com/conjure-cp/conjure-oxide/tree/main/solvers/chuffed)

This project is being produced by staff and students of University of St
Andrews, and is licenced under the [MPL 2.0](./LICENCE).

## Contributing

See the [Contributors Guide](https://github.com/conjure-cp/conjure-oxide/wiki/Contributing).

<!-- vim: cc=80
-->
18 changes: 12 additions & 6 deletions solvers/chuffed/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,20 @@ use std::path::PathBuf;
use std::process::Command;

fn main() {
println!("cargo:rustc-rerun-if-changed=vendor");
let out_dir = env::var("OUT_DIR").unwrap();

println!("cargo:rerun-if-changed=vendor");
println!("cargo:rerun-if-changed=wrapper.h");
println!("cargo:rerun-if-changed=wrapper.cpp");

println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=build.sh");

println!("cargo:rustc-link-search=all={}/", out_dir);
println!("cargo:rustc-link-search=all={}/build", out_dir);

// must be ./ to be recognised as relative path
// from project root
println!("cargo:rustc-link-search=all=./solvers/chuffed/vendor/build/");
println!("cargo:rustc-link-lib=static=chuffed");
println!("cargo:rustc-link-lib=static=chuffed_fzn");
println!("cargo:rustc-link-search=all=./solvers/chuffed/");
println!("cargo:rustc-link-lib=static=wrapper");

// also need to (dynamically) link to c++ stdlib
Expand Down Expand Up @@ -52,6 +57,7 @@ fn build() {
}

fn bind() {
let out_dir = env::var("OUT_DIR").unwrap();
// The bindgen::Builder is the main entry point
// to bindgen, and lets you build up options for
// the resulting bindings.
Expand All @@ -78,7 +84,7 @@ fn bind() {
.allowlist_function("p_setcallback")
.allowlist_function("p_print")
.allowlist_function("branch_IntVar")
.clang_arg("-Ivendor/build") // generated from configure.py
.clang_arg(format!("-I{}/build", out_dir))
.clang_arg("-Ivendor")
.clang_arg(r"--std=gnu++11")
.clang_arg(r"-xc++")
Expand Down
27 changes: 18 additions & 9 deletions solvers/chuffed/build.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
#!/bin/bash

SCRIPT_DIR=$(dirname "$0")
SCRIPT_DIR="$(readlink -f "$(dirname "$0")")"
cd "$SCRIPT_DIR"

git submodule init
git submodule update
cd "$SCRIPT_DIR" || exit
git submodule init -- vendor
git submodule sync -- vendor
git submodule update --init --recursive -- vendor


if [[ -z "$OUT_DIR" ]]; then
echo "OUT_DIR env variable does not exist - did you run this script through cargo build?"
exit 1
fi

echo "------ BUILDING ------"
cd vendor || exit
cmake -B build -S .
cmake --build build
cd ..

mkdir -p "$OUT_DIR/build"
cd "$OUT_DIR/build"
cmake -B . -S "$SCRIPT_DIR/vendor"
cmake --build .

# Build wrapper.cpp as static library
c++ -c wrapper.cpp -Ivendor --std=c++11
cd "$OUT_DIR" || exit 1
c++ -c "$SCRIPT_DIR/wrapper.cpp" -I"$SCRIPT_DIR/vendor" --std=c++11
ar rvs libwrapper.a wrapper.o
6 changes: 0 additions & 6 deletions solvers/chuffed/clean.sh

This file was deleted.

12 changes: 7 additions & 5 deletions solvers/minion/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ use std::path::PathBuf;
use std::process::Command;

fn main() {
println!("cargo:rustc-rerun-if-changed=vendor");
let out_dir = env::var("OUT_DIR").unwrap();

println!("cargo:rerun-if-changed=vendor");
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=build.sh");

// must be ./ to be recognised as relative path
// from project root
println!("cargo:rustc-link-search=all=./solvers/minion/vendor/build/");
println!("cargo:rustc-link-search=all={}/build", out_dir);
println!("cargo:rustc-link-lib=static=minion");

// also need to (dynamically) link to c++ stdlib
Expand Down Expand Up @@ -54,6 +55,7 @@ fn build() {
}

fn bind() {
let out_dir = env::var("OUT_DIR").unwrap();
// The bindgen::Builder is the main entry point
// to bindgen, and lets you build up options for
// the resulting bindings.
Expand Down Expand Up @@ -94,7 +96,7 @@ fn bind() {
.allowlist_function("vec_int_new")
.allowlist_function("vec_int_push_back")
.allowlist_function("vec_int_free")
.clang_arg("-Ivendor/build/src/") // generated from configure.py
.clang_arg(format!("-I{}/build/src/", out_dir)) // generated from configure.py
.clang_arg("-Ivendor/minion/")
.clang_arg("-DLIBMINION")
.clang_arg(r"--std=gnu++11")
Expand Down
28 changes: 14 additions & 14 deletions solvers/minion/build.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
#!/bin/bash

SCRIPT_DIR=$(dirname "$0")

git submodule init
git submodule update
SCRIPT_DIR="$(readlink -f "$(dirname "$0")")"
cd "$SCRIPT_DIR"

echo "------ CONFIGURE STEP ------"
git submodule init -- vendor
git submodule sync -- vendor
git submodule update --init --recursive -- vendor

if [ -d vendor/build ]; then
echo "vendor/build already exists; skipping"
echo "if you need to reconfigure minion (such as after an update), delete this directory!"
else
mkdir -p vendor/build
cd vendor/build
python3 ../configure.py --lib --quick
if [[ -z "$OUT_DIR" ]]; then
echo "OUT_DIR env variable does not exist - did you run this script through cargo build?"
exit 1
fi

echo "------ CONFIGURE STEP ------"

mkdir -p "$OUT_DIR/build"
cd "$OUT_DIR/build"
python3 "$SCRIPT_DIR/vendor/configure.py" --lib --quick

echo "------ BUILD STEP ------"
cd "$SCRIPT_DIR"
cd vendor/build
cd "$OUT_DIR/build"
make
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ cd $(git rev-parse --show-toplevel)
git submodule update --init --recursive 1>&2 2>/dev/null

{
for module in $(sh "$CI_SCRIPTS_DIR/get_submodule_paths.sh")
for module in $(sh "$CI_SCRIPTS_DIR/../scripts/get_submodule_paths.sh")
do
git rev-parse "HEAD:$module" >> $SHAS
done;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# !/bin/bash
# generate coverage for all crates in the workspace

PATH_TO_GEN_COV="/etc/scripts/gen_coverage.sh"
PATH_TO_GEN_COV="tools/gen_coverage.sh"
echo_err () {
echo "$@" 1>&2
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# these paths are relative to the git repository.

# go to top level of git repo
cd $(git rev-parse --show-toplevel)
cd $(git rev-parse --show-superproject-working-tree --show-toplevel | head -n 1)

# https://stackoverflow.com/questions/12641469/list-submodules-in-a-git-repository
git config --file .gitmodules --get-regexp path | awk '{print $2}'
Expand Down
28 changes: 28 additions & 0 deletions tools/update-submodules.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
# vim: cc=80

# root of project
cd $(dirname "$0")/..

# update, initialise, and sync all submodules to ensure that changes are
# reflected here. `git submodule sync` means change where the submodule points
# to match .gitmodules, should it have changed (in particular, from a dev fork
# to upstream).

echo "=== Cleaning submodules ===" 1>&2

bash ./tools/plumbing/get_submodule_paths.sh |
{
while read -r submodule_path; do
cd "$submodule_path"
git clean -dfx .
cd - &> /dev/null
done
}

echo "=== Updating and resetting submodules ===" 1>&2

git submodule init --recursive
git submodule sync --recursive
git submodule update --init --recursive

0 comments on commit 5dda8e7

Please sign in to comment.