Skip to content

Commit

Permalink
is link should use the base nodes lstat instead of local fs stat
Browse files Browse the repository at this point in the history
builder is not garunteed to be in the environment, so check if the node is the ninja_file
fix sider issues
  • Loading branch information
dmoody256 committed May 14, 2020
1 parent 0d1602a commit bbec480
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 42 deletions.
7 changes: 3 additions & 4 deletions SCons/Node/FS.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,12 +762,11 @@ def isfile(self):

if hasattr(os, 'symlink'):
def islink(self):
try: st = self.fs.lstat(self.get_abspath())
except os.error: return 0
return stat.S_ISLNK(st[stat.ST_MODE])
st = self.lstat()
return st is not None and stat.S_ISLNK(st[stat.ST_MODE])
else:
def islink(self):
return 0 # no symlinks
return False # no symlinks

def is_under(self, dir):
if self is dir:
Expand Down
9 changes: 5 additions & 4 deletions SCons/Tool/ninja.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,10 @@ def action_to_ninja_build(self, node, action=None):
# Ninja builders out of being sources of ninja builders but I
# can't fix every DAG problem so we just skip ninja_builders
# if we find one
if node.builder == self.env["BUILDERS"]["Ninja"]:
global NINJA_STATE
if NINJA_STATE.ninja_file == str(node):
build = None
elif isinstance(action, SCons.Action.FunctionAction):
if isinstance(action, SCons.Action.FunctionAction):
build = self.handle_func_action(node, action)
elif isinstance(action, SCons.Action.LazyAction):
# pylint: disable=protected-access
Expand Down Expand Up @@ -1043,7 +1044,7 @@ def ninja_builder(env, target, source):
if env["PLATFORM"] == "win32":
# this is not great, its doesn't consider specific
# node environments, which means on linux the build could
# behave differently, becuase on linux you can set the environment
# behave differently, because on linux you can set the environment
# per command in the ninja file. This is only needed if
# running ninja directly from a command line that hasn't
# had the environment setup (vcvarsall.bat)
Expand Down Expand Up @@ -1492,7 +1493,7 @@ def robust_rule_mapping(var, rule, tool):
# default to using ninja installed with python module
ninja_bin = 'ninja.exe' if env["PLATFORM"] == "win32" else 'ninja'
NINJA_STATE.ninja_bin_path = os.path.abspath(os.path.join(
ninja_syntax.__file__,
ninja.__file__,
os.pardir,
'data',
'bin',
Expand Down
7 changes: 3 additions & 4 deletions test/ninja/build_libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"

import os
import importlib
import TestSCons
from TestCmd import IS_WINDOWS

test = TestSCons.TestSCons()

try:
import ninja
except ImportError:
Expand All @@ -38,14 +39,12 @@
_exe = TestSCons._exe

ninja_bin = os.path.abspath(os.path.join(
importlib.import_module(".ninja_syntax", package='ninja').__file__,
ninja.__file__,
os.pardir,
'data',
'bin',
'ninja' + _exe))

test = TestSCons.TestSCons()

test.dir_fixture('ninja-fixture')

lib_suffix = '.lib' if IS_WINDOWS else '.so'
Expand Down
7 changes: 3 additions & 4 deletions test/ninja/copy_function_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"

import os
import importlib
import TestSCons
from TestCmd import IS_WINDOWS

test = TestSCons.TestSCons()

try:
import ninja
except ImportError:
Expand All @@ -38,14 +39,12 @@
_exe = TestSCons._exe

ninja_bin = os.path.abspath(os.path.join(
importlib.import_module(".ninja_syntax", package='ninja').__file__,
ninja.__file__,
os.pardir,
'data',
'bin',
'ninja' + _exe))

test = TestSCons.TestSCons()

test.dir_fixture('ninja-fixture')

test.write('SConstruct', """
Expand Down
7 changes: 3 additions & 4 deletions test/ninja/generate_and_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"

import os
import importlib
import TestSCons
from TestCmd import IS_WINDOWS

test = TestSCons.TestSCons()

try:
import ninja
except ImportError:
Expand All @@ -38,14 +39,12 @@
_exe = TestSCons._exe

ninja_bin = os.path.abspath(os.path.join(
importlib.import_module(".ninja_syntax", package='ninja').__file__,
ninja.__file__,
os.pardir,
'data',
'bin',
'ninja' + _exe))

test = TestSCons.TestSCons()

test.dir_fixture('ninja-fixture')

test.write('SConstruct', """
Expand Down
7 changes: 3 additions & 4 deletions test/ninja/generate_and_build_cxx.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"

import os
import importlib
import TestSCons
from TestCmd import IS_WINDOWS

test = TestSCons.TestSCons()

try:
import ninja
except ImportError:
Expand All @@ -38,14 +39,12 @@
_exe = TestSCons._exe

ninja_bin = os.path.abspath(os.path.join(
importlib.import_module(".ninja_syntax", package='ninja').__file__,
ninja.__file__,
os.pardir,
'data',
'bin',
'ninja' + _exe))

test = TestSCons.TestSCons()

test.dir_fixture('ninja-fixture')

test.write('SConstruct', """
Expand Down
7 changes: 3 additions & 4 deletions test/ninja/generate_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"

import os
import importlib
import TestSCons
from TestCmd import IS_WINDOWS

test = TestSCons.TestSCons()

try:
import ninja
except ImportError:
Expand All @@ -38,14 +39,12 @@
_exe = TestSCons._exe

ninja_bin = os.path.abspath(os.path.join(
importlib.import_module(".ninja_syntax", package='ninja').__file__,
ninja.__file__,
os.pardir,
'data',
'bin',
'ninja' + _exe))

test = TestSCons.TestSCons()

test.dir_fixture('ninja-fixture')

shell = '' if IS_WINDOWS else './'
Expand Down
15 changes: 7 additions & 8 deletions test/ninja/iterative_speedup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@
import os
import time
import random
import importlib
import TestSCons
from TestCmd import IS_WINDOWS

test = TestSCons.TestSCons()

try:
import ninja
except ImportError:
Expand All @@ -40,14 +41,12 @@
_exe = TestSCons._exe

ninja_bin = os.path.abspath(os.path.join(
importlib.import_module(".ninja_syntax", package='ninja').__file__,
ninja.__file__,
os.pardir,
'data',
'bin',
'ninja' + _exe))

test = TestSCons.TestSCons()

test.dir_fixture('ninja-fixture')

test.write('source_0.c', """
Expand Down Expand Up @@ -220,14 +219,14 @@ def mod_source_orig(test_num):
scons_times += [stop - start]

full_build_print = True
for ninja, scons in zip(ninja_times, scons_times):
if ninja > scons:
for ninja_time, scons_time in zip(ninja_times, scons_times):
if ninja_time > scons_time:
test.fail_test()
if full_build_print:
full_build_print = False
print("Clean build {} files - SCons: {:.3f}s Ninja: {:.3f}s".format(num_source, scons, ninja))
print("Clean build {} files - SCons: {:.3f}s Ninja: {:.3f}s".format(num_source, scons_time, ninja_time))
else:
print("Single File Rebuild - SCons: {:.3f}s Ninja: {:.3f}s".format(scons, ninja))
print("Single File Rebuild - SCons: {:.3f}s Ninja: {:.3f}s".format(scons_time, ninja_time))

test.pass_test()

Expand Down
5 changes: 3 additions & 2 deletions test/ninja/multi_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"

import os
import importlib
import TestSCons
from TestCmd import IS_WINDOWS

test = TestSCons.TestSCons()

try:
import ninja
except ImportError:
Expand All @@ -38,7 +39,7 @@
_exe = TestSCons._exe

ninja_bin = os.path.abspath(os.path.join(
importlib.import_module(".ninja_syntax", package='ninja').__file__,
ninja.__file__,
os.pardir,
'data',
'bin',
Expand Down
7 changes: 3 additions & 4 deletions test/ninja/shell_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"

import os
import importlib
import TestSCons
from TestCmd import IS_WINDOWS

test = TestSCons.TestSCons()

try:
import ninja
except ImportError:
Expand All @@ -38,14 +39,12 @@
_exe = TestSCons._exe

ninja_bin = os.path.abspath(os.path.join(
importlib.import_module(".ninja_syntax", package='ninja').__file__,
ninja.__file__,
os.pardir,
'data',
'bin',
'ninja' + _exe))

test = TestSCons.TestSCons()

test.dir_fixture('ninja-fixture')

shell = '' if IS_WINDOWS else './'
Expand Down

0 comments on commit bbec480

Please sign in to comment.