Skip to content

Commit

Permalink
builder: catgets fix for msys2 + minor changes
Browse files Browse the repository at this point in the history
Change `ln -s` to `cp` in the catgets makefile in the applied patch,
this is used for making symlinks to some header files, this will
hopefully fix building catgets for @ZachBacon on msys2. There seems to
be a problem with the mingw gcc reading headers that are symlinks, even
if they are real windows symlinks.

Also slightly refactor checking for target built files. Add the `-f`
flag for `install_artifact([-f] $dist)` for the full path to the target
file, and add the helper functions `check_install_artifact($dist)` and
`check_install_artifact_relative($dist $root_path)`.

These helper functions also display error messages if the target file
does not exist, as opposed to the previous behavior where it would just
silently exit nonzero.
  • Loading branch information
rkitover committed Nov 23, 2018
1 parent a6034dd commit afbe647
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 14 deletions.
60 changes: 47 additions & 13 deletions tools/builder/core.sh
Expand Up @@ -876,7 +876,7 @@ build_prerequisites() {

dists_are_installed() {
for current_dist; do
if ! path_exists "$(install_artifact $current_dist)"; then
if ! path_exists "$(install_artifact -f $current_dist)"; then
return 1
fi
done
Expand Down Expand Up @@ -1299,7 +1299,7 @@ build_dist_if_needed() {
[ -n "$current_dist" ] || die 'build_dist_if_needed: dist name required'
shift

if ! path_exists "$(install_artifact $current_dist)"; then
if ! path_exists "$(install_artifact -f $current_dist)"; then
build_dist $current_dist "$@"
BUILT_DISTS="$BUILT_DISTS $current_dist"
fi
Expand Down Expand Up @@ -1356,7 +1356,7 @@ build_dist() {
eval "set -- $extra_dist_args"
echo_eval_run "$build_override $@"

path_exists "$(install_artifact $current_dist)"
check_install_artifact "$current_dist"
else
if [ "$config_type" = meson ] || [ -z "$config_type" -a -f meson.build ]; then
mkdir -p build
Expand Down Expand Up @@ -1384,7 +1384,7 @@ build_dist() {
echo_eval_run "$install_override $(dist_make_install_args "$current_dist")"
fi

path_exists "$(install_artifact $current_dist)"
check_install_artifact "$current_dist"
elif [ "$config_type" = autoconf -o "$config_type" = autoreconf ] || [ -z "$config_type" -a \( -f configure -o -f Configure -o -f configure.ac -o -f configure.in -o -f Makefile.am \) ]; then
# workaround a sometimes autoconf bug
touch config.rpath
Expand Down Expand Up @@ -1463,7 +1463,7 @@ build_dist() {
echo_eval_run "$install_override $(dist_make_install_args "$current_dist")"
fi

path_exists "$(install_artifact $current_dist)"
check_install_artifact "$current_dist"
elif [ "$config_type" = cmakeninja ]; then
if ! command -v ninja >/dev/null; then
error "configure type 'cmakeninja' requested but ninja is not available yet";
Expand Down Expand Up @@ -1496,7 +1496,7 @@ build_dist() {
echo_eval_run "$install_override $(dist_make_install_args "$current_dist")"
fi

path_exists "$(install_artifact $current_dist)"
check_install_artifact "$current_dist"
elif [ "$config_type" = cmake ] || [ -z "$config_type" -a -f CMakeLists.txt ]; then
mkdir -p build
cd build
Expand Down Expand Up @@ -1525,7 +1525,7 @@ build_dist() {
echo_eval_run "$install_override $(dist_make_install_args "$current_dist")"
fi

path_exists "$(install_artifact $current_dist)"
check_install_artifact "$current_dist"
elif [ "$config_type" = python ] || [ -z "$config_type" -a -f setup.py ]; then
if [ -z "$install_override" ]; then
pip=
Expand All @@ -1552,7 +1552,7 @@ build_dist() {
echo_eval_run "$install_override $(dist_make_install_args "$current_dist")"
fi

path_exists "$(install_artifact $current_dist)"
check_install_artifact "$current_dist"
elif [ "$config_type" = perl ] || [ -z "$config_type" -a -f Makefile.PL ]; then
echo_run cpanm --notest --installdeps .

Expand All @@ -1575,7 +1575,7 @@ build_dist() {
echo_eval_run "$install_override $(dist_make_install_args "$current_dist")"
fi

path_exists "$(install_artifact $current_dist)"
check_install_artifact "$current_dist"
elif [ "$config_type" = make ] || [ -z "$config_type" -a \( -f Makefile -o -f makefile \) ]; then
makefile=makefile
if [ -f Makefile ]; then
Expand All @@ -1599,7 +1599,7 @@ build_dist() {
echo_eval_run "$install_override $(dist_make_install_args "$current_dist")"
fi

path_exists "$(install_artifact $current_dist)"
check_install_artifact "$current_dist"
else
die "don't know how to build $current_dist, please define a BUILD_OVERRIDE"
fi
Expand Down Expand Up @@ -1695,7 +1695,7 @@ install_dist() {
IFS=$OIFS

# check that key file was built
path_exists "destdir${prefix}/$(install_artifact_relative "$current_dist")"
check_install_artifact_relative "$current_dist" "destdir${prefix}"

# when cross compiling, resolve build root to host or target
inst_root=$(resolve_link "$BUILD_ROOT/root")
Expand Down Expand Up @@ -2683,6 +2683,12 @@ list_remove_duplicates() {
}

install_artifact() {
full=
if [ "$1" = "-f" ]; then
full=1
shift
fi

current_dist=$1
[ -n "$current_dist" ] || die 'install_artifact: dist name required'

Expand All @@ -2697,12 +2703,40 @@ install_artifact() {
# trees
case "$path" in
/*)
puts "$path"
if [ -n "$full" ]; then
puts "$path"
else
puts "$(install_artifact_relative "$current_dist")"
fi
return 0
;;
esac

puts "$BUILD_ROOT/root${prefix}/${path}"
if [ -n "$full" ]; then
puts "$BUILD_ROOT/root${prefix}/${path}"
else
puts "$path"
fi
}

check_install_artifact() {
current_dist=$1
[ -n "$current_dist" ] || die 'check_install_artifact: dist name required'

if ! path_exists "$(install_artifact -f $current_dist)"; then
die "$current_dist: target file not found after install"
fi
}

check_install_artifact_relative() {
current_dist=$1
[ -n "$current_dist" ] || die 'check_install_artifact_relative: dist name required'
root=$2
[ -n "$root" ] || die 'check_install_artifact_relative: directory root relative to required'

if ! path_exists "${root}/$(install_artifact_relative $current_dist)"; then
die "$current_dist: target file not found in unpack directory"
fi
}

install_artifact_relative() {
Expand Down
2 changes: 1 addition & 1 deletion tools/builder/mingw.sh
Expand Up @@ -265,7 +265,7 @@ table_insert_after DISTS libiconv-target '
'

table_line_append DIST_PATCHES catgets "\
https://gist.githubusercontent.com/rkitover/4fe26d4af9e20234ba7821100356b0a6/raw/715b89f23b0e13a5d1859bfeee600f43edd35c07/mingw-catgets-mc_realloc-and-langinfo.patch \
https://gist.githubusercontent.com/rkitover/4fe26d4af9e20234ba7821100356b0a6/raw/1f11522e9feea3c2a431beca57fc3db07ca44a1c/mingw-catgets-mc_realloc-and-langinfo.patch \
"

table_line_append DIST_POST_BUILD catgets ":; \
Expand Down

0 comments on commit afbe647

Please sign in to comment.