Permalink
Browse files

Embed the arun.glade file as a resource in the built-binary

  • Loading branch information...
rtyler committed Jan 8, 2017
1 parent d0f9345 commit 5bf248399355582af49e83e59199fcb985210137
Showing with 40 additions and 4 deletions.
  1. +24 −0 Makefile
  2. +6 −1 arun.gpr
  3. +6 −0 arun.gresource.xml
  4. +1 −0 src/.gitignore
  5. +3 −3 src/arun.adb
@@ -0,0 +1,24 @@

GPRBUILD:=$(shell which gprbuild)
GPRCLEAN:=$(shell which gprclean)
EXE=obj/arun

all: $(EXE)

$(EXE): prepare
$(GPRBUILD) -Parun.gpr -cargs:c $(shell pkg-config --cflags gio-2.0)

prepare: src/arun-resources.c
mkdir -p obj

src/arun-resources.c: arun.gresource.xml arun.glade
glib-compile-resources --generate-source --target=$@ arun.gresource.xml

run: all
./$(EXE)

clean:
$(GPRCLEAN) -Parun.gpr
rm -f src/arun-resources.c

.PHONY: all clean prepare run
@@ -2,17 +2,22 @@ with "gtkada";

project Arun is

for Languages use ("Ada", "C");
for Source_Dirs use ("src");
for Object_Dir use "obj";
for Main use ("main.adb");

package Linker is
For Leading_Switches ("Ada") use ("arun-resources.o");
end Linker;

package Builder is
for Executable ("main.adb") use "arun";
end Builder;

-- Enable Ada 2005.
package Compiler is
for Switches ("ada") use ("-gnat2012");
for Switches ("Ada") use ("-gnat2012");
end Compiler;

end Arun;
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/io/lasagna/arun">
<file preprocess="xml-stripblanks">arun.glade</file>
</gresource>
</gresources>
@@ -0,0 +1 @@
*.c
@@ -30,9 +30,9 @@ package body Arun is
Gtk_New (Builder);


Return_Code := Add_From_File (Builder => Builder,
Filename => "arun.glade",
Error => Error'Access);
Return_Code := Add_From_Resource (Builder => Builder,
Resource_Path => "/io/lasagna/arun/arun.glade",
Error => Error'Access);
if Error /= null then
Put_Line ("Error : " & Get_Message (Error));
Error_Free (Error);

0 comments on commit 5bf2483

Please sign in to comment.