Debian Codegraph @

fatify

raw symbols SCIP
1 #! /bin/shscip-shell filesystem . . `/bin/sh`.
2 #
3 # This script is a part of Cgreen and creates fat versions of
4 # cgreen-runner and libcgreen.dylib which is necessary if you are
5 # using e.g. Homebrew/MacPorts gcc which don't have suppport for fat
6 # binaries built in.
7 #
8 # NOTE: This does not work completely automatic for x86_64/M1 since
9 # Homebrew GCC can only compile for the current architecture.
10 #
11 # Since automatically ensuring that both architectures are built is
12 # currently impossible from a single environment, you have to run this
13 # script once on each architecture. The script will save the built
14 # binaries under descriptive names and if it discovers that binaries
15 # for the other architecture already exists it uses lipo to merge them
16 # into fat binaries.
17 #
18 # At this point there is no way to run this as part of the CMake build
19 # and install, and since the install target of CMake always rebuilds
20 # you can't install them except with manual copying.
21 #
22 # /thoni56
23 #
24 function buildforscip-shell shell shell-project 0.0.0 buildfor().() {
25 rmscip-shell system . . rm. -rf build
26 makescip-shell system . . make.
27 cpscip-shell system . . cp. build/tools/cgreen-runner cgreen-runner.$1
28 cpscip-shell system . . cp. build/src/libcgreen.dylib libcgreen.$1.dylib
29 }
30 arch=`archscip-shell system . . arch.`
31 if [scip-shell system . . `[`. $arch == "arm64" ] ; then
32 buildforscip-shell shell shell-project 0.0.0 buildfor(). arm64
33 if [scip-shell system . . `[`. ! -f libcgreen.x86_64.dylib ] ; then
34 echoscip-shell system . . echo. "You need to run this aldo in an x86_64 environment to create fat binaries."
35 exit
36 fi
37 else
38 buildforscip-shell shell shell-project 0.0.0 buildfor(). x86_64
39 if [scip-shell system . . `[`. ! -f libcgreen.arm64.dylib ] ; then
40 echoscip-shell system . . echo. "You need to run this in an arm64 environment to create fat binaries."
41 exit
42 fi
43 fi
44
45 lipo -create -o cgreen-runner -arch arm64 cgreen-runner.arm64 -arch x86_64 cgreen-runner.x86_64
46 lipo -create -o libcgreen.dylib -arch arm64 libcgreen.arm64.dylib -arch x86_64 libcgreen.x86_64.dylib
47
48 if [scip-shell system . . `[`. -z "$1" ] ; then
49 echoscip-shell system . . echo. "Fat binaries of cgreen-runner and libcgreen.dylib built:"
50 filescip-shell system . . file. cgreen-runner libcgreen.dylib
51 echoscip-shell system . . echo. "Install with:"
52 echoscip-shell system . . echo. " sudo cp cgreen-runner <installpath>/bin/cgreen-runner"
53 echoscip-shell system . . echo. " sudo cp libcgreen.dylib <installpath>/lib/libcgreen.dylib"
54 echoscip-shell system . . echo.
55 echoscip-shell system . . echo. "If <installpath> is the same for bin and lib, such as '/usr/local',"
56 echoscip-shell system . . echo. "you can give that as an argument and the script will do that for you."
57 else
58 echoscip-shell system . . echo. "Installing fat 'cgreen-runner' in $1/bin and 'libcgreen.dylib' in $1/lib..."
59 sudoscip-shell system . . sudo. cp cgreen-runner $1/bin/cgreen-runner
60 sudoscip-shell system . . sudo. cp libcgreen.dylib $1/lib/libcgreen.dylib
61 fi