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 finish(self): root_dir = self.get_root_dir() # Copy IP Connection examples if self.get_config_name().space == 'Tinkerforge': for example in common.find_examples(root_dir, r'^example_.*\.py$'): shutil.copy(example[1], self.tmp_examples_dir) # Copy bindings and readme for filename in self.get_released_files() + ['device_factory.py']: shutil.copy(os.path.join(self.get_bindings_dir(), filename), self.tmp_source_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'ip_connection.py'), self.tmp_source_tinkerforge_dir) 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) # Make __init__.py with open(os.path.join(self.tmp_source_tinkerforge_dir, '__init__.py'), 'w') as f: f.write(' ') # Make setup.py version = self.get_changelog_version() common.specialize_template( os.path.join(root_dir, 'setup.py.template'), os.path.join(self.tmp_source_dir, 'setup.py'), {'<<VERSION>>': '.'.join(version)}) # Make zip self.create_zip_file(self.tmp_dir)
def finish(self): root_dir = self.get_root_dir() # Copy IP Connection examples if self.get_config_name().space == 'Tinkerforge': for example in common.find_examples(root_dir, r'^example_.*\.pl$'): shutil.copy(example[1], self.tmp_examples_dir) # Copy bindings and readme for filename in self.get_released_files(): shutil.copy(os.path.join(self.get_bindings_dir(), filename), self.tmp_source_lib_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'IPConnection.pm'), self.tmp_source_lib_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'Device.pm'), self.tmp_source_lib_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'Error.pm'), self.tmp_source_lib_tinkerforge_dir) 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) # Make Tinkerforge.pm version = self.get_changelog_version() common.specialize_template(os.path.join(root_dir, 'Tinkerforge.pm.template'), os.path.join(self.tmp_source_lib_dir, 'Tinkerforge.pm'), {'<<VERSION>>': '.'.join(version)}) # Copy Makefile.PL shutil.copy(os.path.join(root_dir, 'Makefile.PL'), self.tmp_source_dir) # Make zip self.create_zip_file(self.tmp_dir)
def finish(self): JavaBindingsGenerator.finish(self) consts = [d.get_openhab_binding_constant() for d in self.released_devices] thing_types = [x[0] for x in consts] thing_type_decls = [x[1] for x in consts] channel_types = [x[2] for x in consts] channel_type_decls = common.flatten([x[3] for x in consts]) config_descs = [x[4] for x in consts] config_desc_decls = common.flatten([x[5] for x in consts]) common.specialize_template(os.path.join(self.get_root_dir(), 'TinkerforgeBindingConstants.java.template'), os.path.join(self.get_bindings_dir(), 'TinkerforgeBindingConstants.java'), { '{header}': self.get_header_comment('asterisk'), '{thing_type_decls}': '\n\t'.join(thing_type_decls), '{thing_types}': ',\n\t\t'.join(thing_types), '{channel_type_decls}': '\n\t'.join(channel_type_decls), '{channel_type_assigns}': '\n\t\t'.join('SUPPORTED_CHANNELS.put({}, {});'.format(ctype, ttype) for ctypes, ttype in zip(channel_types, thing_types) for ctype in ctypes), '{config_description_decls}': '\n\t'.join(config_desc_decls), '{config_description_assigns}': '\n\t\t'.join('SUPPORTED_CONFIG_DESCRIPTIONS.put({}, {});'.format(ctype, ttype) for ctypes, ttype in zip(config_descs, thing_types) for ctype in ctypes) }) common.specialize_template(os.path.join(self.get_root_dir(), 'DeviceWrapperFactory.java.template'), os.path.join(self.get_bindings_dir(), 'DeviceWrapperFactory.java'), { '{header}': self.get_header_comment('asterisk'), '{devices}': ',\n\t\t\t'.join(d.get_java_class_name() + 'Wrapper.DEVICE_INFO' for d in self.released_devices) })
def write_cargo_toml(self): common.specialize_template( os.path.join(self.get_root_dir(), "Cargo.toml.template"), os.path.join(self.get_bindings_dir(), "Cargo.toml"), { "{version}": '"' + ".".join(list(self.get_changelog_version())) + '"' })
def finish(self): infos = [] for filename in self.released_files: with open(os.path.join(self.get_bindings_dir(), filename), 'r') as f: infos.append(f.read()) with open( os.path.join(self.get_root_dir(), '..', 'python', 'ip_connection.py'), 'r') as f: content = f.read() unpack_payload_impl = content.split('# UNPACK_PAYLOAD_CUT_HERE\n')[1] common.specialize_template( os.path.join(self.get_root_dir(), 'HighLevelAnalyzer.py.template'), os.path.join(self.get_bindings_dir(), 'HighLevelAnalyzer.py'), { '{{infos}}': ',\n'.join(infos), '{{unpack_payload}}': unpack_payload_impl, '{{header}}': self.get_header_comment('hash') }) common.specialize_template( os.path.join(self.get_root_dir(), 'extension.json.template'), os.path.join(self.get_bindings_dir(), 'extension.json'), {'{{version}}': '{}.{}.{}'.format(*self.get_changelog_version())})
def finish(self): root_dir = self.get_root_dir() # Copy IP Connection examples if self.get_config_name().space == 'Tinkerforge': for example in common.find_examples(root_dir, r'^example_.*\.rb$'): shutil.copy(example[1], self.tmp_examples_dir) # Copy bindings and readme for filename in self.get_released_files(): shutil.copy(os.path.join(self.get_bindings_dir(), filename), self.tmp_source_lib_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'ip_connection.rb'), self.tmp_source_lib_tinkerforge_dir) 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) # Make version.rb version = self.get_changelog_version() with open(os.path.join(self.tmp_source_lib_tinkerforge_dir, 'version.rb'), 'w') as f: f.write(""" module Tinkerforge VERSION = '{0}.{1}.{2}' end """.format(*version)) # Make tinkerforge.rb with open(os.path.join(self.tmp_source_lib_dir, 'tinkerforge.rb'), 'w') as f: f.write(""" require 'tinkerforge/version' module Tinkerforge end """) # Make tinkerforge.gemspec tmp_gemspec = os.path.join(self.tmp_source_dir, 'tinkerforge.gemspec') common.specialize_template(os.path.join(root_dir, 'tinkerforge.gemspec.template'), tmp_gemspec, {'<<VERSION>>': '.'.join(version)}) # Make gem with common.ChangedDirectory(self.tmp_source_dir): common.execute(['gem', 'build', 'tinkerforge.gemspec']) # Remove build stuff tmp_gem = os.path.join(self.tmp_source_dir, 'tinkerforge-{0}.{1}.{2}.gem'.format(*version)) os.remove(tmp_gemspec) shutil.copy(tmp_gem, root_dir) shutil.move(tmp_gem, os.path.join(self.tmp_dir, 'tinkerforge.gem')) shutil.move(os.path.join(self.tmp_source_lib_dir, 'tinkerforge.rb'), self.tmp_source_dir) shutil.move(self.tmp_source_lib_tinkerforge_dir, os.path.join(self.tmp_source_dir, 'tinkerforge')) shutil.rmtree(self.tmp_source_lib_dir) # Make zip self.create_zip_file(self.tmp_dir)
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_source_dir = os.path.join(tmp_dir, 'source') tmp_source_bashcompletion_dir = os.path.join(tmp_source_dir, 'bash-completion') tmp_source_debian_dir = os.path.join(tmp_source_dir, 'debian') tmp_build_dir = os.path.join( tmp_dir, 'tinkerforge-shell-bindings-{0}.{1}.{2}'.format(*version)) # Make directories common.recreate_dir(tmp_dir) # Unzip common.execute([ 'unzip', '-q', os.path.join( root_dir, 'tinkerforge_shell_bindings_{0}_{1}_{2}.zip'.format(*version)), '-d', tmp_dir ]) os.makedirs(tmp_source_dir) os.makedirs(tmp_source_bashcompletion_dir) with open(os.path.join(tmp_dir, 'tinkerforge'), 'r') as f: script = f.read() assert script.startswith('#!/usr/bin/env python\n') script = '#!/usr/bin/python3 -u\n' + script.split('\n', 1)[1] with open(os.path.join(tmp_source_dir, 'tinkerforge'), 'w') as f: f.write(script) shutil.copy(os.path.join(tmp_dir, 'tinkerforge-bash-completion.sh'), os.path.join(tmp_source_bashcompletion_dir, 'tinkerforge')) shutil.copytree(debian_dir, tmp_source_debian_dir) common.specialize_template( os.path.join(tmp_source_debian_dir, 'changelog.template'), os.path.join(tmp_source_debian_dir, 'changelog'), { '<<VERSION>>': '.'.join(version), '<<DATE>>': subprocess.check_output(['date', '-R']).decode('utf-8') }, remove_template=True) # Make package os.rename(tmp_source_dir, tmp_build_dir) with common.ChangedDirectory(tmp_build_dir): common.execute(['dpkg-buildpackage', '--no-sign']) # Check package with common.ChangedDirectory(tmp_dir): common.execute(['lintian', '--pedantic'] + glob.glob('*.deb'))
def finish(self): root_dir = self.get_root_dir() # Copy IP Connection examples if self.get_config_name().space == 'Tinkerforge': for example in common.find_examples(root_dir, r'^Example.*\.php$'): shutil.copy(example[1], self.tmp_examples_dir) # Copy bindings and readme package_files = [ '<file name="Tinkerforge/IPConnection.php" role="php" />' ] for filename in self.get_released_files(): shutil.copy(os.path.join(self.get_bindings_dir(), filename), self.tmp_source_tinkerforge_dir) package_files.append( '<file name="Tinkerforge/{0}" role="php" />'.format( os.path.basename(filename))) shutil.copy(os.path.join(root_dir, 'IPConnection.php'), self.tmp_source_tinkerforge_dir) 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) # Make package.xml version = self.get_changelog_version() date = datetime.datetime.now().strftime("%Y-%m-%d") common.specialize_template( os.path.join(root_dir, 'package.xml.template'), os.path.join(self.tmp_source_dir, 'package.xml'), { '{{VERSION}}': '.'.join(version), '{{DATE}}': date, '{{FILES}}': '\n '.join(package_files) }) # Make PEAR package with common.ChangedDirectory(self.tmp_source_dir): common.execute(['pear', 'package', 'package.xml']) # Remove build stuff shutil.move( os.path.join(self.tmp_source_dir, 'Tinkerforge-{0}.{1}.{2}.tgz'.format(*version)), os.path.join(self.tmp_dir, 'Tinkerforge.tgz')) os.remove(os.path.join(self.tmp_source_dir, 'package.xml')) # Make zip self.create_zip_file(self.tmp_dir)
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 finish(self): root_dir = self.get_root_dir() # Copy IP Connection examples if self.get_config_name().space == 'Tinkerforge': for example in common.find_examples(root_dir, '^Example .*\.vi$'): shutil.copy(example[1], self.tmp_examples_dir) parts = os.path.split(example[1]) shutil.copy(os.path.join(parts[0], '10.0', parts[1]), self.tmp_examples_10_dir) # Copy bindings and readme for filename in self.get_released_files(): shutil.copy(os.path.join(self.get_bindings_dir(), filename), self.tmp_source_tinkerforge_dir) shutil.copy(os.path.join(root_dir, '..', 'csharp', 'IPConnection.cs'), self.tmp_source_tinkerforge_dir) 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) # Make AssemblyInfo.cs version = self.get_changelog_version() common.specialize_template( os.path.join(root_dir, '..', 'csharp', 'AssemblyInfo.cs.template'), os.path.join(self.tmp_source_tinkerforge_dir, 'AssemblyInfo.cs'), { '<<BINDINGS>>': 'LabVIEW', '<<VERSION>>': '.'.join(version) }) # Make dll for sdk in [2, 4]: os.makedirs(os.path.join(self.tmp_dir, 'net{0}0'.format(sdk))) with common.ChangedDirectory(self.tmp_dir): common.execute([ 'mcs', '/optimize+', '/warn:4', '/warnaserror', '/sdk:{0}'.format(sdk), '/target:library', '/out:' + os.path.join(self.tmp_dir, 'net{0}0'.format(sdk), 'Tinkerforge.dll'), os.path.join(self.tmp_source_tinkerforge_dir, '*.cs') ]) # Make zip self.create_zip_file(self.tmp_dir)
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_tinkerforge_dir = os.path.join(tmp_dir, 'tinkerforge') tmp_tinkerforge_debian_dir = os.path.join(tmp_tinkerforge_dir, 'debian') tmp_build_dir = os.path.join( tmp_dir, 'tinkerforge-ruby-bindings-{0}.{1}.{2}'.format(*version)) # Make directories common.recreate_dir(tmp_dir) # Unzip common.execute([ 'unzip', '-q', os.path.join( root_dir, 'tinkerforge_ruby_bindings_{0}_{1}_{2}.zip'.format(*version)), '-d', tmp_dir ]) common.execute(['gem2tgz', os.path.join(tmp_dir, 'tinkerforge.gem')]) common.execute([ 'tar', '-xf', os.path.join(tmp_dir, 'tinkerforge.tar.gz'.format(*version)), '-C', tmp_dir ]) shutil.copytree(debian_dir, tmp_tinkerforge_debian_dir) common.specialize_template( os.path.join(tmp_tinkerforge_debian_dir, 'changelog.template'), os.path.join(tmp_tinkerforge_debian_dir, 'changelog'), { '<<VERSION>>': '.'.join(version), '<<DATE>>': subprocess.check_output(['date', '-R']).decode('utf-8') }, remove_template=True) # Make package os.rename(tmp_tinkerforge_dir, tmp_build_dir) with common.ChangedDirectory(tmp_build_dir): common.execute(['dpkg-buildpackage', '--no-sign']) # Check package with common.ChangedDirectory(tmp_dir): common.execute(['lintian', '--pedantic'] + glob.glob('*.deb'))
def finish(self): root_dir = self.get_root_dir() # Copy IP Connection examples if self.get_config_name().space == 'Tinkerforge': for example in common.find_examples(root_dir, '^Example.*\.vb$'): shutil.copy(example[1], self.tmp_examples_dir) # Copy bindings and readme for filename in self.get_released_files(): shutil.copy(os.path.join(self.get_bindings_dir(), filename), self.tmp_source_tinkerforge_dir) shutil.copy(os.path.join(root_dir, '..', 'csharp', 'IPConnection.cs'), self.tmp_source_tinkerforge_dir) 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) # Make AssemblyInfo.cs version = self.get_changelog_version() common.specialize_template( os.path.join(root_dir, '..', 'csharp', 'AssemblyInfo.cs.template'), os.path.join(self.tmp_source_tinkerforge_dir, 'AssemblyInfo.cs'), { '<<BINDINGS>>': 'Visual Basic .NET', '<<VERSION>>': '.'.join(version) }) # Make dll with common.ChangedDirectory(self.tmp_dir): common.execute([ 'mcs', '/optimize+', '/warn:4', '/warnaserror', '/sdk:2', '/target:library', '/out:' + os.path.join(self.tmp_dir, 'Tinkerforge.dll'), '/doc:' + os.path.join(self.tmp_dir, 'Tinkerforge.xml'), os.path.join(self.tmp_source_tinkerforge_dir, '*.cs') ]) # Make zip self.create_zip_file(self.tmp_dir)
def finish(self): root_dir = self.get_root_dir() # Copy IP Connection examples if self.get_config_name().space == 'Tinkerforge': for example in common.find_examples(root_dir, r'^Example.*\.cs$'): shutil.copy(example[1], self.tmp_examples_dir) # Copy bindings and readme for filename in self.get_released_files(): shutil.copy(os.path.join(self.get_bindings_dir(), filename), self.tmp_source_tinkerforge_dir) shutil.copy(os.path.join(self.get_bindings_dir(), filename), self.tmp_source_tinkerforge_uwp_dir) shutil.copy(os.path.join(root_dir, 'IPConnection.cs'), self.tmp_source_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'IPConnection.cs'), self.tmp_source_tinkerforge_uwp_dir) shutil.copy(os.path.join(root_dir, 'project.json'), self.tmp_source_tinkerforge_uwp_dir) shutil.copy(os.path.join(root_dir, 'project.lock.json'), self.tmp_source_tinkerforge_uwp_dir) shutil.copy(os.path.join(root_dir, 'TinkerforgeUWP.rd.xml'), self.tmp_source_tinkerforge_uwp_dir) 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) # Make AssemblyInfo.cs version = self.get_changelog_version() for target_dir in [self.tmp_source_tinkerforge_dir, self.tmp_source_tinkerforge_uwp_dir]: common.specialize_template(os.path.join(root_dir, 'AssemblyInfo.cs.template'), os.path.join(target_dir, 'AssemblyInfo.cs'), {'<<BINDINGS>>': 'C#', '<<VERSION>>': '.'.join(version)}) # Make Tinkerforge(UWP).csproj project_items = [] for filename in ['AssemblyInfo.cs', 'IPConnection.cs'] + self.get_released_files(): project_items.append('<Compile Include="{0}" />'.format(filename)) common.specialize_template(os.path.join(root_dir, 'Tinkerforge.csproj.template'), os.path.join(self.tmp_source_tinkerforge_dir, 'Tinkerforge.csproj'), {'{{ITEMS}}': '\n '.join(project_items)}) common.specialize_template(os.path.join(root_dir, 'TinkerforgeUWP.csproj.template'), os.path.join(self.tmp_source_tinkerforge_uwp_dir, 'TinkerforgeUWP.csproj'), {'{{ITEMS}}': '\n '.join(project_items)}) # Make dll with common.ChangedDirectory(self.tmp_dir): common.execute(['mcs', '/debug:full', '/optimize+', '/warn:4', '/warnaserror', '/sdk:2', '/target:library', '/doc:' + os.path.join(self.tmp_dir, 'Tinkerforge.xml'), '/out:' + os.path.join(self.tmp_dir, 'Tinkerforge.dll'), os.path.join(self.tmp_source_tinkerforge_dir, '*.cs')]) # Make zip self.create_zip_file(self.tmp_dir)
def finish(self): root_dir = self.get_root_dir() bindings_dir = self.get_bindings_dir() # Copy IP Connection examples if self.get_config_name().space == 'Tinkerforge': for example in common.find_examples(root_dir, r'^example-.*\.txt$'): shutil.copy(example[1], self.tmp_examples_dir) # Copy bindings and readme shutil.copy( os.path.join(bindings_dir, '{}_mqtt'.format(self.get_config_name().under)), self.tmp_dir) common.specialize_template( os.path.join(root_dir, 'tinkerforge_mqtt.zip-service.template'), os.path.join( self.tmp_dir, '{}_mqtt.service'.format(self.get_config_name().under)), { "<<CONFIG_NAME_SPACE>>": self.get_config_name().space, "<<CONFIG_NAME_UNDER>>": self.get_config_name().under }) 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) shutil.copy(os.path.join(root_dir, 'custom.txt'), os.path.join(self.tmp_dir, 'readme.txt')) # Make zip self.create_zip_file(self.tmp_dir)
def finish(self): root_dir = self.get_root_dir() # Copy IP Connection examples if self.get_config_name().space == 'Tinkerforge': for example in common.find_examples(root_dir, r'^Example.*\.pas$'): shutil.copy(example[1], self.tmp_examples_dir) # Copy bindings and readme for filename in self.get_released_files(): shutil.copy(os.path.join(self.get_bindings_dir(), filename), self.tmp_source_dir) shutil.copy(os.path.join(root_dir, 'Base58.pas'), self.tmp_source_dir) shutil.copy(os.path.join(root_dir, 'BlockingQueue.pas'), self.tmp_source_dir) shutil.copy(os.path.join(root_dir, 'DeviceBase.pas'), self.tmp_source_dir) shutil.copy(os.path.join(root_dir, 'Device.pas'), self.tmp_source_dir) shutil.copy(os.path.join(root_dir, 'IPConnection.pas'), self.tmp_source_dir) shutil.copy(os.path.join(root_dir, 'LEConverter.pas'), self.tmp_source_dir) shutil.copy(os.path.join(root_dir, 'TimedSemaphore.pas'), self.tmp_source_dir) shutil.copy(os.path.join(root_dir, 'SHAone.pas'), self.tmp_source_dir) shutil.copy(os.path.join(root_dir, 'BrickDaemon.pas'), self.tmp_source_dir) 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) # Make Makefile.fpc version = self.get_changelog_version() units = sorted([filename.replace('.pas', '') for filename in os.listdir(self.tmp_source_dir)]) common.specialize_template(os.path.join(root_dir, 'Makefile.fpc.template'), os.path.join(self.tmp_source_dir, 'Makefile.fpc'), {'<<UNITS>>': ' '.join(units), '<<VERSION>>': '.'.join(version)}) # Make zip self.create_zip_file(self.tmp_dir)
def finish(self): if self.get_config_name().space != 'Tinkerforge': return root_dir = self.get_root_dir() for src, dst in self.file_dests.items(): shutil.copy(src, dst) binding_dir = os.path.join(self.get_bindings_dir(), '..', 'openhab2-addons', 'bundles', 'org.openhab.binding.tinkerforge') if os.path.isdir(binding_dir): print( "Binding directory exists from last run, skipping clone of openhab2-addons repo." ) with common.ChangedDirectory( os.path.join(self.get_bindings_dir(), '..', 'openhab2-addons')): common.execute(['git', 'stash']) with common.ChangedDirectory( os.path.join(self.get_bindings_dir(), '..', 'openhab2-addons')): common.execute(['git', 'pull']) with common.ChangedDirectory( os.path.join(self.get_bindings_dir(), '..', 'openhab2-addons')): common.execute(['git', 'stash', 'pop']) else: with common.ChangedDirectory( os.path.join(self.get_bindings_dir(), '..')): common.execute([ 'git', 'clone', '-b', '2.5.x', 'https://github.com/openhab/openhab2-addons', '--depth=1' ]) to_patch = os.path.join(self.get_bindings_dir(), '..', 'openhab2-addons', 'bom', 'openhab-addons', 'pom.xml') common.specialize_template( to_patch, to_patch, { '</dependencies>': """ <dependency> <groupId>org.openhab.addons.bundles</groupId> <artifactId>org.openhab.binding.tinkerforge</artifactId> <version>${project.version}</version> </dependency> </dependencies>""" }) to_patch = os.path.join(self.get_bindings_dir(), '..', 'openhab2-addons', 'bundles', 'pom.xml') common.specialize_template( to_patch, to_patch, { '</modules>': """ <module>org.openhab.binding.tinkerforge</module> </modules>""" }) common.recreate_dir(binding_dir) for f in [ k for (k, v) in self.relative_file_dests.items() if v == '.' ]: shutil.copy(os.path.join(self.generation_dir, f), os.path.join(binding_dir, f)) shutil.copytree(os.path.join(self.generation_dir, 'src'), os.path.join(binding_dir, 'src')) with common.ChangedDirectory(binding_dir): common.execute([ 'mvn', 'spotless:apply', '-Dorg.slf4j.simpleLogger.defaultLogLevel=WARN' ]) common.execute([ 'mvn', 'clean', 'install', '-Dorg.slf4j.simpleLogger.defaultLogLevel=WARN' ]) # Beta stuff zip_dir = os.path.join(self.tmp_dir, 'zip') os.makedirs(zip_dir) for f in ['changelog.txt', 'readme_de.txt', 'readme_en.txt']: shutil.copy(os.path.join(self.get_bindings_dir(), '..', 'beta', f), zip_dir) shutil.copytree( os.path.join(binding_dir, 'src'), os.path.join(zip_dir, 'org.openhab.binding.tinkerforge', 'src')) shutil.copy( os.path.join(binding_dir, 'target', 'org.openhab.binding.tinkerforge-2.5.9-SNAPSHOT.jar'), zip_dir) java_bindings = os.path.join(self.get_root_dir(), 'tinkerforge-2.1.26.jar') if not os.path.exists(java_bindings): try: from urllib.request import urlretrieve downloaded_file, _ = urlretrieve( 'https://search.maven.org/remotecontent?filepath=com/tinkerforge/tinkerforge/2.1.26/tinkerforge-2.1.26.jar' ) shutil.copy(downloaded_file, java_bindings) except Exception as e: raise common.GeneratorError( "Failed to download java bindings.") from e shutil.copy(java_bindings, zip_dir) self.create_zip_file(zip_dir)
def finish(self): root_dir = self.get_root_dir() # Copy IP Connection examples if self.get_config_name().space == 'Tinkerforge': for example in common.find_examples(root_dir, r'^Example.*\.js'): shutil.copy(example[1], self.tmp_nodejs_examples_dir) for example in common.find_examples(root_dir, r'^Example.*\.html'): shutil.copy(example[1], self.tmp_browser_examples_dir) # Copy bindings and readme for filename in self.get_released_files(): if filename == 'TinkerforgeNPM.js': shutil.copy( os.path.join(self.get_bindings_dir(), filename), os.path.join(self.tmp_nodejs_package_dir, 'Tinkerforge.js')) elif filename == 'BrowserAPI.js': shutil.copy(os.path.join(self.get_bindings_dir(), filename), self.tmp_nodejs_source_tinkerforge_dir) elif filename == 'TinkerforgeSource.js': shutil.copy( os.path.join(self.get_bindings_dir(), filename), os.path.join(self.tmp_nodejs_source_dir, 'Tinkerforge.js')) else: shutil.copy(os.path.join(self.get_bindings_dir(), filename), self.tmp_nodejs_source_tinkerforge_dir) shutil.copy(os.path.join(self.get_bindings_dir(), filename), self.tmp_nodejs_package_lib_dir) # Make package.json version = self.get_changelog_version() common.specialize_template( os.path.join(root_dir, 'package.json.template'), os.path.join(self.tmp_nodejs_package_dir, 'package.json'), {'<<VERSION>>': '.'.join(version)}) shutil.copy(os.path.join(root_dir, 'IPConnection.js'), self.tmp_nodejs_package_lib_dir) shutil.copy(os.path.join(root_dir, 'Device.js'), self.tmp_nodejs_package_lib_dir) shutil.copy(os.path.join(root_dir, 'LICENSE'), self.tmp_nodejs_package_dir) shutil.copy(os.path.join(root_dir, 'README.md'), self.tmp_nodejs_package_dir) shutil.copy(os.path.join(root_dir, 'IPConnection.js'), self.tmp_nodejs_source_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'Device.js'), self.tmp_nodejs_source_tinkerforge_dir) 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) # Copy browser specific files shutil.copy(os.path.join(root_dir, 'es5-shim.js'), self.tmp_nodejs_source_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'es5-sham.js'), self.tmp_nodejs_source_tinkerforge_dir) # Ensure local browserify is installed browserify_dir = os.path.join(root_dir, 'browserify') browserify_version_path = os.path.join(browserify_dir, 'version') try: with open(browserify_version_path, 'r') as f: browserify_version = int(f.read().strip()) except: browserify_version = None if browserify_version != 1: print('installing/updating local browserify installation') if os.path.exists(browserify_dir): shutil.rmtree(browserify_dir) os.mkdir(browserify_dir) with open(os.path.join(browserify_dir, 'package.json'), 'w') as f: f.write('{"dependencies": {"browserify": "13.1.1"}}\n') with common.ChangedDirectory(browserify_dir): common.execute(['npm', 'install']) self.patch_package_lock( os.path.join(browserify_dir, 'package-lock.json')) shutil.rmtree(os.path.join(browserify_dir, 'node_modules')) with common.ChangedDirectory(browserify_dir): common.execute(['npm', 'install', '--no-save']) with open(os.path.join(browserify_dir, 'version'), 'w') as f: f.write('1\n') # Make Tinkerforge.js for browser with browserify with common.ChangedDirectory(self.tmp_nodejs_source_tinkerforge_dir): args = [ 'node', os.path.join(browserify_dir, 'node_modules', 'browserify', 'bin', 'cmd.js') ] args.extend( sorted(os.listdir(self.tmp_nodejs_source_tinkerforge_dir))) args.append('-o') args.append( os.path.join(self.tmp_browser_source_dir, 'Tinkerforge.js')) common.execute(args) # Remove browser specific files os.remove( os.path.join(self.tmp_nodejs_source_tinkerforge_dir, 'BrowserAPI.js')) os.remove( os.path.join(self.tmp_nodejs_source_tinkerforge_dir, 'es5-shim.js')) os.remove( os.path.join(self.tmp_nodejs_source_tinkerforge_dir, 'es5-sham.js')) # Generate the NPM package and put it on the root of ZIP archive with common.ChangedDirectory(self.tmp_nodejs_package_dir): common.execute(['npm', 'pack']) package_name = 'tinkerforge-{0}.{1}.{2}.tgz'.format(*version) shutil.copy(os.path.join(self.tmp_nodejs_package_dir, package_name), os.path.join(self.tmp_nodejs_dir, 'tinkerforge.tgz')) shutil.copy(os.path.join(self.tmp_nodejs_package_dir, package_name), os.path.join(root_dir, package_name)) # Remove package directory shutil.rmtree(self.tmp_nodejs_package_dir) # Make zip self.create_zip_file(self.tmp_dir) # copy Tinkerforge.js to bindings root dir so copy_all.py can pick it up shutil.copy( os.path.join(self.tmp_browser_source_dir, 'Tinkerforge.js'), root_dir)
def generate(root_dir): tmp_dir = os.path.join(root_dir, 'cpan_package') tmp_unzipped_dir = os.path.join(tmp_dir, 'unzipped') tmp_unzipped_source_dir = os.path.join(tmp_unzipped_dir, 'source') tmp_unzipped_source_lib_dir = os.path.join(tmp_unzipped_source_dir, 'lib') tmp_cpan_dir = os.path.join(tmp_dir, 'cpan') tmp_cpan_lib_dir = os.path.join(tmp_cpan_dir, 'lib') # 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_perl_bindings_{0}_{1}_{2}.zip'.format(*version)), '-d', tmp_unzipped_dir ]) # Make CPAN package structure modules = ['Tinkerforge'] for filename in os.listdir( os.path.join(tmp_unzipped_source_lib_dir, 'Tinkerforge')): modules.append('Tinkerforge::' + filename.replace('.pm', '')) common.execute([ 'module-starter', '--dir=' + tmp_cpan_dir, '--module=' + ','.join(modules), '--distro=Tinkerforge', '--author="Ishraq Ibne Ashraf"', '[email protected]' ]) # Make README common.specialize_template(os.path.join(root_dir, 'README.template'), os.path.join(tmp_cpan_dir, 'README'), {'<<VERSION>>': '.'.join(version)}) # Make Changes shutil.copy(os.path.join(tmp_unzipped_dir, 'changelog.txt'), os.path.join(tmp_cpan_dir, 'Changes')) # Copy Makefile.PL shutil.copy(os.path.join(tmp_unzipped_source_dir, 'Makefile.PL'), tmp_cpan_dir) # Copy source shutil.rmtree(tmp_cpan_lib_dir) shutil.copytree(os.path.join(tmp_unzipped_source_lib_dir), os.path.join(tmp_cpan_lib_dir)) # Make package with common.ChangedDirectory(tmp_cpan_dir): common.execute(['perl', 'Makefile.PL']) common.execute(['make', 'dist']) shutil.copy( os.path.join(tmp_cpan_dir, 'Tinkerforge-{0}.{1}.{2}.tar.gz'.format(*version)), root_dir)
def generate(root_dir): tmp_dir = os.path.join(root_dir, 'nuget_package') tmp_unzipped_net20_dir = os.path.join(tmp_dir, 'unzipped_net20') tmp_unzipped_net40_dir = os.path.join(tmp_dir, 'unzipped_net40') tmp_unzipped_net40_source_tinkerforge_dir = os.path.join( tmp_unzipped_net40_dir, 'source', 'Tinkerforge') tmp_unzipped_netcoreapp20_dir = os.path.join(tmp_dir, 'unzipped_netcoreapp20') tmp_unzipped_netcoreapp20_source_tinkerforge_dir = os.path.join( tmp_unzipped_netcoreapp20_dir, 'source', 'Tinkerforge') # 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_csharp_bindings_{0}_{1}_{2}.zip'.format(*version)), '-d', tmp_unzipped_net20_dir ]) shutil.copytree(tmp_unzipped_net20_dir, tmp_unzipped_net40_dir) shutil.copytree(tmp_unzipped_net20_dir, tmp_unzipped_netcoreapp20_dir) # Make DLL for NET 4.0 with common.ChangedDirectory(tmp_unzipped_net40_dir): common.execute([ 'mcs', '/debug:full', '/optimize+', '/warn:4', '/sdk:4', '/target:library', '/doc:' + os.path.join(tmp_unzipped_net40_dir, 'Tinkerforge.xml'), '/out:' + os.path.join(tmp_unzipped_net40_dir, 'Tinkerforge.dll'), os.path.join(tmp_unzipped_net40_source_tinkerforge_dir, '*.cs') ]) # Make DLL for NET Core 2.0 with open( os.path.join(tmp_unzipped_netcoreapp20_source_tinkerforge_dir, 'Tinkerforge.csproj'), 'w') as f: f.write(NETCORE_CSPROJ) with common.ChangedDirectory( tmp_unzipped_netcoreapp20_source_tinkerforge_dir): common.execute(['dotnet', 'build', '-c', 'Release']) # Download nuget.exe with common.ChangedDirectory(tmp_dir): common.execute([ 'wget', 'https://dist.nuget.org/win-x86-commandline/v5.0.2/nuget.exe' ]) # Make Tinkerforge.nuspec common.specialize_template( os.path.join(root_dir, 'Tinkerforge.nuspec.template'), os.path.join(tmp_dir, 'Tinkerforge.nuspec'), {'{{VERSION}}': '.'.join(version)}) # Make package with common.ChangedDirectory(tmp_dir): common.execute([ 'mono', os.path.join(tmp_dir, 'nuget.exe'), 'pack', os.path.join(tmp_dir, 'Tinkerforge.nuspec') ]) shutil.move( os.path.join(tmp_dir, 'Tinkerforge.{0}.{1}.{2}.nupkg'.format(*version)), os.path.join(root_dir, 'tinkerforge.{0}.{1}.{2}.nupkg'.format(*version)))
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)