diff options
| author | ruki <[email protected]> | 2020-02-26 22:49:57 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-02-26 10:59:44 +0800 |
| commit | 1cfb98b4e65d73ccddcb396a510f1ffa9d1f28ac (patch) | |
| tree | a428af1defd84244b35cdc556d607a9a473c4b11 | |
| parent | 33183c28a74286f34d81b228c91b616af17a1db7 (diff) | |
readlink from programfile
| -rw-r--r-- | core/makefile | 8 | ||||
| -rw-r--r-- | core/src/xmake/machine.c | 14 | ||||
| -rw-r--r-- | makefile | 8 |
3 files changed, 21 insertions, 9 deletions
diff --git a/core/makefile b/core/makefile index 3f1746943..94a9d60a4 100644 --- a/core/makefile +++ b/core/makefile @@ -170,6 +170,10 @@ ARCH :=$(if $(findstring macosx,$(PLAT)),x$(shell getconf LONG_BIT),$(ARCH)) ARCH :=$(if $(findstring linux,$(PLAT)),x$(shell getconf LONG_BIT),$(ARCH)) ARCH :=$(if $(findstring iphoneos,$(PLAT)),armv7,$(ARCH)) ARCH :=$(if $(findstring android,$(PLAT)),armv7,$(ARCH)) +ARCH :=$(if $(findstring any,$(ARCH)),i386,$(ARCH)) # from msys/PKGBUILD +ARCH :=$(if $(findstring i686,$(ARCH)),i386,$(ARCH)) # from msys/mingw32 +ARCH :=$(if $(findstring x32,$(ARCH)),i386,$(ARCH)) +ARCH :=$(if $(findstring x64,$(ARCH)),x86_64,$(ARCH)) # for arm linux? ifeq ($(PLAT),linux) @@ -180,10 +184,6 @@ ARCH := $(if $(findstring armv7,$(ARCHSTR)),armv7,$(ARCH)) ARCH := $(if $(findstring arm,$(ARCHSTR)),arm,$(ARCH)) endif endif -ARCH :=$(if $(findstring any,$(ARCH)),i386,$(ARCH)) # from msys/PKGBUILD -ARCH :=$(if $(findstring i686,$(ARCH)),i386,$(ARCH)) # from msys/mingw32 -ARCH :=$(if $(findstring x32,$(ARCH)),i386,$(ARCH)) -ARCH :=$(if $(findstring x64,$(ARCH)),x86_64,$(ARCH)) # debug DEBUG :=$(if $(DEBUG),$(DEBUG),n) diff --git a/core/src/xmake/machine.c b/core/src/xmake/machine.c index f086dd17f..f9a908c23 100644 --- a/core/src/xmake/machine.c +++ b/core/src/xmake/machine.c @@ -34,6 +34,7 @@ # include <io.h> # include <fcntl.h> #elif defined(TB_CONFIG_OS_MACOSX) +# include <unistd.h> # include <mach-o/dyld.h> #elif defined(TB_CONFIG_OS_LINUX) # include <unistd.h> @@ -494,9 +495,20 @@ static tb_bool_t xm_machine_get_program_directory(xm_machine_t* machine, tb_char // get it from program file path if (programfile) { + // get real program file path from the symbol link +#ifndef TB_CONFIG_OS_WINDOWS + tb_char_t programpath[TB_PATH_MAXN]; + tb_long_t size = readlink(programfile, programpath, sizeof(programpath)); + if (size >= 0 && size < sizeof(programpath)) + programpath[size] = '\0'; + else tb_strlcpy(programpath, programfile, sizeof(programpath)); +#else + tb_char_t const* programpath = programfile; +#endif + // get the root directory tb_char_t data[TB_PATH_MAXN]; - tb_char_t const* rootdir = tb_path_directory(programfile, data, sizeof(data)); + tb_char_t const* rootdir = tb_path_directory(programpath, data, sizeof(data)); tb_assert_and_check_break(rootdir); // find the program (lua) directory @@ -45,6 +45,10 @@ ARCH :=$(if $(findstring macosx,$(PLAT)),x$(shell getconf LONG_BIT),$(ARCH)) ARCH :=$(if $(findstring linux,$(PLAT)),x$(shell getconf LONG_BIT),$(ARCH)) ARCH :=$(if $(findstring iphoneos,$(PLAT)),armv7,$(ARCH)) ARCH :=$(if $(findstring android,$(PLAT)),armv7,$(ARCH)) +ARCH :=$(if $(findstring any,$(ARCH)),i386,$(ARCH)) # from msys/PKGBUILD +ARCH :=$(if $(findstring i686,$(ARCH)),i386,$(ARCH)) # from msys/mingw32 +ARCH :=$(if $(findstring x32,$(ARCH)),i386,$(ARCH)) +ARCH :=$(if $(findstring x64,$(ARCH)),x86_64,$(ARCH)) # for arm linux? ifeq ($(PLAT),linux) @@ -55,10 +59,6 @@ ARCH := $(if $(findstring armv7,$(ARCHSTR)),armv7,$(ARCH)) ARCH := $(if $(findstring arm,$(ARCHSTR)),arm,$(ARCH)) endif endif -ARCH :=$(if $(findstring any,$(ARCH)),i386,$(ARCH)) # from msys/PKGBUILD -ARCH :=$(if $(findstring i686,$(ARCH)),i386,$(ARCH)) # from msys/mingw32 -ARCH :=$(if $(findstring x32,$(ARCH)),i386,$(ARCH)) -ARCH :=$(if $(findstring x64,$(ARCH)),x86_64,$(ARCH)) # conditionally map ARCH from amd64 to x86_64 if set from the outside # |
