xref: /aosp_15_r20/external/nanopb-c/tests/cxx_main_program/SConscript (revision c8d645cafcee3f91213d30caa0fe303887010b9b)
1*c8d645caSAndroid Build Coastguard Worker# Run the alltypes test case, but compile it as C++ instead.
2*c8d645caSAndroid Build Coastguard Worker# In fact, compile the entire nanopb using C++ compiler.
3*c8d645caSAndroid Build Coastguard Worker
4*c8d645caSAndroid Build Coastguard WorkerImport("env")
5*c8d645caSAndroid Build Coastguard Worker
6*c8d645caSAndroid Build Coastguard Worker# This is needed to get INT32_MIN etc. macros defined
7*c8d645caSAndroid Build Coastguard Workerenv = env.Clone()
8*c8d645caSAndroid Build Coastguard Workerenv.Append(CPPDEFINES = ['__STDC_LIMIT_MACROS'])
9*c8d645caSAndroid Build Coastguard Worker
10*c8d645caSAndroid Build Coastguard Worker# Copy the files to .cxx extension in order to force C++ build.
11*c8d645caSAndroid Build Coastguard Workerc = Copy("$TARGET", "$SOURCE")
12*c8d645caSAndroid Build Coastguard Workerenv.Command("pb_encode.cxx", "#../pb_encode.c", c)
13*c8d645caSAndroid Build Coastguard Workerenv.Command("pb_decode.cxx", "#../pb_decode.c", c)
14*c8d645caSAndroid Build Coastguard Workerenv.Command("pb_common.cxx", "#../pb_common.c", c)
15*c8d645caSAndroid Build Coastguard Workerenv.Command("alltypes.pb.h", "$BUILD/alltypes/alltypes.pb.h", c)
16*c8d645caSAndroid Build Coastguard Workerenv.Command("alltypes.pb.cxx", "$BUILD/alltypes/alltypes.pb.c", c)
17*c8d645caSAndroid Build Coastguard Workerenv.Command("encode_alltypes.cxx", "$BUILD/alltypes/encode_alltypes.c", c)
18*c8d645caSAndroid Build Coastguard Workerenv.Command("decode_alltypes.cxx", "$BUILD/alltypes/decode_alltypes.c", c)
19*c8d645caSAndroid Build Coastguard Worker
20*c8d645caSAndroid Build Coastguard Worker# Now build and run the test normally.
21*c8d645caSAndroid Build Coastguard Workerenc = env.Program(["encode_alltypes.cxx", "alltypes.pb.cxx", "pb_encode.cxx", "pb_common.cxx"])
22*c8d645caSAndroid Build Coastguard Workerdec = env.Program(["decode_alltypes.cxx", "alltypes.pb.cxx", "pb_decode.cxx", "pb_common.cxx"])
23*c8d645caSAndroid Build Coastguard Worker
24*c8d645caSAndroid Build Coastguard Workerenv.RunTest(enc)
25*c8d645caSAndroid Build Coastguard Workerenv.RunTest([dec, "encode_alltypes.output"])
26