Forráskód Böngészése

uasm: add package (#7230)

* uasm: add package

* clear

* check mingw

* re

* cl

* check osx

* drop osx

* re-check osx

* re

* fixup

* re

* re

* re

* test without `find`
Saikari 2 hónapja
szülő
commit
38bef97c20

+ 0 - 1
.github/workflows/macos_arm64.yml

@@ -31,7 +31,6 @@ jobs:
           wget https://curl.haxx.se/ca/cacert.pem -O /tmp/cacert.pem
           export CURL_CA_BUNDLE=/tmp/cacert.pem
           sudo ln /opt/homebrew/bin/gfortran-14 /opt/homebrew/bin/gfortran
-          find /opt/homebrew/Cellar/gcc/ -name f951
           export PATH="$PATH:/opt/homebrew/Cellar/gcc/14.2.0/libexec/gcc/aarch64-apple-darwin23/14/"
           export LIBRARY_PATH="$LIBRARY_PATH:/opt/homebrew/Cellar/gcc/14.2.0/lib/gcc/14/"
           export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/homebrew/Cellar/gcc/14.2.0/lib/gcc/14/"

+ 0 - 1
.github/workflows/macos_x86_64.yml

@@ -31,7 +31,6 @@ jobs:
           wget https://curl.haxx.se/ca/cacert.pem -O /tmp/cacert.pem
           export CURL_CA_BUNDLE=/tmp/cacert.pem
           sudo ln /usr/local/bin/gfortran-14 /usr/local/bin/gfortran
-          find /usr/local/Cellar/gcc/ -name f951
           export PATH="$PATH:/usr/local/Cellar/gcc/14.2.0/libexec/gcc/x86_64-apple-darwin21/14/"
           export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/Cellar/gcc/14.2.0/lib/gcc/14/"
           export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/Cellar/gcc/14.2.0/lib/gcc/14/"

+ 16 - 0
packages/u/uasm/patches/fix-bool.diff

@@ -0,0 +1,16 @@
+diff --git a/H/bool.h b/H/bool.h
+index fbf55c8..ddb7396 100644
+--- a/H/bool.h
++++ b/H/bool.h
+@@ -30,10 +30,7 @@
+ ****************************************************************************/
+ 
+ 
+-#if !defined( BOOL_DEFINED )  &&  !defined( bool ) && !(__WATCOMC__ >= 1070 && defined(__cplusplus))
+-    #define BOOL_DEFINED
+-    typedef unsigned char bool;
+-#endif
++#include <stdbool.h>
+ #ifndef TRUE
+     #define TRUE 1
+ #endif

+ 123 - 0
packages/u/uasm/patches/fix-build.diff

@@ -0,0 +1,123 @@
+diff --git a/H/globals.h b/H/globals.h
+index 223d015..953ff41 100644
+--- a/H/globals.h
++++ b/H/globals.h
+@@ -49,6 +49,7 @@
+ #endif
+ #define _ltoa   ltoa
+ #define _strupr strupr
++extern char *strupr(char *);
+ 
+ #elif defined(__POCC__)
+ 
+@@ -946,4 +947,11 @@ extern char             *num2hex64(uint_64 value, char *buffer);
+ extern char             *ConvertSectionName( const struct asym *, enum seg_type *pst, char *buffer );
+ extern void             RewindToWin64(void);
+ 
++extern void CreateMacroLibCases64(void);
++extern void CreateMacroLibCases32(void);
++extern void OutputInterleavedBytes(const unsigned char *pbytes, int len, struct fixup *fixup);
++extern void SymSimd(struct dsym *sym);
++extern void RunLineQueue( void );
++extern ret_code BackPatch( struct asym *sym );
++
+ #endif
+diff --git a/assemble.c b/assemble.c
+index 2ce0e14..a9f2899 100644
+--- a/assemble.c
++++ b/assemble.c
+@@ -43,7 +43,7 @@
+ #include "lqueue.h"
+ #include "orgfixup.h"
+ #include "macrolib.h"
+-//#include "simd.h"
++#include "simd.h"
+ 
+ #if DLLIMPORT
+ #include "mangle.h"
+diff --git a/codegenv2.c b/codegenv2.c
+index 6bcc08d..7063c27 100644
+--- a/codegenv2.c
++++ b/codegenv2.c
+@@ -1,6 +1,7 @@
+ 
+ #include "codegenv2.h"
+ 
++#include <ctype.h>
+ #include <time.h>
+ #include "globals.h"
+ #include "parser.h"
+@@ -12,6 +13,7 @@
+ #include "types.h"
+ #include "macro.h"
+ #include "listing.h"
++#include "input.h"
+ 
+ #define OutputCodeByte( x ) OutputByte( x )
+ 
+diff --git a/macho64.c b/macho64.c
+index 8e74842..8b81d5e 100644
+--- a/macho64.c
++++ b/macho64.c
+@@ -725,7 +725,7 @@ static ret_code macho_write_module( struct module_info *modinfo )
+ 		mm.header.cputype = CPU_TYPE_X86_64;
+ 		mm.header.cpusubtype = CPU_SUBTYPE_LITTLE_ENDIAN | CPU_SUBTYPE_X86_64_ALL;
+ 		mm.header.filetype = MH_OBJECT;
+-		mm.header.flags = NULL;
++		mm.header.flags = 0;
+ 		
+ 		macho_build_structures(modinfo, mm);	
+ 	}
+diff --git a/proc.c b/proc.c
+index a984bb9..16307b3 100644
+--- a/proc.c
++++ b/proc.c
+@@ -162,10 +162,12 @@ struct delphicall_conv {
+ 
+ 
+ static  int ms32_pcheck(struct dsym *, struct dsym *, int *);
++static  int ms32_syspcheck(struct dsym *, struct dsym *, int *, int *);
+ static void ms32_return(struct dsym *, char *);
+ 
+ #if OWFC_SUPPORT
+ static  int watc_pcheck(struct dsym *, struct dsym *, int *);
++static  int watc_syspcheck(struct dsym *, struct dsym *, int *, int *);
+ static void watc_return(struct dsym *, char *);
+ #endif
+ 
+@@ -212,9 +214,9 @@ static const struct vectorcall_conv vectorcall_tab[] = {
+ };
+ 
+ static const struct sysvcall_conv sysvcall_tab[] = {
+-	{ ms32_pcheck, ms32_return },  /* FCT_MSC */
++	{ ms32_syspcheck, ms32_return },  /* FCT_MSC */
+ #if OWFC_SUPPORT		
+-	{ watc_pcheck, watc_return },  /* FCT_WATCOMC */
++	{ watc_syspcheck, watc_return },  /* FCT_WATCOMC */
+ #endif		
+ #if SYSV_SUPPORT		
+ 	{ sysv_pcheck, sysv_return }   /* FCT_WIN64 / SYSTEMV */
+@@ -380,6 +382,11 @@ static int watc_pcheck(struct dsym *proc, struct dsym *paranode, int *used)
+ 	return(1);
+ }
+ 
++static int watc_syspcheck(struct dsym *proc, struct dsym *paranode, int *used, int *vecused)
++{
++	return watc_pcheck(proc, paranode, used);
++}
++
+ static void watc_return(struct dsym *proc, char *buffer)
+ /********************************************************/
+ {
+@@ -433,6 +440,11 @@ static int ms32_pcheck(struct dsym *proc, struct dsym *paranode, int *used)
+ 	return(1);
+ }
+ 
++static int ms32_syspcheck(struct dsym *proc, struct dsym *paranode, int *used, int *vecused)
++{
++	return ms32_pcheck(proc, paranode, used);
++}
++
+ static void ms32_return(struct dsym *proc, char *buffer)
+ /********************************************************/
+ {

+ 73 - 0
packages/u/uasm/patches/fix-esc-seq.diff

@@ -0,0 +1,73 @@
+diff --git a/tokenize.c b/tokenize.c
+index cb71c11..5662ef3 100644
+--- a/tokenize.c
++++ b/tokenize.c
+@@ -1333,28 +1333,28 @@ int Tokenize( char *line, unsigned int start, struct asm_tok tokenarray[], unsig
+                 ;//OK QWORD
+               else
+                 goto nobcst;                       /* let parser throw error */
+-              if (*input1 != '\[') {               /* if address is not inside [] */
+-                *p1++ = '\[';                      /* force it   */
++              if (*input1 != '[') {               /* if address is not inside [] */
++                *p1++ = '[';                      /* force it   */
+                 for (; *input1 > ','; p1++, input1++) {  /* input1 points to [address] */
+                   if (*input1 == ';') 
+                     break;
+                   *p1 = *input1;                     /* copy first memory part over 'qword bcst */
+                 }
+-                *p1++ = '\]';
++                *p1++ = ']';
+                 if (*input1 == ';')
+                   *input1 = 0;
+                 while (isspace(*input1)) input1++;   /* skip the space, now pointing to address  */
+               }
+               else {
+-                for (; *input1 != '\]'; p1++, input1++) /* input1 points to [address] */
++                for (; *input1 != ']'; p1++, input1++) /* input1 points to [address] */
+                   *p1 = *input1;                     /* copy first memory part over 'qword bcst */
+                 *p1++ = *input1++;                   /* copy ']' */
+               }
+               /* now add broadcast size */
+-              if (cnt == 2)       strcpy(p1, "\{1to2\}");
+-              else if (cnt == 4)  strcpy(p1, "\{1to4\}");
+-              else if (cnt == 8)  strcpy(p1, "\{1to8\}");
+-              else if (cnt == 16) strcpy(p1, "\{1to16\}");
++              if (cnt == 2)       strcpy(p1, "{1to2}");
++              else if (cnt == 4)  strcpy(p1, "{1to4}");
++              else if (cnt == 8)  strcpy(p1, "{1to8}");
++              else if (cnt == 16) strcpy(p1, "{1to16}");
+               else goto nobcst;                   /* let parser throw error */
+               strcat(p1, input1);
+             }
+@@ -1364,24 +1364,24 @@ int Tokenize( char *line, unsigned int start, struct asm_tok tokenarray[], unsig
+                 if (*p1 == ';') {                        /* found  ';' */
+                   *p1 = 0;                             /* that means '{' is in comment */
+                 }
+-                if (*p1 == '\{') {                     /* found  '{' */
+-                  if ((_memicmp(p1, "\{1to", 4) == 0))
++                if (*p1 == '{') {                     /* found  '{' */
++                  if ((_memicmp(p1, "{1to", 4) == 0))
+                     break;                             /* found "bcst" */
+                 }                                      /* if it was {kn} or {z} search till end */
+               }
+-              if (*p1 == '\{') {                       /* if found {1toN} */
++              if (*p1 == '{') {                       /* if found {1toN} */
+                 p1--;                                  /* go back 1 byte to check if ']' is present */
+                 while (isspace(*p1)) --p1;             /* skip the space  */
+-                if (*p1 != '\]') {                     /* if not present insert it  */
++                if (*p1 != ']') {                     /* if not present insert it  */
+                   while (*p1 != ',') --p1;             /* step backwards till the comma */
+                   p1++;                                /* skip the comma forward  */
+                   input1 = p1;                         /* save that location in input1  */
+                   while (isspace(*p1)) p1++;           /* skip the space  */
+                   strcpy(buff, p1);                    /* copy to the buffer from variable on  */
+-                  *input1++ = '\[';                    /* skip the space  */
+-                  for (p1 = buff; *p1 != '\{'; p1++, input1++) /* till the end of var  */
++                  *input1++ = '[';                    /* skip the space  */
++                  for (p1 = buff; *p1 != '{'; p1++, input1++) /* till the end of var  */
+                     *input1 = *p1;                      /* copy it back to input string  */
+-                  *input1++ = '\]';                    /* insert ']' before '{' */
++                  *input1++ = ']';                    /* insert ']' before '{' */
+                   strcpy(input1, p1);                  /* now copy the rest of string from buffer */
+                 }
+               }

+ 65 - 0
packages/u/uasm/patches/uint64-fix.diff

@@ -0,0 +1,65 @@
+diff --git a/CodeGenV2_WIP/codegenv2.c b/CodeGenV2_WIP/codegenv2.c
+index e6460a8..19807ae 100644
+--- a/CodeGenV2_WIP/codegenv2.c
++++ b/CodeGenV2_WIP/codegenv2.c
+@@ -34,7 +34,7 @@ struct Instr_Def* InstrHash[16384];
+ static unsigned int hash(const uint_8* data, int size)
+ /******************************************/
+ {
+-	uint_64 fnv_basis = 14695981039346656037;
++	uint_64 fnv_basis = 14695981039346656037ULL;
+ 	uint_64 register fnv_prime = 1099511628211;
+ 	uint_64 h = fnv_basis;
+ 	int cnt = 0;
+diff --git a/codegenv2.c b/codegenv2.c
+index 6bcc08d..9558fe3 100644
+--- a/codegenv2.c
++++ b/codegenv2.c
+@@ -34,7 +34,7 @@ struct Instr_Def* InstrHash[16384];
+ static unsigned int hash(const uint_8* data, int size)
+ /******************************************/
+ {
+-	uint_64 fnv_basis = 14695981039346656037;
++	uint_64 fnv_basis = 14695981039346656037ULL;
+ 	uint_64 register fnv_prime = 1099511628211;
+ 	uint_64 h = fnv_basis;
+ 	int cnt = 0;
+diff --git a/invoke.c b/invoke.c
+index 750bd64..bdc40cb 100644
+--- a/invoke.c
++++ b/invoke.c
+@@ -3192,7 +3192,7 @@ static int ParamIsString(char *pStr, int param, struct dsym* proc) {
+ static unsigned int hashpjw(const char *s)
+ /******************************************/
+ {
+-	uint_64 fnv_basis = 14695981039346656037;
++	uint_64 fnv_basis = 14695981039346656037ULL;
+ 	uint_64 register fnv_prime = 1099511628211;
+ 	uint_64 h;
+ 	for (h = fnv_basis; *s; ++s) {
+diff --git a/reswords.c b/reswords.c
+index 03273f9..e16836d 100644
+--- a/reswords.c
++++ b/reswords.c
+@@ -970,7 +970,7 @@ static bool  b64bit = FALSE; /* resw tables in 64bit mode? */
+ static unsigned get_hash(const char *s, unsigned char size)
+ /***********************************************************/
+ {
+-  uint_64 fnv_basis = 14695981039346656037;
++  uint_64 fnv_basis = 14695981039346656037ULL;
+   uint_64 register fnv_prime = 1099511628211;
+   uint_64 h;
+   for (h = fnv_basis; size; size--) {
+diff --git a/symbols.c b/symbols.c
+index 1b28fa8..e05e1c2 100644
+--- a/symbols.c
++++ b/symbols.c
+@@ -155,7 +155,7 @@ static bool structLookup = FALSE;
+ static unsigned int hashpjw( const char *s )
+ /******************************************/
+ {
+-	uint_64 fnv_basis = 14695981039346656037;
++	uint_64 fnv_basis = 14695981039346656037ULL;
+ 	uint_64 register fnv_prime = 1099511628211;
+ 	uint_64 h;
+ 	for (h = fnv_basis; *s; ++s) {

+ 60 - 0
packages/u/uasm/ports/osx64.mak

@@ -0,0 +1,60 @@
+
+# This makefile creates the UASM binary for macOS 64-bit
+
+TARGET1=uasm
+
+ifndef DEBUG
+DEBUG=0
+endif
+
+inc_dirs  = -IH
+
+#cflags stuff
+
+ifeq ($(DEBUG),0)
+extra_c_flags = -DNDEBUG -O3 -Wno-parentheses -Wno-pointer-sign -Wno-switch -Wno-comment -Wno-unsequenced -Wno-enum-conversion -Wno-incompatible-pointer-types
+#-funsigned-char -fwritable-strings
+OUTD=GccUnixR
+else
+extra_c_flags = -DDEBUG_OUT -g
+OUTD=GccUnixD
+endif
+
+c_flags = -D __UNIX__ $(extra_c_flags)
+
+.SUFFIXES:
+.SUFFIXES: .c .o
+
+include gccmod.inc
+
+#.c.o:
+#	$(CC) -c $(inc_dirs) $(c_flags) -o $(OUTD)/$*.o $<
+$(OUTD)/%.o: %.c
+	$(CC) -c $(inc_dirs) $(c_flags) -o $(OUTD)/$*.o $<
+
+all:  $(OUTD) $(OUTD)/$(TARGET1)
+
+$(OUTD):
+	mkdir $(OUTD)
+
+$(OUTD)/$(TARGET1) : $(OUTD)/main.o $(proj_obj)
+ifeq ($(DEBUG),0)
+	$(CC) -D __UNIX__ $(OUTD)/main.o $(proj_obj) -o $@ -Wl,-S,-dead_strip,-dead_strip_dylibs
+	strip -x $@
+else
+	$(CC) -D __UNIX__ $(OUTD)/main.o $(proj_obj) -o $@ -Wl
+endif
+
+$(OUTD)/msgtext.o: msgtext.c H/msgdef.h
+	$(CC) -c $(inc_dirs) $(c_flags) -o $*.o msgtext.c
+
+$(OUTD)/reswords.o: reswords.c H/instruct.h H/special.h H/directve.h H/opndcls.h H/instravx.h
+	$(CC) -c $(inc_dirs) $(c_flags) -o $*.o reswords.c
+
+######
+
+clean:
+	rm -f $(OUTD)/$(TARGET1)
+	rm -f $(OUTD)/*.o
+	rm -f $(OUTD)/*.map
+

+ 58 - 0
packages/u/uasm/xmake.lua

@@ -0,0 +1,58 @@
+package("uasm")
+    set_kind("binary")
+    set_homepage("http://www.terraspace.co.uk/uasm.html")
+    set_description("UASM - Macro Assembler")
+
+    add_urls("https://github.com/Terraspace/UASM/archive/refs/tags/$(version).tar.gz",
+             "https://github.com/Terraspace/UASM.git")
+
+    add_versions("v2.57r", "09fa69445f2af47551e82819d024e6b4b629fcfd47af4a22ccffbf37714230e5")
+
+    if not is_plat("windows") then
+        add_patches("v2.57r", "patches/fix-bool.diff", "91a6b4634fab3fb3991a372c845247bd895ea3d2de104d3687eb6e2c61e44e39")
+        add_patches("v2.57r", "patches/fix-build.diff", "840a36bf7200941cd98331245a5b7b71f9ee56a912b4c10c255498c6f7c89d45")
+        add_patches("v2.57r", "patches/fix-esc-seq.diff", "4011194c59f87b5be798b4e85dca869e3a3f7ddf2b0fc4f8b3b26190df1abca3")
+        add_patches("v2.57r", "patches/uint64-fix.diff", "ea6bab7192894fc673b55b9ead67cf1eb0046cd34c425f33781e167097988662")
+    end
+
+    on_install("macosx", function (package)
+        os.cp(path.join(package:scriptdir(), "ports", "osx64.mak"), "osx64.mak")
+        local configs = { "-f", "osx64.mak", "CC=clang"}
+        import("package.tools.make").install(package, configs)
+        os.cp("GccUnixR/uasm", path.join(package:installdir("bin"), "uasm"))
+    end)
+
+    on_install("msys", "mingw@macosx,linux,windows,msys", function (package)
+        local configs = { "-f", "Makefile-DOS-GCC.mak", "CC=gcc -c -IH -std=gnu11 -funsigned-char -fcommon -Wno-implicit-function-declaration -Wno-incompatible-pointer-types"}
+        import("package.tools.make").install(package, configs)
+        os.cp("*/hjwasm.exe", path.join(package:installdir("bin"), "uasm.exe"))
+    end)
+
+    on_install("@windows", function (package)
+        import("package.tools.msbuild")
+        local arch = package:is_arch("x64") and "x64" or "Win32"
+        if package:is_arch("arm64") then
+            arch = "ARM64"
+            io.replace("UASM.sln", "|x64", "|ARM64", {plain = true})
+        end
+        local mode = package:is_debug() and "Debug" or "Release"
+        local configs = { "UASM.sln" }
+        table.insert(configs, "/p:Configuration=" .. mode)
+        table.insert(configs, "/p:Platform=" .. arch)
+        if package:is_arch("arm64") then
+            io.replace("UASM.vcxproj", "|x64", "|ARM64", {plain = true})
+            io.replace("UASM.vcxproj", "<Platform>x64", "<Platform>ARM64", {plain = true})
+        end
+        if package:has_runtime("MT", "MTd") then
+            -- Allow MT, MTd
+            io.replace("UASM.vcxproj", "<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>", "<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>", {plain = true})
+            io.replace("UASM.vcxproj", "<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>", "<RuntimeLibrary>MultiThreaded</RuntimeLibrary>", {plain = true})
+        end
+        io.replace("UASM.vcxproj", [[<Command>regress\runtestsVS.cmd</Command>]], [[]], {plain = true})
+        msbuild.build(package, configs)
+        os.cp("*/*/UASM.exe", path.join(package:installdir("bin"), "uasm.exe"))
+    end)
+
+    on_test(function (package)
+        os.vrun("uasm -h")
+    end)