Browse Source

+ initial compiler support for WebAssembly resources. Requires WebAssembly
support in the fpcres utility, which is not implemented, yet.

Nikolay Nikolov 1 year ago
parent
commit
440a635bce
5 changed files with 18 additions and 16 deletions
  1. 1 1
      compiler/ngenutil.pas
  2. 12 0
      compiler/rescmn.pas
  3. 1 1
      compiler/systems.inc
  4. 1 12
      compiler/systems/i_wasi.pas
  5. 3 2
      compiler/systems/t_wasi.pas

+ 1 - 1
compiler/ngenutil.pas

@@ -1503,7 +1503,7 @@ implementation
     var
     var
       tcb: ttai_typedconstbuilder;
       tcb: ttai_typedconstbuilder;
     begin
     begin
-      if (target_res.id in [res_elf,res_macho,res_xcoff]) or
+      if (target_res.id in [res_elf,res_macho,res_xcoff,res_wasm]) or
          { generate the FPC_RESLOCATION symbol even when using external resources,
          { generate the FPC_RESLOCATION symbol even when using external resources,
            because in SysInit we can only reference it unconditionally }
            because in SysInit we can only reference it unconditionally }
          ((target_res.id=res_ext) and (target_info.system in systems_darwin)) then
          ((target_res.id=res_ext) and (target_info.system in systems_darwin)) then

+ 12 - 0
compiler/rescmn.pas

@@ -54,6 +54,18 @@ uses
              resflags : [];
              resflags : [];
           );
           );
 
 
+       res_wasm_info : tresinfo =
+          (
+             id     : res_wasm;
+             resbin : 'fpcres';
+             rescmd : '-o $OBJ -a $ARCH -of wasm $DBG';
+             { cross compiled windres can be used to compile .rc files on other platforms }
+             rcbin  : 'windres';
+             rccmd  : '--include $INC -O res -D FPC -o $RES $RC';
+             resourcefileclass : nil;
+             resflags : [];
+          );
+
        res_ext_info : tresinfo =
        res_ext_info : tresinfo =
           (
           (
              id     : res_ext;
              id     : res_ext;

+ 1 - 1
compiler/systems.inc

@@ -353,7 +353,7 @@
             ,res_m68k_palmos,res_m68k_mpw
             ,res_m68k_palmos,res_m68k_mpw
             ,res_powerpc_mpw,res_elf,res_xcoff
             ,res_powerpc_mpw,res_elf,res_xcoff
             ,res_win64_gorc, res_macho, res_ext
             ,res_win64_gorc, res_macho, res_ext
-            ,res_jvm_raw
+            ,res_jvm_raw,res_wasm
        );
        );
 
 
        tresinfoflags = (res_external_file,res_arch_in_file_name
        tresinfoflags = (res_external_file,res_arch_in_file_name

+ 1 - 12
compiler/systems/i_wasi.pas

@@ -29,17 +29,6 @@ unit i_wasi;
        systems,rescmn;
        systems,rescmn;
 
 
     const
     const
-       res_wasmraw_info : tresinfo =
-           (
-             id     : res_none; // todo: not implemented. but could be as memory
-             resbin : 'fpcwasmres';
-             rescmd : '-o $OBJ $DBG';
-             rcbin  : '';
-             rccmd  : '';
-             resourcefileclass : nil;
-             resflags : [res_no_compile];
-           );
-
         system_wasm32_wasi_info : tsysteminfo =
         system_wasm32_wasi_info : tsysteminfo =
           (
           (
             system       : system_wasm32_wasi;
             system       : system_wasm32_wasi;
@@ -82,7 +71,7 @@ unit i_wasi;
             link         : ld_int_wasi;
             link         : ld_int_wasi;
             linkextern   : ld_wasi;
             linkextern   : ld_wasi;
             ar           : ar_none;
             ar           : ar_none;
-            res          : res_none;
+            res          : res_wasm;
             dbg          : dbg_dwarf2;
             dbg          : dbg_dwarf2;
             script       : script_unix;
             script       : script_unix;
             endian       : endian_little;
             endian       : endian_little;

+ 3 - 2
compiler/systems/t_wasi.pas

@@ -90,7 +90,8 @@ implementation
 
 
 uses
 uses
   SysUtils,
   SysUtils,
-  verbose;
+  verbose,
+  comprsrc,rescmn;
 
 
 { timportlibwasi }
 { timportlibwasi }
 
 
@@ -332,5 +333,5 @@ initialization
   RegisterExport(system_wasm32_wasi, texportlibwasi);
   RegisterExport(system_wasm32_wasi, texportlibwasi);
   RegisterLinker(ld_int_wasi,TInternalLinkerWasi);
   RegisterLinker(ld_int_wasi,TInternalLinkerWasi);
   RegisterLinker(ld_wasi, tlinkerwasi);
   RegisterLinker(ld_wasi, tlinkerwasi);
-
+  RegisterRes(res_wasm_info,TWinLikeResourceFile);
 end.
 end.