Sha256: 3864304ac99f58c12e36963ab6c2c61b08541b046dd94e8ff00dd85292fa134f

Contents?: true

Size: 1.08 KB

Versions: 5

Compression:

Stored size: 1.08 KB

Contents

#!/usr/bin/env python

# Copyright (c) 2010 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import sys
import time

output = sys.argv[1]
persistoutput = "%s.persist" % sys.argv[1]

count = 0
try:
  count = open(persistoutput, 'r').read()
except:
  pass
count = int(count) + 1

if len(sys.argv) > 2:
  max_count = int(sys.argv[2])
  if count > max_count:
    count = max_count

oldcount = 0
try:
  oldcount = open(output, 'r').read()
except:
  pass

# Save the count in a file that is undeclared, and thus hidden, to gyp. We need
# to do this because, prior to running commands, some build systems deletes
# any declared outputs, so we would lose our count if we just wrote to the
# given output file.
open(persistoutput, 'w').write('%d' % (count))

# Only write the given output file if the count has changed.
if int(oldcount) != count:
  open(output, 'w').write('%d' % (count))
  # Sleep so the next run changes the file time sufficiently to make the build
  # detect the file as changed.
  time.sleep(1)

sys.exit(0)

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
mt-libuv-4.1.04 ext/gyp/test/actions/src/subdir1/counter.py
mt-libuv-4.1.03 ext/gyp/test/actions/src/subdir1/counter.py
mt-libuv-4.1.02 ext/gyp/test/actions/src/subdir1/counter.py
tree-sitter-0.1.0 ext/tree-sitter/tree-sitter/externals/gyp/test/actions/src/subdir1/counter.py
tree-sitter-0.0.1 ext/tree-sitter/tree-sitter/externals/gyp/test/actions/src/subdir1/counter.py