Skip to content

Commit

Permalink
copy source directories also when marked with .build.assets file
Browse files Browse the repository at this point in the history
We currently use these marker files for remote assets. A more descriptive
file may replace this this later.
  • Loading branch information
adrianschroeter committed Jan 19, 2022
1 parent 57fbb8f commit 0c3b6a3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
13 changes: 13 additions & 0 deletions PBuild/Util.pm
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ sub readstr {
return $d;
}

sub touch($) {
my ($file) = @_;
if (-e $file) {
my $t = time();
utime($t, $t, $file);
} else {
# create new file, mtime is anyway current
my $f;
open($f, '>>', $file) || die("$file: $!\n");
close($f) || die("$file close: $!\n");
}
}

sub ls {
my $d;
opendir($d, $_[0]) || return ();
Expand Down
2 changes: 1 addition & 1 deletion build
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ copy_sources() {
local ii="${i##*/}"
test "$ii" = . -o "$ii" = .. -o "$ii" = .git && continue
if test -L "$i" -o -d "$i" -o "${ii#.}" != "$ii" ; then
if git -C "$1" --noglob-pathspecs ls-files --error-unmatch -- "$ii" >& /dev/null ; then
if test -e "$i/.build.asset" || git -C "$1" --noglob-pathspecs ls-files --error-unmatch -- "$ii" >& /dev/null ; then
cp -pRd "$i" "$2"
continue
fi
Expand Down
7 changes: 7 additions & 0 deletions download_assets
Original file line number Diff line number Diff line change
Expand Up @@ -158,5 +158,12 @@ for my $dir (@dirs) {
} else {
$assetmgr->copy_assets($p, $dir, $opts->{'unpack'});
}
# mark directories as assets for build script
if ($opts->{'unpack'}) {
my $af = $p->{'asset_files'} || {};
for (keys %$af) {
PBuild::Util::touch("$dir/$_/.build.asset") if $af->{$_}->{'isdir'};
}
}
}

0 comments on commit 0c3b6a3

Please sign in to comment.