summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin.mock/packages/symly/package.py
blob: ce3a4696f16de5ce1047ea3f5c347cc5416f5d1d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)


import os
import sys

from spack import *


class Symly(Package):
    """A toy package full of symlinks."""

    homepage = "https://www.example.com"
    has_code = False
    version('3.0.0')

    def install(self, spec, prefix):
        symly_c = '''
#include <stdio.h>

int main() {
    printf("I'm just here to give the build system something to do...");
    return 0;
}
'''
        mkdirp('%s/symly' % self.stage.source_path)
        with open('%s/symly/symly.c' % self.stage.source_path, 'w') as f:
            f.write(symly_c)
        gcc = which('/usr/bin/gcc')
        if sys.platform == 'darwin':
            gcc = which('/usr/bin/clang')
        mkdirp(prefix.bin)
        mkdirp(prefix.lib64)
        gcc('-o', 'symly.bin',
            'symly/symly.c')
        print("prefix.bin", prefix.bin)
        copy('symly.bin', '%s/symly' % prefix.bin)
        # create a symlinked file.
        os.symlink('%s/symly' % prefix.bin,
                   '%s/symly' % prefix.lib64)
        # Create a symlinked directory.
        os.symlink(prefix.bin, prefix.include)