aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Chatelet <gchatelet@google.com>2023-08-31 12:11:42 +0000
committerGitHub <noreply@github.com>2023-08-31 14:11:42 +0200
commitfd4ffc1632db7b4e763bd28ffa6fc9d761cf3587 (patch)
tree2643bb06c4954bde4ad7bb6bf7ec99bfa0d8f216
parentb39a27d6946b5d3dccc941505ba8cb1c9d53c2a0 (diff)
downloadcpu_features-fd4ffc1632db7b4e763bd28ffa6fc9d761cf3587.tar.gz
Fix badge shebang and enable badges from workflow files (#327)
* Fix badge shebang and enable badges from workflow files * Remove chmod +x from documentation
-rwxr-xr-xscripts/generate_badges.d31
1 files changed, 14 insertions, 17 deletions
diff --git a/scripts/generate_badges.d b/scripts/generate_badges.d
index 4766771..e5037ef 100755
--- a/scripts/generate_badges.d
+++ b/scripts/generate_badges.d
@@ -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));
@@ -63,20 +69,6 @@ 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;
@@ -84,6 +76,11 @@ private:
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)