Skip to content

Commit

Permalink
Merge pull request #195127 from Homebrew/a-f-switch-eos-code-blocks-t…
Browse files Browse the repository at this point in the history
…o-language-specific

a-f: Use language-specific heredoc delimiters for C code
  • Loading branch information
chenrui333 authored Oct 22, 2024
2 parents 70099b7 + f6f2529 commit cd8ecd9
Show file tree
Hide file tree
Showing 93 changed files with 190 additions and 190 deletions.
4 changes: 2 additions & 2 deletions Formula/a/aarch64-elf-gcc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ def install
end

test do
(testpath/"test-c.c").write <<~EOS
(testpath/"test-c.c").write <<~C
int main(void)
{
int i=0;
while(i<10) i++;
return i;
}
EOS
C
system bin/"aarch64-elf-gcc", "-c", "-o", "test-c.o", "test-c.c"
assert_match "file format elf64-littleaarch64",
shell_output("#{Formula["aarch64-elf-binutils"].bin}/aarch64-elf-objdump -a test-c.o")
Expand Down
4 changes: 2 additions & 2 deletions Formula/a/acl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def install
other::r-x
EOS

(testpath/"test.c").write <<~EOS
(testpath/"test.c").write <<~C
#include <stdio.h>
#include <sys/acl.h>
Expand All @@ -64,7 +64,7 @@ def install
acl_free(acl_text);
return 0;
}
EOS
C
system ENV.cc, "test.c", "-o", "test", "-I#{include}", "-L#{lib}", "-lacl"
assert_equal <<~EOS, shell_output("./test").chomp
user::rwx
Expand Down
4 changes: 2 additions & 2 deletions Formula/a/airspy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def install
end

test do
(testpath/"test.c").write <<~EOS
(testpath/"test.c").write <<~C
#include <stdio.h>
#include <libairspy/airspy.h>
Expand All @@ -47,7 +47,7 @@ def install
return 0;
}
EOS
C

system ENV.cc, "test.c", "-L#{lib}", "-lairspy", "-o", "test"
assert_match version.to_s, shell_output("./test")
Expand Down
4 changes: 2 additions & 2 deletions Formula/a/airspyhf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def install
end

test do
(testpath/"test.c").write <<~EOS
(testpath/"test.c").write <<~C
#include <libairspyhf/airspyhf.h>
int main() {
Expand All @@ -51,7 +51,7 @@ def install
return 1;
}
EOS
C

system ENV.cc, "test.c", "-o", "test", "-I#{include}", "-L#{lib}", "-lairspyhf", "-lm"
system "./test"
Expand Down
4 changes: 2 additions & 2 deletions Formula/a/alsa-lib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ def install
end

test do
(testpath/"test.c").write <<~EOS
(testpath/"test.c").write <<~C
#include <alsa/asoundlib.h>
int main(void)
{
snd_ctl_card_info_t *info;
snd_ctl_card_info_alloca(&info);
return 0;
}
EOS
C
system ENV.cc, "test.c", "-L#{lib}", "-lasound", "-o", "test"
system "./test"
end
Expand Down
4 changes: 2 additions & 2 deletions Formula/a/appstream-glib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ def install
end

test do
(testpath/"test.c").write <<~EOS
(testpath/"test.c").write <<~C
#include <appstream-glib.h>
int main(int argc, char *argv[]) {
AsScreenshot *screen_shot = as_screenshot_new();
g_assert_nonnull(screen_shot);
return 0;
}
EOS
C
gdk_pixbuf = Formula["gdk-pixbuf"]
gettext = Formula["gettext"]
glib = Formula["glib"]
Expand Down
4 changes: 2 additions & 2 deletions Formula/a/appstream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def install
<name>Test App</name>
</component>
EOS
(testpath/"test.c").write <<~EOS
(testpath/"test.c").write <<~C
#include "appstream.h"
int main(int argc, char *argv[]) {
Expand All @@ -95,7 +95,7 @@ def install
g_clear_error (&error);
}
}
EOS
C
flags = shell_output("pkg-config --cflags --libs appstream").strip.split
system ENV.cc, "test.c", "-o", "test", *flags
system "./test"
Expand Down
4 changes: 2 additions & 2 deletions Formula/a/apr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ def install

test do
assert_match opt_prefix.to_s, shell_output("#{bin}/apr-#{version.major}-config --prefix")
(testpath/"test.c").write <<~EOS
(testpath/"test.c").write <<~C
#include <stdio.h>
#include <apr-#{version.major}/apr_version.h>
int main() {
printf("%s", apr_version_string());
return 0;
}
EOS
C
system ENV.cc, "test.c", "-I#{include}", "-L#{lib}", "-lapr-#{version.major}", "-o", "test"
assert_equal version.to_s, shell_output("./test")
end
Expand Down
4 changes: 2 additions & 2 deletions Formula/a/arb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def install
end

test do
(testpath/"test.c").write <<~EOS
(testpath/"test.c").write <<~C
#include <arb.h>
int main()
Expand All @@ -58,7 +58,7 @@ def install
arb_clear(x); arb_clear(y);
flint_cleanup();
}
EOS
C

system ENV.cc, "test.c", "-I#{include}", "-I#{Formula["flint"].opt_include}",
"-L#{lib}", "-L#{Formula["flint"].opt_lib}",
Expand Down
4 changes: 2 additions & 2 deletions Formula/a/argp-standalone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ def install
end

test do
(testpath/"test.c").write <<~EOS
(testpath/"test.c").write <<~C
#include <stdio.h>
#include <argp.h>
int main(int argc, char ** argv)
{
return argp_parse(0, argc, argv, 0, 0, 0);
}
EOS
C
system ENV.cc, "test.c", "-L#{lib}", "-largp", "-o", "test"
system "./test"
end
Expand Down
4 changes: 2 additions & 2 deletions Formula/a/argtable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def install
end

test do
(testpath/"test.c").write <<~EOS
(testpath/"test.c").write <<~C
#include "argtable2.h"
#include <assert.h>
#include <stdio.h>
Expand All @@ -57,7 +57,7 @@ def install
puts ("Invalid option");
}
}
EOS
C
system ENV.cc, "test.c", "-L#{lib}", "-I#{include}", "-largtable2",
"-o", "test"
assert_match "Received option", shell_output("./test -a")
Expand Down
4 changes: 2 additions & 2 deletions Formula/a/argtable3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def install
end

test do
(testpath/"test.c").write <<~EOS
(testpath/"test.c").write <<~C
#include "argtable3.h"
#include <assert.h>
#include <stdio.h>
Expand All @@ -50,7 +50,7 @@ def install
puts ("Invalid option");
}
}
EOS
C

system ENV.cc, "test.c", "-L#{lib}", "-I#{include}", "-largtable3",
"-o", "test"
Expand Down
4 changes: 2 additions & 2 deletions Formula/a/aribb24.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def install
end

test do
(testpath/"test.c").write <<~EOS
(testpath/"test.c").write <<~C
#include <aribb24/aribb24.h>
#include <stdlib.h>
int main() {
Expand All @@ -42,7 +42,7 @@ def install
arib_instance_destroy(ptr);
return 0;
}
EOS
C
system ENV.cc, "-o", "test", "test.c", "-I#{include}",
"-L#{lib}", "-laribb24"
system "./test"
Expand Down
4 changes: 2 additions & 2 deletions Formula/a/arm-none-eabi-gcc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ def install
end

test do
(testpath/"test-c.c").write <<~EOS
(testpath/"test-c.c").write <<~C
int main(void)
{
int i=0;
while(i<10) i++;
return i;
}
EOS
C
system bin/"arm-none-eabi-gcc", "-c", "-o", "test-c.o", "test-c.c"
assert_match "file format elf32-littlearm",
shell_output("#{Formula["arm-none-eabi-binutils"].bin}/arm-none-eabi-objdump -a test-c.o")
Expand Down
4 changes: 2 additions & 2 deletions Formula/a/at-spi2-core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def install
end

test do
(testpath/"test.c").write <<~EOS
(testpath/"test.c").write <<~C
/*
* List the applications registered on at-spi.
*/
Expand Down Expand Up @@ -70,7 +70,7 @@ def install
return 1;
}
EOS
C

pkg_config_cflags = shell_output("pkg-config --cflags --libs atspi-2").chomp.split
system ENV.cc, "test.c", *pkg_config_cflags, "-lgobject-2.0", "-o", "test"
Expand Down
4 changes: 2 additions & 2 deletions Formula/a/automake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ def install
end

test do
(testpath/"test.c").write <<~EOS
(testpath/"test.c").write <<~C
int main() { return 0; }
EOS
C
(testpath/"configure.ac").write <<~EOS
AC_INIT(test, 1.0)
AM_INIT_AUTOMAKE
Expand Down
4 changes: 2 additions & 2 deletions Formula/a/avahi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def install
end

test do
(testpath/"test.c").write <<~EOS
(testpath/"test.c").write <<~C
#include <glib.h>
#include <avahi-client/client.h>
Expand Down Expand Up @@ -97,7 +97,7 @@ def install
return 0;
}
EOS
C

pkg_config_flags = shell_output("pkg-config --cflags --libs avahi-client avahi-core avahi-glib").chomp.split
system ENV.cc, "test.c", *pkg_config_flags, "-o", "test"
Expand Down
4 changes: 2 additions & 2 deletions Formula/b/babl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def install
end

test do
(testpath/"test.c").write <<~EOS
(testpath/"test.c").write <<~C
#include <babl/babl.h>
int main() {
babl_init();
Expand All @@ -49,7 +49,7 @@ def install
babl_exit();
return 0;
}
EOS
C
system ENV.cc, "-I#{include}/babl-0.1", testpath/"test.c", "-L#{lib}", "-lbabl-0.1", "-o", "test"
system testpath/"test"

Expand Down
4 changes: 2 additions & 2 deletions Formula/b/bam.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ def install
end

test do
(testpath/"hello.c").write <<~EOS
(testpath/"hello.c").write <<~C
#include <stdio.h>
int main() {
printf("hello\\n");
return 0;
}
EOS
C

(testpath/"bam.lua").write <<~EOS
settings = NewSettings()
Expand Down
4 changes: 2 additions & 2 deletions Formula/b/bdw-gc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def install
end

test do
(testpath/"test.c").write <<~EOS
(testpath/"test.c").write <<~C
#include <assert.h>
#include <stdio.h>
#include "gc.h"
Expand All @@ -73,7 +73,7 @@ def install
}
return 0;
}
EOS
C

system ENV.cc, "test.c", "-I#{include}", "-L#{lib}", "-lgc", "-o", "test"
system "./test"
Expand Down
4 changes: 2 additions & 2 deletions Formula/b/bear.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ def install
end

test do
(testpath/"test.c").write <<~EOS
(testpath/"test.c").write <<~C
#include <stdio.h>
int main() {
printf("hello, world!\\n");
return 0;
}
EOS
C
system bin/"bear", "--", "clang", "test.c"
assert_predicate testpath/"compile_commands.json", :exist?
end
Expand Down
4 changes: 2 additions & 2 deletions Formula/b/beecrypt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def install
end

test do
(testpath/"test.c").write <<~EOS
(testpath/"test.c").write <<~C
#include "beecrypt/base64.h"
#include "beecrypt/sha256.h"
#include <stdio.h>
Expand All @@ -76,7 +76,7 @@ def install
return 0;
}
EOS
C
system ENV.cc, "test.c", "-L#{lib}", "-lbeecrypt", "-o", "test"
assert_match "FJOO", shell_output("./test")
end
Expand Down
Loading

0 comments on commit cd8ecd9

Please sign in to comment.