Skip to content

Commit 0159210

Browse files
committed
Fixes for build.sh
Avoiding doing "cd" for generating files. For details, please see: gildor2/BuildTools@b0c0bdc
1 parent 69c6031 commit 0159210

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

Unreal/Shaders/make.pl

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ sub getline {
5454
sub process {
5555
my ($file) =@_;
5656
open(IN, $file) or die "Unable to read file $file\n";
57-
my $name = $file;
57+
$file =~ s/\\/\//;
58+
my ($name) = $file =~ /.*[\/]([^\/]+)/;
5859
$name =~ s/\./_/;
5960
print(OUT "\n// $file\nstatic const char ${name}[] = \"${file}\\x00\"");
6061
my $accum = "";
@@ -75,17 +76,21 @@ sub process {
7576

7677
# return file modification time
7778
sub FileTime {
78-
my @s = stat($_[0]) or die "File \"${_[0]}\" was not found\n";
79+
my @s = stat($_[0]) or die;
7980
return $s[9];
8081
}
8182

8283

84+
# Get the directory of script file
85+
$ThisExec = $0; # $PROGRAM_NAME does not works
86+
($root) = $ThisExec =~ /^(.+)[\\\/][^\/\\]+$/;
87+
$root = "." if !defined($root);
88+
$OUT = "$root/$OUT";
8389

84-
opendir(DIR, ".");
90+
opendir(DIR, $root);
8591
@filelist = readdir(DIR);
8692
closedir(DIR);
8793

88-
$ThisExec = $0; # $PROGRAM_NAME does not works
8994
$ExecTime = FileTime($ThisExec);
9095

9196
my $rebuild = 0;
@@ -95,7 +100,7 @@ sub FileTime {
95100
} else {
96101
$OutTime = FileTime($OUT);
97102
if ($ExecTime > $OutTime) {
98-
print STDERR "Updated this script, rebuilding $OUT ...\n";
103+
print STDERR "This script has been updated, rebuilding $OUT ...\n";
99104
$rebuild = 1;
100105
}
101106
}
@@ -105,13 +110,13 @@ sub FileTime {
105110
# verify individual file times
106111
for $f (@filelist)
107112
{
108-
if ($f =~ /.*\.($EXTS)$/) {
109-
my $ShaderTime = FileTime($f);
113+
# if ($f =~ /.*\.($EXTS)$/) {
114+
my $ShaderTime = FileTime("$root/$f");
110115
if ($ShaderTime > $OutTime) {
111-
print STDERR "$f is updated, rebuilding $OUT ...\n";
116+
print STDERR "$f has been updated, rebuilding $OUT ...\n";
112117
$rebuild = 1;
113118
}
114-
}
119+
# }
115120
}
116121
}
117122

@@ -130,7 +135,7 @@ sub FileTime {
130135

131136
for $f (@filelist) {
132137
if ($f =~ /.*\.($EXTS)$/) {
133-
process($f);
138+
process("$root/$f");
134139
}
135140
}
136141

build.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,7 @@ if [ $render -eq 1 ]; then
9797
fi
9898
# build shaders
9999
#?? move to makefile
100-
cd "Unreal/Shaders"
101-
./make.pl
102-
cd "../.."
100+
Unreal/Shaders/make.pl
103101
fi
104102

105103
# prepare makefile parameters, store in obj directory

0 commit comments

Comments
 (0)