Skip to content

Commit

Permalink
Merge pull request #761 from adrianschroeter/buildassetmarker
Browse files Browse the repository at this point in the history
copy source directories also when marked with .build.assets file
  • Loading branch information
mlschroe committed Jan 20, 2022
2 parents 1f7008c + 0c3b6a3 commit ffa35af
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 ffa35af

Please sign in to comment.