def generate(root_dir): tmp_dir = os.path.join(root_dir, 'maven_package') tmp_source_dir = os.path.join(tmp_dir, 'source') # Make directories common.recreate_dir(tmp_dir) # Unzip version = common.get_changelog_version(root_dir) common.execute(['unzip', '-q', os.path.join(root_dir, 'tinkerforge_java_bindings_{0}_{1}_{2}.zip'.format(*version)), '-d', tmp_dir]) # Override pom.xml common.specialize_template(os.path.join(root_dir, 'pom.xml.bundle-template'), os.path.join(tmp_source_dir, 'pom.xml'), {'{{VERSION}}': '.'.join(version)}) # Make package with common.ChangedDirectory(tmp_source_dir): # FIXME: maven-toolchains-plugin doesn't stop the default JDK from # leaking into the build process. it is still necessary to set # JAVA_HOME to Java 8 in order to stop the default JDK from # being recorded as the Build-Jdk-Spec in the manifest file. env = dict(os.environ) env['JAVA_HOME'] = java_common.detect_java_home() common.execute(['mvn', 'clean', 'verify'], env=env)
def test(self, cookie, path, extra): # create unique copy of the Tinkerforge.jar to avoid Java from randomly # complaining about the JAR being missing if Java is started multiple # times concurrently jar_path = '/tmp/tester/java/Tinkerforge.jar' tries = 100 while os.path.exists(jar_path) and tries > 0: r = int(round(random.random() * 10000000000)) jar_path = '/tmp/tester/java/Tinkerforge_{:010X}.jar'.format(r) tries -= 1 if os.path.exists(jar_path): self.handle_result( cookie, 1, 'cloud not create unique copy of Tinkerforge.jar') return shutil.copy('/tmp/tester/java/Tinkerforge.jar', jar_path) if extra: shutil.copy(path, '/tmp/tester/java') path = os.path.join('/tmp/tester/java', os.path.split(path)[1]) args = [ os.path.join(java_common.detect_java_home(), 'bin/javac'), '-Xlint:all', '-Werror', '-cp', jar_path + ':.', path ] self.execute(cookie, args)
def generate(root_dir, language): version = common.get_changelog_version(root_dir) debian_dir = os.path.join(root_dir, 'debian') tmp_dir = os.path.join(root_dir, 'debian_package') tmp_octave_dir = os.path.join(tmp_dir, 'octave') tmp_octave_debian_dir = os.path.join(tmp_octave_dir, 'debian') tmp_build_dir = os.path.join( tmp_dir, 'tinkerforge-octave-bindings-{0}.{1}.{2}'.format(*version)) # Make directories common.recreate_dir(tmp_dir) # Unzip common.execute([ 'unzip', '-q', os.path.join( root_dir, 'tinkerforge_matlab_bindings_{0}_{1}_{2}.zip'.format(*version)), os.path.join('octave', '*'), '-x', os.path.join('octave', 'examples', '*'), '-d', tmp_dir ]) shutil.copytree(debian_dir, tmp_octave_debian_dir) common.specialize_template( os.path.join(tmp_octave_debian_dir, 'changelog.template'), os.path.join(tmp_octave_debian_dir, 'changelog'), { '<<VERSION>>': '.'.join(version), '<<DATE>>': subprocess.check_output(['date', '-R']).decode('utf-8') }, remove_template=True) os.replace(os.path.join(tmp_octave_dir, 'Tinkerforge.jar'), os.path.join(tmp_octave_dir, 'tinkerforge.jar')) # Make package os.rename(tmp_octave_dir, tmp_build_dir) with common.ChangedDirectory(tmp_build_dir): # FIXME: maven-toolchains-plugin doesn't stop the default JDK from # leaking into the build process. it is still necessary to set # JAVA_HOME to Java 8 in order to stop the default JDK from # being recorded as the Build-Jdk-Spec in the manifest file. env = dict(os.environ) env['JAVA_HOME'] = java_common.detect_java_home() common.execute(['dpkg-buildpackage', '--no-sign'], env=env) # Check package with common.ChangedDirectory(tmp_dir): common.execute(['lintian', '--pedantic'] + glob.glob('*.deb'))
def after_unzip(self): print('>>> generating javadoc') args = [ os.path.join(java_common.detect_java_home(), 'bin/javadoc'), '-quiet', '-d', '/tmp/tester/java/javadoc', '-classpath', '/tmp/tester/java/source/src/main/java', 'com.tinkerforge' ] rc = subprocess.call(args) if rc != 0: print('>>> could not generate javadoc') else: print('>>> generating javadoc done\n') return rc == 0
def finish(self): root_dir = self.get_root_dir() if self.get_config_name().space == 'Tinkerforge': shutil.copy(os.path.join(root_dir, 'changelog.txt'), self.tmp_dir) shutil.copy(os.path.join(root_dir, 'readme.txt'), self.tmp_dir) shutil.copy(os.path.join(root_dir, '..', 'configs', 'license.txt'), self.tmp_dir) else: shutil.copy(os.path.join(self.get_config_dir(), 'changelog.txt'), self.tmp_dir) for flavor in ['matlab', 'octave']: tmp_dir = self.tmp_flavor_dir[flavor] tmp_source_dir = self.tmp_flavor_source_dir[flavor] tmp_source_src_main_java_com_tinkerforge_dir = self.tmp_flavor_source_src_main_java_com_tinkerforge_dir[ flavor] tmp_source_src_main_resources_metainf_services_dir = self.tmp_flavor_source_src_main_resources_metainf_services_dir[ flavor] tmp_source_src_main_resources_com_tinkerforge_dir = self.tmp_flavor_source_src_main_resources_com_tinkerforge_dir[ flavor] tmp_source_target_dir = self.tmp_flavor_source_target_dir[flavor] tmp_examples_dir = self.tmp_flavor_examples_dir[flavor] # Copy IP Connection examples if self.get_config_name().space == 'Tinkerforge': for example in common.find_examples( root_dir, '^' + flavor + r'_example_.*\.m$'): shutil.copy(example[1], tmp_examples_dir) # Copy bindings and readme for filename in self.get_released_files(): shutil.copy( os.path.join(root_dir, self.get_bindings_dir(), flavor, filename), tmp_source_src_main_java_com_tinkerforge_dir) shutil.copy( os.path.join(self.get_bindings_dir(), flavor, 'com.tinkerforge.DeviceProvider'), tmp_source_src_main_resources_metainf_services_dir) shutil.copy( os.path.join(root_dir, '..', 'java', 'BrickDaemon.java'), tmp_source_src_main_java_com_tinkerforge_dir) shutil.copy( os.path.join(root_dir, '..', 'java', 'DeviceBase.java'), tmp_source_src_main_java_com_tinkerforge_dir) shutil.copy( os.path.join(root_dir, 'Device_{0}.java'.format(flavor)), os.path.join(tmp_source_src_main_java_com_tinkerforge_dir, 'Device.java')) shutil.copy( os.path.join(root_dir, '..', 'java', 'DeviceListener.java'), tmp_source_src_main_java_com_tinkerforge_dir) shutil.copy( os.path.join(root_dir, '..', 'java', 'DeviceProvider.java'), tmp_source_src_main_java_com_tinkerforge_dir) shutil.copy( os.path.join(root_dir, '..', 'java', 'DeviceFactory.java'), tmp_source_src_main_java_com_tinkerforge_dir) shutil.copy( os.path.join(root_dir, 'IPConnection_{0}.java'.format(flavor)), os.path.join(tmp_source_src_main_java_com_tinkerforge_dir, 'IPConnection.java')) shutil.copy( os.path.join(root_dir, '..', 'java', 'IPConnectionBase.java'), tmp_source_src_main_java_com_tinkerforge_dir) shutil.copy( os.path.join(root_dir, '..', 'java', 'TinkerforgeException.java'), tmp_source_src_main_java_com_tinkerforge_dir) shutil.copy( os.path.join(root_dir, '..', 'java', 'TimeoutException.java'), tmp_source_src_main_java_com_tinkerforge_dir) shutil.copy( os.path.join(root_dir, '..', 'java', 'AlreadyConnectedException.java'), tmp_source_src_main_java_com_tinkerforge_dir) shutil.copy( os.path.join(root_dir, '..', 'java', 'NotConnectedException.java'), tmp_source_src_main_java_com_tinkerforge_dir) shutil.copy( os.path.join(root_dir, '..', 'java', 'CryptoException.java'), tmp_source_src_main_java_com_tinkerforge_dir) shutil.copy( os.path.join(root_dir, '..', 'java', 'NetworkException.java'), tmp_source_src_main_java_com_tinkerforge_dir) shutil.copy( os.path.join(root_dir, '..', 'java', 'StreamOutOfSyncException.java'), tmp_source_src_main_java_com_tinkerforge_dir) shutil.copy( os.path.join(root_dir, '..', 'java', 'InvalidParameterException.java'), tmp_source_src_main_java_com_tinkerforge_dir) shutil.copy( os.path.join(root_dir, '..', 'java', 'NotSupportedException.java'), tmp_source_src_main_java_com_tinkerforge_dir) shutil.copy( os.path.join(root_dir, '..', 'java', 'UnknownErrorCodeException.java'), tmp_source_src_main_java_com_tinkerforge_dir) shutil.copy( os.path.join(root_dir, '..', 'java', 'WrongDeviceTypeException.java'), tmp_source_src_main_java_com_tinkerforge_dir) shutil.copy( os.path.join(root_dir, '..', 'java', 'DeviceReplacedException.java'), tmp_source_src_main_java_com_tinkerforge_dir) shutil.copy( os.path.join(root_dir, '..', 'java', 'WrongResponseLengthException.java'), tmp_source_src_main_java_com_tinkerforge_dir) shutil.copy( os.path.join(root_dir, '..', 'java', 'TinkerforgeListener.java'), tmp_source_src_main_java_com_tinkerforge_dir) if flavor == 'octave': shutil.copy(os.path.join(root_dir, 'liboctaveinvokewrapper.c'), tmp_source_src_main_resources_com_tinkerforge_dir) shutil.copy( os.path.join(root_dir, 'liboctaveinvokewrapper-linux-i386.so'), tmp_source_src_main_resources_com_tinkerforge_dir) shutil.copy( os.path.join(root_dir, 'liboctaveinvokewrapper-linux-amd64.so'), tmp_source_src_main_resources_com_tinkerforge_dir) shutil.copy( os.path.join(root_dir, 'liboctaveinvokewrapper-linux-arm.so'), tmp_source_src_main_resources_com_tinkerforge_dir) shutil.copy( os.path.join(root_dir, 'liboctaveinvokewrapper-windows-x86.dll'), tmp_source_src_main_resources_com_tinkerforge_dir) shutil.copy( os.path.join(root_dir, 'liboctaveinvokewrapper-windows-amd64.dll'), tmp_source_src_main_resources_com_tinkerforge_dir) shutil.copy( os.path.join(root_dir, 'liboctaveinvokewrapper-macos-x86_64.dynlib'), tmp_source_src_main_resources_com_tinkerforge_dir) # Make pom.xml version = self.get_changelog_version() if self.get_config_name().space == 'Tinkerforge': common.specialize_template( os.path.join(root_dir, 'pom.xml.{0}-jar-template'.format(flavor)), os.path.join(tmp_source_dir, 'pom.xml'), {'{{VERSION}}': '.'.join(version)}) else: common.specialize_template( os.path.join(root_dir, 'pom.xml.{0}-custom-template'.format(flavor)), os.path.join(tmp_source_dir, 'pom.xml'), { '{{CONFIG_NAME}}': self.get_config_name().dash, '{{VERSION}}': '.'.join(version), '{{TINKERFORGE_VERSION}}': '.'.join(common.get_changelog_version(root_dir)) }) # Compile source with common.ChangedDirectory(tmp_source_dir): # FIXME: maven-toolchains-plugin doesn't stop the default JDK from # leaking into the build process. it is still necessary to set # JAVA_HOME to Java 8 in order to stop the default JDK from # being recorded as the Build-Jdk-Spec in the manifest file. env = dict(os.environ) env['JAVA_HOME'] = java_common.detect_java_home() common.execute(['mvn', 'clean', 'install'], env=env) os.rename( os.path.join( tmp_source_target_dir, '{0}-{1}-{2}.{3}.{4}.jar'.format( self.get_config_name().dash, flavor, *version)), os.path.join(tmp_dir, '{0}.jar'.format(self.get_config_name().camel))) shutil.rmtree(tmp_source_target_dir) # Make zip self.create_zip_file(self.tmp_dir)