Skip to content

Commit f10e3e8

Browse files
committed
Import shared.py properly
1 parent b6ebeed commit f10e3e8

File tree

8 files changed

+26
-19
lines changed

8 files changed

+26
-19
lines changed

emcc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ Example uses:
4141
4242
* For SCons the shared.py can be imported like so:
4343
__file__ = str(Dir('#/project_path_to_emscripten/dummy/dummy'))
44-
__rootpath__ = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
44+
__rootpath__ = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
4545
def path_from_root(*pathelems):
4646
return os.path.join(__rootpath__, *pathelems)
47-
exec(open(path_from_root('tools', 'shared.py'), 'r').read())
47+
sys.path += [path_from_root('')]
48+
from tools.shared import *
4849
4950
For using the Emscripten compilers/linkers/etc. you can do:
5051
env = Environment()

tests/runner.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@
1818

1919
# Setup
2020

21-
__rootpath__ = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
21+
__rootpath__ = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
2222
def path_from_root(*pathelems):
2323
return os.path.join(__rootpath__, *pathelems)
24-
exec(open(path_from_root('tools', 'shared.py'), 'r').read())
25-
2624
sys.path += [path_from_root('')]
25+
from tools.shared import *
2726

2827
# Sanity check for config
2928

third_party/demangler.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@
2121

2222
import os, sys, subprocess, re
2323

24-
__rootpath__ = os.path.abspath(os.path.dirname(__file__))
24+
__rootpath__ = os.path.dirname(os.path.abspath(__file__))
2525
def path_from_root(*pathelems):
2626
return os.path.join(os.path.sep, *(__rootpath__.split(os.sep)[:-1] + list(pathelems)))
27-
exec(open(path_from_root('tools', 'shared.py'), 'r').read())
27+
sys.path += [path_from_root('')]
28+
from tools.shared import *
2829

2930
data = open(sys.argv[1], 'r').readlines()
3031

tools/bindings_generator.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,11 @@
5050

5151
import os, sys, glob, re
5252

53-
__rootpath__ = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
53+
__rootpath__ = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
5454
def path_from_root(*pathelems):
5555
return os.path.join(__rootpath__, *pathelems)
56-
exec(open(path_from_root('tools', 'shared.py'), 'r').read())
56+
sys.path += [path_from_root('')]
57+
from tools.shared import *
5758

5859
# Find ply and CppHeaderParser
5960
sys.path = [path_from_root('third_party', 'ply'), path_from_root('third_party', 'CppHeaderParser')] + sys.path

tools/emconfiguren.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99

1010
import os, sys
1111

12-
__rootpath__ = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
12+
__rootpath__ = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
1313
def path_from_root(*pathelems):
1414
return os.path.join(__rootpath__, *pathelems)
15-
exec(open(path_from_root('tools', 'shared.py'), 'r').read())
15+
sys.path += [path_from_root('')]
16+
from tools.shared import *
1617

1718
Building.configure(sys.argv[1:])
1819

tools/emmaken.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,11 @@
5656
5757
* For SCons the shared.py can be imported like so:
5858
__file__ = str(Dir('#/project_path_to_emscripten/dummy/dummy'))
59-
__rootpath__ = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
59+
__rootpath__ = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
6060
def path_from_root(*pathelems):
6161
return os.path.join(__rootpath__, *pathelems)
62-
exec(open(path_from_root('tools', 'shared.py'), 'r').read())
62+
sys.path += [path_from_root('')]
63+
from tools.shared import *
6364
6465
For using the Emscripten compilers/linkers/etc. you can do:
6566
env = Environment()
@@ -99,10 +100,11 @@ def path_from_root(*pathelems):
99100

100101
print >> sys.stderr, 'emmaken.py: ', ' '.join(sys.argv)
101102

102-
__rootpath__ = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
103+
__rootpath__ = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
103104
def path_from_root(*pathelems):
104105
return os.path.join(__rootpath__, *pathelems)
105-
exec(open(path_from_root('tools', 'shared.py'), 'r').read())
106+
sys.path += [path_from_root('')]
107+
from tools.shared import *
106108

107109
# If this is a configure-type thing, just do that
108110
CONFIGURE_CONFIG = os.environ.get('EMMAKEN_JUST_CONFIGURE')

tools/emmakenxx.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66

77
import os, sys
88

9-
__rootpath__ = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
9+
__rootpath__ = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
1010
def path_from_root(*pathelems):
1111
return os.path.join(__rootpath__, *pathelems)
12-
exec(open(path_from_root('tools', 'shared.py'), 'r').read())
12+
sys.path += [path_from_root('')]
13+
from tools.shared import *
1314

1415
emmaken = path_from_root('tools', 'emmaken.py')
1516
os.environ['EMMAKEN_CXX'] = '1'

tools/exec_llvm.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@
3636
import os, sys
3737
from subprocess import Popen, PIPE, STDOUT
3838

39-
__rootpath__ = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
39+
__rootpath__ = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
4040
def path_from_root(*pathelems):
4141
return os.path.join(__rootpath__, *pathelems)
42-
exec(open(path_from_root('tools', 'shared.py'), 'r').read())
42+
sys.path += [path_from_root('')]
43+
from tools.shared import *
4344

4445
Popen([LLVM_OPT, sys.argv[1], '-strip-debug', '-o=' + sys.argv[1]+'.clean.bc']).communicate()[0]
4546

0 commit comments

Comments
 (0)