Code/CFLite/CFNetwork: Difference between revisions

From kJams Wiki
Jump to navigation Jump to search
No edit summary
 
(48 intermediate revisions by the same user not shown)
Line 1: Line 1:
Download the [http://kjams.com/cflite/downloads/cfnetwork.zip CFNetwork] test framework.
I hereby release everything here under the terms of the "[https://en.wikipedia.org/wiki/BSD_licenses#2-clause_license_.28.22Simplified_BSD_License.22_or_.22FreeBSD_License.22.29 FreeBSD License]".
==If you use QuickTime on Windows, or Parallels Desktop for debugging Windows==
Be very sure you [[CFLite#Cooperating_with_QuickTime|check this stuff out]], it's important.


= OpenCFLite project and file changes =
==How to get started==
* CFNetTest\CFTest\win_vs\pre_build.bat; Change VS vars path to call "%VS90COMNTOOLS%\..\..\VC\vcvarsall.bat"
#if you're on Windows:
* CFTest.vcproj - change QuickTime libraries path in Linker to $(SolutionDir)..\..\kJams\External\QuickTime SDK\Libraries
##Install [http://support.apple.com/kb/DL999 Bonjour Print Services].  (you do not need to run the printer wizard nor set up a printer, this is just a service that CFTest makes use of)
* Add explicit direction __WIN32__ to PreprocessorDefinitions so that VS2008 properly reflects disabled code
##install [http://downloads.activestate.com/ActivePython/releases/ Python 2.7] do NOT install python 3. Python is used for post-build steps / deployment
* mDNSResponder support (dns-sd)
## i installed [https://www.visualstudio.com/downloads/ Visual Studio Community Edition] (the free one). if you install something else, YMMV
** Add mDNSResponder folder to the include path to OpenCFLite project;
## when [https://info.qt.io/download-qt-for-application-development installing Qt Open Source], be sure to install MSVC2015 32 and 64
** Add lib file to linker configuration $(ProjectDir)..\..\mDNSResponder\lib\dnssd.lib
#download <googa>../../../cflite/downloads/CoreFoundation.zip|CoreFoundation|/downloads/CoreFoundationInstaller</googa> (which includes CFTest with CFLite and CFNetwork) and put it in your development tree
 
# using Qt (tested on 5.9.1)
=== File modifications ===
## on Windows: open CF/opencflite-476.17.2/Qt/CFLite/CFLite.pro.
* CFBase.h - make typedef for Boolean type available to WINDOWS target
## you SHOULD be able to use the .user file, cuz all paths are relative, so if it asks if you want to "take over" that file, even though it was created on another machine, go ahead
** Line added to CFBase.h - "typedef unsigned char Boolean;
## open CFTest/project/qt/CFTest/CFTest_win.pro (do the same thing, take over that file if it asks)
* CFRuntime.c - Added two new functions for socket initialization (WinSock requires startup code)
## your "Session" should look like this: (on Mac you will not see CFLite )<br>{{SERVER}}/cflite/screenshots/qt_session.png
** Added __CFSocketInitialize
## on Windows:
** Added __CFSocketInitializeWinSock
### set CFTest_win/mac to the active project, use the 64bit one
* Socket initialization is added to __CFInitialize
### set it to depend on and sync with CFLite, like this:<br>{{SERVER}}/cflite/screenshots/qt_session_dependencies.png
** CFSocket ensures initialization on creation. However this is needed so that any other code could reference WinSock API (Ex: AddressLookup)
## below screen shots show 64bit debug as an example, (on mac they'll show "clang" instead of "MSVC2015") you can optionally set up 32bit debug, and also release of both 32 and 64. Note mac doesn't have 32bit.
* CFSocketStream.c  - instead of the default need to use the code in CFNetwork (NOTE: This file needs to be references in includes)
## Windows: how CFLite build settings should look: (ignore run settings)<br>{{SERVER}}/cflite/screenshots/qt_build_cflite.png
* CFUrlAccess.c - merge in new functionality from _CFUrlAccess.c available in CFNetwork distribution
## how CFTest build settings should look:<br>{{SERVER}}/cflite/screenshots/qt_build_cftest.png
** Added _CFHTTPMessageSendRequest
## how CFTest run settings should look:<br>{{SERVER}}/cflite/screenshots/qt_run_cftest.png
** Added _CFURLCreateDataAndPropertiesFromResource
# if you're using Visual Studio
** Added _CFURLWriteDataAndPropertiesToResource
## Open the file "CFNetwork/CFTest/win_vs/CFTest.sln".
** Added _CFURLDestroyResource
## go to "Solution Explorer"
* Add support for HTTP URL into the existing function CFURLCreateDataAndPropertiesFromResource
## select "CFTest", right click it and pick "Properties"
* ForFoundationOnly.h - added HTTP cleanup routines
## in the "Configuration:" menu, pick "All Configurations"
 
## go to "configuration properties->debugging"
 
## set "Command" to "$(SolutionDir)build\$(TargetName).app\Contents\Windows\$(TargetFileName)".
= External libraries changes =
## in VS2010 and later, actually you may need to just specify the full path (in step 4 above), as "$(TargetName)" does not seem to expand correctly for debug vs. release
* QuickTime ConditionalMacros.h issue fix:
** the file is available in both QuickTime and OpenCFLite, which makes it confusing for the compiler
** if it uses the wrong file, CFTest compilation fails with ~100 errors
** To fix this, change includes <ConditionalMacroh.h> to "ConditionalMacros.h" (File MacTypes.h)
 
 
= Porting CFNetwork to VS complier =
 
First import thing to note is compiler differences on difference platforms - Visual Studio 2008 supports C90 standard. A newer complier was used to develop CFNetwork. Hence the most important differences:
* All variable definitions must be placed at the beginning of each scope (otherwise it fails with "illegal type as an expression" errors)
* C90 allows structure initialization only by compile time constants (no pointers or even constants pointers to constant data)
* inline support - Visual studio uses keyword __inline (double underscore is required)
* Visual Studio compiler does not allow double class storage specifier such as "static static int var"

Latest revision as of 16:48, 10 August 2017

I hereby release everything here under the terms of the "FreeBSD License".

If you use QuickTime on Windows, or Parallels Desktop for debugging Windows

Be very sure you check this stuff out, it's important.

How to get started

  1. if you're on Windows:
    1. Install Bonjour Print Services. (you do not need to run the printer wizard nor set up a printer, this is just a service that CFTest makes use of)
    2. install Python 2.7 do NOT install python 3. Python is used for post-build steps / deployment
    3. i installed Visual Studio Community Edition (the free one). if you install something else, YMMV
    4. when installing Qt Open Source, be sure to install MSVC2015 32 and 64
  2. download CoreFoundation (which includes CFTest with CFLite and CFNetwork) and put it in your development tree
  3. using Qt (tested on 5.9.1)
    1. on Windows: open CF/opencflite-476.17.2/Qt/CFLite/CFLite.pro.
    2. you SHOULD be able to use the .user file, cuz all paths are relative, so if it asks if you want to "take over" that file, even though it was created on another machine, go ahead
    3. open CFTest/project/qt/CFTest/CFTest_win.pro (do the same thing, take over that file if it asks)
    4. your "Session" should look like this: (on Mac you will not see CFLite )
      qt_session.png
    5. on Windows:
      1. set CFTest_win/mac to the active project, use the 64bit one
      2. set it to depend on and sync with CFLite, like this:
        qt_session_dependencies.png
    6. below screen shots show 64bit debug as an example, (on mac they'll show "clang" instead of "MSVC2015") you can optionally set up 32bit debug, and also release of both 32 and 64. Note mac doesn't have 32bit.
    7. Windows: how CFLite build settings should look: (ignore run settings)
      qt_build_cflite.png
    8. how CFTest build settings should look:
      qt_build_cftest.png
    9. how CFTest run settings should look:
      qt_run_cftest.png
  4. if you're using Visual Studio
    1. Open the file "CFNetwork/CFTest/win_vs/CFTest.sln".
    2. go to "Solution Explorer"
    3. select "CFTest", right click it and pick "Properties"
    4. in the "Configuration:" menu, pick "All Configurations"
    5. go to "configuration properties->debugging"
    6. set "Command" to "$(SolutionDir)build\$(TargetName).app\Contents\Windows\$(TargetFileName)".
    7. in VS2010 and later, actually you may need to just specify the full path (in step 4 above), as "$(TargetName)" does not seem to expand correctly for debug vs. release