Permalink
Browse files

MacOS compatibility changes + file permissions

- File and directory permissions changed to 755 and 644
- Simpler extension loading with dlsym() on MacOS
  • Loading branch information...
1 parent 3ad0116 commit 3efc31d74cc3d0f2873bd825df19fa90f430c42f @chsc committed Apr 15, 2012
Showing with 4 additions and 16 deletions.
  1. +2 −2 download.go
  2. +2 −14 generator.go
View
@@ -40,11 +40,11 @@ func DownloadFile(baseURL, fileName, outDir string) error {
if err != nil {
return err
}
- err = os.MkdirAll(absPath, 0666)
+ err = os.MkdirAll(absPath, 0755)
if err != nil {
return err
}
- err = ioutil.WriteFile(filepath.Join(absPath, fileName), data, 0666)
+ err = ioutil.WriteFile(filepath.Join(absPath, fileName), data, 0644)
if err != nil {
return err
}
View
@@ -69,8 +69,7 @@ func writePackage(w io.Writer, packageName string, pak *Package, functsInfo *Fun
fmt.Fprintf(w, "// #include <stdlib.h>\n")
fmt.Fprintf(w, "// #if defined(__APPLE__)\n")
- fmt.Fprintf(w, "// #include <mach-o/dyld.h>\n")
- fmt.Fprintf(w, "// #include <string.h>\n")
+ fmt.Fprintf(w, "// #include <dlfcn.h>\n")
fmt.Fprintf(w, "// #elif defined(_WIN32)\n")
fmt.Fprintf(w, "// #define WIN32_LEAN_AND_MEAN 1\n")
fmt.Fprintf(w, "// #include <windows.h>\n")
@@ -116,18 +115,7 @@ func writePackage(w io.Writer, packageName string, pak *Package, functsInfo *Fun
fmt.Fprintf(w, "// void* goglGetProcAddress(const char* name) { \n")
fmt.Fprintf(w, "// #ifdef __APPLE__\n")
- fmt.Fprintf(w, "// NSSymbol symbol;\n")
- fmt.Fprintf(w, "// char symbolname[1024];\n")
- fmt.Fprintf(w, "// symbolname[0] = '_';\n")
- fmt.Fprintf(w, "// strcpy(symbolname + 1, name);\n")
- fmt.Fprintf(w, "// symbol = NULL;\n")
- fmt.Fprintf(w, "// if(NSIsSymbolNameDefined(symbolname)) {\n")
- fmt.Fprintf(w, "// symbol = NSLookupAndBindSymbol(symbolname);\n")
- fmt.Fprintf(w, "// if (symbol) {\n")
- fmt.Fprintf(w, "// return NSAddressOfSymbol(symbol);\n")
- fmt.Fprintf(w, "// }\n")
- fmt.Fprintf(w, "// }\n")
- fmt.Fprintf(w, "// return NULL;\n")
+ fmt.Fprintf(w, "// return dlsym(RTLD_DEFAULT, name);\n")
fmt.Fprintf(w, "// #elif _WIN32\n")
fmt.Fprintf(w, "// void* pf = wglGetProcAddress((LPCSTR)name);\n")
fmt.Fprintf(w, "// if(pf) {\n")

0 comments on commit 3efc31d

Please sign in to comment.