~emersion/gyosu

ref: bcc2eda9ba1b7292700f6ac32190f9ab6f89c05a gyosu/cc.go -rw-r--r-- 1023 bytes
bcc2eda9Simon Ser ci: add .build.yml 4 months ago
                                                                                
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
46
47
48
49
50
51
package main

import (
	"fmt"
	"strings"
)

const builtin = `
#define __builtin_va_list void *
#define __asm(x)
#define __inline
#define __inline__
#define __signed
#define __signed__
#define __const const
#define __extension__
#define __attribute__(x)
#define __attribute(x)
#define __restrict
#define __volatile__
#define __builtin_inff() (0)
#define __builtin_infl() (0)
#define __builtin_inf() (0)
#define __builtin_fabsf(x) (0)
#define __builtin_fabsl(x) (0)
#define __builtin_fabs(x) (0)
#define __INTRINSIC_PROLOG(name)
#define __typeof
#define __typeof__
`

func generateDefines(D []string) string {
	var sb strings.Builder
	for _, def := range D {
		split := strings.SplitN(def, "=", 2)
		if len(split) == 2 {
			fmt.Fprintf(&sb, "#define %v %v\n", split[0], split[1])
		} else {
			fmt.Fprintf(&sb, "#define %v 1\n", def)
		}
	}
	return sb.String()
}

func generateUndefines(U []string) string {
	var sb strings.Builder
	for _, undef := range U {
		fmt.Fprintf(&sb, "#undef %s\n", undef)
	}
	return sb.String()
}