gdjn  Diff

Differences From Artifact [ab479c70d3]:

To Artifact [3ece26026f]:


    25     25   #   form.
    26     26   #
    27     27   # * ["ext] is a Keter-class high-security containment unit for
    28     28   #   Other People's Code.
    29     29   #
    30     30   # * ["lib] contains (mostly janet) code that will be included
    31     31   #   as blobs in the binary. janet code will be able to import
    32         -#   them. these will be compiled down to .jimage files and
           32  +#   them. these will be compiled into the api.jimage file and
    33     33   #   then bundled into rsrc.o. libraries used in ["tool/*] 
    34         -#   should only be placed in this directory if they are also
    35         -#   used at runtime in the godot environment (e.g. the OOP
    36         -#   macros). library code used only by tools belongs in the
    37         -#   tool directory.
           34  +#   should only be placed in ["lib] if they are also used at
           35  +#   runtime in the godot environment (e.g. the OOP macros).
           36  +#   library code used only by tools belongs in the tool
           37  +#   directory.
    38     38   #
    39     39   # * ["out] contains all live binaries and object files.
    40     40   
    41     41   godot = godot4
    42     42   godot.flags = --headless
    43     43   godot.cmd = "$(godot)" $(godot.flags)
    44     44   janet = $o/janet
    45     45   git = git
    46     46   git.flags.clone = --depth=1
    47     47   
    48     48   janet.src.path = $x/janet
    49     49   janet.src.git = https://github.com/janet-lang/janet.git
    50     50   janet.root = $x/janet/src
    51         -janet.cfg = 
           51  +janet.cfgfile = $s/janetconf.h
           52  +janet.cfg = JANETCONF_HEADER=$(realpath janet.cfgfile)
           53  +janet.cc.bin = -D_gdjn_shims
           54  +janet.cc.lib = 
    52     55   
    53     56   cc.link = -flto
    54     57   cc.comp = -fPIC
    55     58   
    56     59   ifeq ($(debug),1)
    57         -    cc.link += -g
    58         -    cc.comp += -g -O0
           60  +    cc.link += -g 
           61  +    cc.comp += -g -O0 -Wall -D_gdjn_build_debug
           62  +    ifndef feat.editor
           63  +        feat.editor = 1
           64  +    endif
           65  +else
           66  +    cc.comp += -D_gdjn_build_release
           67  +endif
           68  +
           69  +# are we building with editor support?
           70  +ifeq ($(feat.editor),1)
           71  +	cc.comp += -D_gdjn_build_editor
    59     72   endif
    60     73   
    61     74   cc.gdjn.comp = $(cc.comp) \
    62     75   	-std=gnu23 \
    63     76   	-I"$g" \
    64     77   	-I"$s" \
    65     78   	-I"$(janet.root)/include" \
................................................................................
    82     95   
    83     96   .PHONY: all clean purge
    84     97   all: $o/gdjn.so 
    85     98   clean:
    86     99   	rm "$o/"*.o "$g/"*.{jimage,h} "$o/gdjn.so"
    87    100   purge:
    88    101   	rm "$o/"* "$g/"*
          102  +	$(MAKE) -C "$(janet.src.path)" clean
    89    103   
    90    104   %/:; $(path-ensure)
    91    105   %: | $(@D)/
    92    106   
    93    107   tags: .
    94    108   	find "$s" "$g" -name "*.h" -o -name "*.c" | xargs ctags
    95    109   
    96         -$o/gdjn.so: $o/gdjn.o $o/rsrc.o $o/interface.o \
          110  +$o/gdjn.so: $o/gdjn.o $o/rsrc.o $o/interface.o $o/vm.o \
    97    111               $o/janet-lang.o $o/janet-rsrc.o \
    98    112   			$o/libjanet.a 
    99    113   	"$(cc)" $(cc.gdjn.link) $^ -o"$@"
   100    114   
   101    115   $o/interface.o: $t/c-bind-gen.janet \
   102    116                   $g/interface.h \
   103    117   				$(gd_api_spec) \
   104         -				$(gd_api_iface)
          118  +				$(gd_api_iface) \
          119  +				$(janet)
   105    120   	"$(janet)" "$<" loader | "$(cc)" $(cc.gdjn.comp) -c -xc - -o "$@"
   106    121   
   107    122   $g/interface.h: $t/c-bind-gen.janet \
   108         -				$(gd_api_spec)
          123  +				$(gd_api_spec) \
          124  +				$(janet)
   109    125   	"$(janet)" "$<" header >"$@"
   110    126   
   111         -$g/%.h: $s/%.gcd $t/class-compile.janet $(realpath $(janet))
          127  +$g/%.h: $s/%.gcd $t/class-compile.janet $(janet)
   112    128   	"$(janet)" "$t/class-compile.janet" "$<" header >"$@"
   113         -$o/%.o: $s/%.gcd $g/%.h $t/class-compile.janet $(realpath $(janet))
          129  +$o/%.o: $s/%.gcd $g/%.h $s/gdjn.h $g/interface.h $t/class-compile.janet $(janet)
   114    130   	"$(janet)" "$t/class-compile.janet" "$<" loader \
   115    131   		| "$(cc)" $(cc.gdjn.comp) -c -xc - -o "$@"
   116    132   
   117         -$o/%.o: $s/%.c $s/%.h $(realpath $(janet.root)/include/janet.h)
          133  +$o/%.o: $s/%.c $s/%.h $(janet.root)/include/janet.h
   118    134   	"$(cc)" -c $(cc.gdjn.comp) "$<" -o"$@"
   119    135   
   120         -$o/rsrc.o: $t/rsrc.janet $(realpath $(janet)) \
          136  +$o/rsrc.o: $t/rsrc.janet $(janet) \
   121    137              $g/api.jimage
   122    138   	"$(janet)" "$<" -- "$g/api.jimage"
   123    139   
   124         -%.jimage: $(realpath $(janet))
          140  +%.jimage: $(janet)
   125    141   
   126         -$g/api.jimage: $t/api-compile.janet $(gd_api_spec)
   127         -	"$(janet)" "$<" "$(gd_api_spec)" "$@"
   128         -
   129         -$g/%.jimage: $l/%.janet
   130         -	"$(janet)" -c "$<" "$@"
          142  +$g/api.jimage: $t/api-compile.janet $(wildcard $l/*.janet) $(janet)
          143  +	"$(janet)" "$<" "$@"
   131    144   
   132    145   $x/janet $x/janet/src/include/janet.h:
   133    146   	"$(git)" $(git.flags) clone $(git.flags.clone) "$(janet.src.git)" "$x/janet"
   134    147   
   135    148   canon = $(realpath $(dir $1))/$(notdir $1)
   136    149   define janet.build =
   137    150   	"$(MAKE)" -C "$(janet.src.path)" "$(call canon,$@)" \
   138    151   		JANET_$1="$(call canon,$@)"    \
          152  +		CFLAGS+="-O2 -g $(janet.cc) $(janet.cc.$2)" \
   139    153   		$(janet.cfg)
   140    154   endef
   141    155   
   142    156   $o/libjanet.a: $(janet.src.path)
   143         -	$(call janet.build,STATIC_LIBRARY)
          157  +	$(call janet.build,STATIC_LIBRARY,lib)
   144    158   $o/janet: $(janet.src.path)
   145         -	$(call janet.build,TARGET)
          159  +	$(call janet.build,TARGET,bin)
   146    160   
   147    161   $g/extension_api.json $g/gdextension_interface.h:
   148    162   	cd "$g" && $(godot.cmd) --dump-extension-api-with-docs \
   149    163   	                        --dump-gdextension-interface
   150    164   
   151    165   
   152    166   # individual dependencies
   153    167   
   154    168   janet-header = $(janet.root)/include/janet.h
   155    169   
   156         -$o/gdjn.o: $s/util.h $g/interface.h $g/janet-lang.h $g/janet-rsrc.h $(gd_api_iface)
   157         -$o/janet-lang.o: $s/util.h $(janet-header)
   158         -$o/janet-rsrc.o: $s/util.h $g/janet-lang.h $(janet-header)
          170  +$o/gdjn.o: $s/util-gd.h $s/type.h $g/interface.h $g/janet-lang.h $g/janet-rsrc.h $(gd_api_iface)
          171  +$o/janet-lang.o $g/janet-lang.h: $s/util-gd.h $s/type.h $s/util-jn.h $(janet-header)
          172  +$o/janet-rsrc.o $g/janet-rsrc.h: $s/util-gd.h $s/type.h $s/util-jn.h $g/janet-lang.h $(janet-header)
          173  +$o/vm.o: $s/util-jn.h