How to create a Package.swift for an existing xcode project - swift

Consider a small existing project ffttest https://github.com/javadba/Swift-FFT-Example/tree/upgrade_swift52 . This works :
> Amplitude: 8.0
Frequency: 4.0
Phase: -1.1102230246251565e-15
0 0.0 -8.038073113980855e-15
1 0.7841371226364848 0.7841371226364765
2 1.560722576129026 1.5607225761290189
..
509 -2.3222774180357333 -2.3222774180357075
510 -1.5607225761290364 -1.560722576129034
511 -0.784137122636526 -0.7841371226364928
Program ended with exit code: 0
The program has the following directory structure:
Now I would like to add dependencies and other things traditionally performed in a Package.swift. Is there a tool to build/infer it from this existing project?

Related

AWS CodeBuild S3 cache for swift lambda

So I have some aws swift lambdas that I deployed via sam deploy. That works fine.
The swift lambda looks like this: aws-samples
I am currently in the middle of building a CI/CD pipeline using Codepipeline and Codebuild. My Codebuild project executes the following buildspec.yml and is configured to cache to S3:
version: 0.2
phases:
build:
commands:
- sam build
- sam package -t template.yml --s3-bucket bucketName --output-template-file packaged.yaml
artifacts:
files:
- packaged.yaml
cache:
paths:
- ".aws-sam/**/*"
To build the swift lambdas sam buildexecuted the following makefile as the function in template.yml is set to: BuildMethod: makefile
Makefile:
### Add functions here and link them to builder-bot format MUST BE "build-FunctionResourceName in template.yaml"
build-ExpiredMediaItemProcessorLambda: builder-bot
builder-bot:
$(eval $#PRODUCT = $(subst build-,,$(MAKECMDGOALS)))
$(eval $#BUILD_DIR = $(PWD)/.aws-sam/build-$($#PRODUCT))
$(eval $#STAGE = $($#BUILD_DIR)/lambda)
$(eval $#ARTIFACTS_DIR = $(PWD)/.aws-sam/build/$($#PRODUCT))
# prep directories
mkdir -p $($#BUILD_DIR)/lambda $($#ARTIFACTS_DIR)
# Compile application
swift build --product $($#PRODUCT) -c release --build-path $($#BUILD_DIR)
# copy deps
ldd '/$($#BUILD_DIR)/release/$($#PRODUCT)' | grep swift | cut -d' ' -f3 | xargs cp -Lv -t /$($#BUILD_DIR)/lambda
# copy binary to stage
cp $($#BUILD_DIR)/release/$($#PRODUCT) $($#BUILD_DIR)/lambda/bootstrap
# copy app from stage to artifacts dir
cp $($#STAGE)/* $($#ARTIFACTS_DIR)
I got the makefile from the linked aws-samples project above which I modified slightly to work on codebuild.
Now to my question: How do I get codebuild S3 cache to work with swift lambdas?
when I cache the .aws-sam/**/* folder swift cannot compile because the build paths are different due to the different build machines. The error looks like so:
swift build --product LambdaName -c release --build-path /codebuild/output/src409372700/src/.swift-build/build-LambdaName
33 [1/863] Compiling CSotoExpat xmltok_impl.c
34 [2/863] Compiling CSotoExpat xmltok_ns.c
35 [3/865] Compiling INIParser INIParser.swift
36 <unknown>:0: error: PCH was compiled with module cache path '.aws-sam/build-LambdaName/x86_64-unknown-linux-gnu/release/ModuleCache/1LD7OVICEM9JB', but the path is currently '/codebuild/output/src409372700/src/.aws-sam/build-LambdaName/x86_64-unknown-linux-gnu/release/ModuleCache/1LD7OVICEM9JB'
37 <unknown>:0: error: missing required module 'SwiftShims'
38 [4/865] Compiling Logging Locks.swift
39 <unknown>:0: error: PCH was compiled with module cache path '.aws-sam/build-LambdaName/x86_64-unknown-linux-gnu/release/ModuleCache/1LD7OVICEM9JB', but the path is currently '/codebuild/output/src409372700/src/.aws-sam/build-LambdaName/x86_64-unknown-linux-gnu/release/ModuleCache/1LD7OVICEM9JB'
40 <unknown>:0: error: missing required module 'SwiftShims'
As far as I understand this is due to the fact that swift build cannot cope with a changing or relative path.
After some digging I found this stack overflow post which has a similar problem. I tried there solution and the swift compile error is gone but after a rebuild swift compiles the entire project again even if no code was changed.
Any help is much appreciated!
Thanks!

`swift build` aborted with "Assertion `isInProgress()' failed."

Run swift build gives me these error.
swift-build: /home/build-user/llbuild/lib/Core/BuildEngine.cpp:250: (anonymous namespace)::BuildEngineImpl::TaskInfo *(anonymous namespace)::BuildEngineImpl::RuleInfo::getPendingTaskInfo(): Assertion `isInProgress()' failed.
Aborted (core dumped)
What I tried
restart windows.
run ps -aux | grep swift, not found swift process.
run swift and run ps display below.
*** 708 0.0 0.1 498876 25472 tty2 Sl 13:21 0:00 /home/***/Swift/swift-5.2.4-RELEASE-ubuntu20.04/usr/bin/lldb --repl=-disable-objc-interop -color-diagnostics
*** 713 0.0 0.0 146108 7620 tty2 S 13:21 0:00 /home/***/Swift/swift-5.2.4-RELEASE-ubuntu20.04/usr/bin/lldb-server gdbserver --fd=9 --native-regs --setsid
*** 720 0.0 0.0 8404 176 tty2 t 13:21 0:00 /home/***/Swift/swift-5.2.4-RELEASE-ubuntu20.04/usr/bin/repl_swift
downloaded Swift 5.2.5 but it didn't work either.
Enviroment
Windows Subsystem for Linux, Ubuntu
Swift version 5.2.4 (swift-5.2.4-RELEASE) Target: x86_64-unknown-linux-gnu
I cleaned project .build directory, then build works fine.
.build directory may be broken by VSCode Swift Development Enviroment Extension.
Perhaps it seems that sqlite related error is caused by running swift build from Electron in Swift Development Enviroment Extension.
As a temporary solution, I solved it by emptying "Swift ›Path: Swift_driver_bin" in VS Code settings so that swift build is not executed.

Output from Eclipse CDT on Linux have incorrect permission

I'm having problems with files created from within Eclipse running on Linux.
All files (as far as I know) only gets the owner read and write permissions. Build output is the same but with the execute permission added.
The "test" file is created in Eclipse by File > New, and the "test1" file is created in command line by "touch" by the same user in the same folder.
-rw-------. 1 user stdgroup 0 Mar 15 10:22 test
-rw-r--r--. 1 user stdgroup 0 Mar 15 10:23 test1
My umask is set to 0022, so the output from the "touched" file is correct.
I'm running Eclipse Oxygen.2 Release 4.7.2 on Linux RedHatEnterpriseServer 7.3.
Anyone knows if there is a setting in Eclipse that can cause this, or any other ideas as to why this happens?

GGTS 3.2 console timout failure on new Grails project

I tried upgrading to GGTS 3.2 on windows7 64bit and java 7.0.21. running on works pc with a proxy config enabled in internet settings
i create a new project in a new workspace. I then try and run the console for the app.
the console fires up and you can use for ~60 seconds. After that the sts ide throws a timeout error and the console is killed
error in log looks like this :
!ENTRY org.grails.ide.eclipse.core 4 0 2013-06-18 22:08:15.103
!MESSAGE Problem executing: console
!STACK 1
org.eclipse.core.runtime.CoreException: The command 'C:\Program Files (x86)\Java\jdk1.7.0_21\bin\javaw.exe (18 Jun 2013 22:06:14)' was terminated because it didn't produce new output for some time.
See details for the output produced so far.
If you think the command simply needed more time, you can increase the time limit in the Grails preferences page.
See menu Windows >> Preferences >> Grails >> Launch
at org.grails.ide.eclipse.core.launch.SynchLaunch$LaunchResult.getCoreException(SynchLaunch.java:168)
at org.grails.ide.eclipse.core.launch.SynchLaunch.synchExec(SynchLaunch.java:57)
at org.grails.ide.eclipse.commands.GrailsExecutor.synchExec(GrailsExecutor.java:131)
at org.grails.ide.eclipse.commands.GrailsCommand.synchExec(GrailsCommand.java:169)
at org.grails.ide.eclipse.ui.internal.inplace.GrailsLaunchUtils$1.run(GrailsLaunchUtils.java:120)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
Contains: ------System.out:-----------
| Loading Grails 2.2.1
| Configuring classpath.
| Environment set to development.....
| Packaging Grails application....
| Compiling 1 source files.....
| Packaging Grails application.
| Compiling 1 source files.....
Contains: ------System.err:-----------
Terminating process: Timeout: no new output for 60000 milliseconds
!SUBENTRY 1 org.grails.ide.eclipse.core 4 4 2013-06-18 22:08:15.103
!MESSAGE The command 'C:\Program Files (x86)\Java\jdk1.7.0_21\bin\javaw.exe (18 Jun 2013 22:06:14)' was terminated because it didn't produce new output for some time.
See details for the output produced so far.
If you think the command simply needed more time, you can increase the time limit in the Grails preferences page.
See menu Windows >> Preferences >> Grails >> Launch
!SUBENTRY 2 org.grails.ide.eclipse.core 4 0 2013-06-18 22:08:15.103
!MESSAGE ------System.out:-----------
| Loading Grails 2.2.1
| Configuring classpath.
| Environment set to development.....
| Packaging Grails application....
| Compiling 1 source files.....
| Packaging Grails application.
| Compiling 1 source files.....
!SUBENTRY 2 org.grails.ide.eclipse.core 4 0 2013-06-18 22:08:15.103
!MESSAGE ------System.err:-----------
Terminating process: Timeout: no new output for 60000 milliseconds
There was something like this is the sts/ggts forum which claimed it had been fixed in 3.3m2. and might have been to do with pref>groovy>grails>launch - keep running flag - however i enebaled and diabsled this and it made no difference
i tried installing 3.3m2 and tried the same - new workspace - new project. I run the console, 60 seconds later i get a timeout buty the console stays up - error now reads
| Configuring classpath.
| Environment set to development.....
| Packaging Grails application....
| Compiling 1 source files.....
| Packaging Grails application.
| Compiling 1 source files.....
Contains: ------System.err:-----------
!SUBENTRY 1 org.grails.ide.eclipse.core 4 4 2013-06-18 23:27:11.110
!MESSAGE Command terminated with an exception: java.io.IOException: Cannot run program "jps": CreateProcess error=2, The system cannot find the file specified (see details for partial output)
!STACK 0
java.io.IOException: Cannot run program "jps": CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(Unknown Source)
at org.grails.ide.eclipse.longrunning.client.GrailsProcessStackTracer.exec(GrailsProcessStackTracer.java:104)
at org.grails.ide.eclipse.longrunning.client.GrailsProcessStackTracer.getGrailsProcessId(GrailsProcessStackTracer.java:72)
at org.grails.ide.eclipse.longrunning.client.GrailsProcessStackTracer.getStackTraces(GrailsProcessStackTracer.java:92)
at org.grails.ide.eclipse.longrunning.client.GrailsClient.executeCommand(GrailsClient.java:381)
at org.grails.ide.eclipse.longrunning.client.GrailsCommandExecution.execute(GrailsCommandExecution.java:85)
at org.grails.ide.eclipse.longrunning.LongRunningProcessGrailsExecutor.synchExec(LongRunningProcessGrailsExecutor.java:82)
at org.grails.ide.eclipse.commands.GrailsCommand.synchExec(GrailsCommand.java:169)
at org.grails.ide.eclipse.ui.internal.inplace.GrailsLaunchUtils$1.run(GrailsLaunchUtils.java:127)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 10 more
!SUBENTRY 2 org.grails.ide.eclipse.core 4 0 2013-06-18 23:27:11.110
!MESSAGE ------System.out:-----------
Loading Grails 2.2.2
| Configuring classpath.
| Environment set to development.....
| Packaging Grails application....
| Compiling 1 source files.....
| Packaging Grails application.
| Compiling 1 source files.....
!SUBENTRY 2 org.grails.ide.eclipse.core 4 0 2013-06-18 23:27:11.110
!MESSAGE ------System.err:-----------
Any one else had this and is there a workaround?
The "Execute Grails Command" function wasn't designed to support persistent processes. It worked previously by chance, but no longer does.
The recommended way to execute long-running grails processes in Eclipse/STS/GGTS is to configure an eclipse run configuration to execute the long-running grails commands. (Run -> Run Configurations...)

Hudson failing build w/o revealing cause

Every build has failed as of Tuesday. I'm not exactly sure what happened. The Phing targets (clean/prepare) are being executed properly. Additionally, the unit tests are passing with flying colors, with only a warning for duplicate code (not a reason for a fail). I tried removing the phpDoc target to see if that was causing the error, but the build still failed.
Started by user chris Updating
file://localhost/projects/svn/ips-com/trunk
At revision 234 no change for
file://localhost/projects/svn/ips-com/trunk
since the previous build [trunk] $
/opt/phing/bin/phing clean prepare
-logger phing.listener.NoBannerLogger Buildfile:
/var/lib/hudson/.hudson/jobs/IPS/workspace/trunk/build.xml
IPS > clean:
[echo] Clean... [delete] Deleting directory
/var/lib/hudson/.hudson/jobs/IPS/workspace/build
IPS > prepare:
[echo] Prepare...
[mkdir] Created dir: /var/lib/hudson/.hudson/jobs/IPS/workspace/build
[mkdir] Created dir: /var/lib/hudson/.hudson/jobs/IPS/workspace/build/logs
[mkdir] Created dir: /var/lib/hudson/.hudson/jobs/IPS/workspace/build/logs/coverage
[mkdir] Created dir: /var/lib/hudson/.hudson/jobs/IPS/workspace/build/logs/coverage-html
[mkdir] Created dir: /var/lib/hudson/.hudson/jobs/IPS/workspace/build/docs
[mkdir] Created dir: /var/lib/hudson/.hudson/jobs/IPS/workspace/build/app
BUILD FINISHED
Total time: 1.0244 second
[workspace] $ /bin/bash -xe
/tmp/hudson3259012225710915845.sh
+ cd trunk/tests
+ /usr/local/bin/phpunit --verbose -d memory_limit=512M --log-junit
../../build/logs/phpunit.xml
--coverage-clover ../../build/logs/coverage/clover.xml
--coverage-html ../../build/logs/coverage-html/
PHPUnit 3.5.0 by Sebastian Bergmann.
IPS Default_IndexControllerTest .
Default_AuthControllerTest ......
Manage_UsersControllerTest .....
testDeleteInvalidUserId ..
testGetPermissionsForInvalidUserId .. Audit_OverviewControllerTest
............
Time: 14 seconds, Memory: 61.00Mb
[30;42m[2KOK (28 tests, 198
assertions) [0m[2K Writing code
coverage data to XML file, this may
take a moment.
Generating code coverage report, this
may take a moment.
Warning: Unknown: Error occured while
closing statement in Unknown on line 0
Warning: Unknown: Error occured while
closing statement in Unknown on line 0
Warning: Unknown: Error occured while
closing statement in Unknown on line 0
Warning: Unknown: Error occured while
closing statement in Unknown on line 0
Warning: Unknown: Error occured while
closing statement in Unknown on line 0
Warning: Unknown: Error occured while
closing statement in Unknown on line 0
Warning: Unknown: Error occured while
closing statement in Unknown on line 0
Warning: Unknown: Error occured while
closing statement in Unknown on line 0
[workspace] $ /bin/bash -xe
/tmp/hudson1439023061736436000.sh
+ /usr/local/bin/phpcpd --log-pmd ./build/logs/cpd.xml ./trunk phpcpd
1.3.2 by Sebastian Bergmann.
Found 1 exact clones with 6 duplicated
lines in 2 files:
library/Ips/Form/Decorator/SplitInput.php:8-14
library/Ips/Form/Decorator/FeetInches.php:10-16
0.04% duplicated lines out of 16585 total lines of code.
Time: 4 seconds, Memory: 19.50Mb [DRY]
Skipping publisher since build result
is FAILURE Publishing Javadoc [xUnit]
[INFO] - Starting to record. [xUnit]
[WARNING] - Can't create the path
/var/lib/hudson/.hudson/jobs/IPS/workspace/generatedJUnitFiles.
Maybe the directory already exists.
[xUnit] [INFO] - Processing
PHPUnit-3.4 (default) [xUnit] [INFO] -
[PHPUnit-3.4 (default)] - 1 test
report file(s) were found with the
pattern 'build/logs/phpunit.xml'
relative to
'/var/lib/hudson/.hudson/jobs/IPS/workspace'
for the testing framework 'PHPUnit-3.4
(default)'. [xUnit] [INFO] -
Converting
'/var/lib/hudson/.hudson/jobs/IPS/workspace/build/logs/phpunit.xml'
. [xUnit] [INFO] - Stopping recording.
Publishing Clover coverage report...
Publishing Clover XML report...
Publishing Clover coverage results...
Finished: FAILURE
What changed since Tuesday? Try to manually run exactly the same commands that Hudson tries to run from the same directory that Hudson starts it from (usually the jobs workspace directory). Of course with the user account that Hudson is started under.
There are several possibilities. ranging from standard groups for a directory, to permission, or other things outside of Hudson. Was Hudson upgraded? Was a plugin upgraded? Was the OS or php upgraded? Was there a change in the default or user .profile or .env (or the equivalent files)? Does another process accesses the workspace? ......
Once I had the problem that all of the sudden my deployment scripts did not run anymore. The mystery was, that I could still run the script from command line with the Hudson user account. The reason was simple but took a while to uncover. There was a java upgrade from 5 to 6. Both versions were available. After comparing the environment variables, there was a difference in the path. The problem was that the new path was set in the global .profile. But Hudson does not open an interactive shell, therefore the .profile will not be executed. If you have a problem like this, you can put the initialization in the .env file (or whatever the filename is for your system), because this will be run regardless if it is a interactive shell or not. Alternatively you can configure Hudson to set it on master or node/slave level.
if you want a command to not break the 'build' as a failure you have to add #! in front of the command to prevent the flags -xe which produce this behaviour.