Skip to content

Commit

Permalink
Merge pull request #195129 from Homebrew/g-l-switch-c-eos-heredocs-to…
Browse files Browse the repository at this point in the history
…-language-specific

g-l: Use language-specific heredoc delimiters for C code
  • Loading branch information
chenrui333 authored Oct 22, 2024
2 parents cd8ecd9 + b5ff278 commit 8bde802
Show file tree
Hide file tree
Showing 107 changed files with 278 additions and 278 deletions.
4 changes: 2 additions & 2 deletions Formula/g/game-music-emu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def install
end

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

if OS.mac?
ubsan_libdir = Dir["#{MacOS::CLT::PKG_PATH}/usr/lib/clang/*/lib/darwin"].first
Expand Down
4 changes: 2 additions & 2 deletions Formula/g/gcc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -253,14 +253,14 @@ def post_install
end

test do
(testpath/"hello-c.c").write <<~EOS
(testpath/"hello-c.c").write <<~C
#include <stdio.h>
int main()
{
puts("Hello, world!");
return 0;
}
EOS
C
system bin/"gcc-#{version_suffix}", "-o", "hello-c", "hello-c.c"
assert_equal "Hello, world!\n", shell_output("./hello-c")

Expand Down
4 changes: 2 additions & 2 deletions Formula/g/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,14 @@ def post_install
end

test do
(testpath/"hello-c.c").write <<~EOS
(testpath/"hello-c.c").write <<~C
#include <stdio.h>
int main()
{
puts("Hello, world!");
return 0;
}
EOS
C
system bin/"gcc-#{version.major}", "-o", "hello-c", "hello-c.c"
assert_equal "Hello, world!\n", `./hello-c`

Expand Down
4 changes: 2 additions & 2 deletions Formula/g/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,14 @@ def post_install
end

test do
(testpath/"hello-c.c").write <<~EOS
(testpath/"hello-c.c").write <<~C
#include <stdio.h>
int main()
{
puts("Hello, world!");
return 0;
}
EOS
C
system bin/"gcc-#{version.major}", "-o", "hello-c", "hello-c.c"
assert_equal "Hello, world!\n", shell_output("./hello-c")

Expand Down
4 changes: 2 additions & 2 deletions Formula/g/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,14 @@ def post_install
end

test do
(testpath/"hello-c.c").write <<~EOS
(testpath/"hello-c.c").write <<~C
#include <stdio.h>
int main()
{
puts("Hello, world!");
return 0;
}
EOS
C
system bin/"gcc-#{version.major}", "-o", "hello-c", "hello-c.c"
assert_equal "Hello, world!\n", shell_output("./hello-c")

Expand Down
4 changes: 2 additions & 2 deletions Formula/g/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,14 @@ def post_install
end

test do
(testpath/"hello-c.c").write <<~EOS
(testpath/"hello-c.c").write <<~C
#include <stdio.h>
int main()
{
puts("Hello, world!");
return 0;
}
EOS
C
system bin/"gcc-#{version.major}", "-o", "hello-c", "hello-c.c"
assert_equal "Hello, world!\n", shell_output("./hello-c")

Expand Down
4 changes: 2 additions & 2 deletions Formula/g/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,14 @@ def post_install
end

test do
(testpath/"hello-c.c").write <<~EOS
(testpath/"hello-c.c").write <<~C
#include <stdio.h>
int main()
{
puts("Hello, world!");
return 0;
}
EOS
C
system bin/"gcc-#{version.major}", "-o", "hello-c", "hello-c.c"
assert_equal "Hello, world!\n", `./hello-c`

Expand Down
4 changes: 2 additions & 2 deletions Formula/g/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,14 @@ def post_install
end

test do
(testpath/"hello-c.c").write <<~EOS
(testpath/"hello-c.c").write <<~C
#include <stdio.h>
int main()
{
puts("Hello, world!");
return 0;
}
EOS
C
system bin/"gcc-#{version.major}", "-o", "hello-c", "hello-c.c"
assert_equal "Hello, world!\n", `./hello-c`

Expand Down
4 changes: 2 additions & 2 deletions Formula/g/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,14 @@ def add_suffix(file, suffix)
end

test do
(testpath/"hello-c.c").write <<~EOS
(testpath/"hello-c.c").write <<~C
#include <stdio.h>
int main()
{
puts("Hello, world!");
return 0;
}
EOS
C
system bin/"gcc-#{version.major}", "-o", "hello-c", "hello-c.c"
assert_equal "Hello, world!\n", `./hello-c`

Expand Down
4 changes: 2 additions & 2 deletions Formula/g/gd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def install
end

test do
(testpath/"test.c").write <<~EOS
(testpath/"test.c").write <<~C
#include "gd.h"
#include <stdio.h>
Expand All @@ -76,7 +76,7 @@ def install
fclose(pngout);
gdImageDestroy(im);
}
EOS
C
system ENV.cc, "test.c", "-I#{include}", "-L#{lib}", "-lgd", "-o", "test"
system "./test"
assert_path_exists "#{testpath}/test.png"
Expand Down
4 changes: 2 additions & 2 deletions Formula/g/gdk-pixbuf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ def post_install
end

test do
(testpath/"test.c").write <<~EOS
(testpath/"test.c").write <<~C
#include <gdk-pixbuf/gdk-pixbuf.h>
int main(int argc, char *argv[]) {
GType type = gdk_pixbuf_get_type();
return 0;
}
EOS
C
flags = shell_output("pkg-config --cflags --libs gdk-pixbuf-#{gdk_so_ver}").chomp.split
system ENV.cc, "test.c", "-o", "test", *flags
system "./test"
Expand Down
4 changes: 2 additions & 2 deletions Formula/g/gdl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ def install
end

test do
(testpath/"test.c").write <<~EOS
(testpath/"test.c").write <<~C
#include <gdl/gdl.h>
int main(int argc, char *argv[]) {
GType type = gdl_dock_object_get_type();
return 0;
}
EOS
C

pkg_config_flags = shell_output("pkg-config --cflags --libs gdl-3.0").chomp.split
system ENV.cc, "test.c", *pkg_config_flags, "-o", "test"
Expand Down
4 changes: 2 additions & 2 deletions Formula/g/gedit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ def post_install
# main executable test
system bin/"gedit", "--version"
# API test
(testpath/"test.c").write <<~EOS
(testpath/"test.c").write <<~C
#include <gedit/gedit-debug.h>
int main(int argc, char *argv[]) {
gedit_debug_init();
return 0;
}
EOS
C

flags = shell_output("pkg-config --cflags --libs gedit").chomp.split
flags << "-Wl,-rpath,#{lib}/gedit" if OS.linux?
Expand Down
4 changes: 2 additions & 2 deletions Formula/g/gegl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ def install
end

test do
(testpath/"test.c").write <<~EOS
(testpath/"test.c").write <<~C
#include <gegl.h>
gint main(gint argc, gchar **argv) {
gegl_init(&argc, &argv);
GeglNode *gegl = gegl_node_new ();
gegl_exit();
return 0;
}
EOS
C
system ENV.cc,
"-I#{Formula["babl"].opt_include}/babl-0.1",
"-I#{Formula["glib"].opt_include}/glib-2.0",
Expand Down
4 changes: 2 additions & 2 deletions Formula/g/geocode-glib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ def post_install
end

test do
(testpath/"test.c").write <<~EOS
(testpath/"test.c").write <<~C
#include <geocode-glib/geocode-glib.h>
int main(int argc, char *argv[]) {
GeocodeLocation *loc = geocode_location_new(1.0, 1.0, 1.0);
return 0;
}
EOS
C
pkg_config_flags = shell_output("pkg-config --cflags --libs geocode-glib-2.0").chomp.split
system ENV.cc, "test.c", "-o", "test", *pkg_config_flags
system "./test"
Expand Down
4 changes: 2 additions & 2 deletions Formula/g/geos.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def install
end

test do
(testpath/"test.c").write <<~EOS
(testpath/"test.c").write <<~C
#include <stdio.h>
#include <stdarg.h>
#include <geos_c.h>
Expand All @@ -58,7 +58,7 @@ def install
printf("Intersection(A, B): %s\\n", wkt_inter);
return 0;
}
EOS
C

cflags = shell_output("#{bin}/geos-config --cflags").split
libs = shell_output("#{bin}/geos-config --clibs").split
Expand Down
4 changes: 2 additions & 2 deletions Formula/g/gerbv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ def install
# executable (GUI) test
system bin/"gerbv", "--version"
# API test
(testpath/"test.c").write <<~EOS
(testpath/"test.c").write <<~C
#include <gerbv.h>
int main(int argc, char *argv[]) {
double d = gerbv_get_tool_diameter(2);
return 0;
}
EOS
C
atk = Formula["atk"]
cairo = Formula["cairo"]
fontconfig = Formula["fontconfig"]
Expand Down
4 changes: 2 additions & 2 deletions Formula/g/getdns.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def install
end

test do
(testpath/"test.c").write <<~EOS
(testpath/"test.c").write <<~C
#include <getdns/getdns.h>
#include <stdio.h>
Expand All @@ -81,7 +81,7 @@ def install
getdns_context_destroy(context);
return 0;
}
EOS
C
system ENV.cc, "-I#{include}", "-o", "test", "test.c", "-L#{lib}", "-lgetdns"
system "./test"
end
Expand Down
4 changes: 2 additions & 2 deletions Formula/g/gexiv2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ def install
end

test do
(testpath/"test.c").write <<~EOS
(testpath/"test.c").write <<~C
#include <gexiv2/gexiv2.h>
int main() {
GExiv2Metadata *metadata = gexiv2_metadata_new();
return 0;
}
EOS
C

system ENV.cc, "test.c", "-o", "test",
"-I#{HOMEBREW_PREFIX}/include/glib-2.0",
Expand Down
4 changes: 2 additions & 2 deletions Formula/g/gitg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ def post_install
# Disable this part of test on Linux because display is not available.
assert_match version.to_s, shell_output("#{bin}/gitg --version") if OS.mac?

(testpath/"test.c").write <<~EOS
(testpath/"test.c").write <<~C
#include <libgitg/libgitg.h>
int main(int argc, char *argv[]) {
GType gtype = gitg_stage_status_file_get_type();
return 0;
}
EOS
C

ENV.prepend_path "PKG_CONFIG_PATH", Formula["[email protected]"].opt_lib/"pkgconfig"
flags = shell_output("pkg-config --cflags --libs libgitg-1.0").chomp.split
Expand Down
4 changes: 2 additions & 2 deletions Formula/g/gl2ps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def install
else
"GL"
end
(testpath/"test.c").write <<~EOS
(testpath/"test.c").write <<~C
#include <#{glu}/glut.h>
#include <gl2ps.h>
Expand Down Expand Up @@ -73,7 +73,7 @@ def install
fclose(fp);
return 0;
}
EOS
C
if OS.mac?
system ENV.cc, "-L#{lib}", "-lgl2ps", "-framework", "OpenGL", "-framework", "GLUT",
"-framework", "Cocoa", "test.c", "-o", "test"
Expand Down
4 changes: 2 additions & 2 deletions Formula/g/glade.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ def post_install
# fails in Linux CI with (glade:20337): Gtk-WARNING **: 21:45:31.876: cannot open display:
system bin/"glade", "--version" if OS.mac?

(testpath/"test.c").write <<~EOS
(testpath/"test.c").write <<~C
#include <gladeui/glade.h>
int main(int argc, char *argv[]) {
gboolean glade_util_have_devhelp();
return 0;
}
EOS
C

pkg_config_flags = shell_output("pkg-config --cflags --libs gladeui-2.0").chomp.split
system ENV.cc, "test.c", "-o", "test", *pkg_config_flags
Expand Down
4 changes: 2 additions & 2 deletions Formula/g/glew.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def install
else
"GL"
end
(testpath/"test.c").write <<~EOS
(testpath/"test.c").write <<~C
#include <GL/glew.h>
#include <#{glut}/glut.h>
Expand All @@ -83,7 +83,7 @@ def install
}
return 0;
}
EOS
C
flags = %W[-L#{lib} -lGLEW]
if OS.mac?
flags << "-framework" << "GLUT"
Expand Down
Loading

0 comments on commit 8bde802

Please sign in to comment.