def test_STATIC_LIBRARY(self): """ test Syntax.STATIC_LIBRARY """ #set local flags tag libs = Syntax.Libs("$OUT_ROOT/baidu/broc/libhello.a") cpptags = Syntax.CppFlags("-DBROC", "-DRELEASE") src = Syntax.Sources("hello.cpp") #an error name of application flag = False try: Syntax.STATIC_LIBRARY("^*^&*!*$^", src) except Syntax.BrocArgumentIllegalError as ex: flag = True self.assertTrue(flag) #an error args of application flag = False try: Syntax.STATIC_LIBRARY("hello", src, cpptags) except Syntax.BrocArgumentIllegalError as ex: flag = True self.assertTrue(flag) #Libs Syntax.STATIC_LIBRARY("hello", src, libs) library = self._env.Targets()[0] library.Action() self.assertEqual(library.tag_libs.V(), ["broc_out/baidu/broc/libhello.a"]) #two samename target flag = False try: Syntax.STATIC_LIBRARY("hello", src) except Syntax.BrocArgumentIllegalError as ex: flag = True self.assertTrue(flag) #library DoCopy Function.RunCommand("mkdir -p %s/lib" % self._module.root_path, \ ignore_stderr_when_ok = True) Function.RunCommand("touch %s/lib/libhello1.a" % self._module.root_path, \ ignore_stderr_when_ok = True) now_dir = os.getcwd() os.chdir(self._module.workspace) Syntax.STATIC_LIBRARY("hello1") lib_paths = os.path.join(self._module.workspace, "broc_out", \ self._module.module_cvspath, "output/lib/libhello1.a") self.assertTrue(os.path.exists(lib_paths)) os.chdir(now_dir)