@@ -992,14 +992,10 @@ def test_symlink_has_bad_suffix(self):
992
992
self .assertContained ('unknown file type: foobar.xxx' , err )
993
993
994
994
def test_multiply_defined_libsymbols (self ):
995
- lib_name = 'libA.c'
996
- a2_name = 'a2.c'
997
- b2_name = 'b2.c'
998
- main_name = 'main.c'
999
- create_file (lib_name , 'int mult() { return 1; }' )
1000
- create_file (a2_name , 'void x() {}' )
1001
- create_file (b2_name , 'void y() {}' )
1002
- create_file (main_name , r'''
995
+ create_file ('libA.c' , 'int mult() { return 1; }' )
996
+ create_file ('a2.c' , 'void x() {}' )
997
+ create_file ('b2.c' , 'void y() {}' )
998
+ create_file ('main.c' , r'''
1003
999
#include <stdio.h>
1004
1000
int mult();
1005
1001
int main() {
@@ -1008,26 +1004,20 @@ def test_multiply_defined_libsymbols(self):
1008
1004
}
1009
1005
''' )
1010
1006
1011
- self .emcc (lib_name , ['-shared' ], output_filename = 'libA.so' )
1007
+ self .emcc ('libA.c' , ['-shared' ], output_filename = 'libA.so' )
1012
1008
1013
- self .emcc (a2_name , ['-r' , '-L.' , '-lA' ])
1014
- self .emcc (b2_name , ['-r' , '-L.' , '-lA' ])
1009
+ self .emcc ('a2.c' , ['-r' , '-L.' , '-lA' , '-o' , 'a2.o ' ])
1010
+ self .emcc ('b2.c' , ['-r' , '-L.' , '-lA' , '-o' , 'b2.o ' ])
1015
1011
1016
- self .emcc (main_name , ['-L.' , '-lA' , a2_name + ' .o' , b2_name + ' .o' ], output_filename = 'a.out.js' )
1012
+ self .emcc ('main.c' , ['-L.' , '-lA' , 'a2 .o' , 'b2 .o' ])
1017
1013
1018
1014
self .assertContained ('result: 1' , self .run_js ('a.out.js' ))
1019
1015
1020
1016
def test_multiply_defined_libsymbols_2 (self ):
1021
- a = "int x() { return 55; }"
1022
- a_name = 'a.c'
1023
- create_file (a_name , a )
1024
- b = "int y() { return 2; }"
1025
- b_name = 'b.c'
1026
- create_file (b_name , b )
1027
- c = "int z() { return 5; }"
1028
- c_name = 'c.c'
1029
- create_file (c_name , c )
1030
- main = r'''
1017
+ create_file ('a.c' , "int x() { return 55; }" )
1018
+ create_file ('b.c' , "int y() { return 2; }" )
1019
+ create_file ('c.c' , "int z() { return 5; }" )
1020
+ create_file ('main.c' , r'''
1031
1021
#include <stdio.h>
1032
1022
int x();
1033
1023
int y();
@@ -1036,18 +1026,15 @@ def test_multiply_defined_libsymbols_2(self):
1036
1026
printf("result: %d\n", x() + y() + z());
1037
1027
return 0;
1038
1028
}
1039
- '''
1040
- main_name = 'main.c'
1041
- create_file (main_name , main )
1029
+ ''' )
1042
1030
1043
- self .emcc (a_name , ['-c' ]) # a.c.o
1044
- self .emcc (b_name , ['-c' ]) # b.c.o
1045
- self .emcc (c_name , ['-c' ]) # c.c.o
1046
- lib_name = 'libLIB.a'
1047
- building .emar ('cr' , lib_name , [a_name + '.o' , b_name + '.o' ]) # libLIB.a with a and b
1031
+ self .emcc ('a.c' , ['-c' ]) # a.o
1032
+ self .emcc ('b.c' , ['-c' ]) # b.o
1033
+ self .emcc ('c.c' , ['-c' ]) # c.o
1034
+ building .emar ('cr' , 'libLIB.a' , ['a.o' , 'b.o' ]) # libLIB.a with a and b
1048
1035
1049
1036
# a is in the lib AND in an .o, so should be ignored in the lib. We do still need b from the lib though
1050
- self .emcc (main_name , [a_name + ' .o' , c_name + ' .o' , '-L.' , '-lLIB' ], output_filename = 'a.out.js' )
1037
+ self .emcc ('main.c' , ['a .o' , 'c .o' , '-L.' , '-lLIB' ])
1051
1038
1052
1039
self .assertContained ('result: 62' , self .run_js ('a.out.js' ))
1053
1040
@@ -1063,9 +1050,9 @@ def test_link_group(self):
1063
1050
}
1064
1051
''' )
1065
1052
1066
- self .emcc ('lib.c' , ['-c' ]) # lib.c. o
1053
+ self .emcc ('lib.c' , ['-c' ]) # lib.o
1067
1054
lib_name = 'libLIB.a'
1068
- building .emar ('cr' , lib_name , ['lib.c. o' ]) # libLIB.a with lib.c .o
1055
+ building .emar ('cr' , lib_name , ['lib.o' ]) # libLIB.a with lib.o
1069
1056
1070
1057
def test (compiler , main_name , lib_args , err_expected ):
1071
1058
print (err_expected )
@@ -1350,9 +1337,7 @@ def test_identical_basenames(self):
1350
1337
1351
1338
def test_main_a (self ):
1352
1339
# if main() is in a .a, we need to pull in that .a
1353
-
1354
- main_name = 'main.c'
1355
- create_file (main_name , r'''
1340
+ create_file ('main.c' , r'''
1356
1341
#include <stdio.h>
1357
1342
extern int f();
1358
1343
int main() {
@@ -1361,18 +1346,17 @@ def test_main_a(self):
1361
1346
}
1362
1347
''' )
1363
1348
1364
- other_name = 'other.c'
1365
- create_file (other_name , r'''
1349
+ create_file ('other.c' , r'''
1366
1350
#include <stdio.h>
1367
1351
int f() { return 12346; }
1368
1352
''' )
1369
1353
1370
- self .run_process ([EMCC , main_name , '-c' , '-o' , main_name + '.o ' ])
1371
- self .run_process ([EMCC , other_name , '-c' , '-o' , other_name + '.o ' ])
1354
+ self .run_process ([EMCC , '-c' , 'main.c ' ])
1355
+ self .run_process ([EMCC , '-c' , 'other.c ' ])
1372
1356
1373
- self .run_process ([EMAR , 'cr' , main_name + ' .a' , main_name + ' .o' ])
1357
+ self .run_process ([EMAR , 'cr' , 'libmain .a' , 'main .o' ])
1374
1358
1375
- self .run_process ([EMCC , other_name + ' .o' , main_name + ' .a' ])
1359
+ self .run_process ([EMCC , 'other .o' , 'libmain .a' ])
1376
1360
1377
1361
self .assertContained ('result: 12346.' , self .run_js ('a.out.js' ))
1378
1362
0 commit comments