~nloomans/ft_select

ref: 204227a12fb616f8e6a8874db1d7b233d3c86aba ft_select/normify -rwxr-xr-x 1.0 KiB
204227a1Noah Loomans add normify script 1 year, 9 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
#!/usr/bin/env python3
import os
import sys
import shutil
from glob import glob

os.chdir(sys.path[0])

shutil.rmtree("normified", ignore_errors=True)
os.mkdir("normified")
shutil.copytree("src", "normified/src")
for spec_file in glob("normified/src/*_test.c"):
  os.remove(spec_file)
shutil.copytree("inc", "normified/inc")

os.system("echo $USER > normified/author")
shutil.copy("normify.mk", "normified/Makefile")

os.system("subprojects/libft/normify")
shutil.move("subprojects/libft/normified", "normified/libft")
os.system("subprojects/libftprintf/normify")
shutil.move("subprojects/libftprintf/normified", "normified/libftprintf")

os.chdir("normified")

with open('Makefile', 'r') as fd:
  makefile = fd.read()

src_files = glob("src/**/*.c", recursive=True)
src_files.remove('src/render.c')
src_files.remove('src/render.debug.c')

makefile = makefile.replace(
    "%SRC_DIR%",
    " \\\n".join(src_files))

makefile = makefile.replace(
    "%INC_DIR%",
    " \\\n".join(glob("inc/**/*.h", recursive=True)))

with open('Makefile', 'w') as fd:
  fd.write(makefile)