Skip to content

Commit

Permalink
Fix badge shebang and enable badges from workflow files (#327)
Browse files Browse the repository at this point in the history
* Fix badge shebang and enable badges from workflow files

* Remove chmod +x from documentation
  • Loading branch information
gchatelet committed Aug 31, 2023
1 parent b39a27d commit fd4ffc1
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions scripts/generate_badges.d
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
#!/usr/bin/env -S docker run --rm -it -v .:/src dlanguage/dmd dmd -run generate_badges.d
#!/usr/bin/env -S docker run --rm -v ${PWD}/scripts:/scripts -v ${PWD}/.github/workflows:/.github/workflows dlanguage/dmd dmd -run /scripts/generate_badges.d

// To run this script:
// cd /path/to/cpu_features
// ./scripts/generate_badges.d

import std.algorithm : each, map, cartesianProduct, filter, joiner, sort, uniq;
import std.array;
import std.base64 : Base64;
import std.conv : to;
import std.file : exists;
import std.format;
import std.range : chain, only;
import std.stdio;
import std.traits : EnumMembers;
import std.string : representation;
import std.base64 : Base64;
import std.traits : EnumMembers;

immutable string bazel_svg = `<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M6 .16l5.786 5.786L6 11.732.214 5.946 6 .161zM0 6.214V12l5.786 5.786V12L0 6.214zM18 .16l5.786 5.786L18 11.732l-5.786-5.786L18 .161zM24 6.214V12l-5.786 5.786V12L24 6.214zM12 6.16l5.786 5.786L12 17.732l-5.786-5.786L12 6.161zM11.84 18.054v5.785l-5.786-5.785v-5.786l5.785 5.786zM12.16 18.054l5.786-5.786v5.786l-5.785 5.785v-5.785z" stroke="transparent" fill="white"/></svg>`;
const string bazel_svg_base64 = Base64.encode(representation(bazel_svg));
Expand Down Expand Up @@ -63,27 +69,18 @@ private:
return format("[i%s]", id());
}

bool enabled()
{
if (cpu == Cpu.LOONGARCH)
return false;
final switch (build_system)
{
case BuildSystem.CMake:
return os == Os.Linux || cpu == Cpu.amd64;
case BuildSystem.Bazel:
return (os == Os.Linux && (cpu == Cpu.amd64 || cpu == Cpu.AArch64))
|| (os == Os.MacOS && cpu == Cpu.amd64);
}
}

string filename()
{
import std.uni : toLower;

return toLower(format("%s_%s_%s.yml", cpu, os, build_system));
}

bool enabled()
{
return exists("../.github/workflows/" ~ filename());
}

string append_logo(string url)
{
final switch (build_system)
Expand Down

0 comments on commit fd4ffc1

Please sign in to comment.