def test_APPLICATION(self): """ test Syntax.APPLICATION """ #set local flags tag ldflag = Syntax.LDFlags("-lpthread", "-lcrypto") libs = Syntax.Libs("$OUT_ROOT/baidu/broc/libhello.a") cpptags = Syntax.CppFlags("-DBROC", "-DRELEASE") #set global flags Syntax.LDFLAGS("-lmcpack", "-lrt") src = Syntax.Sources("hello.cpp") #an error name of application flag = False try: Syntax.APPLICATION("^*^&*!*$^", src) except Syntax.BrocArgumentIllegalError as ex: flag = True self.assertTrue(flag) #an error args of application flag = False try: Syntax.APPLICATION("hello", src, cpptags) except Syntax.BrocArgumentIllegalError as ex: flag = True self.assertTrue(flag) #global ldflags Syntax.APPLICATION("hello", src) app = self._env.Targets()[0] app.Action() self.assertEqual(app.link_options, ["-lmcpack"]) self.assertEqual(app.tag_libs.V(), []) #two samename target flag = False try: Syntax.APPLICATION("hello", src) except Syntax.BrocArgumentIllegalError as ex: flag = True self.assertTrue(flag) #local ldflags Syntax.APPLICATION("hello2", src, ldflag) app = self._env.Targets()[1] app.Action() self.assertEqual(app.link_options, ["-lpthread"]) self.assertEqual(app.tag_libs.V(), []) #Libs Syntax.APPLICATION("hello3", src, ldflag, libs) app = self._env.Targets()[2] app.Action() self.assertEqual(app.link_options, ["-lpthread"]) self.assertEqual(app.tag_libs.V(), ["broc_out/baidu/broc/libhello.a"])
def test_LDFlags(self): """ test Syntax.LDFlags """ #test case of debug mode Environment.SetCurrent(self._env) self._env._build_mode = 'debug' tag = Syntax.LDFlags("-lpthread -lcrypto", "-lprotobuf -lpthread") self.assertTrue("-lpthread -lcrypto" in tag.V() \ and "-lprotobuf -lpthread" not in tag.V()) #reset g_linkflags self._env._g_linkflags = SyntaxTag.TagLDFLAGS() #test case of release mode self._env._build_mode = 'release' tag = Syntax.LDFlags("-lpthread -lcrypto", "-lprotobuf -lpthread") self.assertTrue("-lprotobuf -lpthread" in tag.V() \ and "-lpthread -lcrypto" not in tag.V())