Exemple #1
0
    def configure(self):
        tmt.EclipseProject.configure(self)
        tmt.WinstoneServer.addPlugin(self)

        self.nonJavaResourceDeps |= tmt.glob(self.src, '.*\\.html$', relativeTo=self.src)
        self.nonJavaResourceDeps |= tmt.glob(self.src, '.*\\.yml$', relativeTo=self.src)
        self.nonJavaSrcDeps |= tmt.glob(self.src, '.*\\.yml$', relativeTo=self.src)
Exemple #2
0
	def configure(self):
		tmt.EclipseProject.configure(self)

		self.nonJavaResourceDeps |= tmt.glob(self.srcResource, '.*$', relativeTo=self.srcResource)
		for f in xmlFileTypes:
			self.nonJavaResourceDeps -= tmt.glob(self.srcResource, "%s$" % f, relativeTo=self.srcResource)

		self.nonJavaSrcDeps |= tmt.glob(self.src, '.*\\.properties$', relativeTo=self.src)
		self.nonJavaSrcDeps |= tmt.glob(self.src, '.*\\.xsd$', relativeTo=self.src)
		self.nonJavaSrcDeps |= tmt.glob(self.src, '.*\\.dtd$', relativeTo=self.src)
Exemple #3
0
    def configure(self):
        tmt.EclipseProject.configure(self)
        tmt.WinstoneServer.addPlugin(self)

        self.nonJavaResourceDeps |= tmt.glob(self.src,
                                             '.*html$',
                                             relativeTo=self.src)
        self.nonJavaResourceDeps |= tmt.glob(self.srcResource,
                                             '.*ttf$',
                                             relativeTo=self.srcResource)
Exemple #4
0
    def configure(self):
        tmt.EclipseProject.configure(self)

        self.nonJavaResourceDeps |= tmt.glob(self.srcResource,
                                             '.*$',
                                             relativeTo=self.srcResource)
        for f in xmlFileTypes:
            self.nonJavaResourceDeps -= tmt.glob(self.srcResource,
                                                 "%s$" % f,
                                                 relativeTo=self.srcResource)

        self.nonJavaSrcDeps |= tmt.glob(self.src,
                                        '.*\\.properties$',
                                        relativeTo=self.src)
        self.nonJavaSrcDeps |= tmt.glob(self.src,
                                        '.*\\.xsd$',
                                        relativeTo=self.src)
        self.nonJavaSrcDeps |= tmt.glob(self.src,
                                        '.*\\.dtd$',
                                        relativeTo=self.src)
Exemple #5
0
    def innerCompile(self, src, tempBin, bin):
        if src != self.src:
            return

        skipGwt = os.environ.get(NO_GWT_ENV_VAR)
        if skipGwt:
            # We don't want to skip gwt-ing when we're releasing
            assert not tmt.releasing
            assert not os.environ.get(INSTALL_GWT_ENV_VAR)
            print("%s set, so not compiling with GWT" % NO_GWT_ENV_VAR)
            return

        # I hope people see this and don't just hate working on tnoodle.
        print("*" * 64)
        print("\n".join(textwrap.wrap("Compiling java -> javascript using GWT. This is important to test, as it can break easily, but it's also very slow, and annoying for scrambler development. Set the %s environment variable to skip this." % NO_GWT_ENV_VAR, width=64)))
        print("*" * 64)
        gwtDir = abspath(join(self.name, 'gwt-2.5.1'))
        if not exists(gwtDir):
            print("Could not find GWT at %s" % gwtDir)
            gwtUrl = "https://developers.google.com/web-toolkit/download"
            print("You could visit %s and install GWT yourself (be sure to set up a symlink from %s to wherever you installed gwt." % ( gwtUrl, gwtDir ))
            if os.environ.get(INSTALL_GWT_ENV_VAR) or yesNoPrompt("Would you like me to download GWT and extract it to %s for you?" % gwtDir):
                gwtZipUrl = "https://storage.googleapis.com/gwt-releases/gwt-2.5.1.zip"
                dledZipFile = dl(gwtZipUrl)
                gwtZip = zipfile.ZipFile(dledZipFile)
                gwtZip.extractall(path=dirname(gwtDir))
                assert isdir(gwtDir)
            else:
                print("Please set up GWT and try again")
                sys.exit(1)


        entities = self.getClasspathEntities(includeCompileTimeOnlyDependencies=True, includeSrc=True)
        entities.add(join(gwtDir, "*"))
        # convert to a list, because order matters
        entities = list(entities)
        entities.insert(0, self.postProcessedDir)
        classpath = self.toClasspath(entities)

        resources = {}
        scramblesNonJavaSrcDeps = self.scramblesProject.nonJavaSrcDeps
        for filename in scramblesNonJavaSrcDeps:
            with open(join(self.scramblesProject.src, filename), 'rb') as f:
                data = f.read()
                data64 = base64.b64encode(data).decode()
                resources[filename] = data64
        javaResources = ""
        for filename, data64 in sorted(resources.items()):
            javaResources += 'resources.put("%s", "%s");\n' % ( filename, data64 )
        puzzles = open(join(self.scramblesProject.src, 'puzzle', 'puzzles')).read()
        puzzles = puzzles.replace("\n", "\\n")

        defines = {
            '%%PUZZLES%%': puzzles,
            '%%VERSION%%': tmt.VERSION,
            '//%%RESOURCES%%': javaResources
        }
        javaFiles = tmt.glob(self.scramblesProject.src, r'.*\.java$')
        for f in javaFiles:
            with open(f) as opened:
                contents = opened.read()
            dirty = False
            for define, value in defines.items():
                if define in contents:
                    dirty = True
                    contents = contents.replace(define, value)
            if dirty:
                f = f.replace("/src/", "/postprocessed/", 1)
                if not isdir(dirname(f)):
                    os.makedirs(dirname(f))
                with open(f, 'w') as opened:
                    opened.write(contents)

        # TODO - add documentation target
        # # This seems to blow up with jdk7
        # javadoc -public -verbose -sourcepath src -classpath "$(CLASSPATH)" -d doc -docletpath $(GWT_EXPORTER_JAR) -doclet org.timepedia.exporter.doclet.JsDoclet $(GWT_PACKAGES_DOCUMENT)

        args = []
        args.append('-strict')
        war = join(self.name, 'war')
        if not isdir(war):
            os.mkdir(war)
        args += [ '-war', war ]

        # "-style PRETTY" makes the gwt code almost readable, but also more
        # than doubles the size of the resulting code.
        args += [ '-style', 'PRETTY' ]

        args.append(GWT_MODULE)

        retVal = tmt.java("com.google.gwt.dev.Compiler", classpath=classpath, args=args, maxMemory='512m')
        assert retVal == 0

        scramblejs = open(join(self.src, 'tnoodle.js')).read()
        tnoodlejs_nocache_js = open(join(war, 'tnoodlejs/tnoodlejs.nocache.js')).read()
        tnoodlejs_nocache_js = """function TNOODLEJS_GWT() {
%s
}
TNOODLEJS_GWT();""" % tnoodlejs_nocache_js
        scramblejs = scramblejs.replace('//%%tnoodlejs.nocache.js%%', tnoodlejs_nocache_js)
        with open(join(war, 'tnoodlejs/tnoodle.js'), 'w') as out:
            out.write(scramblejs)
Exemple #6
0
 def configure(self):
     tmt.EclipseProject.configure(self)
     self.nonJavaResourceDeps |= tmt.glob(self.srcResource,
                                          '.*png$',
                                          relativeTo=self.srcResource)
     self.nonJavaResourceDeps.add('scrambler/scramblers')
Exemple #7
0
 def configure(self):
     tmt.EclipseProject.configure(self)
     self.nonJavaSrcDeps |= tmt.glob(self.src,
                                     '.*png$',
                                     relativeTo=self.src)
     self.nonJavaSrcDeps.add('puzzle/puzzles')
Exemple #8
0
	def configure(self):
		tmt.EclipseProject.configure(self)
		self.nonJavaSrcDeps |= tmt.glob(self.src, '.*png$', relativeTo=self.src)
		self.nonJavaSrcDeps.add('puzzle/puzzles')
Exemple #9
0
    def innerCompile(self, src, tempBin, bin):
        if src != self.src:
            return

        skipGwt = os.environ.get(NO_GWT_ENV_VAR)
        if skipGwt:
            # We don't want to skip gwt-ing when we're releasing
            assert not tmt.releasing
            assert not os.environ.get(INSTALL_GWT_ENV_VAR)
            print("%s set, so not compiling with GWT" % NO_GWT_ENV_VAR)
            return

        # I hope people see this and don't just hate working on tnoodle.
        print("*" * 64)
        print("\n".join(
            textwrap.wrap(
                "Compiling java -> javascript using GWT. This is important to test, as it can break easily, but it's also very slow, and annoying for scrambler development. Set the %s environment variable to skip this."
                % NO_GWT_ENV_VAR,
                width=64)))
        print("*" * 64)
        gwtDir = abspath(join(self.name, 'gwt-2.5.1'))
        if not exists(gwtDir):
            print("Could not find GWT at %s" % gwtDir)
            gwtUrl = "https://developers.google.com/web-toolkit/download"
            print(
                "You could visit %s and install GWT yourself (be sure to set up a symlink from %s to wherever you installed gwt."
                % (gwtUrl, gwtDir))
            if os.environ.get(INSTALL_GWT_ENV_VAR) or yesNoPrompt(
                    "Would you like me to download GWT and extract it to %s for you?"
                    % gwtDir):
                gwtZipUrl = "https://storage.googleapis.com/gwt-releases/gwt-2.5.1.zip"
                dledZipFile = dl(gwtZipUrl)
                gwtZip = zipfile.ZipFile(dledZipFile)
                gwtZip.extractall(path=dirname(gwtDir))
                assert isdir(gwtDir)
            else:
                print("Please set up GWT and try again")
                sys.exit(1)

        entities = self.getClasspathEntities(
            includeCompileTimeOnlyDependencies=True, includeSrc=True)
        entities.add(join(gwtDir, "*"))
        # convert to a list, because order matters
        entities = list(entities)
        entities.insert(0, self.postProcessedDir)
        classpath = self.toClasspath(entities)

        resources = {}
        scramblesNonJavaSrcDeps = self.scramblesProject.nonJavaSrcDeps
        for filename in scramblesNonJavaSrcDeps:
            with open(join(self.scramblesProject.src, filename), 'rb') as f:
                data = f.read()
                data64 = base64.b64encode(data).decode()
                resources[filename] = data64
        javaResources = ""
        for filename, data64 in sorted(resources.items()):
            javaResources += 'resources.put("%s", "%s");\n' % (filename,
                                                               data64)
        puzzles = open(join(self.scramblesProject.src, 'puzzle',
                            'puzzles')).read()
        puzzles = puzzles.replace("\n", "\\n")

        defines = {
            '%%PUZZLES%%': puzzles,
            '%%VERSION%%': tmt.VERSION,
            '//%%RESOURCES%%': javaResources
        }
        javaFiles = tmt.glob(self.scramblesProject.src, r'.*\.java$')
        for f in javaFiles:
            with open(f) as opened:
                contents = opened.read()
            dirty = False
            for define, value in defines.items():
                if define in contents:
                    dirty = True
                    contents = contents.replace(define, value)
            if dirty:
                f = f.replace("/src/", "/postprocessed/", 1)
                if not isdir(dirname(f)):
                    os.makedirs(dirname(f))
                with open(f, 'w') as opened:
                    opened.write(contents)

        # TODO - add documentation target
        # # This seems to blow up with jdk7
        # javadoc -public -verbose -sourcepath src -classpath "$(CLASSPATH)" -d doc -docletpath $(GWT_EXPORTER_JAR) -doclet org.timepedia.exporter.doclet.JsDoclet $(GWT_PACKAGES_DOCUMENT)

        args = []
        args.append('-strict')
        war = join(self.name, 'war')
        if not isdir(war):
            os.mkdir(war)
        args += ['-war', war]

        # "-style PRETTY" makes the gwt code almost readable, but also more
        # than doubles the size of the resulting code.
        args += ['-style', 'PRETTY']

        args.append(GWT_MODULE)

        retVal = tmt.java("com.google.gwt.dev.Compiler",
                          classpath=classpath,
                          args=args,
                          maxMemory='512m')
        assert retVal == 0

        scramblejs = open(join(self.src, 'tnoodle.js')).read()
        tnoodlejs_nocache_js = open(join(
            war, 'tnoodlejs/tnoodlejs.nocache.js')).read()
        tnoodlejs_nocache_js = """function TNOODLEJS_GWT() {
%s
}
TNOODLEJS_GWT();""" % tnoodlejs_nocache_js
        scramblejs = scramblejs.replace('//%%tnoodlejs.nocache.js%%',
                                        tnoodlejs_nocache_js)
        with open(join(war, 'tnoodlejs/tnoodle.js'), 'w') as out:
            out.write(scramblejs)
Exemple #10
0
 def configure(self):
     tmt.EclipseProject.configure(self)
     self.nonJavaSrcDeps |= tmt.glob(self.src, ".*png$", relativeTo=self.src)
     self.nonJavaSrcDeps.add("puzzle/puzzles")
     self.javaFilesToIgnore = tmt.glob(join(self.src, "net/gnehzr/tnoodle/js/"), r".*\.java")
     self.javaFilesToIgnore |= tmt.glob(join(self.src, "net/gnehzr/tnoodle/jre/"), r".*\.java")
Exemple #11
0
	def configure(self):
		tmt.EclipseProject.configure(self)
		self.nonJavaResourceDeps |= tmt.glob(self.srcResource, '.*png$', relativeTo=self.srcResource)
		self.nonJavaResourceDeps.add('scrambler/scramblers')
Exemple #12
0
 def configure(self):
     tmt.EclipseProject.configure(self)
     self.nonJavaSrcDeps |= tmt.glob(self.src, '.*png$', relativeTo=self.src)
     self.nonJavaSrcDeps.add('puzzle/puzzles')
     self.javaFilesToIgnore = tmt.glob(join(self.src, 'net/gnehzr/tnoodle/js/'), r'.*\.java')
     self.javaFilesToIgnore |= tmt.glob(join(self.src, 'net/gnehzr/tnoodle/jre/'), r'.*\.java')