Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Versions of Apple clang and corresponding upstream branches
Developer Tools clang: Apple's version clang: upstream branch
8.2.1 800.0.42.1 3.9.0svn
8.1 800.0.42.1 3.9.0svn
8.0 800.0.38 3.9.0svn
7.3.1 703.0.31 3.8.0svn
7.3 703.0.29 3.8.0svn
7.2 700.1.81 3.7.0svn
7.1 700.1.76 3.7.0svn
7.0 700.0.72 3.7.0svn
6.4 602.0.53 3.6.0svn
6.3 602.0.53 3.6.0svn
6.2 600.0.57 3.5svn
6.1 600.0.54 3.5svn
6.0 600.0.51 3.5svn
5.1 503.0.38 3.4svn
5.0 500.2.76 3.3svn
4.6 425.0.24 3.2svn
4.5 421.11.65 3.1svn
4.4 421.0.57 3.1svn
4.3 318.0.45 3.1svn
4.2 211.10.1 3.0
4.1 163.7.1 3.0
4.0 137 2.9
#!/usr/bin/env perl
use strict;
use warnings;
use Mojo::UserAgent;
use String::Util qw(trim);
my $baseurl = 'https://opensource.apple.com';
my $config_path = 'src/CMakeLists.txt';
my $output_format;
my $output_header;
my $output_separator;
sub set_up_format {
my %format_info;
my @format_columns = ("Developer Tools", "clang: Apple's version", "clang: upstream branch");
my @format_lengths = (72, 75, 22);
@format_info{@format_columns} = @format_lengths;
$output_format = "|";
$output_header = "|";
$output_separator = "|";
foreach my $column (@format_columns) {
$output_format .= " " . sprintf("%%-%ds", $format_info{$column}) . " |";
$output_header .= " " . sprintf("%-*s", $format_info{$column}, $column) . " |";
$output_separator .= "-" . ("-" x $format_info{$column}) . "-|";
}
$output_format .= "\n";
$output_header .= "\n";
$output_separator .= "\n";
}
sub format_for_output {
my $developer_tools_info = shift;
my $clang_apple_info = shift;
my $clang_llvm_info = shift;
return sprintf($output_format,
$developer_tools_info, $clang_apple_info, $clang_llvm_info);
}
my $ua = Mojo::UserAgent->new;
sub parse_llvm_version {
my $cmakefile = shift;
my $llvm_version = $1
if $cmakefile =~ /set\(PACKAGE_VERSION\s+(\S*)\s*\)/;
my @llvm_variables = (
'LLVM_VERSION_MAJOR', 'LLVM_VERSION_MINOR',
'LLVM_VERSION_PATCH', 'LLVM_VERSION_SUFFIX'
);
foreach my $llvm_variable (@llvm_variables) {
my $llvm_variable_value = $1
if $cmakefile =~ /set\($llvm_variable\s+(\S*)\s*\)/;
$llvm_version =~ s/\$\{$llvm_variable\}/$llvm_variable_value/;
}
$llvm_version =~ s/^"|"$//g;
return $llvm_version;
}
sub handle_dt_release {
my $dt_atag_ref = shift;
my $dt_relurl = $dt_atag_ref->attr->{href};
my $dt_absurl = $baseurl . $dt_relurl;
my $dt_version = $dt_atag_ref->text;
my $dt_dom = $ua->get($dt_absurl)->result->dom;
my $clang_atag_ref = $dt_dom
->find('td.project-name > a')
->first(sub { $_->text =~ /clang-/ });
return unless defined $clang_atag_ref;
my $clang_relurl = $clang_atag_ref->attr->{href};
my $clang_absurl = $baseurl . $clang_relurl;
my $clang_version = trim($clang_atag_ref->text);
$clang_version =~ s/^clang-//;
my $cmakefile = $ua->get($clang_absurl . $config_path)->result->body;
my $llvm_version = parse_llvm_version($cmakefile);
print(format_for_output(sprintf('[%s](%s)', $dt_version, $dt_absurl),
sprintf('[%s](%s)', $clang_version, $clang_absurl),
$llvm_version));
}
sub main {
set_up_format();
print($output_header);
print($output_separator);
my $main_dom = $ua->get($baseurl)->result->dom;
$main_dom
->find('div.release-list')
->first(sub { $_->at('h3.product-name')->text eq "Developer Tools"; })
->find('ul.release-sublist > li > a')
->each(\&handle_dt_release);
}
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.