📜 ⬆️ ⬇️

As I stand to build from windows to wine migrated

image

Preamble


I have a few old projects written in C ++ that I still develop as much as I can. It would seem - what's the matter? Alas, this is a bunch of regular plug-ins under my favorite Adobe InDesign.

And every time a new Creative Suite comes out, you have to port this business. Interestingly, the main effort goes on to build a new version of the new rules, and bend the installer. Therefore, if you have reached the stage “it is compiled,” then, as a rule, it works. Although of course there are nuances - for example, at one point, PlaceGun stopped laying out several selected images, only the first one. But about it - next time.

And of course - I would like to collect it for all versions and all platforms at a time, and not “opened vizhlu - assembled - close - repeated” .
')
So for assembly, we need both





image

Go to gmake - profit


Why is that? Ah, I did not say - there is still MacOSX. So goodbye nmake no options.

And in the end we get this nightmare:
Hidden text
  1. cl-cs3.mak
  2. cl-cs4.mak
  3. cl-cs5.mak
  4. cl-cs55.mak
  5. cl-cs6.mak
  6. cl-cc.mak
  7. cl-cc2014.mak
  8. cl.mak
  9. commplugs.mak
  10. gcc-cs3.mak
  11. gcc-cs4.mak
  12. gcc-cs5.mak
  13. gcc-cs55.mak
  14. gcc-cs6.mak
  15. gcc-cc.mak
  16. gcc-cc2014.mak
  17. gcc.mak
  18. mac-defs.mak
  19. platform-impl.mak
  20. platform-targets.mak
  21. platform.mak
  22. win-defs.mak



And it starts like this:
make ARCH=x64 INDD=cc2014 compile 


Obviously, the platform is defined through uname. And each part is built in the standard way as make -C foo.

The description of each component looks like this.
Hidden text
 include ../../make/platform.mak TARGET=../../../lib/$(ARCH)/$(INDD)/libz.$(LibSuffix) OBJS=\ $(ARCH)/$(INDD)/adler32.$(OBJSuffix) \ $(ARCH)/$(INDD)/compress.$(OBJSuffix) \ $(ARCH)/$(INDD)/crc32.$(OBJSuffix) \ $(ARCH)/$(INDD)/deflate.$(OBJSuffix) \ $(ARCH)/$(INDD)/gzio.$(OBJSuffix) \ $(ARCH)/$(INDD)/infback.$(OBJSuffix) \ $(ARCH)/$(INDD)/inffast.$(OBJSuffix) \ $(ARCH)/$(INDD)/inflate.$(OBJSuffix) \ $(ARCH)/$(INDD)/inftrees.$(OBJSuffix) \ $(ARCH)/$(INDD)/trees.$(OBJSuffix) \ $(ARCH)/$(INDD)/uncompr.$(OBJSuffix) \ $(ARCH)/$(INDD)/zutil.$(OBJSuffix) \ all: $(TARGET) $(TARGET): $(OBJS) $(AR) $(LFLAGS) $(OBJS) clean: $(RMRF) $(TARGET) $(OBJS) 


And it all worked on a separate dedicated virtual machine under WinXP (and the same under hackintosh).

I can’t see how I see these passions from and to the point; I’ll give only the most interesting excerpts. For example, this is how we calculate the project root and the platform on which compilation will now be performed:

 PR:=$(subst make/,,$(dir $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))) OSA:=$(shell uname -o) ifeq (Darwin,$(OSA)) OS=mac else OS=win endif 


And this is how it is determined where to look for Boost (adobe in each version manage to shift, so here are two parts - we define a macro and then use it):
 ifeq ($(ARCH),x86) BoostARCH=32 else BoostARCH=64 endif BoostLib=$(subst \,/,$(AdobeSDK))/external/dva/third_party/boost_libraries/bin.v2/libs/boost_$1/lib/$(OS)/release/$(BoostARCH)/boost_$1.$(LibSuffix) BoostFilesystemLib=$(call BoostLib,filesystem) BoostThreadLib=$(call BoostLib,threads) BoostRegexLib=$(call BoostLib,regex) BoostSystemLib=$(call BoostLib,system) 


It is clear that I typed it not with my hands, but wrote a pack of batch files, but under MinGW:

genmake-for-dll.bat component-name [path-to-sources [target-directory]]
 @echo off rem genmake component-name [path-to-sources [target-directory]] set CN=%1 set FP=%2 if -%1==- set CN=default if -%2==- set FP=. if -%3==- set TD=. echo> MakeF COMPONENT=%CN% echo>> MakeF include ../make/platform.mak echo>> MakeF TARGET=$(OBJDIR)/$(COMPONENT).$(DLLSuffix) echo>> MakeF OBJS=\ find %FP% -type f -name '*.c*' | grep -v .svn | awk '{ print "\t$(OBJDIR)/" $1 ".$(OBJSuffix)\t\\\"; }' | sed -e 's/\.cpp\./\./' | sed -e 's/\.cxx\./\./' | sed -e 's?/%FP%??' >> MakeF echo>> MakeF # echo>> MakeF HEADERS=\ find %FP% -type f -name '*.h*' | grep -v .svn | awk '{ print "\t" $1 "\t\\\"; }' > headers >> MakeF echo>> MakeF # echo>> MakeF # echo>> MakeF all: $(TARGET) echo>> MakeF # echo>> MakeF $(TARGET): $(OBJS) echo>> MakeF $(LINK) $(LDFLAGS) $(OBJS) $(XLIBS) echo>> MakeF if [ -f $@.manifest ] ; then mt -nologo -manifest $@.manifest "-outputresource:$@;2"; fi echo>> MakeF # echo>> MakeF clean: echo>> MakeF rm -f $(TARGET) $(OBJS) echo>> MakeF # find %FP% -type f -name '*.c*' | grep -v .svn | awk '{ print "$(OBJDIR)/" $1 ".$(OBJSuffix) : " $1 " $(HEADERS)\n\t$(CC) $(CFLAGS) " $1 "\n"; }' | sed -e 's/.cpp././' | sed -e 's/\.cxx\./\./' | sed -e 's?/%FP%/?/?' >> MakeF echo>> MakeF #EOF mv MakeF Makefile 


genmake-for-lib.dll component-name [path-to-sources [target-directory]]
 @echo off rem genmake component-name [path-to-sources [target-directory]] set CN=%1 set FP=%2 if -%1==- set CN=default if -%2==- set FP=. if -%3==- set TD=. echo> MakeF COMPONENT=%CN% echo>> MakeF include ../make/platform.mak echo>> MakeF TARGET=$(OBJDIR)/lib$(COMPONENT).$(LibSuffix) echo>> MakeF OBJS=\ find %FP% -type f -name '*.c*' | grep -v .svn | awk '{ print "\t$(OBJDIR)/" $1 ".$(OBJSuffix)\t\\\"; }' | sed -e 's/\.cpp\./\./' | sed -e 's/\.cxx\./\./' | sed -e 's?/%FP%??' >> MakeF echo>> MakeF # echo>> MakeF HEADERS=\ find %FP% -type f -name '*.h*' | grep -v .svn | awk '{ print "\t" $1 "\t\\\"; }' > headers >> MakeF echo>> MakeF # echo>> MakeF # echo>> MakeF $(TARGET): $(OBJS) echo>> MakeF $(AR) $(LFLAGS) $(OBJS) echo>> MakeF # echo>> MakeF clean: echo>> MakeF rm -f $(TARGET) $(OBJS) echo>> MakeF # find %FP% -type f -name '*.c*' | grep -v .svn | awk '{ print "$(OBJDIR)/" $1 ".$(OBJSuffix) : " $1 " $(HEADERS)\n\t$(CC) $(CFLAGS) " $1 "\n"; }' | sed -e 's/.cpp././' | sed -e 's/\.cxx\./\./' | sed -e 's?/%FP%/?/?' >> MakeF echo>> MakeF #EOF mv MakeF Makefile 


genmake-for-indd.bat plugin-name [path-to-sources [target-directory]]
 @echo off setlocal rem genmake plugin-name [path-to-sources [target-directory]] set CN=%1 set FP=%2 if -%1==- set CN=plugin if -%2==- set FP=. if -%3==- set TD=. echo> MakeF COMPONENT=%CN% echo>> MakeF include ../make/platform.mak echo>> MakeF PluginName=$(COMPONENT) echo>> MakeF TARGET_DIR=$(OBJDIR)/$(PluginPrefix) echo>> MakeF TARGET=$(TARGET_DIR)/$(PluginName)$(PluginSuffix) echo>> MakeF CFLAGS+=-I ../common echo>> MakeF LIBS+=$(call add_component_ref,vl) $(call add_component_ref,common) echo>> MakeF OBJS=\ find %FP% -type f -name '*.c*' | grep -v .svn | awk '{ print "\t$(OBJDIR)/" $1 ".$(OBJSuffix)\t\\\"; }' | sed -e 's/\.cpp\./\./' | sed -e 's/\.cxx\./\./' | sed -e 's?/%FP%??' >> MakeF echo>> MakeF $(COMMON_PLUGIN_OBJS) echo>> MakeF # echo>> MakeF HEADERS=\ find %FP% -type f -name '*.h*' | grep -v .svn | awk '{ print "\t" $1 "\t\\\"; }' > headers >> MakeF echo>> MakeF # echo>> MakeF # echo>> MakeF ifeq (win,$(OS)) echo>> MakeF OBJS+= $(OBJDIR)/$(COMPONENT).res echo>> MakeF FRES_TGT=$(OBJDIR)/$(COMPONENT)_w.$(FRES) echo>> MakeF else echo>> MakeF FRES_TGT=$(OBJDIR)/R/$(COMPONENT)_w.$(FRES) echo>> MakeF endif echo>> MakeF # echo>> MakeF ifeq (mac,$(OS)) echo>> MakeF ifeq (x64,$(ARCH)) echo>> MakeF TARGET:= echo>> MakeF endif echo>> MakeF endif echo>> MakeF # echo>> MakeF all: $(TARGET) echo>> MakeF # echo>> MakeF clean: echo>> MakeF rm -rf $(TARGET) $(OBJS) $(TARGET_DIR)/* echo>> MakeF # echo>> MakeF # echo>> MakeF $(TARGET): $(OBJS) $(LIBS) $(FRES_TGT) echo>> MakeF $(LINK) $(LDFLAGS) $(LDFLAGS_InDesignPlugin) $(OBJS) $(LIBS) $(AdobeLIBS) $(XLIBS) echo>> MakeF # echo>> MakeF # echo>> MakeF ifeq ($(OS),win) echo>> MakeF $(OBJDIR)/$(COMPONENT)_w.$(FRES): $(COMPONENT).fr echo>> MakeF $(ODFRC) $(ODFRCFLAGS) -o $(call unix_to_dos,$(OBJDIR)/$(COMPONENT)_w.$(FRES)) $(COMPONENT).fr echo>> MakeF # echo>> MakeF $(OBJDIR)/$(COMPONENT).res: $(COMPONENT).rc $(OBJDIR)/$(COMPONENT)_w.$(FRES) echo>> MakeF $(RSC) $(RSCFLAGS) $(CFLAGS_INCLUDE) $(COMPONENT).rc echo>> MakeF $(AdobeSDK)\devtools\bin\merge_res.cmd $(call unix_to_dos,$(OBJDIR)) $(COMPONENT) $(COMPONENT)_w echo>> MakeF mkdir -p "$(TARGET_DIR)/($(PluginName) Resources)" echo>> MakeF cp -r $(OBJDIR)/idrc_* "$(TARGET_DIR)/($(PluginName) Resources)" echo>> MakeF endif echo>> MakeF ifeq ($(OS),mac) echo>> MakeF $(OBJDIR)/R/$(COMPONENT)_w.$(FRES): $(COMPONENT).fr echo>> MakeF mkdir -p $(TARGET_DIR)/Resources echo>> MakeF mkdir -p $(OBJDIR)/R echo>> MakeF $(ODFRC) $(ODFRCFLAGS) $(CFLAGS_IXA_OF) -o $@ $(COMPONENT).fr echo>> MakeF /Developer/Tools/ResMerger -dstIs DF $@ -o $(OBJDIR)/$(PluginName).$(FRES) echo>> MakeF /Developer/Tools/ResMerger $(OBJDIR)/$(PluginName).$(FRES) -dstIs DF -o $(TARGET_DIR)/Resources/$(PluginName).rsrc echo>> MakeF cp -r $(OBJDIR)/R/idrc_* Info.plist $(TARGET_DIR)/Resources echo>> MakeF ( cd $(TARGET_DIR)/..; ln -s A Current ; cd .. ; ln -s Versions/Current/Resources Resources ; ln -s Versions/Current/$(PluginName) $(PluginName) ) echo>> MakeF endif echo>> MakeF include ../make/commplugs.mak echo>> MakeF # echo>> MakeF # find %FP% -type f -name '*.c*' | grep -v .svn | awk '{ print "$(OBJDIR)/" $1 ".$(OBJSuffix) : " $1 " $(HEADERS)\n\t$(CC) $(CFLAGS) " $1 "\n"; }' | sed -e 's/.cpp././' | sed -e 's/\.cxx\./\./' | sed -e 's?/%FP%/?/?' >> MakeF echo>> MakeF #EOF rem mv MakeF Makefile endlocal 


image

Nothing foreshadowed, and yeah


And all this worked perfectly until the Adobe InDesign CC 2014 came out. I wanted a visual studio 2012. It was then that the white fur animal kaak jumped out!

No, of course I knew in theory that the visual studio had not worked on Khrusha for a long time . But the fact that cl.exe suddenly turned out to be not a valid Win32 image - it was a hit.

I will explain a little bit - since the time of two visual studios of 2005 with service pack and without service pack at the same time, I honestly don’t put anything on the build machine. To do this, there is a pure virtual machine, in which I put the visual studio express edition, roll in the correct platform sdk, and copy what happened (licensed and so on) into the appropriate daddy. A virtual roll back to the state of "there was nothing."

And since the installer of 2012 studios wanted a newer one — no question, here’s Windows 8.1. Any whim - for microsoft.

I put, copy - opanki.

image

Monsieur knows a lot about perversions



And then the question arose - what to do?

There are few options.

  1. Put and obzhit new virtualka under Windows 8.1, starting from MinGW and ending with indigogs. And you need to find licenses - of course, I have everything, but they are in completely different places. Long and tedious.
  2. Move to the Amazon cloud - on w2k12, enough for a long time and will work quickly. But again the same problem is long and tedious. And all these accumulated versions and copies are 25 gigs to transfer. Lazy.
  3. To dodge so that he did not have to change anything.

I scratched my poppy head, and I thought - wouldn't I have a puruetan ? After all, my host is worth it.

Typing
 wine ---2012-\vc\bin\cl.exe /help 

and it does work.

- Yeah! - said the harsh Siberian men.

Of course, not without a rake, it turned out that some libraries from the visual studio runtime in Vaina are not quite like that. This is not a problem - the visual studio has a reference, copied the visual studio for daddies.

But what surprised me, the quite simple mt.exe not only crashed, but also caused SIGSEGV in wine. Shamanism with libraries did not give a solution, I had to quickly write my own substitute with poetess.

Hidden text
 #include <windows.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <io.h> #include <fcntl.h> #include <sys/types.h> #include <sys/stat.h> static void usage() { printf("Usage: mt.exe -manifest foo.dll.manifest -outputresource:foo.dll[;2]\n"); } static void alert(char* fn, char* msg, int code) { static char* lpstrError; FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, GetLastError(), LANG_USER_DEFAULT, &lpstrError, 1, NULL); fprintf(stderr, "%s: %s: %s, %d\n", fn, msg, lpstrError, code); LocalFree(lpstrError); } static int update_res(char* ou, int resk, char* mf) { HANDLE hUpdateRes; LPVOID buf; BOOL result; FILE* fp; struct _stat st; int ressz = 0, outk; fp = fopen(mf, "rb"); if(!fp) { alert(mf, "could not open manifest file", errno); return 2; } if(_fstat( fileno(fp), &st) != 0) { fclose(fp); alert(mf, "could not determine manifest file size", errno); return 2; } ressz = st.st_size; buf = (void*)malloc(ressz); if(!buf) { fclose(fp); free(buf); alert(mf, "could not allocate buffer for resource", ressz); return 2; } outk = fread(buf, 1, ressz, fp); if(outk != ressz) { fclose(fp); free(buf); alert(mf, "could not read manifest", ressz - outk); return 2; } fclose(fp); hUpdateRes = BeginUpdateResourceA(ou, FALSE); if (hUpdateRes == NULL) { free(buf); alert(ou, "Could not open file for writing.", 0); return 3; } result = UpdateResourceA(hUpdateRes, RT_MANIFEST, MAKEINTRESOURCE(resk), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), buf, ressz); if (result == FALSE) { alert(ou, "could not add resource", 0); free(buf); return 4; } if (!EndUpdateResource(hUpdateRes, FALSE)) { alert(ou, "could not write changes to file", 0); free(buf); return 4; } free(buf); return 0; } int main(int argc, char** argv) { char* mf = NULL; char* ou = NULL; char* v; int resk = 1; int k; if(argc < 2) { usage(); return 2; } for(k=1; k < argc; ++k) { if(argv[k][0] == '-') { if(argv[k][1] =='m') { // manifest mf = argv[k+1]; ++k; continue; } else if(argv[k][1] == 'o' ) { // outputresource if(argv[k+1]) ou = argv[k+1]; else { ou = strchr(argv[k], ':'); if(!ou) { usage(); return 3; } ++ou; } ++k; v = strchr(ou, ';'); if(v) { resk = atoi(v + 1); *v = '\0'; } else resk = 1; continue; } } usage(); return 2; } if(!mf || !ou) { usage(); return 2; } return update_res(ou, resk, mf); } 


But InnoSetup against expectations - did not bring surprises, collects with a whistle.

So far - so, and then I will go to the cloud, the moment has matured.

But nevertheless I decided to share with the community - all of a sudden I’m missing something, all of a sudden someone will come in handy ...

Source: https://habr.com/ru/post/232341/


All Articles