• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

D bindings to the GraphicsMagick library.


Commit MetaInfo

Revisão86cc55ebb84b77905c11c70b1e48b43e6141477e (tree)
Hora2023-07-22 10:15:52
AutorMio <stigma@disr...>
CommiterMio

Mensagem de Log

[examples] Consolidate magickd build scripts

Mudança Sumário

Diff

--- a/.gitignore
+++ b/.gitignore
@@ -29,10 +29,16 @@ graphicsmagick_c/examples/*_ldc
2929 graphicsmagick_c/examples/*_dmd
3030 graphicsmagick_c/examples/*.o
3131
32+# OLD examples (separate build scripts)
3233 examples/gdc
3334 examples/dmd
3435 examples/ldc
3536
37+# NEW examples (shared build script)
38+examples/*_gdc
39+examples/*_ldc
40+examples/*_dmd
41+
3642 # graphicsmagick_c
3743 graphicsmagick_c/graphicsmagick_c-test-*
3844
--- a/examples/README
+++ b/examples/README
@@ -4,10 +4,10 @@ MagickD Examples
44 This directory contains a few example files showing different ways of using
55 the MagickD API.
66
7-Also included in this directory are three scripts for compiling the examples:
8-gdc.sh, dmd.sh, and ldc.sh. As you may have guessed, each of these will
9-compile the examples using the respective D compiler. Each one creates a new
10-sub-directory which will contain all the build examples so you can run them.
7+Also included in this directory is a build script (build.sh) which will
8+compile all of the examples. You can specify which compiler to use with
9+the respective flag (--dmd, --gdc, --ldc) and the prodduces binary will
10+be suffixed with the compiler identifier (_dmd, _gdc, _ldc).
1111
1212
1313 Descriptions
--- /dev/null
+++ b/examples/build.sh
@@ -0,0 +1,161 @@
1+#!/bin/bash
2+# -------------------------------------------------------------------------------------------------
3+#
4+# Permission to use, copy, modify, and/or distribute this file for any purpose
5+# with or without fee is hereby granted. This file is offered as-is, without
6+# any warranty.
7+#
8+# This file compiles all the examples in this directory using the specified
9+# compiler, either using the shared GraphicsMagick library, or the static one.
10+#
11+# usage: build.sh [--gdc] [--ldc] [--dmd] [--debug] [--shared]
12+# build.sh --clean
13+#
14+# options:
15+# --gdc Compile all examples using GDC (https://wiki.dlang.org/GDC)
16+# --ldc Compile all examples using LDC (https://wiki.dlang.org/LDC)
17+# --dmd Compile all examples using DMD (https://wiki.dlang.org/DMD)
18+#
19+# --debug Compile with graphicsmagick_c debug messages.
20+# --shared Compile using the shared GraphicsMagick library.
21+#
22+# --clean Clean any built executables
23+# -------------------------------------------------------------------------------------------------
24+set -e
25+
26+FALSE=0
27+TRUE=1
28+
29+which gm > /dev/null || {
30+ printf "error: could not find 'gm' executable\n" >&2
31+ printf " is graphicsmagick installed?\n"
32+ exit 1
33+}
34+
35+QDEPTH="$(gm version | head -n1 | cut -d' ' -f4)"
36+
37+# This doesn't always work correctly. For example, Devuan Chimaera (4)
38+# has a snapshot version 1.4, which is not an available version.
39+GM_RAW_VERSION="$(gm version | head -n1 | cut -d' ' -f2)"
40+GM_EDT_VERSION="$(gm version | head -n1 | cut -d' ' -f2 | sed 's/\.//g')"
41+
42+GMAGICK_SOURCES="$(find ../graphicsmagick_c/src -type f -regex '.*\.d')"
43+MD_SOURCES="$(find ../source -maxdepth 2 -type f -regex '.*\.d')"
44+
45+case "$QDEPTH" in
46+ Q8 | Q16 | Q32) ;; # no-op
47+ *) printf "error: unsupported Quantum Depth '%s'.\n" "$QDEPTH" >&2 ; exit 1 ;;
48+esac
49+
50+GDC=$FALSE
51+LDC=$FALSE
52+DMD=$FALSE
53+SHARED=$FALSE
54+DEBUG=$FALSE
55+OS_TYPE="$(uname -s)"
56+
57+for arg in "$@"
58+do
59+ case "$arg" in
60+ --gdc) GDC=$TRUE ;;
61+ --ldc) LDC=$TRUE ;;
62+ --dmd) DMD=$TRUE ;;
63+ --shared) SHARED=$TRUE ;;
64+ --debug) DEBUG=$TRUE ;;
65+ --clean) set -x; rm -f *_gdc *_ldc *_dmd *.o ; exit 0 ;;
66+ *) printf "notice: unsupported option '$arg'...\n" >&2 ;;
67+ esac
68+done
69+
70+
71+if [ $GDC -eq $FALSE ] && [ $LDC -eq $FALSE ] && [ $DMD -eq $FALSE ]
72+then
73+ printf "error: no compiler selected...\n" >&2
74+ printf "usage: %s [--gdc] [--ldc] [--dmd] [--debug] [--shared]\n" $0
75+ printf " %s --clean\n" $0
76+ exit 1
77+fi
78+
79+printf "Compiling magickd version %s with %s...\n" "$GM_RAW_VERSION" "$QDEPTH"
80+
81+if [ $GDC -eq $TRUE ]
82+then
83+ printf "...for GDC..."
84+ DFLAGS="-g -I../source -fversion=$QDEPTH -fversion=GMagick_${GM_EDT_VERSION}"
85+
86+ if [ $DEBUG -eq $TRUE ]; then DFLAGS="$DFLAGS -fdebug=graphicsmagick_c -fdebug=magickd"; fi
87+
88+ if [ $SHARED -eq $TRUE ]
89+ then
90+ DFLAGS="$DFLAGS -fversion=GMagick_Dynamic"
91+ else
92+ DFLAGS="$DFLAGS -fversion=GMagick_Static"
93+ fi
94+
95+ for dfile in *.d
96+ do
97+ fname="${dfile%.*}"
98+ printf "$fname..."
99+ gdc $DFLAGS -o "${fname}_gdc" "$dfile" $GMAGICK_SOURCES $MD_SOURCES \
100+ -lGraphicsMagick -lGraphicsMagickWand -ldl
101+ done
102+ printf "\n"
103+fi
104+
105+if [ $LDC -eq $TRUE ]
106+then
107+
108+ if [ "Darwin" = "$OS_TYPE" ]
109+ then
110+ LDFLAGS="$LDFLAGS -L-L/opt/local/lib"
111+ fi
112+
113+ printf "...for LDC..."
114+ DFLAGS="$DFLAGS --d-version=$QDEPTH --d-version=GMagick_${GM_EDT_VERSION}"
115+
116+ if [ $DEBUG -eq $TRUE ]; then DFLAGS="$DFLAGS -g -d-debug=graphicsmagick_c -d-debug=magickd"; fi
117+ if [ $SHARED -eq $TRUE ]
118+ then
119+ DFLAGS="$DFLAGS --d-version=GMagick_Dynamic"
120+ else
121+ DFLAGS="$DFLAGS --d-version=GMagick_Static"
122+ fi
123+
124+ for dfile in *.d
125+ do
126+ fname="${dfile%.*}"
127+ printf "$fname..."
128+ ldc2 $DFLAGS -of="${fname}_ldc" "$dfile" $GMAGICK_SOURCES $MD_SOURCES \
129+ $LDFLAGS -L-lGraphicsMagick -L-lGraphicsMagickWand -L-ldl
130+ done
131+ printf "\n"
132+fi
133+
134+if [ $DMD -eq $TRUE ]
135+then
136+
137+ if [ "Darwin" = "$OS_TYPE" ]
138+ then
139+ LDFLAGS="$LDFLAGS -L-L/opt/local/lib"
140+ fi
141+
142+ printf "...for DMD..."
143+ DFLAGS="-version=$QDEPTH -version=GMagick_${GM_EDT_VERSION}"
144+
145+ if [ $DEBUG -eq $TRUE ]; then DFLAGS="$DFLAGS -g -debug -debug=graphicsmagick_c"; fi
146+ if [ $SHARED -eq $TRUE ]
147+ then
148+ DFLAGS="$DFLAGS -version=GMagick_Dynamic"
149+ else
150+ DFLAGS="$DFLAGS -version=GMagick_Static"
151+ fi
152+
153+ for dfile in *.d
154+ do
155+ fname="${dfile%.*}"
156+ printf "$fname..."
157+ dmd $DFLAGS -of="${fname}_dmd" "$dfile" $GMAGICK_SOURCES $MD_SOURCES \
158+ $LDFLAGS -L-lGraphicsMagick -L-lGraphicsMagickWand -L-ldl
159+ done
160+ printf "\n"
161+fi
--- a/examples/dmd.sh
+++ /dev/null
@@ -1,71 +0,0 @@
1-#!/bin/sh
2-# -----------------------------------------------------------------------------
3-#
4-# This file compiles all the examples in this directory using the DMD compile.
5-# The version of DMD currently used for testing is DMD v2.100.0.
6-#
7-# Copyright (C) 2021-2023 by kaerou <stigma@disroot.org>
8-#
9-# Permission to use, copy, modify, and/or distribute this file for any purpose
10-# with or without fee is hereby granted. This file is offered as-is, without
11-# any warranty.
12-#
13-# -----------------------------------------------------------------------------
14-set -e
15-
16-print_usage() {
17- printf "usage: %s [option]\n" $0
18- printf "\n%s\n" "options:"
19- printf "%s\n" "-v, --verbose Enable verbose logging"
20- printf "%s\n" "-s, --shared Enable shared library loading"
21- printf "%s\n" "-h, --help Print this message and exit"
22- printf "%s\n" "-q8 Compile for Quantum Depth 8 (default)"
23- printf "%s\n" "-q16 Compile for Quantum Depth 16"
24- printf "%s\n" "-q32 Compile for Quantum Depth 32"
25-}
26-
27-DEPTH="Q8"
28-SHARED=0
29-
30-for arg in "$@"
31-do
32- case $arg in
33- "-v" | "--verbose") set -x ;;
34- "-s" | "--shared") SHARED=1 ;;
35- "-h" | "--help") print_usage ; exit 0 ;;
36- "-q16") DEPTH="Q16" ;;
37- "-q32") DEPTH="Q32" ;;
38- *) printf "Unknown option: '%s'.\n" "$arg" ;;
39- esac
40-done
41-
42-# graphicsmagick_c
43-MAGICKD_FILES="$(find ../graphicsmagick_c/src/ -type f -iname '*.d')"
44-# magickd
45-MAGICKD_FILES="$MAGICKD_FILES $(find ../source/ -type f -iname '*.d')"
46-
47-# make sure to rebuild
48-rm -rf "dmd" && mkdir "dmd"
49-
50-DFLAGS="$DFLAGS -version=$DEPTH -I../source"
51-
52-if [ "$(uname -s)" = "Darwin" ]
53-then
54- # MacPorts default install location
55- LDFLAGS="-L-L/opt/local/lib"
56-fi
57-
58-
59-if [ $SHARED -eq 1 ]
60-then
61- DFLAGS="$DFLAGS -version=GMagick_Dynamic"
62-else
63- DFLAGS="$DFLAGS -version=GMagick_Static -Xcc=-lGraphicsMagick -Xcc=-lGraphicsMagickWand"
64-fi
65-
66-for file in ./*.d
67-do
68- dmd "$file" -of="dmd/${file%.*}_dmd" $DFLAGS $MAGICKD_FILES $LDFLAGS
69-done
70-
71-printf "Done compiling for DMD!\n"
--- a/examples/gdc.sh
+++ /dev/null
@@ -1,69 +0,0 @@
1-#!/bin/sh
2-# -----------------------------------------------------------------------------
3-#
4-# This file compiles all the examples in this directory using the GDC compiler.
5-# The version of GDC currently used for testing is GDC 10.2.1 (D v2.076).
6-#
7-# Copyright (C) 2021-2023 by kaerou <stigma@disroot.org>
8-#
9-# Permission to use, copy, modify, and/or distribute this file for any purpose
10-# with or without fee is hereby granted. This file is offered as-is, without
11-# any warranty.
12-#
13-# -----------------------------------------------------------------------------
14-set -e
15-
16-print_usage() {
17- printf "usage: %s [option]\n" $0
18- printf "\n%s\n" "options:"
19- printf "%s\n" "-v, --verbose Enable verbose logging"
20- printf "%s\n" "-s, --shared Enable shared library loading"
21- printf "%s\n" "-h, --help Print this message and exit"
22- printf "%s\n" "-q8 Compile for Quantum Depth 8 (default)"
23- printf "%s\n" "-q16 Compile for Quantum Depth 16"
24- printf "%s\n" "-q32 Compile for Quantum Depth 32"
25-}
26-
27-SHARED=0
28-DEPTH="Q8"
29-
30-if [ "$(uname -s)" = "Darwin" ]
31-then
32- printf "WARN: Use of GDC on macOS is not supported.\n"
33- sleep 3
34-fi
35-
36-for arg in "$@"
37-do
38- case $arg in
39- "-v" | "--verbose") set -x ;;
40- "-s" | "--shared") SHARED=1 ;;
41- "-h" | "--help") print_usage ; exit 0 ;;
42- "-q16") DEPTH="Q16" ;;
43- "-q32") DEPTH="Q32" ;;
44- *) printf "Unknown option: '%s'.\n" "$arg" ;;
45- esac
46-done
47-
48-# graphicsmagick_c
49-MAGICKD_FILES="$(find ../graphicsmagick_c/src/ -type f -iname '*.d')"
50-# magickd
51-MAGICKD_FILES="$MAGICKD_FILES $(find ../source/ -type f -iname '*.d')"
52-
53-rm -rf "gdc" && mkdir "gdc"
54-
55-DFLAGS="$DFLAGS --version=$DEPTH -I../source"
56-
57-if [ $SHARED -eq 1 ]
58-then
59- DFLAGS="$DFLAGS --version=GMagick_Dynamic"
60-else
61- DFLAGS="$DFLAGS --version=GMagick_Static -lGraphicsMagick -lGraphicsMagickWand"
62-fi
63-
64-for file in ./*.d
65-do
66- gdc "$file" -o "gdc/${file%.*}_gdc" $DFLAGS $MAGICKD_FILES
67-done
68-
69-printf "Done compiling for GDC!\n"
--- a/examples/ldc.sh
+++ /dev/null
@@ -1,74 +0,0 @@
1-#!/bin/sh
2-# -----------------------------------------------------------------------------
3-#
4-# This file compiles all the examples in this directory using the LDC2 compiler.
5-# The version of LDC2 currently used for testing is LDC 1.24.0 (D v2.094.1).
6-#
7-# Copyright (C) 2021-2023 by kaerou <stigma@disroot.org>
8-#
9-# Permission to use, copy, modify, and/or distribute this file for any purpose
10-# with or without fee is hereby granted. This file is offered as-is, without
11-# any warranty.
12-#
13-# -----------------------------------------------------------------------------
14-set -e
15-
16-print_usage() {
17- printf "usage: %s [option]\n" $0
18- printf "\n%s\n" "options:"
19- printf "%s\n" "-v, --verbose Enable verbose logging"
20- printf "%s\n" "-s, --shared Enable shared library loading"
21- printf "%s\n" "-h, --help Print this message and exit"
22- printf "%s\n" "-q8 Compile for Quantum Depth 8 (default)"
23- printf "%s\n" "-q16 Compile for Quantum Depth 16"
24- printf "%s\n" "-q32 Compile for Quantum Depth 32"
25-}
26-
27-SHARED=0
28-DEPTH="Q8"
29-
30-for arg in "$@"
31-do
32- case $arg in
33- "-v" | "--verbose") set -x ;;
34- "-s" | "--shared") SHARED=1 ;;
35- "-h" | "--help") print_usage ; exit 0 ;;
36- "-q16") DEPTH="Q16" ;;
37- "-q32") DEPTH="Q32" ;;
38- *) printf "Unknown option: '%s'.\n" "$arg" ;;
39- esac
40-done
41-
42-# graphicsmagick_c
43-MAGICKD_FILES="$(find ../graphicsmagick_c/src/ -type f -iname '*.d')"
44-# magickd
45-#
46-# Small difference with LDC, without specifying -maxdepth it would
47-# result in an IR type mismatch when compiling. Since these examples
48-# no longer use magickd.core or magickd.wand, we don't need to include
49-# those when compiling.
50-MAGICKD_FILES="$MAGICKD_FILES $(find ../source/ -maxdepth 2 -type f -iname '*.d')"
51-
52-rm -rf "ldc" && mkdir "ldc"
53-
54-DFLAGS="$DFLAGS -d-version=$DEPTH -I../source"
55-
56-if [ "$(uname -s)" = "Darwin" ]
57-then
58- # MacPorts default install location
59- LDFLAGS="$LDFLAGS -L-L/opt/local/lib"
60-fi
61-
62-if [ $SHARED -eq 1 ]
63-then
64- DFLAGS="$DFLAGS -d-version=GMagick_Dynamic"
65-else
66- DFLAGS="$DFLAGS -d-version=GMagick_Static -Xcc=-lGraphicsMagick -Xcc=-lGraphicsMagickWand"
67-fi
68-
69-for file in ./*.d
70-do
71- ldc2 "$file" -of="ldc/${file%.*}_ldc" $DFLAGS $MAGICKD_FILES $LDFLAGS
72-done
73-
74-printf "Done compiling for LDC!\n"