Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • hammer/hammer
  • mlp/hammer
  • xentrac/hammer
  • pesco/hammer
  • letitiali/hammer
  • nobody/hammer
  • kia/hammer-sandbox
  • vyrus001/hammer
  • denleylam/hammer
9 results
Show changes
...@@ -24,6 +24,8 @@ extern void register_bitwriter_tests(); ...@@ -24,6 +24,8 @@ extern void register_bitwriter_tests();
extern void register_parser_tests(); extern void register_parser_tests();
extern void register_grammar_tests(); extern void register_grammar_tests();
extern void register_misc_tests(); extern void register_misc_tests();
extern void register_mm_tests();
extern void register_names_tests();
extern void register_benchmark_tests(); extern void register_benchmark_tests();
extern void register_regression_tests(); extern void register_regression_tests();
...@@ -36,6 +38,8 @@ int main(int argc, char** argv) { ...@@ -36,6 +38,8 @@ int main(int argc, char** argv) {
register_parser_tests(); register_parser_tests();
register_grammar_tests(); register_grammar_tests();
register_misc_tests(); register_misc_tests();
register_mm_tests();
register_names_tests();
register_regression_tests(); register_regression_tests();
if (g_test_slow() || g_test_perf()) if (g_test_slow() || g_test_perf())
register_benchmark_tests(); register_benchmark_tests();
......
...@@ -35,6 +35,18 @@ ...@@ -35,6 +35,18 @@
} \ } \
} while(0) } while(0)
/* Comparison for ptr types; only == and != will work */
#define g_check_cmp_ptr(p1, op, p2) do { \
const void *_p1 = (p1); \
const void *_p2 = (p2); \
if (!(_p1 op _p2)) { \
g_test_message("Check failed: (%s): (%p %s %p)", \
#p1 " " #op " " #p2, \
_p1, #op, _p2); \
g_test_fail(); \
} \
} while (0);
#define g_check_bytes(len, n1, op, n2) do { \ #define g_check_bytes(len, n1, op, n2) do { \
const uint8_t *_n1 = (n1); \ const uint8_t *_n1 = (n1); \
const uint8_t *_n2 = (n2); \ const uint8_t *_n2 = (n2); \
...@@ -56,6 +68,32 @@ ...@@ -56,6 +68,32 @@
} \ } \
} while(0) } while(0)
#define g_check_maybe_string_eq(n1, n2) do { \
const char *_n1 = (n1); \
const char *_n2 = (n2); \
if (_n1 != _n2 && _n1 != NULL && _n2 != NULL) { \
if (!(strcmp(_n1, _n2) == 0)) { \
g_test_message("Check failed: (%s) (\"%s\" == \"%s\")", \
#n1 " == " #n2, _n1, _n2); \
g_test_fail(); \
} \
} else { \
if (_n1 != NULL || _n2 != NULL) { \
if (_n1 != NULL && _n2 == NULL) { \
g_test_message("Check failed: (%s) (\"%s\" == NULL)", \
#n1 " == " #n2, _n1); \
g_test_fail(); \
} else if (_n1 == NULL && _n2 != NULL) { \
g_test_message("Check failed: (%s) (NULL == \"%s\")", \
#n1 " == " #n2, _n2); \
g_test_fail(); \
} \
/* else both are not-NULL, but point to the same string - succeed */ \
} \
/* else both are NULL, succeed */ \
} \
} while(0)
#define g_check_regular(lang) do { \ #define g_check_regular(lang) do { \
if (!lang->isValidRegular(lang->env)) { \ if (!lang->isValidRegular(lang->env)) { \
g_test_message("Language is not regular"); \ g_test_message("Language is not regular"); \
...@@ -71,24 +109,36 @@ ...@@ -71,24 +109,36 @@
} while(0) } while(0)
#define g_check_compilable(lang, backend, params) do { \ #define g_check_compilable(lang, backend, params) do { \
if (!h_compile(lang, backend, params)) { \ int r = h_compile((HParser *)(lang), (HParserBackend)(backend), (void *)(params)); \
g_test_message("Language is not %s(%s)", #backend, params); \ if (r != 0) { \
g_test_message("Language is not %s(%s)", #backend, #params); \
g_test_fail(); \ g_test_fail(); \
} \ } \
} while(0) } while(0)
#define print_arena_stats(arena) do { \
if (g_test_verbose()) { \
HArenaStats stats; \
h_allocator_stats(arena, &stats); \
g_test_message("Parse used %zd bytes, wasted %zd bytes. " \
"Inefficiency: %5f%%", \
stats.used, stats.wasted, \
stats.wasted * 100. / (stats.used+stats.wasted)); \
} \
} while(0)
#define g_check_parse_failed__m(mm__, parser, backend, input, inp_len) do { \ #define g_check_parse_failed__m(mm__, parser, backend, input, inp_len) do { \
int skip = h_compile__m(mm__, (HParser *)(parser), (HParserBackend)backend, NULL); \ int skip = h_compile__m(mm__, (HParser *)(parser), (HParserBackend)backend, NULL); \
if(skip != 0) { \ if(skip != 0) { \
g_test_message("Compile failed"); \ g_test_message("Compile failed on line %d", __LINE__); \
g_test_fail(); \ g_test_fail(); \
break; \ break; \
} \ } \
HParseResult *result = h_parse__m(mm__, parser, (const uint8_t*)input, inp_len); \ HParseResult *res = h_parse__m(mm__, parser, (const uint8_t*)input, inp_len); \
if (NULL != result) { \ if (NULL != res) { \
h_parse_result_free(result); \ print_arena_stats(res->arena); \
g_test_message("Check failed: shouldn't have succeeded, but did"); \ h_parse_result_free(res); \
g_test_message("Check failed: parse shouldn't have succeeded, but did on line %d", __LINE__); \
g_test_fail(); \ g_test_fail(); \
} \ } \
} while(0) } while(0)
...@@ -96,36 +146,61 @@ ...@@ -96,36 +146,61 @@
#define g_check_parse_failed(p, be, input, len) \ #define g_check_parse_failed(p, be, input, len) \
g_check_parse_failed__m(&system_allocator, p, be, input, len) g_check_parse_failed__m(&system_allocator, p, be, input, len)
#define g_check_parse_ok(parser, backend, input, inp_len) do { \ #define g_check_parse_failed_no_compile__m(mm__, parser, input, inp_len) do { \
int skip = h_compile((HParser *)(parser), (HParserBackend) backend, NULL); \ HParseResult *res = h_parse__m(mm__, parser, (const uint8_t*)input, inp_len); \
if (NULL != res) { \
print_arena_stats(res->arena); \
h_parse_result_free(res); \
g_test_message("Check failed: shouldn't have succeeded, but did on ;ine %d", __LINE__); \
g_test_fail(); \
} \
} while(0)
#define g_check_parse_failed_no_compile(p, input, len) \
g_check_parse_failed__m(&system_allocator, p, input, len)
#define g_check_parse_ok__m(mm__, parser, backend, input, inp_len) do { \
int skip = h_compile__m(mm__, (HParser *)(parser), (HParserBackend) backend, NULL); \
if(skip) { \ if(skip) { \
g_test_message("Compile failed"); \ g_test_message("Compile failed"); \
g_test_fail(); \ g_test_fail(); \
break; \ break; \
} \ } \
HParseResult *res = h_parse(parser, (const uint8_t*)input, inp_len); \ HParseResult *res = h_parse__m(mm__, parser, (const uint8_t*)input, inp_len); \
if (!res) { \ if (!res) { \
g_test_message("Parse failed on line %d", __LINE__); \ g_test_message("Parse failed on line %d", __LINE__); \
g_test_fail(); \ g_test_fail(); \
} else { \ } else { \
HArenaStats stats; \ print_arena_stats(res->arena); \
h_allocator_stats(res->arena, &stats); \
g_test_message("Parse used %zd bytes, wasted %zd bytes. " \
"Inefficiency: %5f%%", \
stats.used, stats.wasted, \
stats.wasted * 100. / (stats.used+stats.wasted)); \
h_parse_result_free(res); \ h_parse_result_free(res); \
} \ } \
} while(0) } while(0)
#define g_check_parse_match(parser, backend, input, inp_len, result) do { \ #define g_check_parse_ok(p, be, input, len) \
int skip = h_compile((HParser *)(parser), (HParserBackend) backend, NULL); \ g_check_parse_ok__m(&system_allocator, p, be, input, len)
#define g_check_parse_ok_no_compile__m(mm__, parser, input, inp_len) do { \
HParseResult *res = h_parse__m(mm__, parser, (const uint8_t*)input, inp_len); \
if (!res) { \
g_test_message("Parse failed on line %d", __LINE__); \
g_test_fail(); \
} else { \
print_arena_stats(res->arena); \
h_parse_result_free(res); \
} \
} while(0)
#define g_check_parse_ok_no_compile(p, input, len) \
g_check_parse_ok_no_compile__m(&system_allocator, p, input, len)
#define g_check_parse_match__m(mm__, parser, backend, input, inp_len, result) do { \
int skip = h_compile__m(mm__, (HParser *)(parser), (HParserBackend) backend, NULL); \
if(skip) { \ if(skip) { \
g_test_message("Compile failed"); \ g_test_message("Compile failed"); \
g_test_fail(); \ g_test_fail(); \
break; \ break; \
} \ } \
HParseResult *res = h_parse(parser, (const uint8_t*)input, inp_len); \ HParseResult *res = h_parse__m(mm__, (HParser *)(parser), (const uint8_t*)input, inp_len); \
if (!res) { \ if (!res) { \
g_test_message("Parse failed on line %d", __LINE__); \ g_test_message("Parse failed on line %d", __LINE__); \
g_test_fail(); \ g_test_fail(); \
...@@ -133,16 +208,31 @@ ...@@ -133,16 +208,31 @@
char* cres = h_write_result_unamb(res->ast); \ char* cres = h_write_result_unamb(res->ast); \
g_check_string(cres, ==, result); \ g_check_string(cres, ==, result); \
(&system_allocator)->free(&system_allocator, cres); \ (&system_allocator)->free(&system_allocator, cres); \
HArenaStats stats; \ print_arena_stats(res->arena); \
h_allocator_stats(res->arena, &stats); \ h_parse_result_free(res); \
g_test_message("Parse used %zd bytes, wasted %zd bytes. " \ } \
"Inefficiency: %5f%%", \ } while(0)
stats.used, stats.wasted, \
stats.wasted * 100. / (stats.used+stats.wasted)); \ #define g_check_parse_match(parser, backend, input, inp_len, result) \
g_check_parse_match__m(&system_allocator, parser, backend, input, inp_len, result)
#define g_check_parse_match_no_compile__m(mm__, parser, input, inp_len, result) do { \
HParseResult *res = h_parse__m(mm__, (HParser *)(parser), (const uint8_t*)input, inp_len); \
if (!res) { \
g_test_message("Parse failed on line %d", __LINE__); \
g_test_fail(); \
} else { \
char* cres = h_write_result_unamb(res->ast); \
g_check_string(cres, ==, result); \
(&system_allocator)->free(&system_allocator, cres); \
print_arena_stats(res->arena); \
h_parse_result_free(res); \ h_parse_result_free(res); \
} \ } \
} while(0) } while(0)
#define g_check_parse_match_no_compile(parser, input, inp_len, result) \
g_check_parse_match_no_compile__m(&system_allocator, parser, input, inp_len, result)
#define g_check_parse_chunks_failed__m(mm__, parser, backend, chunk1, c1_len, chunk2, c2_len) do { \ #define g_check_parse_chunks_failed__m(mm__, parser, backend, chunk1, c1_len, chunk2, c2_len) do { \
int skip = h_compile__m(mm__, (HParser *)(parser), (HParserBackend)backend, NULL); \ int skip = h_compile__m(mm__, (HParser *)(parser), (HParserBackend)backend, NULL); \
if(skip) { \ if(skip) { \
...@@ -154,7 +244,7 @@ ...@@ -154,7 +244,7 @@
} while(0) } while(0)
#define g_check_parse_chunks_failed___m(mm__, parser, chunk1, c1_len, chunk2, c2_len) do { \ #define g_check_parse_chunks_failed___m(mm__, parser, chunk1, c1_len, chunk2, c2_len) do { \
HSuspendedParser *s = h_parse_start__m(mm__, parser); \ HSuspendedParser *s = h_parse_start__m(mm__, (HParser *)(parser)); \
if(!s) { \ if(!s) { \
g_test_message("Chunk-wise parsing not available"); \ g_test_message("Chunk-wise parsing not available"); \
g_test_fail(); \ g_test_fail(); \
...@@ -187,7 +277,7 @@ ...@@ -187,7 +277,7 @@
} while(0) } while(0)
#define g_check_parse_chunks_ok_(parser, chunk1, c1_len, chunk2, c2_len) do { \ #define g_check_parse_chunks_ok_(parser, chunk1, c1_len, chunk2, c2_len) do { \
HSuspendedParser *s = h_parse_start(parser); \ HSuspendedParser *s = h_parse_start((HParser *)(parser)); \
if(!s) { \ if(!s) { \
g_test_message("Chunk-wise parsing not available"); \ g_test_message("Chunk-wise parsing not available"); \
g_test_fail(); \ g_test_fail(); \
...@@ -200,12 +290,7 @@ ...@@ -200,12 +290,7 @@
g_test_message("Parse failed on line %d", __LINE__); \ g_test_message("Parse failed on line %d", __LINE__); \
g_test_fail(); \ g_test_fail(); \
} else { \ } else { \
HArenaStats stats; \ print_arena_stats(res->arena); \
h_allocator_stats(res->arena, &stats); \
g_test_message("Parse used %zd bytes, wasted %zd bytes. " \
"Inefficiency: %5f%%", \
stats.used, stats.wasted, \
stats.wasted * 100. / (stats.used+stats.wasted)); \
h_parse_result_free(res); \ h_parse_result_free(res); \
} \ } \
} while(0) } while(0)
...@@ -221,7 +306,7 @@ ...@@ -221,7 +306,7 @@
} while(0) } while(0)
#define g_check_parse_chunks_match_(parser, chunk1, c1_len, chunk2, c2_len, result) do { \ #define g_check_parse_chunks_match_(parser, chunk1, c1_len, chunk2, c2_len, result) do { \
HSuspendedParser *s = h_parse_start(parser); \ HSuspendedParser *s = h_parse_start((HParser *)(parser)); \
if(!s) { \ if(!s) { \
g_test_message("Chunk-wise parsing not available"); \ g_test_message("Chunk-wise parsing not available"); \
g_test_fail(); \ g_test_fail(); \
...@@ -237,12 +322,98 @@ ...@@ -237,12 +322,98 @@
char* cres = h_write_result_unamb(res->ast); \ char* cres = h_write_result_unamb(res->ast); \
g_check_string(cres, ==, result); \ g_check_string(cres, ==, result); \
(&system_allocator)->free(&system_allocator, cres); \ (&system_allocator)->free(&system_allocator, cres); \
HArenaStats stats; \ print_arena_stats(res->arena); \
h_allocator_stats(res->arena, &stats); \ h_parse_result_free(res); \
g_test_message("Parse used %zd bytes, wasted %zd bytes. " \ } \
"Inefficiency: %5f%%", \ } while(0)
stats.used, stats.wasted, \
stats.wasted * 100. / (stats.used+stats.wasted)); \ #define g_check_parse_chunk_failed__m(mm__, parser, backend, chunk1, c1_len) do { \
int skip = h_compile__m(mm__, (HParser *)(parser), (HParserBackend)backend, NULL); \
if(skip) { \
g_test_message("Compile failed"); \
g_test_fail(); \
break; \
} \
g_check_parse_chunk_failed___m(mm__, parser, chunk1, c1_len); \
} while(0)
#define g_check_parse_chunk_failed___m(mm__, parser, chunk1, c1_len) do { \
HSuspendedParser *s = h_parse_start__m(mm__, (HParser *)(parser)); \
if(!s) { \
g_test_message("Chunk-wise parsing not available"); \
g_test_fail(); \
break; \
} \
h_parse_chunk(s, (const uint8_t*)chunk1, c1_len); \
HParseResult *res = h_parse_finish(s); \
if (NULL != res) { \
h_parse_result_free(res); \
g_test_message("Check failed: shouldn't have succeeded, but did"); \
g_test_fail(); \
} \
} while(0)
#define g_check_parse_chunk_failed(p, be, c1, c1_len) \
g_check_parse_chunk_failed__m(&system_allocator, p, be, c1, c1_len)
#define g_check_parse_chunk_failed_(p, c1, c1_len) \
g_check_parse_chunk_failed___m(&system_allocator, p, c1, c1_len)
#define g_check_parse_chunk_ok(parser, backend, chunk1, c1_len) do { \
int skip = h_compile((HParser *)(parser), (HParserBackend)backend, NULL); \
if(skip) { \
g_test_message("Compile failed"); \
g_test_fail(); \
break; \
} \
g_check_parse_chunk_ok_(parser, chunk1, c1_len); \
} while(0)
#define g_check_parse_chunk_ok_(parser, chunk1, c1_len) do { \
HSuspendedParser *s = h_parse_start((HParser *)(parser)); \
if(!s) { \
g_test_message("Chunk-wise parsing not available"); \
g_test_fail(); \
break; \
} \
h_parse_chunk(s, (const uint8_t*)chunk1, c1_len); \
HParseResult *res = h_parse_finish(s); \
if (!res) { \
g_test_message("Parse failed on line %d", __LINE__); \
g_test_fail(); \
} else { \
print_arena_stats(res->arena); \
h_parse_result_free(res); \
} \
} while(0)
#define g_check_parse_chunk_match(parser, backend, chunk1, c1_len, result) do { \
int skip = h_compile((HParser *)(parser), (HParserBackend) backend, NULL); \
if(skip) { \
g_test_message("Compile failed"); \
g_test_fail(); \
break; \
} \
g_check_parse_chunk_match_(parser, chunk1, c1_len, result); \
} while(0)
#define g_check_parse_chunk_match_(parser, chunk1, c1_len, result) do { \
HSuspendedParser *s = h_parse_start((HParser *)(parser)); \
if(!s) { \
g_test_message("Chunk-wise parsing not available"); \
g_test_fail(); \
break; \
} \
h_parse_chunk(s, (const uint8_t*)chunk1, c1_len); \
HParseResult *res = h_parse_finish(s); \
if (!res) { \
g_test_message("Parse failed on line %d", __LINE__); \
g_test_fail(); \
} else { \
char* cres = h_write_result_unamb(res->ast); \
g_check_string(cres, ==, result); \
(&system_allocator)->free(&system_allocator, cres); \
print_arena_stats(res->arena); \
h_parse_result_free(res); \ h_parse_result_free(res); \
} \ } \
} while(0) } while(0)
...@@ -321,6 +492,7 @@ ...@@ -321,6 +492,7 @@
#define g_check_cmp_int64(n1, op, n2) g_check_inttype("%" PRId64, int64_t, n1, op, n2) #define g_check_cmp_int64(n1, op, n2) g_check_inttype("%" PRId64, int64_t, n1, op, n2)
#define g_check_cmp_uint32(n1, op, n2) g_check_inttype("%u", uint32_t, n1, op, n2) #define g_check_cmp_uint32(n1, op, n2) g_check_inttype("%u", uint32_t, n1, op, n2)
#define g_check_cmp_uint64(n1, op, n2) g_check_inttype("%" PRIu64, uint64_t, n1, op, n2) #define g_check_cmp_uint64(n1, op, n2) g_check_inttype("%" PRIu64, uint64_t, n1, op, n2)
#define g_check_cmp_size(n1, op, n2) g_check_inttype("%zu", size_t, n1, op, n2)
#define g_check_cmpfloat(n1, op, n2) g_check_inttype("%g", float, n1, op, n2) #define g_check_cmpfloat(n1, op, n2) g_check_inttype("%g", float, n1, op, n2)
#define g_check_cmpdouble(n1, op, n2) g_check_inttype("%g", double, n1, op, n2) #define g_check_cmpdouble(n1, op, n2) g_check_inttype("%g", double, n1, op, n2)
......
#!/bin/bash
#
# Script to run valgrind against the test suite for hunting memory leaks
#
# This assumes you run it in the Hammer base directory and have a debug build
HAMMER_ROOT=.
VARIANT=debug
BUILD_PATH=$HAMMER_ROOT/build/$VARIANT
LD_LIBRARY_PATH=$BUILD_PATH/src:$LD_LIBRARY_PATH
VALGRIND=valgrind
VALGRIND_OPTS="-v --leak-check=full --leak-resolution=high --num-callers=40 --partial-loads-ok=no --show-leak-kinds=all --track-origins=yes --undef-value-errors=yes"
VALGRIND_SUPPRESSIONS="valgrind-glib.supp"
for s in $VALGRIND_SUPPRESSIONS
do
VALGRIND_OPTS="$VALGRIND_OPTS --suppressions=$HAMMER_ROOT/testing/valgrind/$s"
done
export LD_LIBRARY_PATH
$VALGRIND $VALGRIND_OPTS $BUILD_PATH/src/test_suite $@
{
<g_test_add_vtable_supp>
Memcheck:Leak
match-leak-kinds: reachable
...
fun:g_malloc
...
fun:g_test_add_vtable
...
}
{
<g_test_init_malloc_supp>
Memcheck:Leak
match-leak-kinds: reachable
fun:malloc
...
fun:g_test_init
...
}
{
<g_test_init_calloc_supp>
Memcheck:Leak
match-leak-kinds: reachable
fun:calloc
...
fun:g_test_init
...
}
{
<g_rand_new_with_seed_array_supp>
Memcheck:Leak
match-leak-kinds: reachable
fun:calloc
fun:g_malloc0
fun:g_rand_new_with_seed_array
...
fun:g_test_run_suite
fun:g_test_run
...
}
...@@ -21,4 +21,6 @@ ...@@ -21,4 +21,6 @@
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from csharp import exists, generate from __future__ import absolute_import, division, print_function
from .csharp import exists, generate
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
# This is an attempt to meld to two based initially on the Microsoft C# tool with amendmnets from the Mono # This is an attempt to meld to two based initially on the Microsoft C# tool with amendmnets from the Mono
# tool. # tool.
from __future__ import absolute_import, division, print_function
import os.path import os.path
import SCons.Builder import SCons.Builder
import SCons.Node.FS import SCons.Node.FS
...@@ -203,7 +205,7 @@ def AddToModPaths(env, files, **kw): ...@@ -203,7 +205,7 @@ def AddToModPaths(env, files, **kw):
def cscFlags(target, source, env, for_signature): def cscFlags(target, source, env, for_signature):
listCmd = [] listCmd = []
if (env.has_key('WINEXE')): if ('WINEXE' in env):
if (env['WINEXE'] == 1): if (env['WINEXE'] == 1):
listCmd.append('-t:winexe') listCmd.append('-t:winexe')
return listCmd return listCmd
...@@ -243,7 +245,7 @@ def cscSourcesNoResources(target, source, env, for_signature): ...@@ -243,7 +245,7 @@ def cscSourcesNoResources(target, source, env, for_signature):
def cscRefs(target, source, env, for_signature): def cscRefs(target, source, env, for_signature):
listCmd = [] listCmd = []
if (env.has_key('ASSEMBLYREFS')): if ('ASSEMBLYREFS' in env):
refs = SCons.Util.flatten(env['ASSEMBLYREFS']) refs = SCons.Util.flatten(env['ASSEMBLYREFS'])
for ref in refs: for ref in refs:
if SCons.Util.is_String(ref): if SCons.Util.is_String(ref):
...@@ -256,7 +258,7 @@ def cscRefs(target, source, env, for_signature): ...@@ -256,7 +258,7 @@ def cscRefs(target, source, env, for_signature):
def cscMods(target, source, env, for_signature): def cscMods(target, source, env, for_signature):
listCmd = [] listCmd = []
if (env.has_key('NETMODULES')): if ('NETMODULES' in env):
mods = SCons.Util.flatten(env['NETMODULES']) mods = SCons.Util.flatten(env['NETMODULES'])
for mod in mods: for mod in mods:
listCmd.append('-addmodule:%s' % mod) listCmd.append('-addmodule:%s' % mod)
...@@ -274,7 +276,7 @@ def alLinkSources(target, source, env, for_signature): ...@@ -274,7 +276,7 @@ def alLinkSources(target, source, env, for_signature):
# just treat this as a generic unidentified source file # just treat this as a generic unidentified source file
listCmd.append('-link:%s' % s.get_string(for_signature)) listCmd.append('-link:%s' % s.get_string(for_signature))
if env.has_key('VERSION'): if 'VERSION' in env:
version = parseVersion(env) version = parseVersion(env)
listCmd.append('-version:%d.%d.%d.%d' % version) listCmd.append('-version:%d.%d.%d.%d' % version)
...@@ -296,7 +298,7 @@ def cliLinkSources(target, source, env, for_signature): ...@@ -296,7 +298,7 @@ def cliLinkSources(target, source, env, for_signature):
return listCmd return listCmd
def add_version(target, source, env): def add_version(target, source, env):
if env.has_key('VERSION'): if 'VERSION' in env:
if SCons.Util.is_String(target[0]): if SCons.Util.is_String(target[0]):
versionfile = target[0] + '_VersionInfo.cs' versionfile = target[0] + '_VersionInfo.cs'
else: else:
...@@ -319,14 +321,14 @@ def lib_emitter(target, source, env): ...@@ -319,14 +321,14 @@ def lib_emitter(target, source, env):
def add_depends(target, source, env): def add_depends(target, source, env):
"""Add dependency information before the build order is established""" """Add dependency information before the build order is established"""
if (env.has_key('NETMODULES')): if ('NETMODULES' in env):
mods = SCons.Util.flatten(env['NETMODULES']) mods = SCons.Util.flatten(env['NETMODULES'])
for mod in mods: for mod in mods:
# add as dependency # add as dependency
for t in target: for t in target:
env.Depends(t, mod) env.Depends(t, mod)
if (env.has_key('ASSEMBLYREFS')): if ('ASSEMBLYREFS' in env):
refs = SCons.Util.flatten(env['ASSEMBLYREFS']) refs = SCons.Util.flatten(env['ASSEMBLYREFS'])
for ref in refs: for ref in refs:
# add as dependency # add as dependency
...@@ -417,7 +419,7 @@ res_action = SCons.Action.Action('$CLIRCCOM', '$CLIRCCOMSTR') ...@@ -417,7 +419,7 @@ res_action = SCons.Action.Action('$CLIRCCOM', '$CLIRCCOMSTR')
def res_emitter(target, source, env): def res_emitter(target, source, env):
# prepend NAMESPACE if provided # prepend NAMESPACE if provided
if (env.has_key('NAMESPACE')): if ('NAMESPACE' in env):
newtargets = [] newtargets = []
for t in target: for t in target:
tname = t.name tname = t.name
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
# This C# Tool for Mono taken from http://www.scons.org/wiki/CsharpBuilder. # This C# Tool for Mono taken from http://www.scons.org/wiki/CsharpBuilder.
from __future__ import absolute_import, division, print_function
import os.path import os.path
import SCons.Builder import SCons.Builder
import SCons.Node.FS import SCons.Node.FS
......
from __future__ import absolute_import, division, print_function
from string import Template from string import Template
def replace_action(target, source, env): def replace_action(target, source, env):
......