Skip to content

Commit 09fa949

Browse files
committed
Switch to AMBuild 2.2.
1 parent 79227c6 commit 09fa949

File tree

5 files changed

+26
-16
lines changed

5 files changed

+26
-16
lines changed

.appveyor/build.bat

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ mkdir opt32 && cd opt32
44
C:\python27\python.exe ..\configure.py --enable-optimize
55
ambuild
66
cd ..
7-
opt32\tests\testrunner\testrunner.exe
7+
opt32\dist\testrunner.exe

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ script:
7373
- mkdir build-opt && cd build-opt
7474
- python ../configure.py --enable-optimize
7575
- ambuild
76-
- ./tests/testrunner/testrunner
76+
- ./dist/testrunner
7777
- cd ..
7878

7979
- mkdir build-debug && cd build-debug
8080
- python ../configure.py --enable-debug
8181
- ambuild
82-
- ./tests/testrunner/testrunner
82+
- ./dist/testrunner

AMBuildScript

+8-5
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ class KEConfig(object):
99
def configure(self):
1010
cxx = builder.DetectCxx()
1111

12+
builder.cxx = cxx
13+
builder.dist_folder = builder.AddFolder('dist')
14+
1215
if cxx.like('gcc'):
13-
if builder.target.platform != 'windows':
16+
if cxx.target.platform != 'windows':
1417
if cxx.version >= 'gcc-8.0' or cxx.version >= 'clang-5.0':
1518
cxx.cxxflags += ['-std=c++17']
1619
else:
@@ -23,7 +26,7 @@ class KEConfig(object):
2326
'_vsnprintf=vsnprintf',
2427
]
2528
cxx.linkflags += ['-lpthread']
26-
if builder.target.platform != 'mac':
29+
if cxx.target.platform != 'mac':
2730
cxx.linkflags += ['-lrt']
2831
else:
2932
cxx.cxxflags += [
@@ -111,13 +114,13 @@ class KEConfig(object):
111114
cxx.cflags += ['/Oy-']
112115

113116
# Platform-specifics
114-
if builder.target.platform == 'linux':
117+
if cxx.target.platform == 'linux':
115118
cxx.defines += ['_LINUX', 'POSIX']
116119
if cxx.like('gcc'):
117120
cxx.linkflags += ['-static-libgcc']
118121
elif cxx.like('clang'):
119122
cxx.linkflags += ['-lgcc_eh']
120-
elif builder.target.platform == 'mac':
123+
elif cxx.target.platform == 'mac':
121124
cxx.defines += ['OSX', '_OSX', 'POSIX']
122125
cxx.cflags += ['-mmacosx-version-min=10.7']
123126
cxx.linkflags += [
@@ -126,7 +129,7 @@ class KEConfig(object):
126129
'-stdlib=libc++',
127130
]
128131
cxx.cxxflags += ['-stdlib=libc++']
129-
elif builder.target.platform == 'windows':
132+
elif cxx.target.platform == 'windows':
130133
cxx.defines += ['WIN32', '_WINDOWS']
131134

132135
def Program(self, context, name):

configure.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,16 @@
1212
sys.stderr.write('http://www.alliedmods.net/ambuild\n')
1313
sys.exit(1)
1414

15-
parser = run.BuildParser(sourcePath=sys.path[0], api='2.1')
16-
parser.options.add_option('--enable-debug', action='store_const', const='1', dest='debug',
17-
help='Enable debugging symbols')
18-
parser.options.add_option('--enable-optimize', action='store_const', const='1', dest='opt',
19-
help='Enable optimization')
20-
parser.options.add_option('--std', type=str, default=None, help='Override C++ standard')
15+
# Hack to show a decent upgrade message, which wasn't done until 2.2.
16+
ambuild_version = getattr(run, 'CURRENT_API', '2.1')
17+
if ambuild_version.startswith('2.1'):
18+
sys.stderr.write("AMBuild 2.2 or higher is required; please update\n")
19+
sys.exit(1)
20+
21+
parser = run.BuildParser(sourcePath=sys.path[0], api='2.2')
22+
parser.options.add_argument('--enable-debug', action='store_const', const='1', dest='debug',
23+
help='Enable debugging symbols')
24+
parser.options.add_argument('--enable-optimize', action='store_const', const='1', dest='opt',
25+
help='Enable optimization')
26+
parser.options.add_argument('--std', type=str, default=None, help='Override C++ standard')
2127
parser.Configure()

tests/AMBuild.tests

+3-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ compiler.includes += [
3737

3838
if compiler.like('msvc'):
3939
compiler.linkflags.append('/SUBSYSTEM:CONSOLE')
40-
if builder.target.platform == 'linux':
40+
if builder.cxx.target.platform == 'linux':
4141
compiler.linkflags.append('-ldl')
4242
compiler.linkflags.append(libgtest.binary)
4343
compiler.linkflags.append(KE.libamtl)
@@ -61,4 +61,5 @@ binary.sources += [
6161
'test-vector.cpp',
6262
]
6363

64-
builder.Add(binary)
64+
node = builder.Add(binary)
65+
builder.AddCopy(node.binary, builder.dist_folder)

0 commit comments

Comments
 (0)