update readme and add gitignore
[client-tools.git] / tools / swg-lint-win32.pl
blob1c9439e82e9b7451f03d20a388d4561adbee9918
1 #!/bin/perl
3 use strict;
5 use Cwd;
6 use Cwd 'chdir';
7 use File::Spec;
9 my $debug = 0;
11 # Find project.lnt file.
12 my @directories = File::Spec->splitdir(cwd());
13 my $projectFileName = "project.lnt";
14 my $projectFilePath = "";
15 my $foundProjectFile = 0;
17 while (!$foundProjectFile && (scalar(@directories) > 0))
19 $projectFilePath = File::Spec->catfile(@directories, $projectFileName);
20 $foundProjectFile = -f $projectFilePath;
21 pop(@directories) if !$foundProjectFile;
24 die "failed to find file [$projectFileName] starting in directory [", cwd(), "], stopping" if !$foundProjectFile;
25 print "found project file: [$projectFilePath]\n" if $debug;
27 # Change directory to directory of project file. Our lint setup expects the
28 # exe to run in the project file directory.
29 my $newWorkingDirectory = File::Spec->catdir(@directories);
30 print "new working directory: [$newWorkingDirectory]\n" if $debug;
31 chdir($newWorkingDirectory);
33 # Find the tools directory.
34 @directories = File::Spec->splitdir(cwd());
35 my $toolsDirName = "tools";
36 my $lintDirName = "lint";
37 my $toolsDirPath = "";
38 my $foundToolsDir = 0;
40 while (!$foundToolsDir && (scalar(@directories) > 0))
42 $toolsDirPath = File::Spec->catdir((@directories, $toolsDirName, $lintDirName));
43 $foundToolsDir = -d $toolsDirPath;
44 pop(@directories);
47 die "failed to find tools directory [$toolsDirPath] starting in directory [", cwd(), "], stopping" if !$foundToolsDir;
48 print "found tools directory: [$toolsDirPath]\n" if $debug;
50 my $lintCommand = "lint-nt -u -i$ENV{LINT_HOME} -i$toolsDirPath $projectFilePath @ARGV";
51 print "lint command: [$lintCommand]\n" if $debug;
52 my $lintCommandResult = system($lintCommand);
53 my $exitCode = $lintCommandResult >> 8;
55 print "--- Lint DONE.\n";
57 exit($exitCode);